@bluefin-exchange/bluefin-v2-client
Version:
The Bluefin client Library allows traders to sign, create, retrieve and listen to orders on Bluefin Exchange.
172 lines (171 loc) • 7.35 kB
TypeScript
import { address, ADJUST_MARGIN, OnChainCalls, SuiClient, SuiTransactionBlockResponse, TransactionBlock, TRANSFERABLE_COINS, ZkPayload } from "@firefly-exchange/library-sui";
import { Signer } from "@mysten/sui/cryptography";
import { ResponseSchema } from "./contractErrorHandling.service";
import { UserCalls as ProUserOnChainCalls } from "@firefly-exchange/library-sui/v3";
import { OnChainCalls as OnChainCallsSwap } from "@firefly-exchange/library-sui/spot";
import { ExtendedNetwork } from "../interfaces/routes";
export declare class ContractCalls {
onChainCalls: OnChainCalls;
signer: Signer;
suiClient: SuiClient;
marginBankId: string | undefined;
walletAddress: string;
is_wallet_extension: boolean;
network: ExtendedNetwork;
spotOnchain: OnChainCallsSwap;
proOnchain: ProUserOnChainCalls;
constructor(signer: Signer, deployment: any, provider: SuiClient, network: ExtendedNetwork, 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, sponsor?: boolean) => 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, sponsor?: boolean) => Promise<ResponseSchema>;
/**
* Deposits funds to the margin bank contract
* @param amount the amount to deposit
* @returns ResponseSchema
* */
getUSDCHavingBalance: (amount: number) => Promise<any>;
/**
* Deposits funds to the margin bank contract
* @param walletAddress user wallet address
* @returns ResponseSchema
* */
getUSDCCoins: (walletAddress: string) => Promise<any>;
/**
* Deposits funds to the margin bank contract
* @param sponsor is the tx sponsored or not
* @returns ResponseSchema
* */
mergeAllUSDCCOins: (sponsor?: boolean) => Promise<SuiTransactionBlockResponse | TransactionBlock>;
/**
* 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, sponsorTx?: boolean) => Promise<ResponseSchema>;
adjustLeverageContractCallRawTransaction: (leverage: number, symbol: string, 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, sponsor?: boolean) => Promise<string | TransactionBlock>;
/**
* 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, sponsor?: 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, sponsorTx?: boolean) => 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>;
/**
* transfer coins
* @param to recipient wallet address
* @param balance amount to transfer
* @param coinObject
* @param dryRun
* @returns Response Schema
* */
transferCoinObjects: (to: string, balance: number, coinObject: {
balance: string;
coinObjectIds: string[];
coinType: string;
decimals: number;
}, dryRun?: boolean) => 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>;
closeDelistedPositionContractCall: (symbol: string, args?: {
gasBudget?: number;
}) => Promise<ResponseSchema>;
closeAllPositionsAndWithdrawMarginPTB: (delistedMarketPositions: string[], args?: {
gasBudget?: number;
sponsor?: boolean;
dryRunOnly?: boolean;
}) => Promise<ResponseSchema>;
closeAllPositionsdWithdrawSwapAndDepositToProPTB: (delistedMarketPositions: string[], args?: {
gasBudget?: number;
sponsor?: boolean;
use7k?: boolean;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => Promise<ResponseSchema>;
withdrawAllSwapAndDepositToProPTB: (args?: {
gasBudget?: number;
sponsor?: boolean;
use7k?: boolean;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => Promise<ResponseSchema>;
swapAndDepositToProPTB: (amount: number, args?: {
gasBudget?: number;
sponsor?: boolean;
use7k?: boolean;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => Promise<ResponseSchema>;
inspectEstimatedWithdrawalAndSwapAmountFrom7k: (delistedUserPositionsSymbols: string[], args?: {
gasBudget?: number;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => Promise<ResponseSchema>;
}