@firefly-exchange/library-sui
Version:
Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui
231 lines (230 loc) • 5.52 kB
TypeScript
import { Address, ID, NumStr } from "../../types";
import { OPERATORS, PAYLOAD_REQUEST_TYPE, PRUNE_TABLES_INDEX } from "../enums";
import { MarketName, PositionType, Side, SupportedAssets } from "../types";
import { IAssetBankDepositEvent } from "./IChainEvents";
import { ICompleteOrder } from "./IOrder";
import { IFundingRate } from "./IPerpetual";
export type IAssetBankDeposit = IAssetBankDepositEvent;
export interface IPerpetualUpdate {
id: Address;
symbol: string;
imr: string;
mmr: string;
stepSize: string;
tickSize: string;
minTradeQty: string;
maxTradeQty: string;
minTradePrice: string;
maxTradePrice: string;
maxNotionalAtOpen: string[];
mtbLong: string;
mtbShort: string;
makerFee: string;
takerFee: string;
maxFundingRate: string;
insurancePool_ratio: string;
insurancePool: string;
feePool: string;
tradingStart_time: string;
delist: boolean;
tradingStatus: boolean;
delistingPrice: string;
oraclePrice: string;
funding: IFundingRate;
}
export interface IWithdrawal {
type: PAYLOAD_REQUEST_TYPE;
eds: ID | Address;
assetSymbol: SupportedAssets;
account: Address;
amount: string;
salt: string;
signedAt: string;
}
export interface IAuthorizeUser {
type: PAYLOAD_REQUEST_TYPE;
ids: Address;
account: Address;
user: Address;
status: boolean;
salt: string;
signedAt: string;
}
export interface IOrder {
type: PAYLOAD_REQUEST_TYPE;
ids: Address;
account: Address;
market: MarketName;
price: string;
quantity: string;
leverage: string;
side: Side;
positionType: PositionType;
expiration: string;
salt: string;
signedAt: string;
}
export interface ITradeData {
makerSignature: Uint8Array;
takerSignature: Uint8Array;
quantity: string;
timestamp: string;
}
export interface ILiquidate {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
liquidatee: Address;
liquidator: Address;
market: MarketName;
quantity: string;
isolated: boolean;
assumeAsCross: boolean;
allOrNothing: boolean;
leverage: string;
expiry: string;
salt: string;
signedAt: string;
}
export interface IAdjustMargin {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
account: Address;
market: MarketName;
add: boolean;
amount: string;
salt: string;
signedAt: string;
}
export interface IAdjustLeverage {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
account: Address;
market: MarketName;
leverage: string;
salt: string;
signedAt: string;
}
export interface ISyncOperator {
operatorType: OPERATORS;
previousOperator: Address;
newOperator: Address;
}
export interface IMarketFundingRate {
market: MarketName;
value: NumStr;
sign: boolean;
oraclePrice: NumStr;
}
export interface ISetFundingRate {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
timestamp: NumStr;
marketFundingRates: Array<Uint8Array>;
salt: NumStr;
signedAt: NumStr;
}
export interface IApplyFundingRate {
ids: ID | Address;
timestamp: string;
accounts: Array<Address>;
salt: string;
signedAt: string;
market: string;
}
export interface IPruneTable {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
hashes: Array<Uint8Array>;
table_index: PRUNE_TABLES_INDEX;
salt: string;
signedAt: string;
}
export interface IAuthorizeLiquidator {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
account: Address;
authorized: boolean;
salt: string;
signedAt: string;
}
export interface ISetAccountType {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
account: Address;
isInstitution: boolean;
salt: string;
signedAt: string;
}
export interface ISetFeeTier {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
account: Address;
makerFee: NumStr;
takerFee: NumStr;
applied: boolean;
salt: string;
signedAt: string;
}
export interface ISetGasFee {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
amount: string;
salt: string;
signedAt: string;
}
export interface ISetGasPool {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
pool: string;
salt: string;
signedAt: string;
}
export interface IDeleverage {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
maker: Address;
taker: Address;
makerIsolated: boolean;
takerIsolated: boolean;
market: MarketName;
quantity: string;
expiry: string;
salt: string;
signedAt: string;
}
export interface IClosePosition {
type: PAYLOAD_REQUEST_TYPE;
ids: ID | Address;
account: Address;
market: MarketName;
isolated: boolean;
salt: string;
signedAt: string;
}
export interface IBatchTrade {
makerOrders: Array<ICompleteOrder>;
takerOrders: Array<ICompleteOrder>;
fills: Array<NumStr>;
}
export interface IOverwriteUserPosition {
ids: ID | Address;
account: Address;
perpetual: string;
size: NumStr;
average_entry_price: NumStr;
leverage: NumStr;
margin: NumStr;
is_long: boolean;
is_isolated: boolean;
pending_funding_payment: NumStr;
last_funding_timestamp: NumStr;
last_funding_rate_value: NumStr;
last_funding_rate_sign: boolean;
timestamp: NumStr;
}
export interface IOverwriteUserAssets {
ids: ID | Address;
account: Address;
amount: NumStr;
timestamp: NumStr;
}