TradableMarginVault
- This is a generic vault contract that attaches to any contract and handles the processing of user balance and calls the depositValidation and withdrawalValidationn function of the contract
- This contract stores user balances and is used to hold the proof of ownership of funds to users.
- This contract is an attempt to seperate the balance holding mechanism from the business logic.
function marginAccountDeposit(address user, ITradableSettings.AcceptedToken memory selectedToken, uint256 amount) external { ..... }
Name | Type | Description |
user | address | address of the user that is initiating the deposit |
selectedToken | ITradableSettings.AcceptedToken | this is the ITradableSettings.AcceptedToken of the token being transacted |
amount | uint256 | amount to be deposited to balance |
dstVault | address | address of side vault where the deposit was initiated |
function marginAccountWithdrawal(address user, ITradableSettings.AcceptedToken memory selectedToken, uint256 amount, address dstVault) external { ..... }
Name | Type | Description |
user | address | address of the user that is initiating the withdrawal |
selectedToken | ITradableSettings.AcceptedToken | this is the ITradableSettings.AcceptedToken of the token being transacted |
amount | uint256 | amount to be withdrawn from balance |
dstVault | address | address of side vault where the withdrawal will be finalized |
function transferWithdrawableBalance(address reciever, address token, uint256 amount) external { ..... }
Name | Type | Description |
reciever | address | address of reciever of balance transfer |
token | address | address of token balance that is being updated |
amount | uint256 | amount to be transferred from balance |
function getUserTokenBalance(address user, address token) view external returns (uint256) { ..... }
Name | Type | Description |
user | address | address of user whose balance is being checked |
token | address | address of token of which balance is being checked |
Name | Type | Description |
getUserTokenBalance | uint256 | token balance a user has in their margin account |
event BaseChainDepositProcessed(address indexed user, address token, uint256 amount);
event BaseChainWithdrawalProcessed(address indexed user, address token, uint256 amount);
event WithdrawableBalanceUpdated(address indexed user, address token, uint256 balance, bool isAdded);
event WithdrawableBalanceTransferred(address sender, address indexed reciever, address token, uint256 amount);