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 DepositWithdrawalProxyhere.
Depositing
Depositing an asset requires an approval for the corresponding amount on DolomiteMargin. You can find the contract addresses for DolomiteMarginhere.
/** * @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 */functiondepositWei(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 */functiondepositETH(uint256_toAccountNumber) externalpayable;/** * @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. */functiondepositPar(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.
libraryAccountBalanceLib {enumBalanceCheckFlag { 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 */functionwithdrawWei(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 */functionwithdrawETH(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. */functionwithdrawPar(uint256_fromAccountNumber,uint256_marketId,uint256_amountPar,AccountBalanceLib.BalanceCheckFlag_balanceCheckFlag) external;
Isolation Mode Assets
This part of the docs is still under construction 🚧