Constructor
new Prices(options)
Create an instance of the Prices service.
Parameters:
Name | Type | Description |
---|---|---|
options |
See CaskSDK configuration. |
- See:
Methods
balance(args) → {string|number|*}
Get the current balance of a specified asset for a given address (or the address of the connected signer).
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Function arguments
Properties
|
- See:
-
- The SDK guide for more details on unit formatting at https://docs.cask.fi/developer-docs/javascript-sdk
Returns:
- Type
- string | number | *
currenRawPrice(asset) → {string}
Current price of an asset in the raw price feed asset decimal format.
Parameters:
Name | Type | Description |
---|---|---|
asset |
Vault.Asset | Asset |
Returns:
- Type
- string
currentRawBalance(asset) → {string}
Current balance of an asset in the monitored address represented in the native decimals of the asset.
Parameters:
Name | Type | Description |
---|---|---|
asset |
Asset | Asset |
Returns:
- Type
- string
currentWalletAddress() → {string}
Get current wallet being monitored for balances.
Returns:
- Type
- string
(async) init(args)
Initialize the price feed service.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Function arguments
Properties
|
(async) onBalancesReady(handler)
Register a callback to be called after the wallet balances are available. Is called both when the price
feed is first loaded if there is a wallet address, or after the signer changes.
Parameters:
Name | Type | Description |
---|---|---|
handler |
(async) onPricesReady(handler)
Register a callback to be called after the price feed is ready
Parameters:
Name | Type | Description |
---|---|---|
handler |
(async) onPricesUpdated(handler)
Register a callback to be called after prices/balances have been refreshed
Parameters:
Name | Type | Description |
---|---|---|
handler |
(async) refreshData()
Refresh the current asset prices and token balances. Called automatically if the price service
was constructed with a refresh interval.
stop()
Stop automatically refreshing price data.
usdPrice(args) → {string|number|*}
Convert an amount of a specified asset into its current USD price.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Function arguments
Properties
|
- See:
-
- The SDK guide for more details on unit formatting at https://docs.cask.fi/developer-docs/javascript-sdk
Returns:
- Type
- string | number | *