@firefly-exchange/library-sui
Version:
Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui
71 lines (70 loc) • 3.42 kB
TypeScript
import { SuiClient } from "../../types";
import { DepositedAsset, IAccount, IPosition } from "../interfaces";
import { DeploymentParser } from "../utils";
import { Address } from "../../types";
export default class Account {
/**
* Fetches the account details from on-chain from provided internal data store
* @param suiClient Sui Client
* @param storeID The id/address of the internal store
* @param account The address of user to be fetched
* @returns
*/
static getAccount(suiClient: SuiClient, storeID: string, account: string): Promise<IAccount>;
/**
* Fetches the user assets from on-chain from provided internal data store
* @param suiClient Sui Client
* @param storeID The id/address of the internal store
* @param account The address of user to be fetched
* @returns Array of Deposited Assets
*/
static getAccountAssets(suiClient: SuiClient, storeID: string, account: string): Promise<Array<DepositedAsset>>;
/**
* Fetches the user margin from on-chain from provided internal data store
* @param suiClient Sui Client
* @param storeID The id/address of the internal store
* @param account The address of user to be fetched
* @returns The margin of the account in base number
*/
static getAccountMargin(suiClient: SuiClient, storeID: string, account: string): Promise<number>;
/**
* Returns the margin user has available for withdrawal on-chain
* @param suiClient Sui Client
* @param parser The deployment config parser
* @param account The account address for which to query withdrawable balance
* @param asset The name of the asset that is to be queried
* @returns The user available margin for withdraw in base number
*/
static getWithdrawableAssets(suiClient: SuiClient, parser: DeploymentParser, account: Address, asset: string): Promise<number>;
/**
* Fetches the user positions from on-chain from provided internal data store
* @param suiClient Sui Client
* @param storeID The id/address of the internal store
* @param account The address of user to be fetched
* @returns
*/
static getAccountCrossPositions(suiClient: SuiClient, storeID: string, account: string): Promise<Array<IPosition>>;
/**
* Fetches the user position for provided perpetual from on-chain from provided internal data store
* @param suiClient Sui Client
* @param storeID The id/address of the internal store
* @param account The address of user to be fetched (address_1)
* @param perpetual The address of the perpetual for which to fetch the position
* @returns Position of the user on provided perp
*/
static getAccountCrossPositionForPerpetual(suiClient: SuiClient, storeID: string, account: string, perpetual: string): Promise<IPosition>;
/**
* Fetches the list of accounts/address that are authorized for given account
* @param suiClient Sui Client
* @param storeID The id/address of the internal store
* @param account The address of user to be fetched (address_1)
* @returns list of addresses
*/
static getAuthorizedAccounts(suiClient: SuiClient, storeID: string, account: string): Promise<Array<string>>;
/**
* Method to parse the position
* @param fields the position fields
* @returns IPosition
*/
private static mapPosition;
}