@firefly-exchange/library-sui
Version:
Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui
76 lines (75 loc) • 3.88 kB
TypeScript
import { SuiClient } from "../../types";
import { IAssetBankDeposit, IDeployment, IOperatorUpdatedEvent, IAssetSupportedEvent, IPosition } from "../interfaces";
import { DeploymentParser } from "./deployment-parser";
import { Address, NumStr, Serialized } from "../../types";
export declare class MarginingEngineSimulator {
suiClient: SuiClient;
parser: DeploymentParser;
private sequenceHash;
constructor(suiClient: SuiClient, deployment: IDeployment);
/**
* Initializes the sequencer by fetching the on-chain sequence hash
*/
init(): Promise<void>;
/**
* Creates sequence hash for a transaction
* @param Serialized payload to be used for sequence hash computation
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @returns the new sequence hash
*/
computeSequenceHash(payload: Serialized, update?: boolean, sequenceHash?: string): string;
/**
* Creates sequence hash for a deposit transaction
* @param event AssetBankDeposit event
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @returns the new sequence hash
*/
depositToInternalBank(event: IAssetBankDeposit, update?: boolean): string;
/**
* Creates sequence hash for a deposit transaction
* @param event AssetBankDeposit event
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @returns the new sequence hash
*/
removeTaintedAsset(event: IAssetBankDeposit, update?: boolean): string;
/**
* Creates sequence hash for sync perpetual state tx
* @param event Event for any perpetual attribute update
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @returns the new sequence hash
*/
syncPerpetual(event: any, update?: boolean): string;
/**
* Creates sequence hash for sync support asset tx
* @param event Event for margin bank creation
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @returns the new sequence hash
*/
syncSupportedAsset(event: IAssetSupportedEvent, update?: boolean): string;
/**
* Creates sequence hash for trade tx
* @param makerSignature The signature of the maker order
* @param takerSignature The signature of the taker order
* @param quantity The quantity of the trade bring filled
* @param timestamp Timestamp in ms (this is sent to chain as well)
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @param sequenceHash (optional) sequence hash to be used to compute the next sequence hash
* @returns the new sequence hash
*/
performTrade(makerSignature: string, takerSignature: string, quantity: NumStr, timestamp: NumStr, update?: boolean, sequenceHash?: string): string;
overwriteUserPosition(ids: Address, account: Address, position: IPosition, timestamp: NumStr, update?: boolean, sequenceHash?: string): string;
overwriteUserAssets(ids: Address, account: Address, amount: NumStr, timestamp: NumStr, update?: boolean, sequenceHash?: string): string;
/**
* Creates sequence hash for sync support asset tx
* @param event Event for margin bank creation
* @param update (optional) if true will update the stored sequence hash else will just return the new hash
* @returns the new sequence hash
*/
syncOperator(event: IOperatorUpdatedEvent | {
operator_type: string;
previous_operator: Address;
new_operator: Address;
}, update?: boolean): string;
getSequenceHash(): string;
setSequenceHash(sequenceHash: string): void;
}