@bluefin-exchange/bluefin-v2-client
Version:
The Bluefin client Library allows traders to sign, create, retrieve and listen to orders on Bluefin Exchange.
1,349 lines (1,347 loc) • 43.5 kB
TypeScript
import { ADJUST_MARGIN, DAPIKlineResponse, DecodeJWT, ExtendedWalletContextState, MarketSymbol, Order, PartialZkLoginSignature, SigPK, SuiClient, TransactionBlock, TRANSFERABLE_COINS, ZkPayload, SuiTransactionBlockResponse, Signer } from "@firefly-exchange/library-sui";
import { type SignaturePayload } from "@firefly-exchange/library-sui/blv";
import { SignatureScheme } from "@mysten/sui/cryptography";
import { ResponseSchema, VaultTVLInterval } from "./exchange/contractErrorHandling.service";
import { Sockets } from "./exchange/sockets";
import { WebSockets } from "./exchange/WebSocket";
import { adjustLeverageRequest, BatchClaimPayload, CancelOrderResponse, ExchangeInfo, ExtendedNetwork, GenerateReferralCodeRequest, GenerateReferralCodeResponse, GetAccountDataResponse, GetAffiliatePayoutsResponse, GetAffiliateRefereeCountResponse, GetAffiliateRefereeDetailsRequest, GetAffiliateRefereeDetailsResponse, GetCampaignDetailsResponse, GetCampaignRewardsResponse, GetCandleStickRequest, GetCountDownsResponse, GetFundingHistoryRequest, GetFundingRateResponse, GetMakerRewardDetailsRequest, GetMakerRewardDetailsResponse, GetMakerRewardsSummaryResponse, GetMarketRecentTradesRequest, GetMarketRecentTradesResponse, GetOffchainSettlementUpdatesRequest, GetOffchainSettlementUpdatesResponse, GetOrderbookRequest, GetOrderBookResponse, GetOrderRequest, GetOrderResponse, GetPositionRequest, GetPositionResponse, GetReferrerInfoResponse, GetTotalHistoricalTradingRewardsResponse, GetTradeAndEarnRewardsDetailRequest, GetTradeAndEarnRewardsDetailResponse, GetTradeAndEarnRewardsOverviewResponse, GetTransactionHistoryRequest, GetTransferHistoryRequest, GetUserFundingHistoryResponse, GetUserRewardsHistoryRequest, GetUserRewardsHistoryResponse, GetUserRewardsSummaryResponse, GetUserTradesHistoryRequest, GetUserTradesHistoryResponse, GetUserTradesRequest, GetUserTradesResponse, GetUserTransactionHistoryResponse, GetUserTransferHistoryResponse, GetUserWhiteListStatusForMarketMakerResponse, IVaultsTVLDatapointsMap, LinkReferredUserRequest, LinkReferredUserResponse, MarketData, MarketMeta, MasterInfo, OpenReferralDetails, OpenReferralOverview, OpenReferralPayoutList, OpenReferralRefereeDetails, OrderCancellationRequest, OrderCancelSignatureRequest, OrderSignatureRequest, OrderSignatureResponse, PlaceOrderRequest, PlaceOrderResponse, PostOrderRequest, PostTimerAttributes, PostTimerResponse, SponsorTxResponse, StatusResponse, SubAccountRequest, TickerData, UserPendingWithdrawRequest, UserVaultDetail, UserVaultDetailSummary, VaultDetail, VerifyWalletStatusResponse } from "./interfaces/routes";
export declare class BluefinClient {
protected readonly network: ExtendedNetwork;
private orderSigner;
private apiService;
sockets: Sockets;
webSockets: WebSockets | undefined;
vaultConfig: any;
marketSymbols: string[];
private walletAddress;
private signer;
private uiWallet;
private isZkLogin;
private contractCalls;
private interactorCalls;
private provider;
private isTermAccepted;
private maxSaltLimit;
private MarginTokenPrecision;
private maxEpoch;
private proof;
private decodedJWT;
private salt;
private is_wallet_extension;
/**
* initializes the class instance
* @param _isTermAccepted boolean indicating if exchange terms and conditions are accepted
* @param _network containing network rpc url and chain id
* @param _account accepts either privateKey or AWS-KMS-SIGNER object if user intend to sign using kms
* @param _scheme signature scheme to be used
* @param _isUI (optional) is initialized from UI
* @param _uiWalletType (optional) wallet type connected on the UI i.e SUI, Nightly etc
*/
constructor(_isTermAccepted: boolean, _network: ExtendedNetwork, _account?: string | Signer, _scheme?: SignatureScheme, _isUI?: boolean, _uiWalletType?: string, _uiSignerObject?: any);
/**
* @description
* initializes the required objects
* @param userOnboarding boolean indicating if user onboarding is required
* @param deployment
*/
init: (userOnboarding?: boolean, deployment?: any, apiToken?: string) => Promise<void>;
initializeWithHook: (uiSignerObject: ExtendedWalletContextState, walletAddress: string) => Promise<void>;
initializeForZkLogin: ({ _account, walletAddress, maxEpoch, proof, decodedJWT, salt, }: {
_account: string;
walletAddress: string;
maxEpoch: number;
salt: string;
proof: PartialZkLoginSignature;
decodedJWT: DecodeJWT;
}) => void;
/** *
* Set UUID to api headers for colocation partners
*/
setUUID: (uuid: string) => void;
/**
* @description
* initializes web3 and wallet with the given account private key
* @param keypair key pair for the account to be used for placing orders
*/
initializeWithKeyPair: (keypair: Signer) => Promise<void>;
/**
* @description
* initializes web3 and wallet with the given account private key
* @param seed seed for the account to be used for placing orders
* @param scheme signature scheme to be used
* @returns void
*/
initializeWithSeed: (seed: string, scheme: any) => void;
/**
* @description
* initializes contract calls
* @param deployment (optional) The deployment json provided by deployer
*/
initContractCalls: (deployment?: any) => Promise<void>;
/**
* @description
* initializes contract calls
* @param deployment (optional) The deployment json provided by deployer
*/
initInteractorCalls: () => Promise<void>;
/**
* @description
* Gets the RawSigner of the client
* @returns RawSigner
* */
getSigner: () => Signer;
/**
* @description
* Gets the RPC Provider of the client
* @returns JsonRPCProvider
* */
getProvider: () => SuiClient;
/**
* Generate and receive readOnlyToken, this can only be accessed at the time of generation
* @returns readOnlyToken string
*/
generateReadOnlyToken: () => Promise<{
data: string;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Creates message to be signed, creates signature and authorize it from dapi
* @returns auth token
*/
userOnBoarding: (token?: string, useDeprecatedSigningMethod?: boolean) => Promise<string>;
createZkSignature({ userSignature, zkPayload, }: {
userSignature: string;
zkPayload: ZkPayload;
}): string;
getZkPayload: () => ZkPayload;
createOnboardingSignature: ({ useDeprecatedSigningMethod, }: {
useDeprecatedSigningMethod?: boolean;
}) => Promise<string>;
/**
* @description
* Gets the payload containing key and mesasge to sign
* @returns SigPK
* */
signPayloadUsingZkWallet: (payload: object) => Promise<SigPK>;
/**
* @description
* Gets the payload containing bytes mesasge to sign
* @returns SigPK
* */
signBytesPayloadUsingZkWallet: (payload: Uint8Array) => Promise<SigPK>;
/**
* @description
* Gets the wallets Public address
* @returns string
* */
getPublicAddress: () => string;
parseAndShapeSignedData: ({ signature, isParsingRequired, }: {
signature: string;
isParsingRequired?: boolean;
}) => SigPK;
signOrder: (orderToSign: Order) => Promise<SigPK>;
/**
* @description
* Gets a signed order from the client
* @returns OrderSignatureResponse
* @param order OrderSignatureRequest
* */
createSignedOrder: (order: OrderSignatureRequest, parentAddress?: string) => Promise<OrderSignatureResponse>;
/**
* @description
* Places a signed order on bluefin exchange
* @param params PlaceOrderRequest containing the signed order created using createSignedOrder
* @returns PlaceOrderResponse containing status and data. If status is not 201, order placement failed.
*/
placeSignedOrder: (params: PlaceOrderRequest) => Promise<{
data: PlaceOrderResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Given an order payload, signs it on chain and submits to exchange for placement
* @param params PostOrderRequest
* @returns PlaceOrderResponse
*/
postOrder: (params: PostOrderRequest) => Promise<{
data: PlaceOrderResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Creates signature for cancelling orders
* @param params OrderCancelSignatureRequest containing market symbol and order hashes to be cancelled
* @returns generated signature string
*/
createOrderCancellationSignature: (params: OrderCancelSignatureRequest) => Promise<string>;
/**
* @description
* Posts to exchange for cancellation of provided orders with signature
* @param params OrderCancellationRequest containing order hashes to be cancelled and cancellation signature
* @returns response from exchange server
*/
placeCancelOrder: (params: OrderCancellationRequest) => Promise<{
data: CancelOrderResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Creates signature and posts order for cancellation on exchange of provided orders
* @param params OrderCancelSignatureRequest containing order hashes to be cancelled
* @returns response from exchange server
*/
postCancelOrder: (params: OrderCancelSignatureRequest) => Promise<{
data: CancelOrderResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Cancels all open orders for a given market
* @param symbol DOT-PERP, market symbol
* @returns cancellation response
*/
cancelAllOpenOrders: (symbol: MarketSymbol, parentAddress?: string) => Promise<{
data: CancelOrderResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Returns the USDC balance of user in USDC contract
* @returns list of User's coins in USDC contract
*/
getUSDCCoins: (amount?: number, limit?: number, cursor?: string) => Promise<any[]>;
/**
* @description
* Returns the usdc Balance(Free Collateral) of the account in Margin Bank contract
* @param contract (optional) address of Margin Bank contract
* @returns Number representing balance of user in Margin Bank contract
*/
getMarginBankBalance: () => Promise<number>;
/**
* @description
* Returns the usdc Balance(Free Collateral) of the account in USDC contract
* @returns Number representing balance of user in USDC contract
*/
getUSDCBalance: () => Promise<number>;
/**
* @description
* fetch user sui balance
* @param walletAddress wallet address of the user
* @returns string
* */
getSUIBalance: (walletAddress?: string) => Promise<string>;
/**
* @description
* Faucet function, mints 10K USDC to wallet - Only works on Testnet
* Assumes that the user wallet has native gas Tokens on Testnet
* @returns Boolean true if user is funded, false otherwise
*/
mintTestUSDC: (amount?: number) => Promise<boolean>;
/**
* @description
* Updates user's leverage to given leverage
* @param symbol market symbol get information about
* @param leverage new leverage you want to change to
* @returns ResponseSchema
*/
adjustLeverage: (params: adjustLeverageRequest) => Promise<ResponseSchema>;
/**
* @description
* Whitelist subaccount and/or remove the already exists subaccounts for One Click Trading
* @param subAccountAddress
* @param accountsToRemove (optional)
* @returns ResponseSchema
*/
upsertSubAccount: (params: SubAccountRequest, sponsorTx?: boolean) => Promise<ResponseSchema>;
/**
* @description
* Add or remove margin from the open position
* @param symbol market symbol of the open position
* @param operationType operation you want to perform `Add` | `Remove` margin
* @param amount (number) amount user wants to add or remove from the position
* @returns ResponseSchema
*/
adjustMargin: (symbol: MarketSymbol, operationType: ADJUST_MARGIN, amount: number, sponsorTx?: boolean) => Promise<ResponseSchema>;
/**
* @description
* Deposits USDC to Margin Bank contract
* @param amount amount of USDC to deposit
* @param coinID coinID of USDC coin to use
* @returns ResponseSchema
*/
depositToMarginBank: (amount: number, coinID?: string, sponsorTx?: boolean) => Promise<ResponseSchema>;
depositToMarginBankSponsored: (amount: number, coinID?: string, sponsorTx?: boolean) => Promise<ResponseSchema>;
/**
* @description
* withdraws USDC from Margin Bank contract
* @param amount amount of USDC to withdraw
* @returns ResponseSchema
*/
withdrawFromMarginBank: (amount?: number, sponsorTx?: boolean) => Promise<ResponseSchema>;
closeDelistedPosition: (symbol: MarketSymbol, args?: {
gasBudget?: number;
dryRunOnly?: boolean;
}) => Promise<ResponseSchema>;
closeAllDelistedPositionsAndWithdrawMargin: (args?: {
gasBudget?: number;
sponsor?: boolean;
dryRunOnly?: boolean;
}) => any;
closeAllDelistedPositionsWithdrawSwapAndDepositToPro: (args?: {
gasBudget?: number;
sponsor?: boolean;
use7k?: boolean;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => any;
withdrawAllWusdcSwapAndDepositToPro: (args?: {
gasBudget?: number;
sponsor?: boolean;
use7k?: boolean;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => any;
swapWusdcAndDepositToPro: (amount: number, args?: {
gasBudget?: number;
sponsor?: boolean;
use7k?: boolean;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => any;
inspectEstimatedWithdrawalAndSwapAmountFrom7k: (args?: {
gasBudget?: number;
slippage?: number;
dryRunOnly?: boolean;
defaultSlippage?: number;
}) => Promise<{
ok: boolean;
code: number;
data: any;
message: string;
} | {
ok: boolean;
code: number;
data: string;
message: any;
}>;
/**
* @description
* Sets subaccount to wallet.
* @param publicAddress the address to add as sub account
* @param status true to add, false to remove
* @returns ResponseSchema
*/
setSubAccount: (publicAddress: string, status: boolean, sponsorTx?: boolean) => Promise<ResponseSchema>;
/**
* @description
* Gets Users default leverage.
* @param symbol market symbol get information about
* @returns user default leverage
*/
getUserDefaultLeverage: (symbol: MarketSymbol, parentAddress?: string) => Promise<number>;
/**
* @description
* Gets Orders placed by the user. Returns the first 50 orders by default.
* @param params of type OrderRequest,
* @returns OrderResponse array
*/
getUserOrders: (params: GetOrderRequest) => Promise<{
data: GetOrderResponse[];
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user open position. If the market is not specified then will return first 50 open positions for 50 markets.
* @param params GetPositionRequest
* @returns GetPositionResponse
*/
getUserPosition: (params: GetPositionRequest) => Promise<{
data: GetPositionResponse[];
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets state of orderbook for provided market. At max top 50 bids/asks are retrievable
* @param params GetOrderbookRequest
* @returns GetOrderbookResponse
*/
getOrderbook: (params: GetOrderbookRequest) => Promise<{
data: GetOrderBookResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user trades
* @param params GetUserTradesRequest
* @returns GetUserTradesResponse
*/
getUserTrades: (params: GetUserTradesRequest) => Promise<{
data: GetUserTradesResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets user trades history
* @param params GetUserTradesHistoryRequest
* @returns GetUserTradesHistoryResponse
*/
getUserTradesHistory: (params: GetUserTradesHistoryRequest) => Promise<{
data: GetUserTradesHistoryResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user Account Data
* @returns GetAccountDataResponse
*/
getUserAccountData: (parentAddress?: string) => Promise<{
data: GetAccountDataResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets if user has account value
* @returns boolean
*/
hasAccountValue: (userAddress?: string) => Promise<{
data: boolean;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets verification status of user account
* @param amount deposit amount
* @returns verification status of user
*/
verifyWalletStatus: (amount: number) => Promise<{
data: VerifyWalletStatusResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user transaction history
* @param params GetTransactionHistoryRequest
* @returns GetUserTransactionHistoryResponse
*/
getUserTransactionHistory: (params: GetTransactionHistoryRequest) => Promise<{
data: GetUserTransactionHistoryResponse[];
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user funding history
* @param params GetFundingHistoryRequest
* @returns GetUserTransactionHistoryResponse
*/
getUserFundingHistory: (params: GetFundingHistoryRequest) => Promise<{
data: GetUserFundingHistoryResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user transfer history
* @param params GetTransferHistoryRequest
* @returns GetUserTransferHistoryResponse
*/
getUserTransferHistory: (params: GetTransferHistoryRequest) => Promise<{
data: GetUserTransferHistoryResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets market funding rate
* @param symbol market symbol to fetch funding rate of
* @returns GetFundingRateResponse
*/
getMarketFundingRate: (symbol: MarketSymbol) => Promise<{
data: GetFundingRateResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets market recent trades
* @param params GetMarketRecentTradesRequest
* @returns GetMarketRecentTradesResponse
*/
getMarketRecentTrades: (params: GetMarketRecentTradesRequest) => Promise<{
data: GetMarketRecentTradesResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets market candle stick data
* @param params GetMarketRecentTradesRequest
* @returns DAPIKlineResponse
*/
getMarketCandleStickData: (params: GetCandleStickRequest) => Promise<{
data: DAPIKlineResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets publicly available market info about market(s)
* @param symbol (optional) market symbol get information about, by default fetches info on all available markets
* @returns ExchangeInfo or ExchangeInfo[] in case no market was provided as input
*/
getExchangeInfo: (symbol?: MarketSymbol) => Promise<{
data: ExchangeInfo;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets MarketData data for market(s)
* @param symbol (optional) market symbol get information about, by default fetches info on all available markets
* @returns MarketData or MarketData[] in case no market was provided as input
*/
getMarketData: (symbol?: MarketSymbol) => Promise<{
data: MarketData;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets Meta data of the market(s)
* @param symbol (optional) market symbol get information about, by default fetches info on all available markets
* @returns MarketMeta or MarketMeta[] in case no market was provided as input
*/
getMarketMetaInfo: (symbol?: MarketSymbol) => Promise<{
data: MarketMeta;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets Master Info of the market(s)
* @param symbol (optional) market symbol get information about, by default fetches info on all available markets
* @returns MasterInfo
*/
getMasterInfo: (symbol?: MarketSymbol) => Promise<{
data: MasterInfo;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets the list of market symbols available on exchange
* @returns array of strings representing MARKET SYMBOLS
*/
getMarketSymbols: () => Promise<{
data: string[];
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets contract addresses of market
* @param symbol (optional) market symbol get information about, by default fetches info on all available markets
* @returns deployed contract addresses
*/
getContractAddresses: (symbol?: MarketSymbol) => Promise<{
data: Record<string, object>;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets status of the exchange
* @returns StatusResponse
*/
getExchangeStatus: () => Promise<{
data: StatusResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets ticker data of any market
* @param symbol market symbol to get information about, if not provided fetches data of all markets
* @returns TickerData
*/
getTickerData: (symbol?: MarketSymbol) => Promise<{
data: TickerData;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Generates referral code
* @param params GenerateReferralCodeRequest
* @returns GenerateReferralCodeResponse
*/
generateReferralCode: (params: GenerateReferralCodeRequest) => Promise<{
data: GenerateReferralCodeResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Links referred user
* @param params LinkReferredUserRequest
* @returns LinkReferredUserResponse
*/
affiliateLinkReferredUser: (params: LinkReferredUserRequest) => Promise<{
data: LinkReferredUserResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets referrer Info
* @param parentAddress
* @returns GetReferrerInfoResponse
*/
getReferrerInfo: (parentAddress?: string) => Promise<{
data: GetReferrerInfoResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets campaign details
* @returns Array of GetCampaignDetailsResponse
*/
getCampaignDetails: () => Promise<{
data: GetCampaignDetailsResponse[];
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets campaign reward details
* @param campaignId
* @param parentAddress
* @returns GetCampaignRewardsResponse
*/
getCampaignRewards: (campaignId: number, parentAddress?: string) => Promise<{
data: GetCampaignRewardsResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets affiliate payout details
* @param campaignId
* @param parentAddress
* @returns Array of GetAffiliatePayoutsResponse
*/
getAffiliatePayouts: (campaignId: number, parentAddress?: string) => Promise<{
data: GetAffiliatePayoutsResponse[];
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets affiliate referree details
* @param GetAffiliateRefereeDetailsRequest
* @returns GetAffiliateRefereeDetailsResponse
*/
getAffiliateRefereeDetails: (params: GetAffiliateRefereeDetailsRequest) => Promise<{
data: GetAffiliateRefereeDetailsResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets referree count
* @param campaignId
* @param parentAddress
* @returns GetAffiliateRefereeCountResponse
*/
getAffiliateRefereeCount: (campaignId: number, parentAddress?: string) => Promise<{
data: GetAffiliateRefereeCountResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets user rewards history
* @param optional params GetUserRewardsHistoryRequest
* @returns GetUserRewardsHistoryResponse
*/
getUserRewardsHistory: (params?: GetUserRewardsHistoryRequest) => Promise<{
data: GetUserRewardsHistoryResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets user rewards summary
* @returns GetUserRewardsSummaryResponse
*/
getUserRewardsSummary: (parentAddress?: string) => Promise<{
data: GetUserRewardsSummaryResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets rewards overview
* @param campaignId
* @param parentAddress
* @returns GetTradeAndEarnRewardsOverviewResponse
*/
getTradeAndEarnRewardsOverview: (campaignId: number, parentAddress?: string) => Promise<{
data: GetTradeAndEarnRewardsOverviewResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets rewards details
* @param GetTradeAndEarnRewardsDetailRequest
* @returns GetTradeAndEarnRewardsDetailResponse
*/
getTradeAndEarnRewardsDetail: (params: GetTradeAndEarnRewardsDetailRequest) => Promise<{
data: GetTradeAndEarnRewardsDetailResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets total historical trading reward details
* @returns GetTotalHistoricalTradingRewardsResponse
*/
getTotalHistoricalTradingRewards: (parentAddress?: string) => Promise<{
data: GetTotalHistoricalTradingRewardsResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets maker rewards summary
* @returns GetMakerRewardsSummaryResponse
*/
getMakerRewardsSummary: (parentAddress?: string) => Promise<{
data: GetMakerRewardsSummaryResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets maker reward details
* @param GetMakerRewardDetailsRequest
* @returns GetMakerRewardDetailsResponse
*/
getMakerRewardDetails: (params: GetMakerRewardDetailsRequest) => Promise<{
data: GetMakerRewardDetailsResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Gets market maker whitelist status
* @returns GetUserWhiteListStatusForMarketMaker
*/
getUserWhiteListStatusForMarketMaker: () => Promise<{
data: GetUserWhiteListStatusForMarketMakerResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* get open referral referee details
* @param payload
* @returns OpenReferralRefereeDetails
*/
getOpenReferralRefereeDetails: (payload: {
cursor: string;
pageSize: number;
parentAddress?: string;
}) => Promise<{
data: {
data: OpenReferralRefereeDetails;
nextCursor: string;
isMoreDataAvailable: boolean;
parentAddress?: string;
};
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* get open referral payouts
* @param payload
* @returns OpenReferralDetails
*/
getOpenReferralDetails: (payload: {
campaignId: number;
parentAddress?: string;
}) => Promise<{
data: OpenReferralDetails;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* get open referral payouts
* @param payload
* @returns OpenReferralPayoutList
*/
getOpenReferralPayouts: (payload: {
cursor: string;
pageSize: number;
parentAddress?: string;
}) => Promise<{
data: {
data: OpenReferralPayoutList;
nextCursor: string;
isMoreDataAvailable: boolean;
};
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* generate open referral code
* @param campaignId
* @param parentAddress
* @returns OpenReferralOverview
*/
generateOpenReferralReferralCode: (payload: {
campaignId: string;
}) => Promise<{
data: {
referralAddress: string;
referralCode: string;
message: string;
};
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* get open referral overview
* @returns OpenReferralOverview
*/
getOpenReferralOverview: (parentAddress?: string) => Promise<{
data: OpenReferralOverview;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* Link open referral
* @param referralCode
* @returns boolean
*/
openReferralLinkReferredUser: (payload: {
referralCode: string;
}) => Promise<{
data: unknown;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Initializes order signer
* @param keypair keypair of the account to be used for placing orders
* @returns void
*/
private initOrderSigner;
/**
* @description
* Gets deployment json from local file (will get from DAPI in future)
* @returns deployment json
* */
private getDeploymentJson;
/**
* @description
* sign transaction using wallet
* @param tx transcation block
* @param signer signer object
* @returns transactionBlockBytes & signature
* */
private signTransactionUsingWallet;
/**
* @description
* sign transcation using ZK
* @param tx transcation block
* @returns SignatureWithBytes
* */
private signTransactionUsingZK;
/**
* @description
* sign transcation using keypair
* @param txBytes transaction bytes
* @returns SignatureWithBytes
* */
private signTransactionUsingKeypair;
/**
* @description
* execute sponsored transaction block
* @param blockTxBytes transaction bytes
* @param signature signature
* @param sponsorerSignature sponserer signature
* @returns SuiTransactionBlockResponse
* */
private executeSponseredTransactionBlock;
/**
* @description
* build gasless transaction payload bytes
* @param tx transcation block
* @returns string
* */
private buildGaslessTxPayloadBytes;
/**
* @description
* prompts user to sign the transaction and executes
* @param sponsorPayload payload from library-sui
* @returns completed transaction
* */
private signAndExecuteSponsoredTx;
private signAndExecuteAdjustLeverageSponsoredTx;
/**
* Function to create order payload that is to be signed on-chain
* @param params OrderSignatureRequest
* @returns Order
*/
createOrderToSign: (params: OrderSignatureRequest, parentAddress?: string) => Order;
/**
* @description
* Posts signed Auth Hash to dAPI and gets token in return if signature is valid
* @returns GetAuthHashResponse which contains auth hash to be signed
*/
private authorizeSignedHash;
/**
* @description
* Posts signed Auth Hash to dAPI and gets token in return if signature is valid
* @returns GetAuthHashResponse which contains auth hash to be signed
*/
private updateLeverage;
/**
* @description
* Posts subAccount request to whitelist/remove the subaccount for One Click Trading
* @returns SubAccountResponse containing whitelisted subaccount details
*/
private addSubAccountFor1CT;
/**
* @description
* Get expired 1CT subAccount list for user that are still active
* @returns ExpiredSubAccounts1CTResponse
*/
private getExpiredAccountsFor1CT;
/**
* @description
* Get transcation response for sponsored payload
* @returns SponsorTxResponse
*/
getSponsoredTxResponse: (txBytes: any) => Promise<{
data: SponsorTxResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Get transcation response for sponsored payload
* @returns SponsorTxResponse
*/
getOffchainSettlementUpdates: (params: GetOffchainSettlementUpdatesRequest) => Promise<{
data: GetOffchainSettlementUpdatesResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Reset timer for cancel on disconnect for open orders
* @param params PostTimerAttributes containing the countdowns of all markets
* @returns PostTimerResponse containing accepted and failed countdowns. If status is not 201, request wasn't successful.
*/
resetCancelOnDisconnectTimer: (params: PostTimerAttributes) => Promise<{
data: PostTimerResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
/**
* @description
* Gets user Cancel on Disconnect timer
* @returns GetCountDownsResponse
*/
getCancelOnDisconnectTimer: (symbol?: string, parentAddress?: string) => Promise<{
data: GetCountDownsResponse;
ok: boolean;
status: number;
response: {
data: any;
message: any;
errorCode: any;
};
}>;
signAndExecuteZkTransaction: (tx: TransactionBlock) => Promise<SuiTransactionBlockResponse>;
/**
* transfer coin
* @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 coin
* @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 amount to transfer
* @returns BigInt
* */
estimateGasForSuiTransfer: (to: string, balance: number) => Promise<BigInt>;
/**
* estimate gas for usdc token transfer
* @param to recipient wallet address
* @param balance amount to transfer
* @returns BigInt
* */
estimateGasForUsdcTransfer: (to: string, balance: number) => Promise<BigInt>;
/**
* @description
* Gets deployment json from vaultConfig table
* @returns deployment json
* */
private getVaultConfigsForInteractor;
/**
* @description
* Gets user's vault details
* @returns user vault details
* */
getUserVaultDetails: (userAddress: string, vaultId: string) => Promise<UserVaultDetail[]>;
/**
* @description
* Gets user's vault details
* @returns user vault details
* */
getVaultDetails: (vaultId: string) => Promise<VaultDetail>;
/**
* @description
* Gets vault pending withdraw requests
* @returns pending withdraw requests
* */
getPendingWithdrawRequests: (vaultId: string, startTime?: string, endTime?: number) => Promise<UserPendingWithdrawRequest>;
/**
* @description
* Gets user vault details summary
* @returns pending withdraw requests
* */
getUserVaultDetailsSummary: (userAddress: string) => Promise<UserVaultDetailSummary[]>;
/**
* @description
* withdraws USDC from Vault Bank
* @param amount amount of USDC to withdraw
* @returns ResponseSchema
*/
withdrawFromVault: (vaultName: string, amount?: number) => Promise<ResponseSchema>;
/**
* @description
* deposit USDC to Vault Bank
* @param amount amount of USDC to withdraw
* @returns ResponseSchema
*/
depositToVault: (vaultName: string, amount?: number, coinId?: string) => Promise<ResponseSchema>;
/**
* @description
* claim all vaults in batch contract call
* @param batch array containing SignaturePayload and user's signature
* @returns ResponseSchema
*/
claimFromVaultBatch: (batch: BatchClaimPayload[]) => Promise<ResponseSchema>;
/**
* @description
* claim USDC from Vault Bank
* @param amount amount of USDC to withdraw
* @returns ResponseSchema
*/
claimFromVault: (vaultName: string, signaturePayload: SignaturePayload, signature: string) => Promise<ResponseSchema>;
/**
* @description
* claim rewards from reward pool
* @returns ResponseSchema
*/
claimRewards: (batch: {
payload: SignaturePayload;
signature: string;
}[]) => Promise<ResponseSchema>;
/**
* @description
* Gets vault TVL graph data
* @returns pending withdraw requests
* */
getVaultTVL: (vaultName: string, endTime?: number, intervals?: Array<VaultTVLInterval>) => Promise<IVaultsTVLDatapointsMap>;
private transformPoolId;
}