@firefly-exchange/library-sui
Version:
Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui
245 lines (244 loc) • 15 kB
TypeScript
import { BigNumberable, OnChainCallResponse, Serialized } from "../../types";
import { IBatchTradeArgs, IBluefinV3OptionalParams, IOraclePriceUpdate } from "../interfaces/IOnChainCalls";
import { MarketName, SupportedAssets } from "../types";
import { Address, ID, NumStr } from "../../types";
import { ISignedOrder } from "../interfaces";
import { OnChainCalls } from "./on-chain-calls";
import { OPERATORS } from "../enums";
export declare class SequencerCalls extends OnChainCalls {
/**
* Create and executes internal data store transfer call
* @param sequencer address of the new sequencer that will own ids
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
transferInternalDataStore(sequencer: string, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows the owner of internal bank to invoke the method and
* update/deposit user funds into internal bank from external
* @param nonce the nonce emitted during asset deposit in shared bank
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param options Optional tx execution params
* @returns OnChainCallResponse & (assetSymbol of the deposit asset)
*/
depositToInternalBank(nonce: NumStr, sequenceHash: string, options?: IBluefinV3OptionalParams & {
assetSymbol?: SupportedAssets;
}): Promise<OnChainCallResponse>;
/**
* Allows the sequencer to remove a tainted asset from EDS
* @param nonce the nonce emitted during asset deposit in shared bank
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param options Optional tx execution params
* @returns OnChainCallResponse & (assetSymbol of the deposit asset)
*/
removeTaintedAsset(nonce: NumStr, sequenceHash: string, options?: IBluefinV3OptionalParams & {
assetSymbol?: SupportedAssets;
}): Promise<OnChainCallResponse>;
/**
* Allows the sequencer to invoke withdraw call on-chain to move funds for a user
* from the bank to user address
* @param data serialized hex string of the withdrawal payload
* @param signature bas64 signature generated by the user by signing the withdrawal request
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which withdraw was performed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
withdrawFromBank(data: Serialized, signature: string, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows the owner of internal bank to invoke the method and
* synchronize the attributes of provided perpetual between ids and eds
* @param perpetual the symbol of the perpetual/market to be synced
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
syncPerpetual(perpetual: MarketName, sequenceHash: string, options?: IBluefinV3OptionalParams & {
ids?: ID | Address;
eds?: ID | Address;
}): Promise<OnChainCallResponse>;
/**
* Allows the sequencer to execute the authorized user call to whitelist/blacklist
* the given user to use the account
* @param data serialized hex string of the authorization payload
* @param signature bas64 signature by singing the request payload data
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which withdraw was performed off-chain
* @param options Optional tx execution params & timestamp - this is the time at which withdraw was performed off-chain
* @returns OnChainCallResponse
*/
authorizeUser(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows sequencer to replicate asset details from external data store to internal data store
* @param symbol the symbol of the asset
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
syncSupportedAsset(symbol: string, sequenceHash: string, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows sequencer to execute trade between two orders
* @param makerOrder The signed maker order
* @param takerOrder The signed taker order
* @param quantity The quantity to be traded
* @param oraclePrice The list of perpetuals and their new oracle prices
* @param sequenceHash Sequence hash
* @param timestamp The timestamp at which withdraw was performed off-chain
* @param options Optional tx execution params & execution time
* @returns OnChainCallResponse
*/
performTrade(makerOrder: ISignedOrder, takerOrder: ISignedOrder, quantity: BigNumberable, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows sequencer to execute liquidation trade
* @param data The serialized liquidation payload
* @param signature The liquidator's signature on the data payload
* @param oraclePrice The list of perpetuals and their new oracle prices
* @param sequenceHash Sequence hash
* @param timestamp The time at which liquidation was executed off-chain
* @param options Optional tx execution params & execution time
* @returns OnChainCallResponse
*/
performLiquidation(data: Serialized, signature: string, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows sequencer to execute batch of trades
* @param args Array of trade arguments
* @param options Optional tx execution params & execution time
* @returns OnChainCallResponse
*/
performTradeBatch(args: Array<IBatchTradeArgs>, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows the sequencer to invoke adjust margin call on-chain for the provided signed payload
* to add/remove margin from a user's isolated position to/from cross account
* @param data serialized hex string of the adjust margin payload
* @param signature bas64 signature generated by the user by signing the adjust margin request
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param oraclePrices: The oracle prices of perpetuals at the time this tx was executed
* @param timestamp The time at which adjust margin was executed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
adjustMargin(data: Serialized, signature: string, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows the sequencer to invoke adjust leverage call on-chain for the provided signed payload
* to change the leverage for provided perpetual position
* @param data serialized hex string of the adjust leverage payload
* @param signature bas64 signature generated by the user by signing the adjust leverage request
* @param oraclePrices: The oracle prices of perpetuals at the time this tx was executed
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The time at which adjust leverage was executed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
adjustLeverage(data: Serialized, signature: string, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to synchronize the operator between eds and ids
* @param type The type of the operator be synced
* @param sequenceHash The sequence hash computed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
syncOperator(type: OPERATORS, sequenceHash: string, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to set funding rate on chain
* @param data serialized hex string of the set funding rate payload
* @param signature bas64 signature generated by the user by signing the funding rate request
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The time at which funding rate was set off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
setFundingRate(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams & {
timestamp?: NumStr;
}): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to apply funding rate on chain
* @param data serialized hex string of the apply funding rate payload
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The time at which funding rate was applied off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
applyFundingRate(data: Serialized, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to prune table
* @param data serialized hex string of purging table
* @param signature base64 signature generated by the user by signing the prune table request
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which table got pruned off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
pruneTable(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to authorize an account as a liquidator
* @param data serialized hex string of whitelisting liquidator payload
* @param signature base64 signature generated by the signer/guardian
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which request was processed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
authorizeLiquidator(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to set fee tier of an account
* @param data bcs serialized data
* @param signature base64 signature encoded signature of the data
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which the request was processed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
setFeeTier(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to set an account type
* @param data bcs serialized data
* @param signature base64 signature encoded signature of the data
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which the request was processed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
setAccountType(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to set gas fee
* @param data bcs serialized data
* @param signature base64 signature encoded signature of the data
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which the request was processed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
setGasFee(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Create and executes transaction to set gas pool
* @param data bcs serialized data
* @param signature base64 signature encoded signature of the data
* @param sequenceHash the expected sequence hash on-chain after the tx execution
* @param timestamp The timestamp at which the request was processed off-chain
* @param options Optional tx execution params
* @returns OnChainCallResponse
*/
setGasPool(data: Serialized, signature: string, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows sequencer to execute adl trade
* @param data The serialized adl payload
* @param signature The adl operator's signature on the data payload
* @param oraclePrice The list of perpetuals and their new oracle prices
* @param sequenceHash Sequence hash
* @param timestamp The time at which adl was executed off-chain
* @param options Optional tx execution params & execution time
* @returns OnChainCallResponse
*/
performADL(data: Serialized, signature: string, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
/**
* Allows sequencer to execute close position call for delisted markets
* @param data The serialized close position payload
* @param signature The account signature on the data payload
* @param oraclePrice The list of perpetuals and their new oracle prices
* @param sequenceHash Sequence hash
* @param timestamp The time at which position was closed was executed off-chain
* @param options Optional tx execution params & execution time
* @returns OnChainCallResponse
*/
closePosition(data: Serialized, signature: string, oraclePrices: Array<IOraclePriceUpdate>, sequenceHash: string, timestamp: NumStr, options?: IBluefinV3OptionalParams): Promise<OnChainCallResponse>;
}