Vault
Keeps track of all token reserves for all market
Methods
DEFAULT_ADMIN_ROLE
Returns
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
EMERGENCY_ADMIN
Returns
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
GOVERNANCE
Returns
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
UA
Returns
Name | Type | Description |
---|---|---|
_0 | contract IERC20Metadata | undefined |
UA_IDX
Returns
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
addWhiteListedCollateral
Add a new token to the list of whitelisted ERC20 which can be used as collaterals
Parameters
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | Address of the token to be whitelisted as a valid collateral in the Vault |
weight | uint256 | Discount weight to be applied on the asset vault |
maxAmount | uint256 | Maximum total amount that the Vault will accept of this collateral |
changeCollateralMaxAmount
Change max amount of a whitelisted collateral Useful as a risk mitigation measure in case one collateral drops in value
Parameters
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | Address of asset to change max amount |
newMaxAmount | uint256 | New max amount for the collateral |
changeCollateralWeight
Change weight of a whitelisted collateral Useful as a risk mitigation measure in case one collateral drops in value
Parameters
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | Address of asset to change collateral weight |
newWeight | uint256 | New weight. 18 decimals |
clearingHouse
Returns
Name | Type | Description |
---|---|---|
_0 | contract IClearingHouse | undefined |
decreaseAllowance
Decrease the approval of another account to withdraw a user's tokens
Parameters
Name | Type | Description |
---|---|---|
user | address | Address to debit Vault collateral from |
receiver | address | Address to credit ERC20 token to |
subtractedAmount | uint256 | Amount to be decrease the current approval by. 18 decimals |
token | contract IERC20Metadata | One whitelisted token |
deposit
Add an amount of a whitelisted token to the balance of a user
Parameters
Name | Type | Description |
---|---|---|
sender | address | undefined |
user | address | Account to deposit collateral to |
amount | uint256 | Amount to be used as the collateral of the position. Might not be 18 decimals (decimals of the token) |
depositToken | contract IERC20Metadata | One whitelisted token |
getAllowance
Get the Allowance that a user has given a receiver for a specified token
Parameters
Name | Type | Description |
---|---|---|
user | address | address of the user to withdraw from |
receiver | address | address of the receiver of tokens for a withdrawal |
tokenIdx | uint256 | Index of the token |
Returns
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
getBalance
Get the balance of a user of a given token
Parameters
Name | Type | Description |
---|---|---|
user | address | User address |
tokenIdx | uint256 | Index of the token |
Returns
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
getNumberOfCollaterals
Get number of whitelisted tokens
Returns
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
getReserveValue
Get the balance of a user, accounted for in USD. 18 decimals
Parameters
Name | Type | Description |
---|---|---|
user | address | User address |
isDiscounted | bool | Whether or not the reserve value should be discounted by the weight of the collateral |
Returns
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
getRoleAdmin
Returns the admin role that controls role
. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
getTotalValueLocked
Get total value of all tokens deposited in the vault, in USD. 18 decimals
Returns
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
getWhiteListedCollateral
Get details of a whitelisted collateral token
Parameters
Name | Type | Description |
---|---|---|
idx | uint256 | Index of the whitelisted collateral to get details from |
Returns
Name | Type | Description |
---|---|---|
_0 | IVault.Collateral | undefined |
grantRole
Grants role
to account
. If account
had not been already granted role
, emits a {RoleGranted} event. Requirements: - the caller must have role
's admin role. May emit a {RoleGranted} event.
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
hasRole
Returns true
if account
has been granted role
.
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
increaseAllowance
Increase the approval of another account to withdraw a user's tokens
Parameters
Name | Type | Description |
---|---|---|
user | address | Address to debit Vault collateral from |
receiver | address | Address to credit ERC20 token to |
addedAmount | uint256 | Amount to be increase the current approval by. 18 decimals |
token | contract IERC20Metadata | One whitelisted token |
insurance
Returns
Name | Type | Description |
---|---|---|
_0 | contract IInsurance | undefined |
isEmergencyAdmin
Parameters
Name | Type | Description |
---|---|---|
account | address | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
isGovernor
Parameters
Name | Type | Description |
---|---|---|
account | address | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
oracle
Returns
Name | Type | Description |
---|---|---|
_0 | contract IOracle | undefined |
renounceRole
Revokes role
from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked role
, emits a {RoleRevoked} event. Requirements: - the caller must be account
. May emit a {RoleRevoked} event.
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
revokeRole
Revokes role
from account
. If account
had been granted role
, emits a {RoleRevoked} event. Requirements: - the caller must have role
's admin role. May emit a {RoleRevoked} event.
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
setClearingHouse
Update the ClearingHouse address
Parameters
Name | Type | Description |
---|---|---|
newClearingHouse | contract IClearingHouse | Address of the new ClearingHouse |
setInsurance
Update the Insurance address
Parameters
Name | Type | Description |
---|---|---|
newInsurance | contract IInsurance | Address of the new Insurance |
setOracle
Update the Oracle address
Parameters
Name | Type | Description |
---|---|---|
newOracle | contract IOracle | Address of the new Oracle |
settleLiquidationOnCollaterals
Allow liquidator to buy back non-UA collateral(s) of liquidated user at a discounted price whereby settling the latter debt
The liquidator buys just as much non-UA collaterals to cover the liquidatee's debt, not moreIf the USD value of all the non-UA collaterals of the liquidatee < his UA debt, Increment insurance steps in to cover the remainder of the UA debt
Parameters
Name | Type | Description |
---|---|---|
liquidator | address | Address of the liquidator |
liquidatee | address | Address of the liquidatee |
settlePnL
Settle PnL for user in UA
Parameters
Name | Type | Description |
---|---|---|
user | address | Account to apply the PnL to |
amount | int256 | PnL amount in UA to apply. 18 decimals |
supportsInterface
See {IERC165-supportsInterface}.
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
tokenToCollateralIdx
Map whitelisted collateral tokens to their whiteListedCollaterals indices
Parameters
Name | Type | Description |
---|---|---|
_0 | contract IERC20Metadata | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
transferUa
Transfer UA tokens from the vault
Important: the balance of the user from whom the UA tokens are being withdrawn must be updated separately
Parameters
Name | Type | Description |
---|---|---|
user | address | Account to withdraw UA tokens to |
amount | uint256 | Amount of UA tokens to be withdrawn. 18 decimals |
withdraw
Withdraw tokens stored by a user in the vault
Unlike deposit
, withdraw
treats withdrawals of UA differently than other collaterals
Parameters
Name | Type | Description |
---|---|---|
user | address | Account to withdraw from |
amount | uint256 | Amount to withdraw from the vault. Might not be 18 decimals (decimals of the token) |
withdrawToken | contract IERC20Metadata | Token whose balance is to be withdrawn from the vault |
withdrawAll
Withdraw all tokens stored by a user in the vault
Parameters
Name | Type | Description |
---|---|---|
user | address | Account to withdraw from |
withdrawToken | contract IERC20Metadata | Token whose balance is to be withdrawn from the vault |
withdrawFrom
Withdraw tokens from a user in the vault to a receiving account
Unlike deposit
, withdraw
treats withdrawals of UA differently than other collaterals
Parameters
Name | Type | Description |
---|---|---|
user | address | Account to withdraw from |
receiver | address | Account that should receiver the tokens |
amount | uint256 | Amount to withdraw from the vault. Might not be 18 decimals (decimals of the token) |
withdrawToken | contract IERC20Metadata | Token whose balance is to be withdrawn from the vault |
Events
Approval
Emitted when a new approval value is set
Parameters
Name | Type | Description |
---|---|---|
user | address | undefined |
receiver | address | undefined |
tokenIdx | uint256 | undefined |
amount | uint256 | undefined |
ClearingHouseChanged
Emitted when the ClearingHouse address is updated
Parameters
Name | Type | Description |
---|---|---|
newClearingHouse | contract IClearingHouse | undefined |
CollateralAdded
Emitted when a new collateral is added to the Vault
Parameters
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | undefined |
weight | uint256 | undefined |
maxAmount | uint256 | undefined |
CollateralMaxAmountChanged
Emitted when a collateral max amount is updated
Parameters
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | undefined |
newMaxAmount | uint256 | undefined |
CollateralWeightChanged
Emitted when a collateral weight is updated
Parameters
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | undefined |
newWeight | uint256 | undefined |
Deposit
Emitted when collateral is deposited into the vault
Parameters
Name | Type | Description |
---|---|---|
user | address | undefined |
asset | address | undefined |
amount | uint256 | undefined |
InsuranceChanged
Emitted when the Insurance address is updated
Parameters
Name | Type | Description |
---|---|---|
newInsurance | contract IInsurance | undefined |
OracleChanged
Emitted when the Oracle address is updated
Parameters
Name | Type | Description |
---|---|---|
newOracle | contract IOracle | undefined |
RoleAdminChanged
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
previousAdminRole | bytes32 | undefined |
newAdminRole | bytes32 | undefined |
RoleGranted
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
sender | address | undefined |
RoleRevoked
Parameters
Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
sender | address | undefined |
TraderBadDebtGenerated
Emitted when bad debt is settled for by the insurance reserve
Parameters
Name | Type | Description |
---|---|---|
beneficiary | address | undefined |
amount | uint256 | undefined |
Withdraw
Emitted when collateral is withdrawn from the vault
Parameters
Name | Type | Description |
---|---|---|
user | address | undefined |
asset | address | undefined |
amount | uint256 | undefined |
Errors
PRBMathSD59x18__MulInputTooSmall
Emitted when one of the inputs is MIN_SD59x18.
PRBMathSD59x18__MulOverflow
Emitted when the intermediary absolute result overflows SD59x18.
Parameters
Name | Type | Description |
---|---|---|
rAbs | uint256 | undefined |
PRBMath__MulDivFixedPointOverflow
Emitted when the result overflows uint256.
Parameters
Name | Type | Description |
---|---|---|
prod1 | uint256 | undefined |
PRBMath__MulDivOverflow
Emitted when the result overflows uint256.
Parameters
Name | Type | Description |
---|---|---|
prod1 | uint256 | undefined |
denominator | uint256 | undefined |
Vault_ApproveZeroAddress
Emitted when a user attempts to approve the zero address
Vault_ClearingHouseAlreadySet
Emitted when the clearingHouse has already been set (one time call function)
Vault_ClearingHouseZeroAddress
Emitted when the proposed clearingHouse address is equal to the zero address
Vault_CollateralAlreadyWhiteListed
Emitted when owner tries to whitelist a collateral already whitelisted
Vault_ExcessiveCollateralWeight
Emitted when the proposed collateral weight is above the limit
Vault_InsufficientBalance
Emitted when a user attempts to withdraw more collateral than available in vault
Vault_InsufficientCollateralWeight
Emitted when the proposed collateral weight is under the limit
Vault_InsuranceAlreadySet
Emitted when the insurance has already been set (one time call function)
Vault_InsuranceZeroAddress
Emitted when the proposed insurance address is equal to the zero address
Vault_MaxCollateralAmountExceeded
Emitted when a user attempts to withdraw more collateral than available in vault
Vault_OracleZeroAddress
Emitted when the proposed oracle address is equal to the zero address
Vault_SenderNotClearingHouse
Emitted when the sender is not the clearing house
Vault_SenderNotInsurance
Emitted when the sender is nor the insurance
Vault_UADebt
Emitted when user tries to withdraw collateral while having a UA debt
Vault_UnsupportedCollateral
Emitted when a user attempts to use a token which is not whitelisted as collateral
Vault_WithdrawExcessiveAmount
Emitted when a user attempts to withdraw more than their balance
Vault_WithdrawInsufficientAllowance
Emitted when a user attempts to withdraw more than their allowance
Vault_ZeroAddressConstructor
Emitted when the zero address is provided as a parameter in the constructor
Parameters
Name | Type | Description |
---|---|---|
paramIndex | uint8 | undefined |
Last updated