Constructor
new Vault(options)
Create an instance of the Vault service.
Parameters:
Name |
Type |
Description |
options |
|
See CaskSDK configuration. |
- See:
-
Members
assetMap
Map of asset address to Asset object for all assets supported by the vault
- See:
-
Methods
(async) allowance(args) → {Promise.<boolean>}
Get current allowance the vault can access of an asset for a given address.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
Returns:
-
Type
-
Promise.<boolean>
amountInAsset(args) → {string}
Format the specified amount into the native format of the specified asset.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Description |
asset |
Vault.Asset
|
string
|
|
Asset |
amountSimple |
float
|
<optional>
|
Amount (simple format) |
amountAsset |
string
|
<optional>
|
Amount (asset format) |
|
Returns:
-
Type
-
string
(async) approve(args) → {Promise.<{tx}>}
Approve an amount of the specified asset for the vault to make deposits.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Description |
asset |
Vault.Asset
|
string
|
|
Asset |
amountSimple |
float
|
<optional>
|
Amount in float format |
amountAsset |
string
|
<optional>
|
Amount in asset decimals format |
|
Returns:
-
Type
-
Promise.<{tx}>
(async) approveAndDeposit(args) → {Promise.<{tx}>}
Approve and deposit an asset into the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
amountSimple |
float
|
<optional>
|
|
Amount in float format |
amountAsset |
string
|
<optional>
|
|
Amount in asset decimals format |
to |
string
|
<optional>
|
ethersConnection.address
|
Address to receive deposit credit |
|
Returns:
-
Type
-
Promise.<{tx}>
(async) balance(args) → {Promise.<(number|*)>}
Get the total value that an address owns in the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
address |
number
|
<optional>
|
ethersConnection.address
|
Address for balance inquery |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
Promise.<(number|*)>
(async) convertAmount(args) → {Promise.<(number|*)>}
Convert an amount from one vault asset into another asset using oracle price feeds.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset being converted |
toAsset |
Vault.Asset
|
string
|
|
|
Asset the amount is being converted into |
amountSimple |
float
|
<optional>
|
|
Amount to convert (simple format) |
amountAsset |
string
|
<optional>
|
|
Amount to convert (asset format) |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
Promise.<(number|*)>
(async) deposit(args) → {Promise.<{tx}>}
Deposit an asset into the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
amountSimple |
float
|
<optional>
|
|
Amount to deposit (simple format) |
amountAsset |
string
|
<optional>
|
|
Amount to deposit (asset format) |
to |
string
|
<optional>
|
ethersConnection.address
|
Address to receive deposit credit |
|
Returns:
-
Type
-
Promise.<{tx}>
Get the details of a vault asset
Parameters:
Name |
Type |
Description |
asset |
|
Asset address or token name |
Returns:
-
Type
-
Vault.Asset
(async) getFundingSource(args) → {Promise.<{*}>}
Get funding source for an address.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
address |
string
|
<optional>
|
this.ethersConnection.address
|
Address |
|
Returns:
-
Type
-
Promise.<{*}>
(async) init(args)
Initialize the vault service.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Description |
ethersConnection |
EthersConnection
|
<optional>
|
EthersConnection instance |
|
(async) loadVaultAssets()
Load all the vault assets into memory
(async) needApproval(args) → {Promise.<boolean>}
Check if an approval is needed for a certain amount of an asset before a deposit can take place.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Description |
asset |
Vault.Asset
|
string
|
|
Asset |
amountSimple |
float
|
<optional>
|
Amount in float format |
amountAsset |
string
|
<optional>
|
Amount in asset decimals format |
|
Returns:
-
Type
-
Promise.<boolean>
(async) onAssetsLoaded(handler)
Register a callback to be called after the vault is (re-)connected to a blockchain and all the
vault assets have be (re)loaded.
Parameters:
Name |
Type |
Description |
handler |
|
|
(async) quoteDeposit(args) → {Promise.<(number|*)>}
Quote how much vault value will be given for depositing the specified amount of a given asset.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
amountSimple |
float
|
<optional>
|
|
Amount to deposit (simple format) |
amountAsset |
string
|
<optional>
|
|
Amount to deposit (asset format) |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
Promise.<(number|*)>
(async) quoteWithdrawal(args) → {Promise.<(number|*)>}
Quote how much of the specified asset will be given for withdrawing an amount of value from the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
amountSimple |
float
|
<optional>
|
|
Amount to withdraw (simple format) |
amountAsset |
string
|
<optional>
|
|
Amount to withdraw (asset format) |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
Promise.<(number|*)>
(async) setFundingSource(args) → {Promise.<{tx}>}
Set funding source of current signer to use for vault payments.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Description |
fundingSource |
number
|
Funding source |
asset |
Vault.Asset
|
string
|
Asset |
|
Returns:
-
Type
-
Promise.<{tx}>
(async) sharesForAmount(args) → {Promise.<string>}
Calculate the number of shares that represent specified amount in the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
<optional>
|
baseAsset
|
Asset |
amountSimple |
float
|
<optional>
|
|
Amount (simple format) |
amountAsset |
string
|
<optional>
|
|
Amount (asset format) |
|
- See:
-
Returns:
-
Type
-
Promise.<string>
(async) totalAssetBalance(args) → {Promise.<(number|*)>}
Get the total value held of a specified asset in the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
units |
string
|
<optional>
|
|
Units of output |
unitOptions |
Object
|
<optional>
|
{}
|
Options passed to unit formatter. |
|
- See:
-
Returns:
-
Type
-
Promise.<(number|*)>
(async) transfer(args) → {Promise.<{tx}>}
Transfer an amount of value from one cask wallet to another cask wallet.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Description |
amountSimple |
float
|
<optional>
|
Amount to transfer (simple format) |
amountAsset |
string
|
<optional>
|
Amount to transfer (asset format) |
to |
string
|
|
Address to receive the transfer |
|
Returns:
-
Type
-
Promise.<{tx}>
(async) withdraw(args) → {Promise.<{tx}>}
Withdraw an asset from the vault.
Parameters:
Name |
Type |
Description |
args |
Object
|
Function arguments
Properties
Name |
Type |
Attributes |
Default |
Description |
asset |
Vault.Asset
|
string
|
|
|
Asset |
amountSimple |
float
|
<optional>
|
|
Amount to withdraw (simple format) |
amountAsset |
string
|
<optional>
|
|
Amount to withdraw (asset format) |
to |
string
|
<optional>
|
ethersConnection.address
|
Address to receive withdrawn assets |
|
Returns:
-
Type
-
Promise.<{tx}>
Type Definitions
Asset
Type:
Properties:
Name |
Type |
Description |
address |
string
|
Asset address |
priceFeed |
string
|
Oracle price feed address |
slippageBps |
number
|
Basis points applied as slippage on deposits and withdrawals of the asset |
assetDecimals |
number
|
Number of decimals for asset |
priceFeedDecimals |
number
|
Number of decimals used in price feed |
allowed |
boolean
|
true if asset is accepted in the Cask vault, false otherwise |
symbol |
string
|
Asset symbol |
priceFeedContract |
ethers.Contract
|
An ethers.Contract instance of the price feed oracle contract |
tokenContract |
ethers.Contract
|
an ethers.Contract instance of the ERC20 token contract |