Depositing or Withdrawing

Depositing or withdrawing from Dolomite is simple, but the way it's performed may depend on the specific asset.

Normal Assets

Depositing or withdrawing into Dolomite is easy with the DepositWithdrawalProxy. You can find the address for DepositWithdrawalProxy here.

Depositing

Depositing an asset requires an approval for the corresponding amount on DolomiteMargin. You can find the contract addresses for DolomiteMargin here.

/**
 * @param _toAccountNumber  The account number into which `msg.sender` will be
 *                          depositing
 * @param _marketId         The ID of the market being deposited
 * @param _amountWei        The amount, in Wei, to deposit. Use `uint(-1)` to deposit
 *                          `msg.sender`'s entire balance
 */
function depositWei(
    uint256 _toAccountNumber,
    uint256 _marketId,
    uint256 _amountWei
) external;

/**
 * @dev Same as `depositWei` but converts the `msg.sender`'s sent ETH into WETH before
 *      depositing into `DolomiteMargin`.
 *
 * @param _toAccountNumber The account number into which `msg.sender` will be
 *                         depositing
 */
function depositETH(
    uint256 _toAccountNumber
) external payable;

/**
 * @param _toAccountNumber  The account number into which `msg.sender` will be
 *                          depositing
 * @param _marketId         The ID of the market being deposited
 * @param _amountPar        The amount, in Par, to deposit.
 */
function depositPar(
    uint256 _toAccountNumber,
    uint256 _marketId,
    uint256 _amountPar
) external;

Withdrawing

Withdrawing more than your supplied balance (to a negative number) will put you in a borrowed state.

Your withdrawal may fail if you attempt to withdraw more liquidity than there is available in Dolomite. If this happens, you must wait until more liquidity becomes available or you can attempt to swap your virtual balance to another asset that is withdrawable.

library AccountBalanceLib {
    enum BalanceCheckFlag {
        Both,
        From,
        To,
        None
    }
}

/**
 * @param _fromAccountNumber    The account number from which `msg.sender` will be
 *                              withdrawing
 * @param _marketId             The ID of the market being withdrawn
 * @param _amountWei            The amount, in Wei, to withdraw. Use `uint(-1)` to
 *                              withdraw `msg.sender`'s entire balance
 * @param _balanceCheckFlag     Use `BalanceCheckFlag.Both` or `BalanceCheckFlag.From`
 *                              to check that `_fromAccountNumber` balance is
 *                              non-negative after the withdrawal settles
 */
function withdrawWei(
    uint256 _fromAccountNumber,
    uint256 _marketId,
    uint256 _amountWei,
    AccountBalanceLib.BalanceCheckFlag _balanceCheckFlag
) external;

/**
 * @dev Same as `withdrawWei` but for withdrawing ETH. The user will receive unwrapped
 *      ETH from DolomiteMargin.
 *
 * @param _fromAccountNumber    The account number from which `msg.sender` will be
 *                              withdrawing
 * @param _amountWei            The amount, in Wei, to withdraw. Use `uint(-1)` to
 *                              withdraw `msg.sender`'s entire balance
 * @param _balanceCheckFlag     Use `BalanceCheckFlag.Both` or `BalanceCheckFlag.From`
 *                              to check that `_fromAccountNumber` balance is
 *                              non-negative after the withdrawal settles
 */
function withdrawETH(
    uint256 _fromAccountNumber,
    uint256 _amountWei,
    AccountBalanceLib.BalanceCheckFlag _balanceCheckFlag
) external;

/**
 * @param _fromAccountNumber    The account number from which `msg.sender` will be
 *                              withdrawing.
 * @param _marketId             The ID of the market being withdrawn
 * @param _amountPar            The amount, in Par, to withdraw. Use `uint(-1)` to
 *                              withdraw `msg.sender`'s entire balance.
 * @param _balanceCheckFlag     Use `BalanceCheckFlag.Both` or `BalanceCheckFlag.From`
 *                              to check that `_fromAccountNumber` balance is
 *                              non-negative after the withdrawal settles.
 */
function withdrawPar(
    uint256 _fromAccountNumber,
    uint256 _marketId,
    uint256 _amountPar,
    AccountBalanceLib.BalanceCheckFlag _balanceCheckFlag
) external;

Isolation Mode Assets

This part of the docs is still under construction 🚧

Last updated