UNPKG

ulysses-sdk

Version:

An sdk for interacting with the Ulysses contracts

92 lines (91 loc) 3.88 kB
import { Currency, CurrencyAmount } from 'maia-core-sdk'; export interface ICurrencyBalances { native: CurrencyAmount<Currency> | undefined; global: CurrencyAmount<Currency> | undefined; hToken: CurrencyAmount<Currency> | undefined; virtual: { native: CurrencyAmount<Currency> | undefined; global: CurrencyAmount<Currency> | undefined; }; } /** * Represents the balances of a user across all currencies on the chain */ export declare class CurrencyBalances { readonly token: Currency; readonly currencyBalances: ICurrencyBalances; private _totalBalance?; private _rootBalance?; /** * @param Currency The global token of the chain * @param currencyBalances The balances of the user * @param currencyBalances.native The native balance of the user * @param currencyBalances.global The global balance of the user * @param currencyBalances.hToken The hToken balance of the user * @param currencyBalances.virtual The virtual balance of the user * @param currencyBalances.virtual.native The virtual native balance of the user * @param currencyBalances.virtual.global The virtual global balance of the user * @returns The currency balances of the user * @example * ```ts * const currencyBalances = new CurrencyBalances(Currency, { * native: CurrencyAmount.fromRawAmount(Currency.wrapped, 100), * global: CurrencyAmount.fromRawAmount(Currency, 100), * hToken: CurrencyAmount.fromRawAmount(hToken, 100), * virtual: { * native: CurrencyAmount.fromRawAmount(Currency.wrapped, 100), * global: CurrencyAmount.fromRawAmount(Currency, 100), * }, * }) * ``` */ constructor(token: Currency, currencyBalances: ICurrencyBalances); /** * Returns the total sum of balances of the user, including the balance from the virtual account. * @returns The total spendable balance of the user. */ getTotalBalance(): CurrencyAmount<Currency>; /** * Returns the total sum of balances of the user, spendable from a chain. * @param isRootChain Whether the chain is the root chain or not. * @dev If isRootChain is not provided, it defaults to false. * @returns The total spendable balance of the user from the chain. */ getBalance(isRootChain?: boolean): CurrencyAmount<Currency>; /** * Returns the total sum of balances of the user, spendable from a remote chain. * @returns The total spendable balance of the user from the remote chain. */ getRemoteBalance(): CurrencyAmount<Currency>; /** * Returns the total sum of balances of the user, spendable from the root chain. * @returns The total spendable balance of the user from the root chain. */ getRootBalance(): CurrencyAmount<Currency>; getNativeBalance(): CurrencyAmount<Currency>; /** * Returns the combined native balance of the user, including the balance from the virtual account. * @returns */ getCombinedNativeBalance(): { native: CurrencyAmount<Currency>; virtual: CurrencyAmount<Currency>; total: CurrencyAmount<Currency>; }; getGlobalBalance(): CurrencyAmount<Currency>; getCombinedGlobalBalance(): { global: CurrencyAmount<Currency>; virtual: CurrencyAmount<Currency>; total: CurrencyAmount<Currency>; }; getHTokenBalance(): CurrencyAmount<Currency>; getVirtualBalance(): { virtual: { native: CurrencyAmount<Currency> | undefined; global: CurrencyAmount<Currency> | undefined; }; }; getVirtualNativeBalance(): CurrencyAmount<Currency>; getVirtualGlobalBalance(): CurrencyAmount<Currency>; private parseCurrencyAmount; }