@mak201010/bluefin-v2-client
Version:
The Bluefin client Library allows traders to sign, create, retrieve and listen to orders on Bluefin Exchange.
96 lines (95 loc) • 4.34 kB
TypeScript
import { address, ADJUST_MARGIN, OnChainCalls, SuiClient, TRANSFERABLE_COINS, ZkPayload } from "@mak201010/library-sui";
import { Signer } from "@mysten/sui.js/cryptography";
import { ResponseSchema } from "./contractErrorHandling.service";
export declare class ContractCalls {
onChainCalls: OnChainCalls;
signer: Signer;
suiClient: SuiClient;
marginBankId: string | undefined;
walletAddress: string;
is_wallet_extension: boolean;
constructor(signer: Signer, deployment: any, provider: SuiClient, is_zkLogin: boolean, zkPayload?: ZkPayload, walletAddress?: string, is_wallet_extension?: boolean);
/**
* Withdraws funds from the margin bank contract
* @param amount the amount to withdraw
* @returns ResponseSchema
* */
withdrawFromMarginBankContractCall: (amount: Number) => Promise<ResponseSchema>;
/**
* Withdraws all funds from the margin bank contract
* @returns ResponseSchema
* */
withdrawAllFromMarginBankContractCall: () => Promise<ResponseSchema>;
/**
* Deposits funds to the margin bank contract
* @param amount the amount to deposit
* @param coinID the coinID to deposit
* @returns ResponseSchema
* */
depositToMarginBankContractCall: (amount: number, coinID: string, getPublicAddress: () => address) => Promise<ResponseSchema>;
/**
* adjusts the leverage of the desiered position
* @param leverage the leverage to set
* @param symbol the position's market symbol
* @returns ResponseSchema
* */
adjustLeverageContractCall: (leverage: number, symbol: string, parentAddress?: string) => Promise<ResponseSchema>;
adjustLeverageContractCallRawTransaction: (leverage: number, symbol: string, getPublicAddress: () => address, parentAddress?: string) => Promise<string>;
/**
* This method return the signed Transaction for adding/removing the subaccount(s) on chain
* @param account The sub account address
* @param accountsToRemove The array of sub account addresses that need to be removed on-chain (optional param)
* @param subAccountsMapID The id of the chain object that holds subaccounts mapping (optional param)
* @param gasBudget The gas budget to be passed to execute the on-chain transaction (optional param)
* @returns string
* */
upsertSubAccountContractCallRawTransaction: (account: string, accountsToRemove?: Array<string>, subAccountsMapID?: string, gasBudget?: number) => Promise<string>;
/**
* closes the desiered position
* @param publicAddress the sub account's public address
* @param status the status to set for sub account true = add, false = remove
* @returns ResponseSchema
* */
setSubAccount: (publicAddress: address, status: boolean) => Promise<ResponseSchema>;
/**
* adjusts the margin of the desiered position
* @param symbol the position's market symbol
* @operationType the operation type to perform (add or remove)
* @amount the amount to add or remove
* @returns Response Schemea
* */
adjustMarginContractCall: (symbol: string, operationType: ADJUST_MARGIN, amount: number) => Promise<ResponseSchema>;
/**
* Get the margin bank balance
* @returns number
* */
getMarginBankBalance: () => Promise<number>;
/**
* transfer coins
* @param to recipient wallet address
* @param balance amount to transfer
* @param coin coin to transfer
* @returns Response Schema
* */
transferCoins: (to: string, balance: number, coin: TRANSFERABLE_COINS) => Promise<ResponseSchema>;
/**
* estimate gas for sui token transfer
* @param to recipient wallet address
* @param balance SUI amount to transfer
* @returns Response Schema
* */
estimateGasForSuiTransfer: (to: string, balance: number) => Promise<BigInt>;
/**
* esimate gas for USDC token transfer
* @param to recipient wallet address
* @param balance USDC amount to transfer
* @returns Response Schema
* */
estimateGasForUsdcTransfer: (to: string, balance: number) => Promise<BigInt>;
/**
* fetch user sui balance
* @param walletAddress wallet address of the user
* @returns string
* */
getSUIBalance: (walletAddress?: string) => Promise<string>;
}