Vault
Keeps track of all token reserves for all market
function DEFAULT_ADMIN_ROLE() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function EMERGENCY_ADMIN() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function GOVERNANCE() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function UA() external view returns (contract IERC20Metadata)
Name | Type | Description |
---|---|---|
_0 | contract IERC20Metadata | undefined |
function UA_IDX() external view returns (uint256)
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function addWhiteListedCollateral(contract IERC20Metadata asset, uint256 weight, uint256 maxAmount) external nonpayable
Add a new token to the list of whitelisted ERC20 which can be used as collaterals
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 |
function changeCollateralMaxAmount(contract IERC20Metadata asset, uint256 newMaxAmount) external nonpayable
Change max amount of a whitelisted collateral Useful as a risk mitigation measure in case one collateral drops in value
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | Address of asset to change max amount |
newMaxAmount | uint256 | New max amount for the collateral |
function changeCollateralWeight(contract IERC20Metadata asset, uint256 newWeight) external nonpayable
Change weight of a whitelisted collateral Useful as a risk mitigation measure in case one collateral drops in value
Name | Type | Description |
---|---|---|
asset | contract IERC20Metadata | Address of asset to change collateral weight |
newWeight | uint256 | New weight. 18 decimals |
function clearingHouse() external view returns (contract IClearingHouse)
Name | Type | Description |
---|---|---|
_0 | contract IClearingHouse | undefined |
function decreaseAllowance(address user, address receiver, uint256 subtractedAmount, contract IERC20Metadata token) external nonpayable
Decrease the approval of another account to withdraw a user's tokens
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 |
function deposit(address sender, address user, uint256 amount, contract IERC20Metadata depositToken) external nonpayable
Add an amount of a whitelisted token to the balance of a user
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 |
function getAllowance(address user, address receiver, uint256 tokenIdx) external view returns (uint256)
Get the Allowance that a user has given a receiver for a specified token
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 |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function getBalance(address user, uint256 tokenIdx) external view returns (int256)
Get the balance of a user of a given token
Name | Type | Description |
---|---|---|
user | address | User address |
tokenIdx | uint256 | Index of the token |
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function getNumberOfCollaterals() external view returns (uint256)
Get number of whitelisted tokens
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function getReserveValue(address user, bool isDiscounted) external view returns (int256)
Get the balance of a user, accounted for in USD. 18 decimals
Name | Type | Description |
---|---|---|
user | address | User address |
isDiscounted | bool | Whether or not the reserve value should be discounted by the weight of the collateral |
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function getRoleAdmin(bytes32 role) external view returns (bytes32)
Returns the admin role that controls
role
. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function getTotalValueLocked() external view returns (int256)
Get total value of all tokens deposited in the vault, in USD. 18 decimals
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function getWhiteListedCollateral(uint256 idx) external view returns (struct IVault.Collateral)
Get details of a whitelisted collateral token
Name | Type | Description |
---|---|---|
idx | uint256 | Index of the whitelisted collateral to get details from |
Name | Type | Description |
---|---|---|
_0 | IVault.Collateral | undefined |
function grantRole(bytes32 role, address account) external nonpayable
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.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
function hasRole(bytes32 role, address account) external view returns (bool)
Returns
true
if account
has been granted role
.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function increaseAllowance(address user, address receiver, uint256 addedAmount, contract IERC20Metadata token) external nonpayable
Increase the approval of another account to withdraw a user's tokens
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 |
function insurance() external view returns (contract IInsurance)
Name | Type | Description |
---|---|---|
_0 | contract IInsurance | undefined |
function isEmergencyAdmin(address account) external view returns (bool)
Name | Type | Description |
---|---|---|
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function isGovernor(address account) external view returns (bool)
Name | Type | Description |
---|---|---|
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function oracle() external view returns (contract IOracle)
Name | Type | Description |
---|---|---|
_0 | contract IOracle | undefined |
function renounceRole(bytes32 role, address account) external nonpayable
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.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
function revokeRole(bytes32 role, address account) external nonpayable
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.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
function setClearingHouse(contract IClearingHouse newClearingHouse) external nonpayable
Update the ClearingHouse address
Name | Type | Description |
---|---|---|
newClearingHouse | contract IClearingHouse | Address of the new ClearingHouse |
function setInsurance(contract IInsurance newInsurance) external nonpayable
Update the Insurance address
Name | Type | Description |
---|---|---|
newInsurance | contract IInsurance | Address of the new Insurance |
function setOracle(contract IOracle newOracle) external nonpayable
Update the Oracle address
Name | Type | Description |
---|---|---|
newOracle | contract IOracle | Address of the new Oracle |
function settleLiquidationOnCollaterals(address liquidator, address liquidatee) external nonpayable
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
Name | Type | Description |
---|---|---|
liquidator | address | Address of the liquidator |
liquidatee | address | Address of the liquidatee |
function settlePnL(address user, int256 amount) external nonpayable
Settle PnL for user in UA
Name | Type | Description |
---|---|---|
user | address | Account to apply the PnL to |
amount | int256 | PnL amount in UA to apply. 18 decimals |
function supportsInterface(bytes4 interfaceId) external view returns (bool)
See {IERC165-supportsInterface}.
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function tokenToCollateralIdx(contract IERC20Metadata) external view returns (uint256)
Map whitelisted collateral tokens to their whiteListedCollaterals indices
Name | Type | Description |
---|---|---|
_0 | contract IERC20Metadata | undefined |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function transferUa(address user, uint256 amount) external nonpayable
Transfer UA tokens from the vault
Important: the balance of the user from whom the UA tokens are being withdrawn must be updated separately
Name | Type | Description |
---|---|---|
user | address | Account to withdraw UA tokens to |
amount | uint256 | Amount of UA tokens to be withdrawn. 18 decimals |
function withdraw(address user, uint256 amount, contract IERC20Metadata withdrawToken) external nonpayable
Withdraw tokens stored by a user in the vault
Unlike
deposit
, withdraw
treats withdrawals of UA differently than other collateralsName | 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 |
function withdrawAll(address user, contract IERC20Metadata withdrawToken) external nonpayable
Withdraw all tokens stored by a user in the vault
Name | Type | Description |
---|---|---|
user | address | Account to withdraw from |
withdrawToken | contract IERC20Metadata | Token whose balance is to be withdrawn from the vault |
function withdrawFrom(address user, address receiver, uint256 amount, contract IERC20Metadata withdrawToken) external nonpayable
Withdraw tokens from a user in the vault to a receiving account
Unlike
deposit
, withdraw
treats withdrawals of UA differently than other collaterals