TradableMarginHandler
- This contract validates withdrawal and deposit requests for users margin accounts depending on the type of user.
- The types of users are either MarketMaker or User.
- The different users undergo different types of verifications for withdrawal and deposit.
- There is also a function to send a message to the side vault to create user margin funding acccount.
function setSettingsProvider(address newSettingsProvider) OnlyAdminUser AddressNotNull(newSettingsProvider) external { ..... }
Name | Type | Description |
newSettingsProvider | address | address of settingsProvider contract |
function setVault(address newVault) OnlyAdminUser AddressNotNull(newVault) external { ...... }
Name | Type | Description |
newVault | address | address of vault to be set as default margin vault |
function depositValidation(address caller, address user, ITradableSettings.AcceptedToken memory selectedToken, uint256 amount) AddressNotNull(caller) external { ...... }
Name | Type | Description |
user | address | address of user performing deposit |
selectedToken | ITradableSettings.AcceptedToken | this is an accepted token struct holding the token address, decimal and isActive |
amount | uint256 | amount of selectedToken to be withdrawn |
caller | address | address of verified contract allowed to call on deposit validation |
function withdrawalValidation(address user, ITradableSettings.AcceptedToken memory selectedToken, uint256 amount, address dstVault) AddressNotNull(user) external { ...... }
Name | Type | Description |
user | address | address of user performing withdrawal |
selectedToken | ITradableSettings.AcceptedToken | this is an accepted token struct holding the token address, decimal and isActive |
amount | uint256 | amount of selectedToken to be withdrawn |
dstVault | address | address of sidevault where withdrawal was initiated |
function createUserMarginAccount(ITradableSettings.UserType userType, address user, address fundingAccount) external { ...... }
Name | Type | Description |
userType | ITradableSettings.UserType | this could either be marketmaker or user |
user | address | address of user that owns the funding account. |
fundingAccount | address | address of user's SideMarginFundingAccount |
function getFundingAccount(address user) AddressNotNull(user) AddressNotNull(_usersMap[user].fundingAccount) view external returns (address) { ...... }
Name | Type | Description |
user | address | address of user that owns the funding account. |
Name | Type | Description |
getFundingAccount | address | gets user funding account address. |
function getUser(address user) view external returns(User memory) { ...... }
Name | Type | Description |
getUser | User | gets user struct containing; user address, usertype enum and funding account address. |
event MarginDepositValidated(address user, ITradableSettings.UserType userType, address token, uint256 amount)
event MarginWithdrawalValidated(address user, ITradableSettings.UserType userType, address token, uint256 amount)
event FundingAccountCreationInstantiated(address user, address dstVault, uint16 chainId);
event FundingAccountStored(address user, address fundingAccount);