aftermath-ts-sdk 1.3.26-perps.13 → 1.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +0 -3
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +1 -1
- package/dist/general/apiHelpers/transactionsApiHelpers.js +0 -12
- package/dist/general/providers/aftermath.d.ts +5 -0
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +6 -1
- package/dist/general/providers/aftermathApi.d.ts +5 -0
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +5 -0
- package/dist/general/types/castingTypes.d.ts +2 -2
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/configTypes.d.ts +10 -6
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/types/generalTypes.d.ts +0 -8
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/types/moveErrorsInterface.d.ts +1 -1
- package/dist/general/types/moveErrorsInterface.d.ts.map +1 -1
- package/dist/general/utils/caller.d.ts +2 -34
- package/dist/general/utils/caller.d.ts.map +1 -1
- package/dist/general/utils/caller.js +12 -111
- package/dist/general/utils/casting.d.ts +5 -4
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +5 -4
- package/dist/general/utils/helpers.d.ts +0 -1
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +6 -38
- package/dist/general/wallet/wallet.d.ts +1 -1
- package/dist/general/wallet/wallet.d.ts.map +1 -1
- package/dist/packages/coin/coin.d.ts +1 -5
- package/dist/packages/coin/coin.d.ts.map +1 -1
- package/dist/packages/coin/coin.js +1 -7
- package/dist/packages/farms/api/farmsApiCasting.js +27 -27
- package/dist/packages/farms/farms.d.ts +1 -1
- package/dist/packages/farms/farms.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakedPosition.d.ts +1 -1
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakingPool.d.ts +1 -1
- package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.d.ts +17 -9
- package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.js +49 -44
- package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApiCasting.js +7 -10
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +4 -1
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.d.ts +1 -1
- package/dist/packages/faucet/faucet.d.ts.map +1 -1
- package/dist/packages/faucet/faucet.js +1 -1
- package/dist/packages/faucet/faucetTypes.d.ts +3 -2
- package/dist/packages/faucet/faucetTypes.d.ts.map +1 -1
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.js +3 -3
- package/dist/packages/multisig/multisig.d.ts +1 -1
- package/dist/packages/multisig/multisig.d.ts.map +1 -1
- package/dist/packages/nftAmm/nftAmm.d.ts +1 -1
- package/dist/packages/nftAmm/nftAmm.d.ts.map +1 -1
- package/dist/packages/oracle/api/oracleApi.d.ts +21 -0
- package/dist/packages/oracle/api/oracleApi.d.ts.map +1 -0
- package/dist/packages/oracle/api/oracleApi.js +76 -0
- package/dist/packages/oracle/api/oracleApiCasting.d.ts +6 -0
- package/dist/packages/oracle/api/oracleApiCasting.d.ts.map +1 -0
- package/dist/packages/oracle/api/oracleApiCasting.js +25 -0
- package/dist/packages/oracle/oracle.d.ts +15 -0
- package/dist/packages/oracle/oracle.d.ts.map +1 -0
- package/dist/packages/oracle/oracle.js +46 -0
- package/dist/packages/oracle/oracleCastingTypes.d.ts +11 -0
- package/dist/packages/oracle/oracleCastingTypes.d.ts.map +1 -0
- package/dist/packages/oracle/oracleCastingTypes.js +2 -0
- package/dist/packages/oracle/oracleTypes.d.ts +10 -0
- package/dist/packages/oracle/oracleTypes.d.ts.map +1 -0
- package/dist/packages/oracle/oracleTypes.js +2 -0
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +203 -12
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.js +615 -926
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +21 -10
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApiCasting.js +238 -260
- package/dist/packages/perpetuals/index.d.ts +0 -1
- package/dist/packages/perpetuals/index.d.ts.map +1 -1
- package/dist/packages/perpetuals/index.js +0 -1
- package/dist/packages/perpetuals/perpetuals.d.ts +28 -813
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetuals.js +70 -984
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +170 -754
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +312 -1267
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +149 -82
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +27 -341
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +78 -411
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +319 -2575
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsTypes.js +82 -92
- package/dist/packages/pools/api/poolsApiCasting.js +3 -3
- package/dist/packages/pools/pool.d.ts +1 -1
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pools.d.ts +1 -1
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/router/api/routerApiCasting.js +1 -1
- package/dist/packages/router/routerTypes.d.ts +1 -1
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApiCasting.js +3 -3
- package/dist/packages/staking/staking.d.ts +1 -1
- package/dist/packages/staking/staking.d.ts.map +1 -1
- package/dist/packages/sui/sui.d.ts +1 -1
- package/dist/packages/sui/sui.d.ts.map +1 -1
- package/dist/packages/suiFrens/api/suiFrensApiCasting.js +4 -4
- package/dist/packages/suiFrens/stakedSuiFren.d.ts +1 -1
- package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +1 -1
- package/dist/packages/suiFrens/suiFren.d.ts +1 -1
- package/dist/packages/suiFrens/suiFren.d.ts.map +1 -1
- package/dist/packages/suiFrens/suiFrens.d.ts +1 -1
- package/dist/packages/suiFrens/suiFrens.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +1 -1
- package/dist/packages/perpetuals/perpetualsVault.d.ts +0 -438
- package/dist/packages/perpetuals/perpetualsVault.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetualsVault.js +0 -601
|
@@ -1,1026 +1,257 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BcsType } from "@mysten/sui/bcs";
|
|
2
|
+
import { AnyObjectType, ApiDataWithCursorBody, Balance, Event, IFixed, Object, ObjectDigest, ObjectId, ObjectVersion, PackageId, Percentage, SuiAddress, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
|
|
2
3
|
import { CoinDecimal, CoinSymbol, CoinType } from "../coin/coinTypes";
|
|
3
|
-
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
4
|
-
/**
|
|
5
|
-
* Unique identifier for a perpetuals market, represented as a Sui object ID
|
|
6
|
-
* (i.e. the `ClearingHouse` object on-chain).
|
|
7
|
-
*/
|
|
8
4
|
export type PerpetualsMarketId = ObjectId;
|
|
9
|
-
/**
|
|
10
|
-
* Unique numeric identifier for a perpetuals account.
|
|
11
|
-
*
|
|
12
|
-
* This is a bigint, as it is derived directly from the on-chain representation.
|
|
13
|
-
*/
|
|
14
5
|
export type PerpetualsAccountId = bigint;
|
|
15
|
-
/**
|
|
16
|
-
* Unique numeric identifier for a perpetuals order.
|
|
17
|
-
*
|
|
18
|
-
* This ID is stable across events and API responses.
|
|
19
|
-
*/
|
|
20
6
|
export type PerpetualsOrderId = bigint;
|
|
21
|
-
/**
|
|
22
|
-
* String representation of a {@link PerpetualsOrderId}.
|
|
23
|
-
*
|
|
24
|
-
* Some APIs serialize order IDs as strings instead of `bigint`.
|
|
25
|
-
*/
|
|
26
7
|
export type PerpetualsOrderIdAsString = string;
|
|
27
|
-
/**
|
|
28
|
-
* Price type for orders, represented as a fixed-point `bigint` in the
|
|
29
|
-
* on-chain format (e.g., scaled by `1e9`).
|
|
30
|
-
*/
|
|
31
8
|
export type PerpetualsOrderPrice = bigint;
|
|
32
|
-
/**
|
|
33
|
-
* Side of a perpetuals order.
|
|
34
|
-
*
|
|
35
|
-
* - `Bid` (0): Long-side orders / buyers.
|
|
36
|
-
* - `Ask` (1): Short-side orders / sellers.
|
|
37
|
-
*/
|
|
38
9
|
export declare enum PerpetualsOrderSide {
|
|
39
10
|
Ask = 1,// true
|
|
40
11
|
Bid = 0
|
|
41
12
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Order execution and posting behavior.
|
|
44
|
-
*
|
|
45
|
-
* - `Standard`: No special constraints.
|
|
46
|
-
* - `FillOrKill`: Either fully fills immediately or cancels.
|
|
47
|
-
* - `PostOnly`: Only posts to the book; will not take liquidity.
|
|
48
|
-
* - `ImmediateOrCancel`: Fills as much as possible immediately; remainder is canceled.
|
|
49
|
-
*/
|
|
50
13
|
export declare enum PerpetualsOrderType {
|
|
51
14
|
Standard = 0,
|
|
52
15
|
FillOrKill = 1,
|
|
53
16
|
PostOnly = 2,
|
|
54
17
|
ImmediateOrCancel = 3
|
|
55
18
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*/
|
|
69
|
-
SlTp = 0,
|
|
70
|
-
/**
|
|
71
|
-
* Stop order that can be both reduce or increase the position's size. May require
|
|
72
|
-
* some collateral to be allocated to be able to be placed.
|
|
73
|
-
*/
|
|
74
|
-
Standalone = 1
|
|
19
|
+
declare function Field<N extends BcsType<any>, V extends BcsType<any>>(name: N, value: V): import("@mysten/sui/bcs").BcsStruct<{
|
|
20
|
+
name: N;
|
|
21
|
+
value: V;
|
|
22
|
+
}, string>;
|
|
23
|
+
export interface PerpetualsAdminCapability extends Object {
|
|
24
|
+
}
|
|
25
|
+
export interface PerpetualsRegistry extends Object {
|
|
26
|
+
activeCollaterals: CoinType[];
|
|
27
|
+
}
|
|
28
|
+
export interface PerpetualsVault extends Object {
|
|
29
|
+
balance: Balance;
|
|
30
|
+
scalingFactor: bigint;
|
|
75
31
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Aggregate market configuration and state for a single perpetuals market.
|
|
78
|
-
*/
|
|
79
32
|
export interface PerpetualsMarketData {
|
|
80
|
-
/** Package ID of the deployed perpetuals contract. */
|
|
81
33
|
packageId: PackageId;
|
|
82
|
-
/** Object ID for the market (clearing house) on-chain. */
|
|
83
34
|
objectId: ObjectId;
|
|
84
|
-
|
|
35
|
+
initialSharedVersion: ObjectVersion;
|
|
85
36
|
collateralCoinType: CoinType;
|
|
86
|
-
/** Static configuration parameters for this market. */
|
|
87
37
|
marketParams: PerpetualsMarketParams;
|
|
88
|
-
/** Dynamic runtime state (funding, open interest, etc.). */
|
|
89
38
|
marketState: PerpetualsMarketState;
|
|
90
|
-
/** Current price of collateral in USD or the platform's base unit. */
|
|
91
|
-
collateralPrice: number;
|
|
92
|
-
/** Oracle/index price of the base asset for this market. */
|
|
93
|
-
indexPrice: number;
|
|
94
|
-
/** Estimated funding rate for the next funding interval. */
|
|
95
|
-
estimatedFundingRate: Percentage;
|
|
96
|
-
/** Timestamp (ms) for the next funding event, as a bigint. */
|
|
97
|
-
nextFundingTimestampMs: bigint;
|
|
98
39
|
}
|
|
99
|
-
|
|
100
|
-
* On-chain capability object that grants control over a perpetuals account.
|
|
101
|
-
*
|
|
102
|
-
* This represents an "owned" account capability, used to sign and authorize
|
|
103
|
-
* account-level actions.
|
|
104
|
-
*/
|
|
105
|
-
export interface PerpetualsAccountCap {
|
|
106
|
-
/** Object ID of the account capability on-chain. */
|
|
107
|
-
objectId: ObjectId;
|
|
108
|
-
/** Wallet address that owns this account capability. */
|
|
109
|
-
walletAddress: SuiAddress;
|
|
110
|
-
/** Logical ID of the associated perpetuals account. */
|
|
40
|
+
export interface PerpetualsAccountCap extends Object {
|
|
111
41
|
accountId: PerpetualsAccountId;
|
|
112
|
-
/** Object ID of the associated `PerpetualsAccountObject`. */
|
|
113
|
-
accountObjectId: ObjectId;
|
|
114
|
-
/** Collateral coin type backing this account. */
|
|
115
42
|
collateralCoinType: CoinType;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/** On-chain object version. */
|
|
43
|
+
collateral: IFixed;
|
|
44
|
+
collateralDecimals: CoinDecimal;
|
|
119
45
|
objectVersion: ObjectVersion;
|
|
120
|
-
/** On-chain object digest. */
|
|
121
46
|
objectDigest: ObjectDigest;
|
|
122
|
-
/** True if this account cap was allocated to an agent wallet from the admin account cap owner. */
|
|
123
|
-
isAgent: boolean;
|
|
124
47
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
export interface PerpetualsVaultCap {
|
|
129
|
-
/** Vault object ID that this cap grants permissions for. */
|
|
130
|
-
vaultId: ObjectId;
|
|
131
|
-
/** Capability object ID. */
|
|
132
|
-
objectId: ObjectId;
|
|
133
|
-
/** Owner of the vault-capability. */
|
|
134
|
-
ownerAddress: SuiAddress;
|
|
135
|
-
/** Collateral coin type used by the vault account. */
|
|
136
|
-
collateralCoinType: CoinType;
|
|
137
|
-
/** Perpetuals account ID controlled by the vault. */
|
|
138
|
-
accountId: PerpetualsAccountId;
|
|
139
|
-
/** Object ID of the account object owned by the vault. */
|
|
140
|
-
accountObjectId: ObjectId;
|
|
141
|
-
}
|
|
142
|
-
export type PerpetualsPartialVaultCap = Omit<PerpetualsVaultCap, "objectId">;
|
|
143
|
-
/**
|
|
144
|
-
* Representation of an LP (share) coin position for a specific vault.
|
|
145
|
-
*
|
|
146
|
-
* This is typically returned by API endpoints that enumerate a wallet's vault
|
|
147
|
-
* positions. `lpAmount` is the raw on-chain balance for the vault's LP coin type.
|
|
148
|
-
*
|
|
149
|
-
* Notes:
|
|
150
|
-
* - `lpAmountUsd` is a convenience valuation derived from current vault TVL and LP supply.
|
|
151
|
-
* - The LP coin itself is an on-chain `Coin<T>` object, but here we expose the derived,
|
|
152
|
-
* aggregated view needed by UIs.
|
|
153
|
-
*/
|
|
154
|
-
export interface PerpetualsVaultLpCoin {
|
|
155
|
-
/** Vault identifier that minted the LP coin. */
|
|
156
|
-
vaultId: ObjectId;
|
|
157
|
-
/** Object ID of the specific LP coin object held by the user. */
|
|
158
|
-
objectId: ObjectId;
|
|
159
|
-
/** Raw LP token amount (native units; not human-decimal adjusted). */
|
|
160
|
-
lpAmount: Balance;
|
|
161
|
-
/** Estimated USD value of `lpAmount` at query time. */
|
|
162
|
-
lpAmountUsd: number;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Aggregate position data for a single perpetuals market and account.
|
|
166
|
-
*
|
|
167
|
-
* Values are generally denoted in:
|
|
168
|
-
* - Base asset units (e.g. BTC)
|
|
169
|
-
* - Quote units (e.g. USD)
|
|
170
|
-
* - Collateral units (per `collateralCoinType`)
|
|
171
|
-
*/
|
|
48
|
+
export type PerpetualsRawAccountCap = Omit<PerpetualsAccountCap, "collateral" | "collateralDecimals"> & {
|
|
49
|
+
collateral: Balance;
|
|
50
|
+
};
|
|
172
51
|
export interface PerpetualsPosition {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
/** Cumulative funding rate accrued on the short side. */
|
|
182
|
-
cumFundingRateShort: number;
|
|
183
|
-
/** Aggregate size of resting asks in this market for the account. */
|
|
184
|
-
asksQuantity: number;
|
|
185
|
-
/** Aggregate size of resting bids in this market for the account. */
|
|
186
|
-
bidsQuantity: number;
|
|
187
|
-
/** Market identifier for this position. */
|
|
52
|
+
collateral: IFixed;
|
|
53
|
+
baseAssetAmount: IFixed;
|
|
54
|
+
quoteAssetNotionalAmount: IFixed;
|
|
55
|
+
cumFundingRateLong: IFixed;
|
|
56
|
+
cumFundingRateShort: IFixed;
|
|
57
|
+
asksQuantity: IFixed;
|
|
58
|
+
bidsQuantity: IFixed;
|
|
59
|
+
collateralCoinType: CoinType;
|
|
188
60
|
marketId: PerpetualsMarketId;
|
|
189
|
-
/** All pending (open) orders associated with this position. */
|
|
190
61
|
pendingOrders: {
|
|
191
|
-
/** Unique ID of the order. */
|
|
192
62
|
orderId: PerpetualsOrderId;
|
|
193
|
-
/** Side of the order (Bid/Ask). */
|
|
194
63
|
side: PerpetualsOrderSide;
|
|
195
|
-
|
|
196
|
-
currentSize: bigint;
|
|
197
|
-
/** Initial size of the order in base units (scaled as bigint). */
|
|
198
|
-
initialSize: bigint;
|
|
64
|
+
size: bigint;
|
|
199
65
|
}[];
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
/** Taker fee rate applied to this position (as a fraction). */
|
|
203
|
-
takerFee: Percentage;
|
|
204
|
-
/** Effective leverage applied to the position. */
|
|
66
|
+
makerFee: IFixed;
|
|
67
|
+
takerFee: IFixed;
|
|
205
68
|
leverage: number;
|
|
206
|
-
/** Collateral value in USD. */
|
|
207
|
-
collateralUsd: number;
|
|
208
|
-
/** Current margin ratio (collateral / exposure). */
|
|
209
|
-
marginRatio: number;
|
|
210
|
-
/** Free margin available in USD. */
|
|
211
|
-
freeMarginUsd: number;
|
|
212
|
-
/** Free (unlocked) collateral in collateral units. */
|
|
213
|
-
freeCollateral: number;
|
|
214
|
-
/** Unrealized funding PnL in USD. */
|
|
215
|
-
unrealizedFundingsUsd: number;
|
|
216
|
-
/** Unrealized position PnL in USD. */
|
|
217
|
-
unrealizedPnlUsd: number;
|
|
218
|
-
/** Average entry price of the position. */
|
|
219
|
-
entryPrice: number;
|
|
220
|
-
/** Approximate liquidation price for the position. */
|
|
221
|
-
liquidationPrice: number;
|
|
222
69
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Static configuration parameters describing a perpetuals market.
|
|
225
|
-
*
|
|
226
|
-
* These values are typically immutable or rarely changed, and are used
|
|
227
|
-
* to drive risk limits, pricing, and fee schedules.
|
|
228
|
-
*/
|
|
229
70
|
export interface PerpetualsMarketParams {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
/** Maintenance margin requirement for open positions (fraction). */
|
|
233
|
-
marginRatioMaintenance: number;
|
|
234
|
-
/** Symbol of the underlying asset. */
|
|
71
|
+
marginRatioInitial: IFixed;
|
|
72
|
+
marginRatioMaintenance: IFixed;
|
|
235
73
|
baseAssetSymbol: CoinSymbol;
|
|
236
|
-
/** On-chain ID of the oracle providing the base asset price. */
|
|
237
74
|
basePriceFeedId: ObjectId;
|
|
238
|
-
/** On-chain ID of the oracle providing the collateral asset price. */
|
|
239
75
|
collateralPriceFeedId: ObjectId;
|
|
240
|
-
/** Funding interval duration in milliseconds. */
|
|
241
76
|
fundingFrequencyMs: bigint;
|
|
242
|
-
/** Funding period used for calculations in milliseconds. */
|
|
243
77
|
fundingPeriodMs: bigint;
|
|
244
|
-
/** TWAP frequency for the premium in milliseconds. */
|
|
245
78
|
premiumTwapFrequencyMs: bigint;
|
|
246
|
-
/** TWAP period for the premium in milliseconds. */
|
|
247
79
|
premiumTwapPeriodMs: bigint;
|
|
248
|
-
/** TWAP frequency for the spread in milliseconds. */
|
|
249
80
|
spreadTwapFrequencyMs: bigint;
|
|
250
|
-
/** TWAP period for the spread in milliseconds. */
|
|
251
81
|
spreadTwapPeriodMs: bigint;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
/** Liquidation fee rate (fraction) charged on liquidations. */
|
|
259
|
-
liquidationFee: Percentage;
|
|
260
|
-
/** Fee rate (fraction) for forced cancellation. */
|
|
261
|
-
forceCancelFee: Percentage;
|
|
262
|
-
/** Fraction of fees directed to the insurance fund. */
|
|
263
|
-
insuranceFundFee: Percentage;
|
|
264
|
-
/** Minimum notional order value in USD. */
|
|
265
|
-
minOrderUsdValue: number;
|
|
266
|
-
/** Minimum base size increment for orders (lot size, scaled bigint). */
|
|
82
|
+
makerFee: IFixed;
|
|
83
|
+
takerFee: IFixed;
|
|
84
|
+
liquidationFee: IFixed;
|
|
85
|
+
forceCancelFee: IFixed;
|
|
86
|
+
insuranceFundFee: IFixed;
|
|
87
|
+
minOrderUsdValue: IFixed;
|
|
267
88
|
lotSize: bigint;
|
|
268
|
-
/** Minimum price increment (tick size, scaled bigint). */
|
|
269
89
|
tickSize: bigint;
|
|
270
|
-
|
|
271
|
-
scalingFactor: number;
|
|
272
|
-
/** Additional taker fee that depends on gas cost. */
|
|
273
|
-
gasPriceTakerFee: Percentage;
|
|
274
|
-
/** Z-score threshold used for outlier detection in pricing. */
|
|
275
|
-
zScoreThreshold: number;
|
|
276
|
-
/** Maximum open interest (notional or base) allowed in the market. */
|
|
90
|
+
liquidationTolerance: bigint;
|
|
277
91
|
maxPendingOrders: bigint;
|
|
278
|
-
|
|
279
|
-
baseOracleTolerance: bigint;
|
|
280
|
-
/** Oracle tolerance for the collateral price (scaled bigint). */
|
|
281
|
-
collateralOracleTolerance: bigint;
|
|
282
|
-
/** Maximum open interest (absolute). */
|
|
283
|
-
maxOpenInterest: number;
|
|
284
|
-
/** Threshold above which open interest is considered elevated. */
|
|
285
|
-
maxOpenInterestThreshold: number;
|
|
286
|
-
/** Maximum fraction of open interest a single position can hold. */
|
|
287
|
-
maxOpenInterestPositionPercent: number;
|
|
92
|
+
oracleTolerance: bigint;
|
|
288
93
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Dynamic runtime state of a perpetuals market.
|
|
291
|
-
*
|
|
292
|
-
* These values are updated frequently and used to compute funding
|
|
293
|
-
* and other time-variant metrics.
|
|
294
|
-
*/
|
|
295
94
|
export interface PerpetualsMarketState {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
premiumTwapLastUpdateTimestamp: Timestamp;
|
|
306
|
-
/** Spread TWAP value. */
|
|
307
|
-
spreadTwap: number;
|
|
308
|
-
/** Timestamp of last spread TWAP update. */
|
|
309
|
-
spreadTwapLastUpdateTimestamp: Timestamp;
|
|
310
|
-
/** Current open interest in the market. */
|
|
311
|
-
openInterest: number;
|
|
312
|
-
/** Total fees accrued by the market. */
|
|
313
|
-
feesAccrued: number;
|
|
95
|
+
cumFundingRateLong: IFixed;
|
|
96
|
+
cumFundingRateShort: IFixed;
|
|
97
|
+
fundingLastUpdateMs: Timestamp;
|
|
98
|
+
premiumTwap: IFixed;
|
|
99
|
+
premiumTwapLastUpdateMs: Timestamp;
|
|
100
|
+
spreadTwap: IFixed;
|
|
101
|
+
spreadTwapLastUpdateMs: Timestamp;
|
|
102
|
+
openInterest: IFixed;
|
|
103
|
+
feesAccrued: IFixed;
|
|
314
104
|
}
|
|
315
|
-
/**
|
|
316
|
-
* Single OHLCV data point for a market candle.
|
|
317
|
-
*
|
|
318
|
-
* Typically used in charts and historical data views.
|
|
319
|
-
*/
|
|
320
105
|
export interface PerpetualsMarketCandleDataPoint {
|
|
321
|
-
|
|
322
|
-
timestamp: Timestamp;
|
|
323
|
-
/** High price within this interval. */
|
|
106
|
+
time: Timestamp;
|
|
324
107
|
high: number;
|
|
325
|
-
/** Low price within this interval. */
|
|
326
108
|
low: number;
|
|
327
|
-
/** Open price at the beginning of the interval. */
|
|
328
109
|
open: number;
|
|
329
|
-
/** Close price at the end of the interval. */
|
|
330
110
|
close: number;
|
|
331
|
-
/** Traded volume (base units) during the interval. */
|
|
332
111
|
volume: number;
|
|
333
112
|
}
|
|
334
|
-
/**
|
|
335
|
-
* A single entry (price level) in an orderbook side.
|
|
336
|
-
*/
|
|
337
|
-
export interface PerpetualsOrderbookItem {
|
|
338
|
-
/** Total size resting at this price level (base units). */
|
|
339
|
-
size: number;
|
|
340
|
-
/** Price level for the aggregated orders. */
|
|
341
|
-
price: number;
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Aggregated orderbook snapshot for a perpetuals market.
|
|
345
|
-
*/
|
|
346
113
|
export interface PerpetualsOrderbook {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
114
|
+
bids: Record<PerpetualsOrderIdAsString, {
|
|
115
|
+
accountId: PerpetualsAccountId;
|
|
116
|
+
size: number;
|
|
117
|
+
price: number;
|
|
118
|
+
}>;
|
|
119
|
+
asks: Record<PerpetualsOrderIdAsString, {
|
|
120
|
+
accountId: PerpetualsAccountId;
|
|
121
|
+
size: number;
|
|
122
|
+
price: number;
|
|
123
|
+
}>;
|
|
352
124
|
asksTotalSize: number;
|
|
353
|
-
/** Sum of ask-side size across all levels. */
|
|
354
125
|
bidsTotalSize: number;
|
|
355
|
-
/** Best bid price (highest bid), or undefined if no bids. */
|
|
356
126
|
bestBidPrice: number | undefined;
|
|
357
|
-
/** Best ask price (lowest ask), or undefined if no asks. */
|
|
358
127
|
bestAskPrice: number | undefined;
|
|
359
|
-
/** Mid price between best bid and best ask, if both exist. */
|
|
360
128
|
midPrice: number | undefined;
|
|
361
|
-
/** Incremental nonce associated with this snapshot. */
|
|
362
|
-
nonce: bigint;
|
|
363
129
|
}
|
|
364
|
-
/**
|
|
365
|
-
* Incremental deltas to an orderbook snapshot.
|
|
366
|
-
*
|
|
367
|
-
* These are typically used over websockets for streaming updates.
|
|
368
|
-
*/
|
|
369
|
-
export interface PerpetualsOrderbookDeltas {
|
|
370
|
-
/** Updated bid-side price levels. */
|
|
371
|
-
bidsDeltas: PerpetualsOrderbookItem[];
|
|
372
|
-
/** Updated ask-side price levels. */
|
|
373
|
-
asksDeltas: PerpetualsOrderbookItem[];
|
|
374
|
-
/** Delta of total ask-side size. */
|
|
375
|
-
asksTotalSizeDelta: number;
|
|
376
|
-
/** Delta of total bid-side size. */
|
|
377
|
-
bidsTotalSizeDelta: number;
|
|
378
|
-
/** Nonce for ordering deltas. */
|
|
379
|
-
nonce: bigint;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Core order metadata for perpetuals orders.
|
|
383
|
-
*
|
|
384
|
-
* This is shared across multiple internal and external APIs.
|
|
385
|
-
*/
|
|
386
130
|
export interface PerpetualsOrderData {
|
|
387
|
-
/** Unique ID of the order. */
|
|
388
131
|
orderId: PerpetualsOrderId;
|
|
389
|
-
/** Initial order size in scaled base units. */
|
|
390
132
|
initialSize: bigint;
|
|
391
|
-
|
|
392
|
-
currentSize: bigint;
|
|
393
|
-
/** Order side (Bid or Ask). */
|
|
133
|
+
filledSize: bigint;
|
|
394
134
|
side: PerpetualsOrderSide;
|
|
395
|
-
/** Market this order belongs to. */
|
|
396
135
|
marketId: PerpetualsMarketId;
|
|
397
136
|
}
|
|
398
|
-
/**
|
|
399
|
-
* Optional integrator fee configuration for an order.
|
|
400
|
-
*
|
|
401
|
-
* When provided, this allows an approved integrator to collect a fee on the taker
|
|
402
|
-
* volume generated by this order. The integrator must have been previously approved
|
|
403
|
-
* by the user via the create-integration endpoint, and the taker fee must not exceed
|
|
404
|
-
* the maximum fee approved by the user.
|
|
405
|
-
*/
|
|
406
|
-
export interface PerpetualsBuilderCodeParamaters {
|
|
407
|
-
/**
|
|
408
|
-
* Sui address of the integrator who will receive the fee.
|
|
409
|
-
*
|
|
410
|
-
* This integrator must have been previously approved by the account owner,
|
|
411
|
-
* and must have a vault created for the market where the order is being placed.
|
|
412
|
-
*/
|
|
413
|
-
integratorAddress: SuiAddress;
|
|
414
|
-
/**
|
|
415
|
-
* Taker fee (as a decimal) to be charged on this order's taker volume.
|
|
416
|
-
*
|
|
417
|
-
* For example, 0.0005 represents a 0.05% fee. This value must not exceed
|
|
418
|
-
* the maximum taker fee that the user approved for this integrator.
|
|
419
|
-
* The fee is only applied to taker volume (not maker volume).
|
|
420
|
-
*/
|
|
421
|
-
takerFee: Percentage;
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Full stop-order representation on-chain.
|
|
425
|
-
*
|
|
426
|
-
* Can represent:
|
|
427
|
-
* - SL/TP orders (`slTp`)
|
|
428
|
-
* - Standalone stops (`nonSlTp`)
|
|
429
|
-
*/
|
|
430
|
-
export interface PerpetualsStopOrderData {
|
|
431
|
-
/** ID of the stop order object on-chain. */
|
|
432
|
-
objectId: ObjectId;
|
|
433
|
-
/** Market the stop order is tied to. */
|
|
434
|
-
marketId: PerpetualsMarketId;
|
|
435
|
-
/** Size to execute when triggered (scaled base units). */
|
|
436
|
-
size: bigint;
|
|
437
|
-
/** Direction of the stop order. */
|
|
438
|
-
side: PerpetualsOrderSide;
|
|
439
|
-
/** Optional expiration time (ms or seconds, depending on protocol). */
|
|
440
|
-
expiryTimestamp?: bigint;
|
|
441
|
-
/** Optional limit order parameters when the stop triggers. */
|
|
442
|
-
limitOrder?: {
|
|
443
|
-
/** Limit price to post or execute at, scaled bigint. */
|
|
444
|
-
price: bigint;
|
|
445
|
-
/** Order type semantics. */
|
|
446
|
-
orderType: PerpetualsOrderType;
|
|
447
|
-
};
|
|
448
|
-
/** Stop loss / take profit configuration. */
|
|
449
|
-
slTp?: {
|
|
450
|
-
/** Index price at which to trigger a stop loss. */
|
|
451
|
-
stopLossIndexPrice?: number;
|
|
452
|
-
/** Index price at which to take profit. */
|
|
453
|
-
takeProfitIndexPrice?: number;
|
|
454
|
-
/** Unique order identifier for limit order sl/tp is tied to. */
|
|
455
|
-
limitOrderId?: PerpetualsOrderId;
|
|
456
|
-
};
|
|
457
|
-
/** Non-SL/TP standalone stop configuration. */
|
|
458
|
-
nonSlTp?: {
|
|
459
|
-
/** Index price threshold used for triggering. */
|
|
460
|
-
stopIndexPrice: number;
|
|
461
|
-
/** If true, triggers when index >= threshold, otherwise index <= threshold. */
|
|
462
|
-
triggerIfGeStopIndexPrice: boolean;
|
|
463
|
-
/** Whether the stop can only reduce an existing position. */
|
|
464
|
-
reduceOnly: boolean;
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Filled order data used in execution price previews and trade details.
|
|
469
|
-
*/
|
|
470
137
|
export interface PerpetualsFilledOrderData {
|
|
471
|
-
/** Filled size in base units (non-scaled). */
|
|
472
138
|
size: number;
|
|
473
|
-
/** Execution price for the fill. */
|
|
474
139
|
price: number;
|
|
475
140
|
}
|
|
476
|
-
/**
|
|
477
|
-
* High-level order info with price and size only.
|
|
478
|
-
*/
|
|
479
141
|
export interface PerpetualsOrderInfo {
|
|
480
|
-
|
|
481
|
-
price: number;
|
|
482
|
-
/** Order size (scaled base units). */
|
|
142
|
+
price: PerpetualsOrderPrice;
|
|
483
143
|
size: bigint;
|
|
484
144
|
}
|
|
485
|
-
/**
|
|
486
|
-
* Pairing of a perpetuals account capability and its current account state.
|
|
487
|
-
*/
|
|
488
145
|
export interface PerpetualsAccountData {
|
|
489
|
-
/** Account capability object. */
|
|
490
146
|
accountCap: PerpetualsAccountCap;
|
|
491
|
-
/** Account state object. */
|
|
492
147
|
account: PerpetualsAccountObject;
|
|
493
148
|
}
|
|
494
|
-
/**
|
|
495
|
-
* Aggregate account-level metrics for perpetuals.
|
|
496
|
-
*/
|
|
497
149
|
export interface PerpetualsAccountObject {
|
|
498
|
-
/** Numeric ID of the account. */
|
|
499
|
-
accountId: PerpetualsAccountId;
|
|
500
|
-
/** Total equity in USD. */
|
|
501
|
-
totalEquityUsd: number;
|
|
502
|
-
/** Available collateral in collateral units. */
|
|
503
|
-
availableCollateral: number;
|
|
504
|
-
/** Available collateral in USD. */
|
|
505
|
-
availableCollateralUsd: number;
|
|
506
|
-
/** Sum of unrealized funding PnL across markets. */
|
|
507
|
-
totalUnrealizedFundingsUsd: number;
|
|
508
|
-
/** Sum of unrealized position PnL across markets. */
|
|
509
|
-
totalUnrealizedPnlUsd: number;
|
|
510
|
-
/** Per-market positions for this account. */
|
|
511
150
|
positions: PerpetualsPosition[];
|
|
512
151
|
}
|
|
513
|
-
/**
|
|
514
|
-
* Human-facing metadata for vault discovery / browsing.
|
|
515
|
-
*
|
|
516
|
-
* This is intended for UI display and is not used for any on-chain risk or
|
|
517
|
-
* accounting logic.
|
|
518
|
-
*
|
|
519
|
-
* Note: The type name contains a historical misspelling ("Metatada") and is
|
|
520
|
-
* preserved for backward compatibility.
|
|
521
|
-
*/
|
|
522
|
-
export interface PerpetualsVaultMetatada {
|
|
523
|
-
/**
|
|
524
|
-
* A human-readable name for the `Vault`.
|
|
525
|
-
*/
|
|
526
|
-
name: string;
|
|
527
|
-
/**
|
|
528
|
-
* A verbose description of the `Vault`.
|
|
529
|
-
*/
|
|
530
|
-
description: string;
|
|
531
|
-
/**
|
|
532
|
-
* The `Vault` curator's name.
|
|
533
|
-
*/
|
|
534
|
-
curatorName: string | undefined;
|
|
535
|
-
/**
|
|
536
|
-
* A url for the `Vault`'s curator. Ideally their website.
|
|
537
|
-
*/
|
|
538
|
-
curatorUrl: string | undefined;
|
|
539
|
-
/**
|
|
540
|
-
* An image url for the `Vault`'s curator. Ideally their logo.
|
|
541
|
-
*/
|
|
542
|
-
curatorLogoUrl: string | undefined;
|
|
543
|
-
/**
|
|
544
|
-
* Extra / optional fields for future extensibility. Recommended keys include: twitter_url.
|
|
545
|
-
*/
|
|
546
|
-
extraFields: Record<string, string>;
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* On-chain representation of a vault that manages user collateral and
|
|
550
|
-
* interacts with clearing houses on their behalf.
|
|
551
|
-
*/
|
|
552
|
-
export interface PerpetualsVaultObject {
|
|
553
|
-
/**
|
|
554
|
-
* Unique identifier for distinct network identification.
|
|
555
|
-
*/
|
|
556
|
-
objectId: ObjectId;
|
|
557
|
-
/**
|
|
558
|
-
* Contract version number for controlled upgrades.
|
|
559
|
-
*/
|
|
560
|
-
version: bigint;
|
|
561
|
-
/**
|
|
562
|
-
* Curator-provided metadata used for vault discovery and display.
|
|
563
|
-
*
|
|
564
|
-
* This data is expected to be relatively stable and is typically set at
|
|
565
|
-
* creation time (though it may be updatable depending on protocol rules).
|
|
566
|
-
*/
|
|
567
|
-
metadata: PerpetualsVaultMetatada;
|
|
568
|
-
/**
|
|
569
|
-
* Supply of LP coins from a `TreasuryCap` for liquidity integrity.
|
|
570
|
-
*
|
|
571
|
-
* This is the total minted supply of the vault's LP token. Together with
|
|
572
|
-
* `tvlUsd` and `totalCollateral`, this is used to derive LP share price.
|
|
573
|
-
*/
|
|
574
|
-
lpSupply: Balance;
|
|
575
|
-
/**
|
|
576
|
-
* Total balance of underlying Coin (`C`), deposited by users.
|
|
577
|
-
*
|
|
578
|
-
* "Idle" collateral is not currently allocated to any clearing house
|
|
579
|
-
* position. It remains held by the vault and can be used for new allocations
|
|
580
|
-
* or withdrawals (subject to lock/queue rules).
|
|
581
|
-
*/
|
|
582
|
-
idleCollateral: Balance;
|
|
583
|
-
/**
|
|
584
|
-
* USD valuation of `idleCollateral` at query time.
|
|
585
|
-
*
|
|
586
|
-
* This is derived using the vault's collateral oracle price and is provided
|
|
587
|
-
* for UI convenience.
|
|
588
|
-
*/
|
|
589
|
-
idleCollateralUsd: number;
|
|
590
|
-
/**
|
|
591
|
-
* Total collateral owned by the vault in native units.
|
|
592
|
-
*
|
|
593
|
-
* This is the sum of:
|
|
594
|
-
* - idle collateral held directly by the vault, and
|
|
595
|
-
* - collateral currently allocated across clearing houses/positions.
|
|
596
|
-
*/
|
|
597
|
-
totalCollateral: Balance;
|
|
598
|
-
/**
|
|
599
|
-
* USD valuation of `totalCollateral` at query time.
|
|
600
|
-
*
|
|
601
|
-
* This is typically derived from `totalCollateral` and the collateral oracle
|
|
602
|
-
* price used by the vault.
|
|
603
|
-
*/
|
|
604
|
-
totalCollateralUsd: number;
|
|
605
|
-
/**
|
|
606
|
-
* Total value locked in USD for this vault.
|
|
607
|
-
*
|
|
608
|
-
* Depending on protocol accounting, this may match `totalCollateralUsd`, or
|
|
609
|
-
* may incorporate additional adjustments. It is the primary headline number
|
|
610
|
-
* used for ranking and display.
|
|
611
|
-
*/
|
|
612
|
-
tvlUsd: number;
|
|
613
|
-
/**
|
|
614
|
-
* IDs of `ClearingHouse` where `Vault` has positions.
|
|
615
|
-
*/
|
|
616
|
-
marketIds: PerpetualsMarketId[];
|
|
617
|
-
/**
|
|
618
|
-
* Vault parameters
|
|
619
|
-
*/
|
|
620
|
-
parameters: {
|
|
621
|
-
/**
|
|
622
|
-
* Lock-in duration for engaged assets in milliseconds.
|
|
623
|
-
*/
|
|
624
|
-
lockPeriodMs: bigint;
|
|
625
|
-
/**
|
|
626
|
-
* Fee rate for vault's owner, collected from user's profits when they withdraw
|
|
627
|
-
*/
|
|
628
|
-
performanceFeePercentage: number;
|
|
629
|
-
/**
|
|
630
|
-
* Delay period to wait for eventual force withdrawing
|
|
631
|
-
*
|
|
632
|
-
* Force-withdrawal is an emergency/escape hatch path; this delay gives the
|
|
633
|
-
* vault time to unwind positions before executing the withdrawal.
|
|
634
|
-
*/
|
|
635
|
-
forceWithdrawDelayMs: bigint;
|
|
636
|
-
/**
|
|
637
|
-
* Price feed storage id idetifying the oracle price for `C`
|
|
638
|
-
*/
|
|
639
|
-
collateralPriceFeedStorageId: ObjectId;
|
|
640
|
-
/**
|
|
641
|
-
* Source object ID for the collateral price feed storage.
|
|
642
|
-
*
|
|
643
|
-
* Some oracle integrations separate the "storage object" from the "source"
|
|
644
|
-
* (e.g., an aggregator or publisher object). This field identifies the
|
|
645
|
-
* upstream source used to populate `collateralPriceFeedStorageId`.
|
|
646
|
-
*/
|
|
647
|
-
collateralPriceFeedStorageSourceId: ObjectId;
|
|
648
|
-
/**
|
|
649
|
-
* Maximum tolerated deviation for the collateral oracle price.
|
|
650
|
-
*
|
|
651
|
-
* Used as a safety bound when valuing deposits/withdrawals and computing
|
|
652
|
-
* USD conversions. This is typically a fixed-point or scaled bigint value,
|
|
653
|
-
* consistent with the on-chain oracle representation.
|
|
654
|
-
*/
|
|
655
|
-
collateralPriceFeedStorageTolerance: bigint;
|
|
656
|
-
/**
|
|
657
|
-
* Maximum margin ratio tolerance for force-withdraw processing.
|
|
658
|
-
*
|
|
659
|
-
* Force-withdraw generally requires closing positions. This tolerance
|
|
660
|
-
* controls how much worse (or better) the resulting margin ratio is allowed
|
|
661
|
-
* to be, compared to a target/expected value, before rejecting the action.
|
|
662
|
-
*/
|
|
663
|
-
maxForceWithdrawMarginRatioTolerance: number;
|
|
664
|
-
/**
|
|
665
|
-
* Scaling factor to apply to `C` to convert a balance to ifixed.
|
|
666
|
-
*/
|
|
667
|
-
/**
|
|
668
|
-
* Used to calculate user's minimum deposit value in usd
|
|
669
|
-
*/
|
|
670
|
-
scalingFactor: number;
|
|
671
|
-
/**
|
|
672
|
-
* The maximum number of distinct `ClearingHouse`.
|
|
673
|
-
*/
|
|
674
|
-
maxMarketsInVault: bigint;
|
|
675
|
-
/**
|
|
676
|
-
* The maximum number of pending orders allowed for a single position in the `Vault`.
|
|
677
|
-
*/
|
|
678
|
-
maxPendingOrdersPerPosition: bigint;
|
|
679
|
-
/**
|
|
680
|
-
* Maximum total collateral (native units) that can be deposited into the vault.
|
|
681
|
-
*
|
|
682
|
-
* This is a capacity/risk control parameter. Deposits that would cause the
|
|
683
|
-
* vault to exceed this limit should be rejected by the protocol/backend.
|
|
684
|
-
*/
|
|
685
|
-
maxTotalDepositedCollateral: Balance;
|
|
686
|
-
/** Minimum position margin (USD) to trigger full close during force withdraw. */
|
|
687
|
-
minForceWithdrawValueUsd: number;
|
|
688
|
-
};
|
|
689
|
-
/** Owner address of the vault. */
|
|
690
|
-
ownerAddress: SuiAddress;
|
|
691
|
-
/** Creation timestamp of the vault. */
|
|
692
|
-
creationTimestamp: Timestamp | undefined;
|
|
693
|
-
/** Underlying perpetuals account ID that the vault uses. */
|
|
694
|
-
accountId: PerpetualsAccountId;
|
|
695
|
-
/** Account object ID used by the vault. */
|
|
696
|
-
accountObjectId: ObjectId;
|
|
697
|
-
/** Collateral coin type accepted by this vault. */
|
|
698
|
-
collateralCoinType: CoinType;
|
|
699
|
-
/**
|
|
700
|
-
* LP coin type minted by this vault.
|
|
701
|
-
*
|
|
702
|
-
* This is the `Coin<T>` type used to represent shares in the vault. Users
|
|
703
|
-
* receive LP coins on deposit and burn/return them on withdrawal.
|
|
704
|
-
*/
|
|
705
|
-
lpCoinType: CoinType;
|
|
706
|
-
/** Decimals for the LP token minted by this vault. */
|
|
707
|
-
lpCoinDecimals: CoinDecimal;
|
|
708
|
-
/**
|
|
709
|
-
* Estimated monthly APR for this vault, expressed as a percentage.
|
|
710
|
-
*
|
|
711
|
-
* This is typically computed off-chain from historical performance and/or
|
|
712
|
-
* accounting state. It is a display metric and should not be treated as a
|
|
713
|
-
* guaranteed rate.
|
|
714
|
-
*/
|
|
715
|
-
monthlyAprPercentage: Percentage;
|
|
716
|
-
/** The annualized percentage return from incentives (added yields) */
|
|
717
|
-
monthlyBoostedAprPercentage: Percentage;
|
|
718
|
-
/** Indicates the vault is temporarily paused until the timestamp (if present). */
|
|
719
|
-
pausedUntilTimestamp: bigint | undefined;
|
|
720
|
-
/** Timestamp at which `pause_vault_for_force_withdraw` was last called. */
|
|
721
|
-
lastPausedTimestamp: Timestamp;
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Represents a single pending vault withdrawal request.
|
|
725
|
-
*/
|
|
726
|
-
export interface PerpetualsVaultWithdrawRequest {
|
|
727
|
-
/**
|
|
728
|
-
* The address of the user that created the withdraw request
|
|
729
|
-
*/
|
|
730
|
-
userAddress: SuiAddress;
|
|
731
|
-
/**
|
|
732
|
-
* Object id of the vault associated with the withdraw request
|
|
733
|
-
*/
|
|
734
|
-
vaultId: SuiAddress;
|
|
735
|
-
/**
|
|
736
|
-
* The amount of the shares requested for withdrawal.
|
|
737
|
-
*/
|
|
738
|
-
lpAmountIn: Balance;
|
|
739
|
-
/**
|
|
740
|
-
* USD valuation of `lpAmountIn` at request time (or at query time, depending on backend).
|
|
741
|
-
*
|
|
742
|
-
* This field is provided for UI convenience and may be computed using the
|
|
743
|
-
* vault's LP share price.
|
|
744
|
-
*/
|
|
745
|
-
lpAmountInUsd: number;
|
|
746
|
-
/**
|
|
747
|
-
* Timestamp of request's creation
|
|
748
|
-
*/
|
|
749
|
-
requestTimestamp: Timestamp;
|
|
750
|
-
/**
|
|
751
|
-
* The minimum amount of the collateral balance expected as output for this withdrawal
|
|
752
|
-
*
|
|
753
|
-
* This acts as a slippage/price-protection bound for the user.
|
|
754
|
-
*/
|
|
755
|
-
minCollateralAmountOut: Balance;
|
|
756
|
-
/**
|
|
757
|
-
* USD valuation of `minCollateralAmountOut`, using the vault's collateral oracle.
|
|
758
|
-
*
|
|
759
|
-
* Provided for display; the on-chain constraint is enforced by
|
|
760
|
-
* `minCollateralAmountOut` (native units).
|
|
761
|
-
*/
|
|
762
|
-
minCollateralAmountOutUsd: number;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Event emitted when a clearing house (market) is upgraded to a new version.
|
|
766
|
-
*/
|
|
767
152
|
export interface UpdatedMarketVersionEvent extends Event {
|
|
768
|
-
/** Market identifier for which the version changed. */
|
|
769
153
|
marketId: PerpetualsMarketId;
|
|
770
|
-
/** New version value. */
|
|
771
154
|
version: bigint;
|
|
772
155
|
}
|
|
773
|
-
/**
|
|
774
|
-
* Type guard for {@link UpdatedMarketVersionEvent}.
|
|
775
|
-
*
|
|
776
|
-
* @param event - Generic event.
|
|
777
|
-
* @returns `true` if this is an `UpdatedMarketVersionEvent`.
|
|
778
|
-
*/
|
|
779
156
|
export declare const isUpdatedMarketVersion: (event: Event) => event is UpdatedMarketVersionEvent;
|
|
780
|
-
|
|
781
|
-
* Cursor-based response wrapping a list of collateral changes for an account.
|
|
782
|
-
*/
|
|
783
|
-
export type ApiPerpetualsAccountCollateralHistoryResponse = ApiPerpetualsHistoricalDataWithCursorResponse & {
|
|
784
|
-
/** Collateral changes in chronological order. */
|
|
157
|
+
export interface PerpetualsAccountCollateralChangesWithCursor {
|
|
785
158
|
collateralChanges: PerpetualsAccountCollateralChange[];
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
* Single collateral change record for an account.
|
|
789
|
-
*
|
|
790
|
-
* This may represent:
|
|
791
|
-
* - Deposits / withdrawals
|
|
792
|
-
* - Liquidations
|
|
793
|
-
* - Funding settlements
|
|
794
|
-
* - Trading fees
|
|
795
|
-
*/
|
|
159
|
+
nextCursor: Timestamp | undefined;
|
|
160
|
+
}
|
|
796
161
|
export type PerpetualsAccountCollateralChange = {
|
|
797
|
-
/** When the change occurred. */
|
|
798
162
|
timestamp: Timestamp;
|
|
799
|
-
/** Sui transaction digest that produced this change. */
|
|
800
163
|
txDigest: TransactionDigest;
|
|
801
|
-
/** Market ID, if applicable (can be undefined for global changes). */
|
|
802
164
|
marketId: PerpetualsMarketId | undefined;
|
|
803
|
-
/** Concrete event type fully qualified (Sui struct type). */
|
|
804
165
|
eventType: AnyObjectType;
|
|
805
|
-
/** Net change in collateral units. */
|
|
806
166
|
collateralChange: number;
|
|
807
|
-
/** Net change in USD value. */
|
|
808
167
|
collateralChangeUsd: number;
|
|
809
|
-
/** Optional breakdown of fees, with variant shapes based on event. */
|
|
810
|
-
fees?: {
|
|
811
|
-
netFeesUsd: number;
|
|
812
|
-
liquidationFeesUsd: number;
|
|
813
|
-
forceCancelFeesUsd: number;
|
|
814
|
-
insuranceFundFeesUsd: number;
|
|
815
|
-
} | {
|
|
816
|
-
netFeesUsd: number;
|
|
817
|
-
liqorFeesUsd: number;
|
|
818
|
-
} | {
|
|
819
|
-
netFeesUsd: number;
|
|
820
|
-
};
|
|
821
168
|
};
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
export type ApiPerpetualsAccountOrderHistoryResponse = ApiPerpetualsHistoricalDataWithCursorResponse & {
|
|
826
|
-
/** Orders in chronological order. */
|
|
827
|
-
orders: PerpetualsAccountOrderHistoryData[];
|
|
828
|
-
};
|
|
829
|
-
/**
|
|
830
|
-
* Historical margin data point for an account, used in margin history views.
|
|
831
|
-
*/
|
|
832
|
-
export interface PerpetualsAccountMarginHistoryData {
|
|
833
|
-
/** Timestamp of this snapshot. */
|
|
834
|
-
timestamp: Timestamp;
|
|
835
|
-
/** Available collateral in USD. */
|
|
836
|
-
availableCollateralUsd: number;
|
|
837
|
-
/** Total equity in USD. */
|
|
838
|
-
totalEquityUsd: number;
|
|
839
|
-
/** Unrealized funding PnL in USD at that time. */
|
|
840
|
-
unrealizedFundingsUsd: number;
|
|
841
|
-
/** Unrealized position PnL in USD at that time. */
|
|
842
|
-
unrealizedPnlUsd: number;
|
|
169
|
+
export interface PerpetualsAccountTradesWithCursor {
|
|
170
|
+
trades: PerpetualsAccountTrade[];
|
|
171
|
+
nextCursor: Timestamp | undefined;
|
|
843
172
|
}
|
|
844
|
-
|
|
845
|
-
* Individual order affecting an account.
|
|
846
|
-
*/
|
|
847
|
-
export type PerpetualsAccountOrderHistoryData = {
|
|
848
|
-
/** Timestamp of the order. */
|
|
173
|
+
export type PerpetualsAccountTrade = {
|
|
849
174
|
timestamp: Timestamp;
|
|
850
|
-
/** Sui transaction digest. */
|
|
851
175
|
txDigest: TransactionDigest;
|
|
852
|
-
/** Market in which this order occurred. */
|
|
853
176
|
marketId: PerpetualsMarketId;
|
|
854
|
-
/** Concrete event type. */
|
|
855
177
|
eventType: AnyObjectType;
|
|
856
|
-
/** Side of the order relative to the account (Bid/Ask). */
|
|
857
178
|
side: PerpetualsOrderSide;
|
|
858
|
-
|
|
179
|
+
} & ({
|
|
180
|
+
orderPrice: bigint;
|
|
181
|
+
} | {
|
|
859
182
|
price: number;
|
|
860
|
-
|
|
183
|
+
}) & ({
|
|
184
|
+
sizeLots: bigint;
|
|
185
|
+
} | {
|
|
861
186
|
size: number;
|
|
862
|
-
|
|
863
|
-
slTp?: {
|
|
864
|
-
/** Optional stop-loss trigger price based on the index price. */
|
|
865
|
-
stopLossIndexPrice?: number;
|
|
866
|
-
/** Optional take-profit trigger price based on the index price. */
|
|
867
|
-
takeProfitIndexPrice?: number;
|
|
868
|
-
/** Unique order identifier for limit order sl/tp is tied to. */
|
|
869
|
-
limitOrderId?: PerpetualsOrderId;
|
|
870
|
-
};
|
|
871
|
-
/** Stop order data that is not a stop-loss / take-profit order
|
|
872
|
-
* (e.g. generic trigger orders).
|
|
873
|
-
*/
|
|
874
|
-
stopOrder?: {
|
|
875
|
-
/** Index price at which the stop order should trigger. */
|
|
876
|
-
stopIndexPrice: number;
|
|
877
|
-
};
|
|
878
|
-
};
|
|
879
|
-
/**
|
|
880
|
-
* Event emitted when collateral is deposited into an account.
|
|
881
|
-
*/
|
|
187
|
+
});
|
|
882
188
|
export interface DepositedCollateralEvent extends Event {
|
|
883
189
|
accountId: PerpetualsAccountId;
|
|
884
190
|
collateralDelta: Balance;
|
|
885
191
|
}
|
|
886
|
-
/**
|
|
887
|
-
* Event emitted when collateral is allocated from general account collateral
|
|
888
|
-
* into a specific market position.
|
|
889
|
-
*/
|
|
890
192
|
export interface AllocatedCollateralEvent extends Event {
|
|
891
|
-
marketId: PerpetualsMarketId;
|
|
892
193
|
accountId: PerpetualsAccountId;
|
|
893
194
|
collateralDelta: Balance;
|
|
195
|
+
positionCollateralAfter: IFixed;
|
|
894
196
|
}
|
|
895
|
-
/**
|
|
896
|
-
* Event emitted when collateral is deallocated from a market back to
|
|
897
|
-
* the account's general collateral.
|
|
898
|
-
*/
|
|
899
197
|
export interface DeallocatedCollateralEvent extends Event {
|
|
900
|
-
marketId: PerpetualsMarketId;
|
|
901
198
|
accountId: PerpetualsAccountId;
|
|
902
199
|
collateralDelta: Balance;
|
|
200
|
+
positionCollateralAfter: IFixed;
|
|
903
201
|
}
|
|
904
|
-
/**
|
|
905
|
-
* Event emitted when collateral is withdrawn from the account.
|
|
906
|
-
*/
|
|
907
202
|
export interface WithdrewCollateralEvent extends Event {
|
|
908
203
|
accountId: PerpetualsAccountId;
|
|
909
204
|
collateralDelta: Balance;
|
|
910
205
|
}
|
|
911
|
-
/**
|
|
912
|
-
* Event emitted when funding is settled for an account and market.
|
|
913
|
-
*/
|
|
914
206
|
export interface SettledFundingEvent extends Event {
|
|
915
207
|
accountId: PerpetualsAccountId;
|
|
916
|
-
collateralDeltaUsd:
|
|
208
|
+
collateralDeltaUsd: IFixed;
|
|
917
209
|
marketId: PerpetualsMarketId;
|
|
918
|
-
marketFundingRateLong:
|
|
919
|
-
marketFundingRateShort:
|
|
210
|
+
marketFundingRateLong: IFixed;
|
|
211
|
+
marketFundingRateShort: IFixed;
|
|
920
212
|
}
|
|
921
|
-
|
|
922
|
-
* Union of all event types that impact account collateral.
|
|
923
|
-
*/
|
|
924
|
-
export type CollateralEvent = WithdrewCollateralEvent | DepositedCollateralEvent | SettledFundingEvent | LiquidatedEvent | FilledTakerOrderEvent | FilledMakerOrdersEvent | AllocatedCollateralEvent | DeallocatedCollateralEvent;
|
|
925
|
-
/**
|
|
926
|
-
* Type guard for {@link WithdrewCollateralEvent}.
|
|
927
|
-
*/
|
|
213
|
+
export type CollateralEvent = WithdrewCollateralEvent | DepositedCollateralEvent | SettledFundingEvent | LiquidatedEvent | FilledTakerOrderEvent | FilledMakerOrderEvent | AllocatedCollateralEvent | DeallocatedCollateralEvent;
|
|
928
214
|
export declare const isWithdrewCollateralEvent: (event: Event) => event is WithdrewCollateralEvent;
|
|
929
|
-
/**
|
|
930
|
-
* Type guard for {@link DepositedCollateralEvent}.
|
|
931
|
-
*/
|
|
932
215
|
export declare const isDepositedCollateralEvent: (event: Event) => event is DepositedCollateralEvent;
|
|
933
|
-
/**
|
|
934
|
-
* Type guard for {@link DeallocatedCollateralEvent}.
|
|
935
|
-
*/
|
|
936
216
|
export declare const isDeallocatedCollateralEvent: (event: Event) => event is DeallocatedCollateralEvent;
|
|
937
|
-
/**
|
|
938
|
-
* Type guard for {@link AllocatedCollateralEvent}.
|
|
939
|
-
*/
|
|
940
217
|
export declare const isAllocatedCollateralEvent: (event: Event) => event is AllocatedCollateralEvent;
|
|
941
|
-
/**
|
|
942
|
-
* Type guard for {@link SettledFundingEvent}.
|
|
943
|
-
*/
|
|
944
218
|
export declare const isSettledFundingEvent: (event: Event) => event is SettledFundingEvent;
|
|
945
|
-
/**
|
|
946
|
-
* Event emitted when an account is liquidated in a given market.
|
|
947
|
-
*/
|
|
948
219
|
export interface LiquidatedEvent extends Event {
|
|
949
220
|
accountId: PerpetualsAccountId;
|
|
950
|
-
collateralDeltaUsd:
|
|
951
|
-
/** Liquidator's account ID. */
|
|
221
|
+
collateralDeltaUsd: IFixed;
|
|
952
222
|
liqorAccountId: PerpetualsAccountId;
|
|
223
|
+
size: bigint;
|
|
224
|
+
markPrice: IFixed;
|
|
953
225
|
marketId: PerpetualsMarketId;
|
|
954
226
|
side: PerpetualsOrderSide;
|
|
955
|
-
/** Amount of base asset liquidated. */
|
|
956
|
-
baseLiquidated: number;
|
|
957
|
-
/** Amount of quote asset liquidated. */
|
|
958
|
-
quoteLiquidated: number;
|
|
959
|
-
/** Liquidated account's PnL in USD for this event. */
|
|
960
|
-
liqeePnlUsd: number;
|
|
961
|
-
/** Liquidation fee paid in USD. */
|
|
962
|
-
liquidationFeesUsd: number;
|
|
963
|
-
/** Force-cancel fees collected in USD. */
|
|
964
|
-
forceCancelFeesUsd: number;
|
|
965
|
-
/** Fees directed to the insurance fund in USD. */
|
|
966
|
-
insuranceFundFeesUsd: number;
|
|
967
227
|
}
|
|
968
|
-
/**
|
|
969
|
-
* Type guard for {@link LiquidatedEvent}.
|
|
970
|
-
*/
|
|
971
228
|
export declare const isLiquidatedEvent: (event: Event) => event is LiquidatedEvent;
|
|
972
|
-
/**
|
|
973
|
-
* Event emitted when a new perpetuals account is created for a user.
|
|
974
|
-
*/
|
|
975
229
|
export interface CreatedAccountEvent extends Event {
|
|
976
230
|
user: SuiAddress;
|
|
977
231
|
accountId: PerpetualsAccountId;
|
|
978
232
|
}
|
|
979
|
-
|
|
980
|
-
* Event emitted when an account's initial margin ratio for a position
|
|
981
|
-
* is explicitly set or adjusted.
|
|
982
|
-
*/
|
|
983
|
-
export interface SetPositionInitialMarginRatioEvent extends Event {
|
|
984
|
-
marketId: PerpetualsMarketId;
|
|
985
|
-
accountId: PerpetualsAccountId;
|
|
986
|
-
initialMarginRatio: number;
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Trade data used for market-level trade history.
|
|
990
|
-
*/
|
|
991
|
-
export interface PerpetualsMarketOrderHistoryData {
|
|
992
|
-
/** Timestamp of the trade. */
|
|
233
|
+
export interface PerpetualsTradeHistoryData {
|
|
993
234
|
timestamp: Timestamp;
|
|
994
|
-
/** Transaction digest. */
|
|
995
235
|
txDigest: TransactionDigest;
|
|
996
|
-
/** Side of the trade. */
|
|
997
236
|
side: PerpetualsOrderSide;
|
|
998
|
-
/** Filled size in base units. */
|
|
999
237
|
sizeFilled: number;
|
|
1000
|
-
/** Order price (limit price) used for the trade. */
|
|
1001
238
|
orderPrice: number;
|
|
1002
239
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
* (book-keeping receipt).
|
|
1013
|
-
*/
|
|
240
|
+
export interface PerpetualsTradeHistoryWithCursor {
|
|
241
|
+
trades: PerpetualsTradeHistoryData[];
|
|
242
|
+
nextCursor: Timestamp | undefined;
|
|
243
|
+
}
|
|
244
|
+
export interface OrderbookPostReceiptEvent extends Event {
|
|
245
|
+
accountId: PerpetualsAccountId;
|
|
246
|
+
orderId: PerpetualsOrderId;
|
|
247
|
+
size: bigint;
|
|
248
|
+
}
|
|
1014
249
|
export interface OrderbookFillReceiptEvent extends Event {
|
|
1015
250
|
accountId: PerpetualsAccountId;
|
|
1016
251
|
orderId: PerpetualsOrderId;
|
|
1017
252
|
size: bigint;
|
|
1018
|
-
/** Whether the order was dropped instead of filled. */
|
|
1019
253
|
dropped: boolean;
|
|
1020
254
|
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Event emitted when an order is canceled.
|
|
1023
|
-
*/
|
|
1024
255
|
export interface CanceledOrderEvent extends Event {
|
|
1025
256
|
accountId: PerpetualsAccountId;
|
|
1026
257
|
marketId: PerpetualsMarketId;
|
|
@@ -1028,1853 +259,366 @@ export interface CanceledOrderEvent extends Event {
|
|
|
1028
259
|
size: bigint;
|
|
1029
260
|
orderId: PerpetualsOrderId;
|
|
1030
261
|
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Event emitted when a new order is posted to the orderbook.
|
|
1033
|
-
*/
|
|
1034
262
|
export interface PostedOrderEvent extends Event {
|
|
1035
263
|
accountId: PerpetualsAccountId;
|
|
1036
264
|
marketId: PerpetualsMarketId;
|
|
1037
|
-
|
|
265
|
+
side: PerpetualsOrderSide;
|
|
1038
266
|
size: bigint;
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
/**
|
|
1043
|
-
* Event emitted when one or more maker orders are filled against a taker.
|
|
1044
|
-
*/
|
|
1045
|
-
export interface FilledMakerOrdersEvent extends Event {
|
|
1046
|
-
/** List of per-maker fills for this aggregate event. */
|
|
1047
|
-
events: FilledMakerOrderEventFields[];
|
|
267
|
+
asksQuantity: IFixed;
|
|
268
|
+
bidsQuantity: IFixed;
|
|
1048
269
|
}
|
|
1049
|
-
|
|
1050
|
-
* Details for a single maker order fill inside a {@link FilledMakerOrdersEvent}.
|
|
1051
|
-
*/
|
|
1052
|
-
export interface FilledMakerOrderEventFields {
|
|
270
|
+
export interface FilledMakerOrderEvent extends Event {
|
|
1053
271
|
accountId: PerpetualsAccountId;
|
|
1054
|
-
|
|
1055
|
-
collateralDeltaUsd: number;
|
|
272
|
+
collateralDeltaUsd: IFixed;
|
|
1056
273
|
marketId: PerpetualsMarketId;
|
|
1057
274
|
side: PerpetualsOrderSide;
|
|
1058
275
|
size: bigint;
|
|
1059
|
-
sizeRemaining: bigint;
|
|
1060
276
|
orderId: PerpetualsOrderId;
|
|
1061
277
|
dropped: boolean;
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
278
|
+
baseAssetAmount: IFixed;
|
|
279
|
+
quoteAssetNotionalAmount: IFixed;
|
|
280
|
+
asksQuantity: IFixed;
|
|
281
|
+
bidsQuantity: IFixed;
|
|
1065
282
|
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Event emitted when a taker order is executed.
|
|
1068
|
-
*/
|
|
1069
283
|
export interface FilledTakerOrderEvent extends Event {
|
|
1070
284
|
accountId: PerpetualsAccountId;
|
|
1071
|
-
collateralDeltaUsd:
|
|
285
|
+
collateralDeltaUsd: IFixed;
|
|
1072
286
|
marketId: PerpetualsMarketId;
|
|
287
|
+
baseAssetAmount: IFixed;
|
|
288
|
+
quoteAssetNotionalAmount: IFixed;
|
|
1073
289
|
side: PerpetualsOrderSide;
|
|
1074
|
-
baseAssetDelta:
|
|
1075
|
-
quoteAssetDelta:
|
|
1076
|
-
|
|
1077
|
-
takerFeesUsd: number;
|
|
290
|
+
baseAssetDelta: IFixed;
|
|
291
|
+
quoteAssetDelta: IFixed;
|
|
292
|
+
liquidatedVolume: IFixed;
|
|
1078
293
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
*/
|
|
1082
|
-
export type PerpetualsOrderEvent = CanceledOrderEvent | PostedOrderEvent | PostedOrderEvent | FilledMakerOrdersEvent | FilledTakerOrderEvent | LiquidatedEvent | ReducedOrderEvent;
|
|
1083
|
-
/**
|
|
1084
|
-
* Event emitted when an order is posted.
|
|
1085
|
-
*
|
|
1086
|
-
* NOTE: This is a second definition of `PostedOrderEvent` used in a
|
|
1087
|
-
* simplified context (without `reduceOnly` / `expiryTimestamp`).
|
|
1088
|
-
*/
|
|
1089
|
-
export interface PostedOrderEvent extends Event {
|
|
294
|
+
export type PerpetualsOrderEvent = CanceledOrderEvent | PostedOrderReceiptEvent | FilledMakerOrderEvent | FilledTakerOrderEvent | LiquidatedEvent | ReducedOrderEvent;
|
|
295
|
+
export interface PostedOrderReceiptEvent extends Event {
|
|
1090
296
|
accountId: PerpetualsAccountId;
|
|
1091
297
|
marketId: PerpetualsMarketId;
|
|
1092
298
|
orderId: PerpetualsOrderId;
|
|
1093
299
|
size: bigint;
|
|
1094
300
|
side: PerpetualsOrderSide;
|
|
1095
301
|
}
|
|
1096
|
-
/**
|
|
1097
|
-
* Event emitted when an existing order is reduced (partial cancellation or
|
|
1098
|
-
* adjustment of size).
|
|
1099
|
-
*/
|
|
1100
302
|
export interface ReducedOrderEvent extends Event {
|
|
1101
303
|
marketId: PerpetualsMarketId;
|
|
1102
304
|
accountId: PerpetualsAccountId;
|
|
1103
305
|
sizeChange: bigint;
|
|
1104
306
|
orderId: PerpetualsOrderId;
|
|
1105
307
|
}
|
|
1106
|
-
/**
|
|
1107
|
-
* Type guard for {@link CanceledOrderEvent}.
|
|
1108
|
-
*/
|
|
1109
308
|
export declare const isCanceledOrderEvent: (event: Event) => event is CanceledOrderEvent;
|
|
1110
|
-
/**
|
|
1111
|
-
* Type guard for {@link PostedOrderEvent}.
|
|
1112
|
-
*/
|
|
1113
309
|
export declare const isPostedOrderEvent: (event: Event) => event is PostedOrderEvent;
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
*/
|
|
1117
|
-
export declare const isFilledMakerOrdersEvent: (event: Event) => event is FilledMakerOrdersEvent;
|
|
1118
|
-
/**
|
|
1119
|
-
* Type guard for {@link FilledTakerOrderEvent}.
|
|
1120
|
-
*/
|
|
310
|
+
export declare const isPostedOrderReceiptEvent: (event: Event) => event is PostedOrderReceiptEvent;
|
|
311
|
+
export declare const isFilledMakerOrderEvent: (event: Event) => event is FilledMakerOrderEvent;
|
|
1121
312
|
export declare const isFilledTakerOrderEvent: (event: Event) => event is FilledTakerOrderEvent;
|
|
1122
|
-
/**
|
|
1123
|
-
* Type guard for {@link ReducedOrderEvent}.
|
|
1124
|
-
*/
|
|
1125
313
|
export declare const isReducedOrderEvent: (event: Event) => event is ReducedOrderEvent;
|
|
1126
|
-
/**
|
|
1127
|
-
* Event emitted when a stop order ticket is created.
|
|
1128
|
-
*
|
|
1129
|
-
* Stop order tickets represent off-chain-executable stop orders that
|
|
1130
|
-
* executors can trigger.
|
|
1131
|
-
*/
|
|
1132
|
-
export interface CreatedStopOrderTicketEvent extends Event {
|
|
1133
|
-
ticketId: ObjectId;
|
|
1134
|
-
accountId: PerpetualsAccountId;
|
|
1135
|
-
subAccountId?: ObjectId;
|
|
1136
|
-
executors: SuiAddress[];
|
|
1137
|
-
gas: Balance;
|
|
1138
|
-
stopOrderType: PerpetualsStopOrderType;
|
|
1139
|
-
/** Encrypted stop-order details (payload). */
|
|
1140
|
-
encryptedDetails: Byte[];
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Event emitted when a stop order ticket is executed.
|
|
1144
|
-
*/
|
|
1145
|
-
export interface ExecutedStopOrderTicketEvent extends Event {
|
|
1146
|
-
ticketId: ObjectId;
|
|
1147
|
-
accountId: PerpetualsAccountId;
|
|
1148
|
-
executor: SuiAddress;
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* Event emitted when a stop order ticket is deleted or canceled.
|
|
1152
|
-
*/
|
|
1153
|
-
export interface DeletedStopOrderTicketEvent extends Event {
|
|
1154
|
-
ticketId: ObjectId;
|
|
1155
|
-
accountId: PerpetualsAccountId;
|
|
1156
|
-
subAccountId?: ObjectId;
|
|
1157
|
-
executor: SuiAddress;
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* Event emitted when the details (payload) of a stop order ticket are edited.
|
|
1161
|
-
*/
|
|
1162
|
-
export interface EditedStopOrderTicketDetailsEvent extends Event {
|
|
1163
|
-
ticketId: ObjectId;
|
|
1164
|
-
accountId: PerpetualsAccountId;
|
|
1165
|
-
subAccountId?: ObjectId;
|
|
1166
|
-
encryptedDetails: Byte[];
|
|
1167
|
-
stopOrderType: PerpetualsStopOrderType;
|
|
1168
|
-
}
|
|
1169
|
-
/**
|
|
1170
|
-
* Event emitted when the set of executors for a stop order ticket is edited.
|
|
1171
|
-
*/
|
|
1172
|
-
export interface EditedStopOrderTicketExecutorEvent extends Event {
|
|
1173
|
-
ticketId: ObjectId;
|
|
1174
|
-
accountId: PerpetualsAccountId;
|
|
1175
|
-
subAccountId?: ObjectId;
|
|
1176
|
-
executors: SuiAddress[];
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Event emitted when deallocated collateral is transferred from a clearing
|
|
1180
|
-
* house to an account or subaccount.
|
|
1181
|
-
*/
|
|
1182
|
-
export interface TransferredDeallocatedCollateralEvent extends Event {
|
|
1183
|
-
chId: ObjectId;
|
|
1184
|
-
/** Account or SubAccount object id. */
|
|
1185
|
-
objectId: ObjectId;
|
|
1186
|
-
accountId: PerpetualsAccountId;
|
|
1187
|
-
collateral: Balance;
|
|
1188
|
-
}
|
|
1189
|
-
/**
|
|
1190
|
-
* Event emitted when an account or subaccount receives collateral.
|
|
1191
|
-
*/
|
|
1192
|
-
export interface ReceivedCollateralEvent extends Event {
|
|
1193
|
-
/** Account or SubAccount object id. */
|
|
1194
|
-
objectId: ObjectId;
|
|
1195
|
-
accountId: PerpetualsAccountId;
|
|
1196
|
-
collateral: Balance;
|
|
1197
|
-
}
|
|
1198
|
-
/**
|
|
1199
|
-
* Event emitted when premium TWAP is updated for a market.
|
|
1200
|
-
*/
|
|
1201
314
|
export interface UpdatedPremiumTwapEvent extends Event {
|
|
1202
315
|
marketId: PerpetualsMarketId;
|
|
1203
|
-
bookPrice:
|
|
1204
|
-
indexPrice:
|
|
1205
|
-
premiumTwap:
|
|
316
|
+
bookPrice: IFixed;
|
|
317
|
+
indexPrice: IFixed;
|
|
318
|
+
premiumTwap: IFixed;
|
|
1206
319
|
premiumTwapLastUpdateMs: number;
|
|
1207
320
|
}
|
|
1208
|
-
/**
|
|
1209
|
-
* Event emitted when spread TWAP is updated for a market.
|
|
1210
|
-
*/
|
|
1211
321
|
export interface UpdatedSpreadTwapEvent extends Event {
|
|
1212
322
|
marketId: PerpetualsMarketId;
|
|
1213
|
-
bookPrice:
|
|
1214
|
-
indexPrice:
|
|
1215
|
-
spreadTwap:
|
|
323
|
+
bookPrice: IFixed;
|
|
324
|
+
indexPrice: IFixed;
|
|
325
|
+
spreadTwap: IFixed;
|
|
1216
326
|
spreadTwapLastUpdateMs: number;
|
|
1217
327
|
}
|
|
1218
|
-
/**
|
|
1219
|
-
* Union of all TWAP-related events.
|
|
1220
|
-
*/
|
|
1221
328
|
export type PerpetualsTwapEvent = UpdatedPremiumTwapEvent | UpdatedSpreadTwapEvent;
|
|
1222
|
-
/**
|
|
1223
|
-
* Type guard for {@link UpdatedPremiumTwapEvent}.
|
|
1224
|
-
*/
|
|
1225
329
|
export declare const isUpdatedPremiumTwapEvent: (event: Event) => event is UpdatedPremiumTwapEvent;
|
|
1226
|
-
/**
|
|
1227
|
-
* Type guard for {@link UpdatedSpreadTwapEvent}.
|
|
1228
|
-
*/
|
|
1229
330
|
export declare const isUpdatedSpreadTwapEvent: (event: Event) => event is UpdatedSpreadTwapEvent;
|
|
1230
|
-
/**
|
|
1231
|
-
* Event emitted when market funding values are updated.
|
|
1232
|
-
*/
|
|
1233
331
|
export interface UpdatedFundingEvent extends Event {
|
|
1234
332
|
marketId: PerpetualsMarketId;
|
|
1235
|
-
cumFundingRateLong:
|
|
1236
|
-
cumFundingRateShort:
|
|
333
|
+
cumFundingRateLong: IFixed;
|
|
334
|
+
cumFundingRateShort: IFixed;
|
|
1237
335
|
fundingLastUpdateMs: Timestamp;
|
|
1238
336
|
}
|
|
1239
|
-
/**
|
|
1240
|
-
* Type guard for {@link UpdatedFundingEvent}.
|
|
1241
|
-
*/
|
|
1242
337
|
export declare const isUpdatedFundingEvent: (event: Event) => event is UpdatedFundingEvent;
|
|
1243
|
-
|
|
1244
|
-
* Request body for fetching all account caps owned by a given wallet.
|
|
1245
|
-
*/
|
|
1246
|
-
export interface ApiPerpetualsOwnedAccountCapsBody {
|
|
338
|
+
export interface ApiPerpetualsAccountsBody {
|
|
1247
339
|
walletAddress: SuiAddress;
|
|
1248
|
-
collateralCoinTypes?: CoinType[];
|
|
1249
|
-
}
|
|
1250
|
-
/**
|
|
1251
|
-
* Request body for fetching specific admin account caps by their account IDs.
|
|
1252
|
-
*/
|
|
1253
|
-
export interface ApiPerpetualsAdminAccountCapsBody {
|
|
1254
|
-
accountIds: PerpetualsAccountId[];
|
|
1255
|
-
}
|
|
1256
|
-
/**
|
|
1257
|
-
* Response payload for fetching positions for one or more accounts.
|
|
1258
|
-
*
|
|
1259
|
-
* The backend returns a list of {@link PerpetualsAccountObject} snapshots.
|
|
1260
|
-
* Each snapshot includes per-market {@link PerpetualsPosition} data.
|
|
1261
|
-
*/
|
|
1262
|
-
export interface ApiPerpetualsAccountPositionsResponse {
|
|
1263
|
-
accounts: PerpetualsAccountObject[];
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Request body for fetching positions for a set of accounts.
|
|
1267
|
-
*
|
|
1268
|
-
* `marketIds` can be supplied as an optimization hint to limit the markets
|
|
1269
|
-
* included in each account's returned `positions` array.
|
|
1270
|
-
*/
|
|
1271
|
-
export interface ApiPerpetualsAccountPositionsBody {
|
|
1272
|
-
accountIds: PerpetualsAccountId[];
|
|
1273
|
-
marketIds?: PerpetualsMarketId[];
|
|
1274
340
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
/**
|
|
1282
|
-
* Response payload for fetching all account caps owned by a wallet.
|
|
1283
|
-
*
|
|
1284
|
-
* This is typically used during onboarding / wallet connect to discover
|
|
1285
|
-
* existing accounts.
|
|
1286
|
-
*/
|
|
1287
|
-
export interface ApiPerpetualsOwnedAccountCapsResponse {
|
|
1288
|
-
accountCaps: PerpetualsAccountCap[];
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Generic shape for Perpetuals API historical data requests that include
|
|
1292
|
-
* `beforeTimestampCursor` and `limit` pagination parameters.
|
|
1293
|
-
*/
|
|
1294
|
-
export interface ApiPerpetualsHistoricalDataWithCursorBody {
|
|
1295
|
-
/**
|
|
1296
|
-
* Cursor for pagination.
|
|
1297
|
-
*/
|
|
1298
|
-
beforeTimestampCursor?: Timestamp;
|
|
1299
|
-
/**
|
|
1300
|
-
* Limit for pagination.
|
|
1301
|
-
*/
|
|
1302
|
-
limit?: number;
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Generic shape for Perpetuals API historical data responses that include
|
|
1306
|
-
* `nextBeforeTimestampCursor` pagination parameter.
|
|
1307
|
-
*/
|
|
1308
|
-
export interface ApiPerpetualsHistoricalDataWithCursorResponse {
|
|
1309
|
-
/**
|
|
1310
|
-
* The next cursor position. If undefined, no more data is available.
|
|
1311
|
-
*/
|
|
1312
|
-
nextBeforeTimestampCursor: Timestamp | undefined;
|
|
1313
|
-
}
|
|
1314
|
-
/**
|
|
1315
|
-
* Enumerates the timeframes available for retrieving historical account margin data,
|
|
1316
|
-
* such as `"1D"`, `"1W"`, `"1M"`, etc.
|
|
1317
|
-
*/
|
|
1318
|
-
export type PerpetualsAccountMarginHistoryTimeframeKey = "1D" | "1W" | "1M" | "ALL";
|
|
1319
|
-
/**
|
|
1320
|
-
* Request payload for fetching historical margin metrics for an account.
|
|
1321
|
-
*/
|
|
1322
|
-
export interface ApiPerpetualsAccountMarginHistoryBody {
|
|
1323
|
-
/**
|
|
1324
|
-
* Account ID.
|
|
1325
|
-
*/
|
|
1326
|
-
accountId: PerpetualsAccountId;
|
|
1327
|
-
/**
|
|
1328
|
-
* Timeframe from which to obtain historical data from.
|
|
1329
|
-
*/
|
|
1330
|
-
timeframe: PerpetualsAccountMarginHistoryTimeframeKey;
|
|
1331
|
-
}
|
|
1332
|
-
/**
|
|
1333
|
-
* Response payload for historical margin metrics.
|
|
1334
|
-
*
|
|
1335
|
-
* The returned array is ordered chronologically by `timestamp` (oldest -> newest)
|
|
1336
|
-
* unless the backend specifies otherwise.
|
|
1337
|
-
*/
|
|
1338
|
-
export interface ApiPerpetualsAccountMarginHistoryResponse {
|
|
1339
|
-
marginHistoryDatas: PerpetualsAccountMarginHistoryData[];
|
|
341
|
+
export type ApiPerpetualsAccountOrderHistoryBody = ApiDataWithCursorBody<Timestamp>;
|
|
342
|
+
export type ApiPerpetualsAccountCollateralHistoryBody = ApiDataWithCursorBody<Timestamp>;
|
|
343
|
+
export interface ApiPerpetualsSetPositionLeverageBody {
|
|
344
|
+
walletAddress: SuiAddress;
|
|
345
|
+
bytes: string;
|
|
346
|
+
signature: string;
|
|
1340
347
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
*/
|
|
1344
|
-
export type ApiPerpetualsMarketOrderHistoryBody = ApiPerpetualsHistoricalDataWithCursorBody & {
|
|
1345
|
-
marketId: PerpetualsMarketId;
|
|
1346
|
-
};
|
|
1347
|
-
/**
|
|
1348
|
-
* Request body for fetching account-level order history with a cursor.
|
|
1349
|
-
*/
|
|
1350
|
-
export type ApiPerpetualsAccountOrderHistoryBody = ApiPerpetualsHistoricalDataWithCursorBody & {
|
|
348
|
+
export type ApiPerpetualsPreviewOrderBody = (Omit<ApiPerpetualsLimitOrderBody, "collateralChange" | "walletAddress" | "accountObjectId" | "accountObjectVersion" | "accountObjectDigest"> | Omit<ApiPerpetualsMarketOrderBody, "collateralChange" | "walletAddress" | "accountObjectId" | "accountObjectVersion" | "accountObjectDigest"> | Omit<ApiPerpetualsSLTPOrderBody, "collateralChange" | "walletAddress" | "accountObjectId" | "accountObjectVersion" | "accountObjectDigest">) & {
|
|
349
|
+
collateralCoinType: CoinType;
|
|
1351
350
|
accountId: PerpetualsAccountId;
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
signature: string;
|
|
1356
|
-
};
|
|
351
|
+
lotSize: number;
|
|
352
|
+
tickSize: number;
|
|
353
|
+
leverage: number;
|
|
1357
354
|
};
|
|
1358
|
-
|
|
1359
|
-
* Request body for fetching account collateral history with a cursor.
|
|
1360
|
-
*/
|
|
1361
|
-
export type ApiPerpetualsAccountCollateralHistoryBody = ApiPerpetualsHistoricalDataWithCursorBody & {
|
|
355
|
+
export interface ApiPerpetualsPreviewCancelOrdersBody {
|
|
1362
356
|
accountId: PerpetualsAccountId;
|
|
1363
|
-
|
|
1364
|
-
walletAddress: SuiAddress;
|
|
1365
|
-
bytes: string;
|
|
1366
|
-
signature: string;
|
|
1367
|
-
};
|
|
1368
|
-
};
|
|
1369
|
-
/**
|
|
1370
|
-
* Request body for previewing a market order placement (before sending a tx).
|
|
1371
|
-
*
|
|
1372
|
-
* This version is used by the API and includes account or vault context.
|
|
1373
|
-
*/
|
|
1374
|
-
export type ApiPerpetualsPreviewPlaceMarketOrderBody = Omit<ApiPerpetualsMarketOrderBody, "collateralChange" | "walletAddress" | "hasPosition" | "cancelSlTp" | "txKind" | "accountId" | "slTp" | "slippage"> & {
|
|
1375
|
-
/** Optional leverage override for the preview. */
|
|
1376
|
-
leverage?: number;
|
|
1377
|
-
} & ({
|
|
1378
|
-
accountId: PerpetualsAccountId | undefined;
|
|
1379
|
-
} | {
|
|
1380
|
-
vaultId: ObjectId | undefined;
|
|
1381
|
-
});
|
|
1382
|
-
/**
|
|
1383
|
-
* Request body for previewing a limit order placement (before sending a tx).
|
|
1384
|
-
*
|
|
1385
|
-
* This version is used by the API and includes account or vault context.
|
|
1386
|
-
*/
|
|
1387
|
-
export type ApiPerpetualsPreviewPlaceLimitOrderBody = Omit<ApiPerpetualsLimitOrderBody, "collateralChange" | "walletAddress" | "hasPosition" | "cancelSlTp" | "txKind" | "accountId" | "slTp"> & {
|
|
1388
|
-
/** Optional leverage override for the preview. */
|
|
1389
|
-
leverage?: number;
|
|
1390
|
-
} & ({
|
|
1391
|
-
accountId: PerpetualsAccountId | undefined;
|
|
1392
|
-
} | {
|
|
1393
|
-
vaultId: ObjectId | undefined;
|
|
1394
|
-
});
|
|
1395
|
-
/**
|
|
1396
|
-
* Request body for previewing cancel-order operations.
|
|
1397
|
-
*/
|
|
1398
|
-
export type ApiPerpetualsPreviewCancelOrdersBody = {
|
|
1399
|
-
/** Per-market mapping of order IDs to cancel. */
|
|
357
|
+
collateralCoinType: CoinType;
|
|
1400
358
|
marketIdsToData: Record<PerpetualsMarketId, {
|
|
1401
359
|
orderIds: PerpetualsOrderId[];
|
|
360
|
+
leverage: number;
|
|
1402
361
|
}>;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
accountCapId?: ObjectId;
|
|
1406
|
-
} | {
|
|
1407
|
-
vaultId: ObjectId;
|
|
1408
|
-
});
|
|
1409
|
-
/**
|
|
1410
|
-
* Request body for previewing a leverage change for a given position.
|
|
1411
|
-
*/
|
|
1412
|
-
export type ApiPerpetualsPreviewSetLeverageBody = {
|
|
1413
|
-
marketId: PerpetualsMarketId;
|
|
1414
|
-
leverage: number;
|
|
1415
|
-
} & ({
|
|
1416
|
-
accountId: PerpetualsAccountId;
|
|
1417
|
-
accountCapId?: ObjectId;
|
|
1418
|
-
} | {
|
|
1419
|
-
vaultId: ObjectId;
|
|
1420
|
-
});
|
|
1421
|
-
/**
|
|
1422
|
-
* Request body for previewing a collateral allocation/deallocation for a given position.
|
|
1423
|
-
*/
|
|
1424
|
-
export type ApiPerpetualsPreviewEditCollateralBody = {
|
|
362
|
+
}
|
|
363
|
+
export interface ApiPerpetualsPreviewReduceOrdersBody {
|
|
1425
364
|
marketId: PerpetualsMarketId;
|
|
1426
|
-
collateralChange: Balance;
|
|
1427
|
-
} & ({
|
|
1428
365
|
accountId: PerpetualsAccountId;
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
*
|
|
1436
|
-
* Either returns an error, or the position and collateral after the change.
|
|
1437
|
-
*/
|
|
1438
|
-
export type ApiPerpetualsPreviewSetLeverageResponse = {
|
|
1439
|
-
error: string;
|
|
1440
|
-
} | {
|
|
1441
|
-
updatedPosition: PerpetualsPosition;
|
|
1442
|
-
collateralChange: number;
|
|
1443
|
-
};
|
|
1444
|
-
/**
|
|
1445
|
-
* Response type for a allocate/deallocate collateral preview request.
|
|
1446
|
-
*
|
|
1447
|
-
* Either returns an error, or the position and collateral after the change.
|
|
1448
|
-
*/
|
|
1449
|
-
export type ApiPerpetualsPreviewEditCollateralResponse = {
|
|
366
|
+
leverage: number;
|
|
367
|
+
orderIds: PerpetualsOrderId[];
|
|
368
|
+
sizesToSubtract: bigint[];
|
|
369
|
+
collateralCoinType: CoinType;
|
|
370
|
+
}
|
|
371
|
+
export type ApiPerpetualsPreviewReduceOrdersResponse = {
|
|
1450
372
|
error: string;
|
|
1451
373
|
} | {
|
|
1452
|
-
|
|
374
|
+
positionAfterReduceOrders: PerpetualsPosition;
|
|
1453
375
|
collateralChange: number;
|
|
1454
376
|
};
|
|
1455
|
-
|
|
1456
|
-
* Generic response type for a place-order preview (market or limit).
|
|
1457
|
-
*/
|
|
1458
|
-
export type ApiPerpetualsPreviewPlaceOrderResponse = {
|
|
377
|
+
export type ApiPerpetualsPreviewOrderResponse = {
|
|
1459
378
|
error: string;
|
|
1460
379
|
} | {
|
|
1461
|
-
|
|
1462
|
-
updatedPosition: PerpetualsPosition;
|
|
1463
|
-
/** Absolute price slippage between reference price and execution price. */
|
|
380
|
+
positionAfterOrder: PerpetualsPosition;
|
|
1464
381
|
priceSlippage: number;
|
|
1465
|
-
|
|
1466
|
-
* (e.g. `0.01` == 1% slippage). */
|
|
1467
|
-
percentSlippage: number;
|
|
1468
|
-
/** Size that is expected to be filled immediately (in base units). */
|
|
382
|
+
percentSlippage: Percentage;
|
|
1469
383
|
filledSize: number;
|
|
1470
|
-
/** Notional value in USD of the `filledSize`. */
|
|
1471
384
|
filledSizeUsd: number;
|
|
1472
|
-
/** Any size that remains posted as liquidity (for market orders this is
|
|
1473
|
-
* usually zero unless partially resting is supported). */
|
|
1474
385
|
postedSize: number;
|
|
1475
|
-
/** Notional value in USD of the `postedSize`. For pure market orders this
|
|
1476
|
-
* is typically `0`. */
|
|
1477
386
|
postedSizeUsd: number;
|
|
1478
|
-
/** Net collateral change in USD (e.g. fees, margin changes). */
|
|
1479
387
|
collateralChange: number;
|
|
1480
|
-
/** Effective execution price for the filled portion of the order. */
|
|
1481
388
|
executionPrice: number;
|
|
1482
|
-
/** Whether there is an existing position in this market. */
|
|
1483
|
-
hasPosition: boolean;
|
|
1484
|
-
/** True is position is closed. */
|
|
1485
|
-
cancelSlTp: boolean;
|
|
1486
389
|
};
|
|
1487
|
-
/**
|
|
1488
|
-
* Response type for cancel-order preview.
|
|
1489
|
-
*/
|
|
1490
390
|
export type ApiPerpetualsPreviewCancelOrdersResponse = {
|
|
1491
391
|
error: string;
|
|
1492
392
|
} | {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
collateralChange: number;
|
|
1496
|
-
}>;
|
|
393
|
+
marketIdsToPositionAfterCancelOrders: Record<PerpetualsMarketId, PerpetualsPosition>;
|
|
394
|
+
collateralChange: number;
|
|
1497
395
|
};
|
|
1498
|
-
/**
|
|
1499
|
-
* Request body for computing an execution price for a hypothetical trade
|
|
1500
|
-
* using the current orderbook state and oracle prices.
|
|
1501
|
-
*/
|
|
1502
396
|
export interface ApiPerpetualsExecutionPriceBody {
|
|
1503
397
|
side: PerpetualsOrderSide;
|
|
1504
398
|
size: bigint;
|
|
1505
|
-
/** Lot size used to discretize the order size. */
|
|
1506
399
|
lotSize: number;
|
|
1507
|
-
/** Available collateral. */
|
|
1508
400
|
collateral: Balance;
|
|
1509
|
-
/** Oracle ID for the base price. */
|
|
1510
401
|
basePriceFeedId: ObjectId;
|
|
1511
|
-
/** Oracle ID for the collateral price. */
|
|
1512
402
|
collateralPriceFeedId: ObjectId;
|
|
1513
|
-
|
|
1514
|
-
price?: number;
|
|
403
|
+
price?: PerpetualsOrderPrice;
|
|
1515
404
|
}
|
|
1516
|
-
/**
|
|
1517
|
-
* Response body for execution price previews.
|
|
1518
|
-
*/
|
|
1519
405
|
export interface ApiPerpetualsExecutionPriceResponse {
|
|
1520
406
|
executionPrice: number;
|
|
1521
407
|
sizeFilled: number;
|
|
1522
408
|
sizePosted: number;
|
|
1523
409
|
fills: PerpetualsFilledOrderData[];
|
|
1524
410
|
}
|
|
1525
|
-
|
|
1526
|
-
* Request payload for fetching historical candle (OHLCV) data for a given
|
|
1527
|
-
* perpetuals market.
|
|
1528
|
-
*/
|
|
1529
|
-
export interface ApiPerpetualsMarketCandleHistoryBody {
|
|
1530
|
-
/**
|
|
1531
|
-
* Identifier of the perpetuals market whose candles you want to fetch.
|
|
1532
|
-
*
|
|
1533
|
-
* Must be a valid on-chain market ID.
|
|
1534
|
-
*/
|
|
1535
|
-
marketId: PerpetualsMarketId;
|
|
1536
|
-
/**
|
|
1537
|
-
* Start of the time range to query, as a Unix timestamp in **milliseconds**.
|
|
1538
|
-
*/
|
|
1539
|
-
fromTimestamp: Timestamp;
|
|
1540
|
-
/**
|
|
1541
|
-
* End of the time range to query, as a Unix timestamp in **milliseconds**.
|
|
1542
|
-
*/
|
|
1543
|
-
toTimestamp: Timestamp;
|
|
1544
|
-
/**
|
|
1545
|
-
* Candle interval / resolution in **milliseconds** (e.g. 60_000 for 1m,
|
|
1546
|
-
* 300_000 for 5m).
|
|
1547
|
-
*/
|
|
1548
|
-
intervalMs: number;
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Response type for historical market candle data.
|
|
1552
|
-
*/
|
|
1553
|
-
export interface ApiPerpetualsMarketCandleHistoryResponse {
|
|
1554
|
-
candles: PerpetualsMarketCandleDataPoint[];
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* Request body for computing the maximum order size for an account in a
|
|
1558
|
-
* given market.
|
|
1559
|
-
*/
|
|
411
|
+
export type ApiPerpetualsHistoricalMarketDataResponse = PerpetualsMarketCandleDataPoint[];
|
|
1560
412
|
export interface ApiPerpetualsMaxOrderSizeBody {
|
|
1561
|
-
marketId: PerpetualsMarketId;
|
|
1562
413
|
accountId: PerpetualsAccountId;
|
|
414
|
+
collateral: Balance;
|
|
1563
415
|
side: PerpetualsOrderSide;
|
|
1564
|
-
leverage
|
|
1565
|
-
price?:
|
|
1566
|
-
/**
|
|
1567
|
-
* Optional integrator fee configuration for an order.
|
|
1568
|
-
*
|
|
1569
|
-
* If provided, the integrator specified in the configuration will receive a fee
|
|
1570
|
-
* on the taker volume generated by this order. The integrator must have been
|
|
1571
|
-
* previously approved by the account owner, and the fee must not exceed the
|
|
1572
|
-
* maximum fee the user approved for that integrator.
|
|
1573
|
-
*/
|
|
1574
|
-
builderCode?: PerpetualsBuilderCodeParamaters;
|
|
416
|
+
leverage: number;
|
|
417
|
+
price?: PerpetualsOrderPrice;
|
|
1575
418
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
walletAddress: SuiAddress;
|
|
1582
|
-
bytes: string;
|
|
1583
|
-
signature: string;
|
|
1584
|
-
marketIds?: PerpetualsMarketId[];
|
|
1585
|
-
} & ({
|
|
1586
|
-
accountId: PerpetualsAccountId;
|
|
1587
|
-
accountCapId?: ObjectId;
|
|
1588
|
-
} | {
|
|
1589
|
-
vaultId: ObjectId;
|
|
1590
|
-
});
|
|
1591
|
-
/**
|
|
1592
|
-
* Response payload for stop-order queries.
|
|
1593
|
-
*
|
|
1594
|
-
* Stop orders are returned in their normalized on-chain shape
|
|
1595
|
-
* ({@link PerpetualsStopOrderData}). Clients should interpret `slTp` vs `nonSlTp`
|
|
1596
|
-
* to determine the stop semantics.
|
|
1597
|
-
*/
|
|
1598
|
-
export interface ApiPerpetualsStopOrderDatasResponse {
|
|
1599
|
-
stopOrderDatas: PerpetualsStopOrderData[];
|
|
419
|
+
export interface ApiPerpetualsAccountOrderDatasBody {
|
|
420
|
+
orderDatas: {
|
|
421
|
+
orderId: PerpetualsOrderId;
|
|
422
|
+
currentSize: bigint;
|
|
423
|
+
}[];
|
|
1600
424
|
}
|
|
1601
|
-
|
|
1602
|
-
* Request body for creating a vault capability (vault cap) for a given wallet.
|
|
1603
|
-
*/
|
|
1604
|
-
export interface ApiPerpetualsCreateVaultCapBody {
|
|
425
|
+
export interface ApiPerpetualsCreateAccountBody {
|
|
1605
426
|
walletAddress: SuiAddress;
|
|
1606
|
-
|
|
1607
|
-
/** Name for the token */
|
|
1608
|
-
name: string;
|
|
1609
|
-
/** Symbol for the token */
|
|
1610
|
-
symbol: string;
|
|
1611
|
-
/** Description of the token */
|
|
1612
|
-
description: string;
|
|
1613
|
-
/** URL for the token logo */
|
|
1614
|
-
iconUrl?: string;
|
|
1615
|
-
};
|
|
427
|
+
collateralCoinType: CoinType;
|
|
1616
428
|
}
|
|
1617
|
-
|
|
1618
|
-
* Request body for creating a new vault with initial deposit.
|
|
1619
|
-
*
|
|
1620
|
-
* The deposit can be specified either:
|
|
1621
|
-
* - As a numeric `initialDepositAmount`, or
|
|
1622
|
-
* - As an existing `depositCoinArg` (coin object).
|
|
1623
|
-
*/
|
|
1624
|
-
export type ApiPerpetualsCreateVaultBody = {
|
|
429
|
+
export interface ApiPerpetualsDepositCollateralBody {
|
|
1625
430
|
walletAddress: SuiAddress;
|
|
1626
|
-
metadata: {
|
|
1627
|
-
/**
|
|
1628
|
-
* A human-readable name for the `Vault`.
|
|
1629
|
-
*/
|
|
1630
|
-
name: string;
|
|
1631
|
-
/**
|
|
1632
|
-
* A verbose description of the `Vault`.
|
|
1633
|
-
*/
|
|
1634
|
-
description: string;
|
|
1635
|
-
/**
|
|
1636
|
-
* The `Vault` curator's name.
|
|
1637
|
-
*/
|
|
1638
|
-
curatorName?: string;
|
|
1639
|
-
/**
|
|
1640
|
-
* A url for the `Vault`'s curator. Ideally their website.
|
|
1641
|
-
*/
|
|
1642
|
-
curatorUrl?: string;
|
|
1643
|
-
/**
|
|
1644
|
-
* An image url for the `Vault`'s curator. Ideally their logo.
|
|
1645
|
-
*/
|
|
1646
|
-
curatorLogoUrl?: string;
|
|
1647
|
-
/**
|
|
1648
|
-
* Extra / optional fields for future extensibility. Recommended keys include: twitter_url.
|
|
1649
|
-
*/
|
|
1650
|
-
extraFields?: Record<string, string>;
|
|
1651
|
-
};
|
|
1652
|
-
coinMetadataId: ObjectId;
|
|
1653
|
-
treasuryCapId: ObjectId;
|
|
1654
431
|
collateralCoinType: CoinType;
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
forceWithdrawDelayMs: bigint;
|
|
1658
|
-
txKind?: SerializedTransaction;
|
|
432
|
+
accountCapId: ObjectId;
|
|
433
|
+
amount: Balance;
|
|
1659
434
|
isSponsoredTx?: boolean;
|
|
1660
|
-
} & ({
|
|
1661
|
-
initialDepositAmount: Balance;
|
|
1662
|
-
} | {
|
|
1663
|
-
initialDepositCoinArg: TransactionObjectArgument;
|
|
1664
|
-
});
|
|
1665
|
-
/**
|
|
1666
|
-
* Request payload for creating an integrator configuration approval transaction.
|
|
1667
|
-
*
|
|
1668
|
-
* This transaction allows a user to approve an integrator to receive fees on orders
|
|
1669
|
-
* placed on their behalf. The user sets a maximum taker fee that the integrator
|
|
1670
|
-
* can charge per order.
|
|
1671
|
-
*/
|
|
1672
|
-
export interface ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody {
|
|
1673
|
-
/**
|
|
1674
|
-
* Account ID encoded as a bigint.
|
|
1675
|
-
*
|
|
1676
|
-
* This is the perpetuals account that is granting permission to the integrator.
|
|
1677
|
-
*/
|
|
1678
|
-
accountId: PerpetualsAccountId;
|
|
1679
|
-
/**
|
|
1680
|
-
* Sui address of the integrator being approved.
|
|
1681
|
-
*
|
|
1682
|
-
* Must be a valid Sui object ID.
|
|
1683
|
-
*/
|
|
1684
|
-
integratorAddress: SuiAddress;
|
|
1685
|
-
/**
|
|
1686
|
-
* Maximum taker fee (as a decimal) that the integrator can charge per order.
|
|
1687
|
-
*
|
|
1688
|
-
* For example, 0.001 represents a 0.1% maximum fee. The integrator can set
|
|
1689
|
-
* any fee up to this maximum when placing orders on behalf of the user.
|
|
1690
|
-
*/
|
|
1691
|
-
maxTakerFee: Percentage;
|
|
1692
|
-
/**
|
|
1693
|
-
* Optional existing transaction kind (base64-encoded) to extend.
|
|
1694
|
-
*
|
|
1695
|
-
* If provided, the new integrator approval will be added to this transaction.
|
|
1696
|
-
*/
|
|
1697
|
-
txKind?: SerializedTransaction;
|
|
1698
|
-
}
|
|
1699
|
-
/**
|
|
1700
|
-
* Request payload for creating a transaction to revoke an integrator's permissions.
|
|
1701
|
-
*
|
|
1702
|
-
* This transaction removes an integrator's approval to collect fees on orders
|
|
1703
|
-
* placed on behalf of the user. After revocation, the integrator will no longer
|
|
1704
|
-
* be able to submit orders with fees for this account.
|
|
1705
|
-
*/
|
|
1706
|
-
export interface ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody {
|
|
1707
|
-
/**
|
|
1708
|
-
* Account ID encoded as a bigint.
|
|
1709
|
-
*
|
|
1710
|
-
* This is the perpetuals account that is revoking the integrator's permission.
|
|
1711
|
-
*/
|
|
1712
|
-
accountId: PerpetualsAccountId;
|
|
1713
|
-
/**
|
|
1714
|
-
* Sui address of the integrator whose permissions are being revoked.
|
|
1715
|
-
*
|
|
1716
|
-
* Must be a valid Sui object ID.
|
|
1717
|
-
*/
|
|
1718
|
-
integratorAddress: SuiAddress;
|
|
1719
|
-
/**
|
|
1720
|
-
* Optional existing transaction kind (base64-encoded) to extend.
|
|
1721
|
-
*
|
|
1722
|
-
* If provided, the integrator removal will be added to this transaction.
|
|
1723
|
-
*/
|
|
1724
|
-
txKind?: SerializedTransaction;
|
|
1725
|
-
}
|
|
1726
|
-
/**
|
|
1727
|
-
* Request payload for creating a transaction to initialize an integrator fee vault.
|
|
1728
|
-
*
|
|
1729
|
-
* Before an integrator can claim fees from a specific market, they must first create
|
|
1730
|
-
* a vault for that market. This is a one-time setup per integrator per market.
|
|
1731
|
-
*/
|
|
1732
|
-
export interface ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody {
|
|
1733
|
-
/**
|
|
1734
|
-
* Market (clearing house) ID where the integrator vault will be created.
|
|
1735
|
-
*
|
|
1736
|
-
* Must be a valid Sui object ID.
|
|
1737
|
-
*/
|
|
1738
|
-
marketId: PerpetualsMarketId;
|
|
1739
|
-
/**
|
|
1740
|
-
* Sui address of the integrator creating the vault.
|
|
1741
|
-
*
|
|
1742
|
-
* Must be a valid Sui object ID.
|
|
1743
|
-
* This integrator will be able to claim fees from this vault.
|
|
1744
|
-
*/
|
|
1745
|
-
integratorAddress: SuiAddress;
|
|
1746
|
-
/**
|
|
1747
|
-
* Optional existing transaction kind (base64-encoded) to extend.
|
|
1748
|
-
*
|
|
1749
|
-
* If provided, the vault creation will be added to this transaction.
|
|
1750
|
-
*/
|
|
1751
|
-
txKind?: SerializedTransaction;
|
|
1752
435
|
}
|
|
1753
|
-
|
|
1754
|
-
* Request payload for creating a transaction to claim accumulated integrator fees from a vault.
|
|
1755
|
-
*
|
|
1756
|
-
* Integrators earn fees on taker volume generated by orders they submit on behalf of users.
|
|
1757
|
-
* These fees accumulate in a vault per market (clearing house), and can be claimed at any time
|
|
1758
|
-
* by the integrator.
|
|
1759
|
-
*/
|
|
1760
|
-
export interface ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody {
|
|
1761
|
-
/**
|
|
1762
|
-
* Market (clearing house) ID where the integrator fees were earned.
|
|
1763
|
-
*
|
|
1764
|
-
* Must be a valid Sui object ID.
|
|
1765
|
-
*/
|
|
1766
|
-
marketId: PerpetualsMarketId;
|
|
1767
|
-
/**
|
|
1768
|
-
* Sui address of the integrator claiming their fees.
|
|
1769
|
-
*
|
|
1770
|
-
* Must be a valid Sui object ID.
|
|
1771
|
-
* Only the integrator who earned the fees can claim them.
|
|
1772
|
-
*/
|
|
1773
|
-
integratorAddress: SuiAddress;
|
|
1774
|
-
/**
|
|
1775
|
-
* Optional recipient address for the claimed fees.
|
|
1776
|
-
*
|
|
1777
|
-
* When provided, the transaction will include an on-chain transfer of the
|
|
1778
|
-
* claimed coin to this address. When omitted, the claimed coin is exposed
|
|
1779
|
-
* as a transaction argument that can be used in subsequent commands.
|
|
1780
|
-
*/
|
|
1781
|
-
recipientAddress?: SuiAddress;
|
|
1782
|
-
/**
|
|
1783
|
-
* Optional existing transaction kind (base64-encoded) to extend.
|
|
1784
|
-
*
|
|
1785
|
-
* If provided, the fee claim will be added to this transaction.
|
|
1786
|
-
*/
|
|
1787
|
-
txKind?: SerializedTransaction;
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Response payload for claim integrator vault fees transaction.
|
|
1791
|
-
*
|
|
1792
|
-
* Contains the transaction kind and optionally a coin output argument when
|
|
1793
|
-
* no recipient address was provided.
|
|
1794
|
-
*/
|
|
1795
|
-
export interface ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse {
|
|
1796
|
-
/**
|
|
1797
|
-
* Base64-encoded Sui `TransactionKind` representing the claim (and
|
|
1798
|
-
* optional transfer) transaction.
|
|
1799
|
-
*/
|
|
1800
|
-
txKind: SerializedTransaction;
|
|
1801
|
-
/**
|
|
1802
|
-
* When `recipientAddress` is omitted, this contains a readable argument
|
|
1803
|
-
* pointing to the claimed coin output, so callers can wire it into
|
|
1804
|
-
* subsequent steps.
|
|
1805
|
-
*/
|
|
1806
|
-
coinOutArg?: TransactionObjectArgument;
|
|
1807
|
-
}
|
|
1808
|
-
/**
|
|
1809
|
-
* Request payload for fetching integrator configuration for a specific account and integrator.
|
|
1810
|
-
*
|
|
1811
|
-
* This endpoint checks whether an integrator has been approved by an account to collect fees,
|
|
1812
|
-
* and if so, returns the maximum taker fee the integrator is authorized to charge.
|
|
1813
|
-
*/
|
|
1814
|
-
export interface ApiPerpetualsBuilderCodesIntegratorConfigBody {
|
|
1815
|
-
/**
|
|
1816
|
-
* Account ID encoded as a bigint.
|
|
1817
|
-
*
|
|
1818
|
-
* This is the perpetuals account whose integrator approval is being queried.
|
|
1819
|
-
*/
|
|
1820
|
-
accountId: PerpetualsAccountId;
|
|
1821
|
-
/**
|
|
1822
|
-
* Sui address of the integrator whose configuration is being queried.
|
|
1823
|
-
*
|
|
1824
|
-
* Must be a valid Sui object ID.
|
|
1825
|
-
*/
|
|
1826
|
-
integratorAddress: SuiAddress;
|
|
1827
|
-
}
|
|
1828
|
-
/**
|
|
1829
|
-
* Response payload containing integrator configuration details.
|
|
1830
|
-
*
|
|
1831
|
-
* Returns whether an integrator configuration exists and the maximum taker fee
|
|
1832
|
-
* if the integrator has been approved.
|
|
1833
|
-
*/
|
|
1834
|
-
export interface ApiPerpetualsBuilderCodesIntegratorConfigResponse {
|
|
1835
|
-
/**
|
|
1836
|
-
* Maximum taker fee (as a decimal) that the integrator is authorized to charge.
|
|
1837
|
-
*
|
|
1838
|
-
* For example, 0.001 represents a 0.1% maximum fee. This value is only meaningful
|
|
1839
|
-
* if `exists` is true.
|
|
1840
|
-
*/
|
|
1841
|
-
maxTakerFee: Percentage | undefined;
|
|
1842
|
-
/**
|
|
1843
|
-
* Whether an integrator configuration exists for this account-integrator pair.
|
|
1844
|
-
*
|
|
1845
|
-
* If false, the integrator has not been approved by the account and cannot
|
|
1846
|
-
* collect fees on orders placed on behalf of the account.
|
|
1847
|
-
*/
|
|
1848
|
-
exists: boolean;
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* Individual integrator vault data for a specific market.
|
|
1852
|
-
*
|
|
1853
|
-
* Contains the market ID and the accumulated fees available to claim from that market's vault.
|
|
1854
|
-
*/
|
|
1855
|
-
export interface PerpetualsIntegratorVaultData {
|
|
1856
|
-
/**
|
|
1857
|
-
* Market (clearing house) object ID.
|
|
1858
|
-
*/
|
|
1859
|
-
marketId: PerpetualsMarketId;
|
|
1860
|
-
/**
|
|
1861
|
-
* Total accumulated fees in the market's collateral currency that are available to claim.
|
|
1862
|
-
*
|
|
1863
|
-
* Fees are denominated in the collateral coin type used by the market.
|
|
1864
|
-
*/
|
|
1865
|
-
fees: number;
|
|
1866
|
-
}
|
|
1867
|
-
/**
|
|
1868
|
-
* Request payload for fetching integrator vault fees across multiple markets.
|
|
1869
|
-
*
|
|
1870
|
-
* This endpoint returns the accumulated fees an integrator has earned in their vaults
|
|
1871
|
-
* across one or more markets (clearing houses). These fees are generated from taker
|
|
1872
|
-
* volume on orders the integrator submitted on behalf of users.
|
|
1873
|
-
*/
|
|
1874
|
-
export interface ApiPerpetualsBuilderCodesIntegratorVaultsBody {
|
|
1875
|
-
/**
|
|
1876
|
-
* List of market (clearing house) IDs to query for integrator vault fees.
|
|
1877
|
-
*
|
|
1878
|
-
* Each market ID must be a valid Sui object ID.
|
|
1879
|
-
*/
|
|
1880
|
-
marketIds: PerpetualsMarketId[];
|
|
1881
|
-
/**
|
|
1882
|
-
* Sui address of the integrator whose vault fees are being queried.
|
|
1883
|
-
*
|
|
1884
|
-
* Must be a valid Sui object ID.
|
|
1885
|
-
*/
|
|
1886
|
-
integratorAddress: SuiAddress;
|
|
1887
|
-
}
|
|
1888
|
-
/**
|
|
1889
|
-
* Response payload containing accumulated fees per market for an integrator.
|
|
1890
|
-
*
|
|
1891
|
-
* Returns a vector of integrator vault data, one entry per market queried.
|
|
1892
|
-
* Markets where the integrator has no vault may be omitted or have zero fees.
|
|
1893
|
-
*/
|
|
1894
|
-
export interface ApiPerpetualsBuilderCodesIntegratorVaultsResponse {
|
|
1895
|
-
/**
|
|
1896
|
-
* Vector of integrator vault data containing market IDs and their accumulated fees.
|
|
1897
|
-
*
|
|
1898
|
-
* Each entry represents a market where the integrator has a vault and potentially
|
|
1899
|
-
* claimable fees. The order matches the order of market IDs in the request.
|
|
1900
|
-
*/
|
|
1901
|
-
integratorVaults: PerpetualsIntegratorVaultData[];
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* Request body for creating a new perpetuals account for a given wallet
|
|
1905
|
-
* and collateral coin type.
|
|
1906
|
-
*/
|
|
1907
|
-
export interface ApiPerpetualsCreateAccountBody {
|
|
436
|
+
export interface ApiPerpetualsWithdrawCollateralBody {
|
|
1908
437
|
walletAddress: SuiAddress;
|
|
1909
438
|
collateralCoinType: CoinType;
|
|
1910
|
-
|
|
439
|
+
accountCapId: ObjectId;
|
|
440
|
+
amount: Balance;
|
|
1911
441
|
}
|
|
1912
|
-
|
|
1913
|
-
* Request body for depositing collateral into a perpetuals account.
|
|
1914
|
-
*
|
|
1915
|
-
* The deposit can be provided by:
|
|
1916
|
-
* - `depositAmount` (numeric amount), or
|
|
1917
|
-
* - `depositCoinArg` (Sui coin object).
|
|
1918
|
-
*/
|
|
1919
|
-
export type ApiPerpetualsDepositCollateralBody = {
|
|
442
|
+
export interface ApiPerpetualsTransferCollateralBody {
|
|
1920
443
|
walletAddress: SuiAddress;
|
|
1921
|
-
accountId: PerpetualsAccountId;
|
|
1922
|
-
accountCapId?: ObjectId;
|
|
1923
444
|
collateralCoinType: CoinType;
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
depositAmount: Balance;
|
|
1928
|
-
} | {
|
|
1929
|
-
depositCoinArg: TransactionObjectArgument;
|
|
1930
|
-
});
|
|
1931
|
-
/**
|
|
1932
|
-
* Request body for withdrawing collateral from an account.
|
|
1933
|
-
*/
|
|
1934
|
-
export type ApiPerpetualsWithdrawCollateralBody = {
|
|
1935
|
-
accountId: PerpetualsAccountId;
|
|
1936
|
-
withdrawAmount: Balance;
|
|
1937
|
-
recipientAddress?: SuiAddress;
|
|
1938
|
-
txKind?: SerializedTransaction;
|
|
1939
|
-
};
|
|
1940
|
-
/**
|
|
1941
|
-
* Response body for withdraw-collateral transactions.
|
|
1942
|
-
*
|
|
1943
|
-
* The SDK typically uses `txKind` to reconstruct a transaction locally.
|
|
1944
|
-
*/
|
|
1945
|
-
export interface ApiPerpetualsWithdrawCollateralResponse {
|
|
1946
|
-
txKind: SerializedTransaction;
|
|
1947
|
-
coinOutArg: TransactionObjectArgument | undefined;
|
|
445
|
+
fromAccountCapId: ObjectId;
|
|
446
|
+
toAccountCapId: ObjectId;
|
|
447
|
+
amount: Balance;
|
|
1948
448
|
}
|
|
1949
|
-
|
|
1950
|
-
* Request body for transferring collateral between two perpetuals accounts.
|
|
1951
|
-
*/
|
|
1952
|
-
export interface ApiPerpetualsTransferCollateralBody {
|
|
449
|
+
export interface ApiPerpetualsAllocateCollateralBody {
|
|
1953
450
|
walletAddress: SuiAddress;
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
toAccountCapId?: ObjectId;
|
|
1958
|
-
transferAmount: Balance;
|
|
1959
|
-
txKind?: SerializedTransaction;
|
|
1960
|
-
}
|
|
1961
|
-
/**
|
|
1962
|
-
* Request body for allocating collateral to a given market (account/vault).
|
|
1963
|
-
*/
|
|
1964
|
-
export type ApiPerpetualsAllocateCollateralBody = {
|
|
1965
|
-
marketId: PerpetualsMarketId;
|
|
1966
|
-
allocateAmount: Balance;
|
|
1967
|
-
txKind?: SerializedTransaction;
|
|
1968
|
-
} & ({
|
|
1969
|
-
accountId: PerpetualsAccountId;
|
|
1970
|
-
accountCapId?: ObjectId;
|
|
1971
|
-
} | {
|
|
1972
|
-
vaultId: ObjectId;
|
|
1973
|
-
});
|
|
1974
|
-
/**
|
|
1975
|
-
* Request body for deallocating collateral from a given market (account/vault).
|
|
1976
|
-
*/
|
|
1977
|
-
export type ApiPerpetualsDeallocateCollateralBody = {
|
|
451
|
+
packageId: PackageId;
|
|
452
|
+
collateralCoinType: CoinType;
|
|
453
|
+
accountCapId: ObjectId;
|
|
1978
454
|
marketId: PerpetualsMarketId;
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
} & ({
|
|
1982
|
-
accountId: PerpetualsAccountId;
|
|
1983
|
-
accountCapId?: ObjectId;
|
|
1984
|
-
} | {
|
|
1985
|
-
vaultId: ObjectId;
|
|
1986
|
-
});
|
|
1987
|
-
/**
|
|
1988
|
-
* SDK-level inputs for placing one or more stop orders.
|
|
1989
|
-
*
|
|
1990
|
-
* This is a client-facing type that wraps the on-chain format.
|
|
1991
|
-
*/
|
|
1992
|
-
export interface SdkPerpetualsPlaceStopOrdersInputs {
|
|
1993
|
-
/** Stop orders to place (without objectId, which is created on-chain). */
|
|
1994
|
-
stopOrders: Omit<PerpetualsStopOrderData, "objectId">[];
|
|
1995
|
-
/** Optional transaction to embed the call in. */
|
|
1996
|
-
tx?: Transaction;
|
|
1997
|
-
/** Optional gas coin for sponsored or custom gas usage. */
|
|
1998
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
1999
|
-
/** Whether the transaction is expected to be sponsored by the API. */
|
|
2000
|
-
isSponsoredTx?: boolean;
|
|
455
|
+
marketInitialSharedVersion: ObjectVersion;
|
|
456
|
+
amount: Balance;
|
|
2001
457
|
}
|
|
2002
|
-
|
|
2003
|
-
* Request body for placing stop orders via the API.
|
|
2004
|
-
*/
|
|
2005
|
-
export type ApiPerpetualsPlaceStopOrdersBody = {
|
|
458
|
+
export interface ApiPerpetualsDeallocateCollateralBody {
|
|
2006
459
|
walletAddress: SuiAddress;
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
accountId: PerpetualsAccountId;
|
|
2013
|
-
accountCapId?: ObjectId;
|
|
2014
|
-
} | {
|
|
2015
|
-
vaultId: ObjectId;
|
|
2016
|
-
});
|
|
2017
|
-
/**
|
|
2018
|
-
* SDK-level inputs for placing stop-loss / take-profit orders bound to a
|
|
2019
|
-
* specific market and position side.
|
|
2020
|
-
*/
|
|
2021
|
-
export type SdkPerpetualsPlaceSlTpOrdersInputs = {
|
|
2022
|
-
marketId: PerpetualsMarketId;
|
|
2023
|
-
/** Optional target size for SL/TP orders (scaled base units). */
|
|
2024
|
-
size?: bigint;
|
|
2025
|
-
/** Index price at which to trigger stop loss. */
|
|
2026
|
-
stopLossIndexPrice?: number;
|
|
2027
|
-
/** Index price at which to trigger take profit. */
|
|
2028
|
-
takeProfitIndexPrice?: number;
|
|
2029
|
-
/** Unique order identifier for limit order sl/tp is tied to. */
|
|
2030
|
-
limitOrderId?: PerpetualsOrderId;
|
|
2031
|
-
/** Optional transaction to embed in. */
|
|
2032
|
-
tx?: Transaction;
|
|
2033
|
-
/** Optional gas coin argument. */
|
|
2034
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
2035
|
-
/** Whether to treat the transaction as sponsored. */
|
|
2036
|
-
isSponsoredTx?: boolean;
|
|
2037
|
-
};
|
|
2038
|
-
/**
|
|
2039
|
-
* API request body for placing SL/TP orders bound to a position.
|
|
2040
|
-
*/
|
|
2041
|
-
export type ApiPerpetualsPlaceSlTpOrdersBody = {
|
|
460
|
+
packageId: PackageId;
|
|
461
|
+
collateralCoinType: CoinType;
|
|
462
|
+
accountCapId: ObjectId;
|
|
463
|
+
basePriceFeedId: ObjectId;
|
|
464
|
+
collateralPriceFeedId: ObjectId;
|
|
2042
465
|
marketId: PerpetualsMarketId;
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
takeProfitIndexPrice?: number;
|
|
2048
|
-
limitOrderId?: PerpetualsOrderId;
|
|
2049
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
2050
|
-
isSponsoredTx?: boolean;
|
|
2051
|
-
leverage?: number;
|
|
2052
|
-
txKind?: SerializedTransaction;
|
|
2053
|
-
} & ({
|
|
2054
|
-
accountId: PerpetualsAccountId;
|
|
2055
|
-
accountCapId?: ObjectId;
|
|
2056
|
-
} | {
|
|
2057
|
-
vaultId: ObjectId;
|
|
2058
|
-
});
|
|
2059
|
-
/**
|
|
2060
|
-
* API request body for editing existing stop orders for an
|
|
2061
|
-
* account or vault.
|
|
2062
|
-
*/
|
|
2063
|
-
export type ApiPerpetualsEditStopOrdersBody = {
|
|
2064
|
-
stopOrders: PerpetualsStopOrderData[];
|
|
2065
|
-
txKind?: SerializedTransaction;
|
|
2066
|
-
} & ({
|
|
2067
|
-
accountId: PerpetualsAccountId;
|
|
2068
|
-
accountCapId?: ObjectId;
|
|
2069
|
-
} | {
|
|
2070
|
-
vaultId: ObjectId;
|
|
2071
|
-
});
|
|
2072
|
-
/**
|
|
2073
|
-
* API request body for placing a market order in a given market.
|
|
2074
|
-
*
|
|
2075
|
-
* This form is used by the backend and includes contextual information
|
|
2076
|
-
* like `accountId` or `vaultId`.
|
|
2077
|
-
*/
|
|
2078
|
-
export type ApiPerpetualsMarketOrderBody = {
|
|
466
|
+
marketInitialSharedVersion: ObjectVersion;
|
|
467
|
+
amount: Balance;
|
|
468
|
+
}
|
|
469
|
+
export interface ApiPerpetualsMarketOrderBody {
|
|
2079
470
|
walletAddress: SuiAddress;
|
|
2080
471
|
marketId: PerpetualsMarketId;
|
|
472
|
+
accountObjectId: ObjectId;
|
|
473
|
+
accountObjectVersion: number;
|
|
474
|
+
accountObjectDigest: ObjectId;
|
|
2081
475
|
side: PerpetualsOrderSide;
|
|
2082
|
-
/** Order size in scaled base units. */
|
|
2083
476
|
size: bigint;
|
|
2084
|
-
|
|
2085
|
-
collateralChange: number;
|
|
2086
|
-
/** Whether the account already has a position in this market. */
|
|
477
|
+
collateralChange: Balance;
|
|
2087
478
|
hasPosition: boolean;
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
/** If true, order can only reduce an existing position. */
|
|
2091
|
-
reduceOnly: boolean;
|
|
2092
|
-
/** Allowable max slippage for trade execution. */
|
|
2093
|
-
slippage: Slippage;
|
|
2094
|
-
/** Optional leverage override. */
|
|
2095
|
-
leverage?: number;
|
|
2096
|
-
/** Optional SL/TP instructions to be placed along with the market order. */
|
|
2097
|
-
slTp?: {
|
|
2098
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
2099
|
-
isSponsoredTx?: boolean;
|
|
2100
|
-
size?: bigint;
|
|
2101
|
-
stopLossIndexPrice?: number;
|
|
2102
|
-
takeProfitIndexPrice?: number;
|
|
2103
|
-
};
|
|
2104
|
-
/**
|
|
2105
|
-
* Optional integrator fee configuration for this order.
|
|
2106
|
-
*
|
|
2107
|
-
* If provided, the integrator specified in the configuration will receive a fee
|
|
2108
|
-
* on the taker volume generated by this order. The integrator must have been
|
|
2109
|
-
* previously approved by the account owner, and the fee must not exceed the
|
|
2110
|
-
* maximum fee the user approved for that integrator.
|
|
2111
|
-
*/
|
|
2112
|
-
builderCode?: PerpetualsBuilderCodeParamaters;
|
|
2113
|
-
/** Optional serialized transaction kind if assembled by the API. */
|
|
2114
|
-
txKind?: SerializedTransaction;
|
|
2115
|
-
} & ({
|
|
2116
|
-
accountId: PerpetualsAccountId;
|
|
2117
|
-
accountCapId?: ObjectId;
|
|
2118
|
-
} | {
|
|
2119
|
-
vaultId: ObjectId;
|
|
2120
|
-
});
|
|
2121
|
-
/**
|
|
2122
|
-
* API request body for placing a limit order in a given market.
|
|
2123
|
-
*/
|
|
2124
|
-
export type ApiPerpetualsLimitOrderBody = {
|
|
2125
|
-
marketId: PerpetualsMarketId;
|
|
479
|
+
}
|
|
480
|
+
export interface ApiPerpetualsLimitOrderBody {
|
|
2126
481
|
walletAddress: SuiAddress;
|
|
482
|
+
marketId: PerpetualsMarketId;
|
|
483
|
+
accountObjectId: ObjectId;
|
|
484
|
+
accountObjectVersion: number;
|
|
485
|
+
accountObjectDigest: ObjectId;
|
|
2127
486
|
side: PerpetualsOrderSide;
|
|
2128
|
-
/** Order size in scaled base units. */
|
|
2129
487
|
size: bigint;
|
|
2130
|
-
|
|
2131
|
-
price: bigint;
|
|
2132
|
-
/** How the order behaves on the orderbook. */
|
|
488
|
+
price: PerpetualsOrderPrice;
|
|
2133
489
|
orderType: PerpetualsOrderType;
|
|
2134
|
-
|
|
2135
|
-
collateralChange: number;
|
|
2136
|
-
/** Whether the account already has a position in this market. */
|
|
490
|
+
collateralChange: Balance;
|
|
2137
491
|
hasPosition: boolean;
|
|
2138
|
-
/** True is position is closed. */
|
|
2139
|
-
cancelSlTp: boolean;
|
|
2140
|
-
/** If true, order can only reduce an existing position. */
|
|
2141
|
-
reduceOnly: boolean;
|
|
2142
|
-
/** Optional expiration for the order. */
|
|
2143
|
-
expiryTimestamp?: bigint;
|
|
2144
|
-
/** Optional leverage override. */
|
|
2145
|
-
leverage?: number;
|
|
2146
|
-
/** Optional SL/TP instructions to be placed along with the limit order. */
|
|
2147
|
-
slTp?: {
|
|
2148
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
2149
|
-
isSponsoredTx?: boolean;
|
|
2150
|
-
size?: bigint;
|
|
2151
|
-
stopLossIndexPrice?: number;
|
|
2152
|
-
takeProfitIndexPrice?: number;
|
|
2153
|
-
};
|
|
2154
|
-
/**
|
|
2155
|
-
* Optional integrator fee configuration for this order.
|
|
2156
|
-
*
|
|
2157
|
-
* If provided, the integrator specified in the configuration will receive a fee
|
|
2158
|
-
* on the taker volume generated by this order. The integrator must have been
|
|
2159
|
-
* previously approved by the account owner, and the fee must not exceed the
|
|
2160
|
-
* maximum fee the user approved for that integrator.
|
|
2161
|
-
*/
|
|
2162
|
-
builderCode?: PerpetualsBuilderCodeParamaters;
|
|
2163
|
-
/** Optionally pre-built transaction payload. */
|
|
2164
|
-
txKind?: SerializedTransaction;
|
|
2165
|
-
} & ({
|
|
2166
|
-
accountId: PerpetualsAccountId;
|
|
2167
|
-
accountCapId?: ObjectId;
|
|
2168
|
-
} | {
|
|
2169
|
-
vaultId: ObjectId;
|
|
2170
|
-
});
|
|
2171
|
-
/**
|
|
2172
|
-
* API request body for canceling one or more orders for an
|
|
2173
|
-
* account or vault, per market.
|
|
2174
|
-
*/
|
|
2175
|
-
export type ApiPerpetualsCancelOrdersBody = {
|
|
2176
|
-
walletAddress: SuiAddress;
|
|
2177
|
-
marketIdsToData: Record<PerpetualsMarketId, {
|
|
2178
|
-
orderIds: PerpetualsOrderId[];
|
|
2179
|
-
/** Collateral change associated with canceling these orders. */
|
|
2180
|
-
collateralChange: number;
|
|
2181
|
-
}>;
|
|
2182
|
-
txKind?: SerializedTransaction;
|
|
2183
|
-
} & ({
|
|
2184
|
-
accountId: PerpetualsAccountId;
|
|
2185
|
-
accountCapId?: ObjectId;
|
|
2186
|
-
} | {
|
|
2187
|
-
vaultId: ObjectId;
|
|
2188
|
-
});
|
|
2189
|
-
/**
|
|
2190
|
-
* API request body for canceling stop orders identified by object IDs.
|
|
2191
|
-
*/
|
|
2192
|
-
export type ApiPerpetualsCancelStopOrdersBody = {
|
|
2193
|
-
stopOrderIds: ObjectId[];
|
|
2194
|
-
txKind?: SerializedTransaction;
|
|
2195
|
-
} & ({
|
|
2196
|
-
accountId: PerpetualsAccountId;
|
|
2197
|
-
accountCapId?: ObjectId;
|
|
2198
|
-
} | {
|
|
2199
|
-
vaultId: ObjectId;
|
|
2200
|
-
});
|
|
2201
|
-
/**
|
|
2202
|
-
* API body for setting leverage on an existing position.
|
|
2203
|
-
*/
|
|
2204
|
-
export type ApiPerpetualsSetLeverageTxBody = {
|
|
2205
|
-
marketId: PerpetualsMarketId;
|
|
2206
|
-
collateralChange: number;
|
|
2207
|
-
leverage: number;
|
|
2208
|
-
txKind?: SerializedTransaction;
|
|
2209
|
-
} & ({
|
|
2210
|
-
accountId: PerpetualsAccountId;
|
|
2211
|
-
accountCapId?: ObjectId;
|
|
2212
|
-
} | {
|
|
2213
|
-
vaultId: ObjectId;
|
|
2214
|
-
});
|
|
2215
|
-
/**
|
|
2216
|
-
* 24 hour statistics for a single perpetuals market.
|
|
2217
|
-
*/
|
|
2218
|
-
export interface PerpetualsMarket24hrStats {
|
|
2219
|
-
/** 24h volume in USD. */
|
|
2220
|
-
volumeUsd: number;
|
|
2221
|
-
/** 24h volume in base asset units. */
|
|
2222
|
-
volumeBaseAssetAmount: number;
|
|
2223
|
-
/** Absolute price change over 24 hours. */
|
|
2224
|
-
priceChange: number;
|
|
2225
|
-
/** Relative price change percentage over 24 hours. */
|
|
2226
|
-
priceChangePercentage: number;
|
|
2227
|
-
}
|
|
2228
|
-
/**
|
|
2229
|
-
* Response type for requesting 24h stats for multiple markets.
|
|
2230
|
-
*/
|
|
2231
|
-
export interface ApiPerpetualsMarkets24hrStatsResponse {
|
|
2232
|
-
marketsStats: PerpetualsMarket24hrStats[];
|
|
2233
492
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
* This endpoint is commonly used to populate a "Markets" list filtered by
|
|
2238
|
-
* the user's selected collateral (e.g., USDC-margined markets).
|
|
2239
|
-
*/
|
|
2240
|
-
export interface ApiPerpetualsAllMarketsBody {
|
|
493
|
+
export interface ApiPerpetualsCancelOrderBody {
|
|
494
|
+
packageId: PackageId;
|
|
495
|
+
walletAddress: SuiAddress;
|
|
2241
496
|
collateralCoinType: CoinType;
|
|
2242
|
-
}
|
|
2243
|
-
/**
|
|
2244
|
-
* Response payload for {@link ApiPerpetualsAllMarketsBody}.
|
|
2245
|
-
*
|
|
2246
|
-
* Returns enriched market data including parameters, state, and current prices.
|
|
2247
|
-
*/
|
|
2248
|
-
export interface ApiPerpetualsAllMarketsResponse {
|
|
2249
|
-
markets: PerpetualsMarketData[];
|
|
2250
|
-
}
|
|
2251
|
-
/**
|
|
2252
|
-
* Request body for fetching a specific set of markets by ID.
|
|
2253
|
-
*/
|
|
2254
|
-
export interface ApiPerpetualsMarketsBody {
|
|
2255
|
-
marketIds: PerpetualsMarketId[];
|
|
2256
|
-
}
|
|
2257
|
-
/**
|
|
2258
|
-
* Response payload for {@link ApiPerpetualsMarketsBody}.
|
|
2259
|
-
*
|
|
2260
|
-
* Each item includes the market data.
|
|
2261
|
-
*/
|
|
2262
|
-
export interface ApiPerpetualsMarketsResponse {
|
|
2263
|
-
marketDatas: {
|
|
2264
|
-
market: PerpetualsMarketData;
|
|
2265
|
-
}[];
|
|
2266
|
-
}
|
|
2267
|
-
/**
|
|
2268
|
-
* Request body for fetching a specific set of orderbooks by market ID.
|
|
2269
|
-
*/
|
|
2270
|
-
export interface ApiPerpetualsOrderbooksBody {
|
|
2271
|
-
marketIds: PerpetualsMarketId[];
|
|
2272
|
-
}
|
|
2273
|
-
/**
|
|
2274
|
-
* Response payload for {@link ApiPerpetualsOrderbooksBody}.
|
|
2275
|
-
*
|
|
2276
|
-
* Each item includes the current orderbook snapshot.
|
|
2277
|
-
*/
|
|
2278
|
-
export interface ApiPerpetualsOrderbooksResponse {
|
|
2279
|
-
orderbooks: {
|
|
2280
|
-
orderbook: PerpetualsOrderbook;
|
|
2281
|
-
}[];
|
|
2282
|
-
}
|
|
2283
|
-
/**
|
|
2284
|
-
* Request body for fetching vault objects.
|
|
2285
|
-
*
|
|
2286
|
-
* If `vaultIds` is omitted, the API may return all vaults (potentially paginated
|
|
2287
|
-
* at the transport layer).
|
|
2288
|
-
*/
|
|
2289
|
-
export interface ApiPerpetualsVaultsBody {
|
|
2290
|
-
vaultIds?: ObjectId[];
|
|
2291
|
-
}
|
|
2292
|
-
/**
|
|
2293
|
-
* Response payload for vault queries.
|
|
2294
|
-
*/
|
|
2295
|
-
export interface ApiPerpetualsVaultsResponse {
|
|
2296
|
-
vaults: PerpetualsVaultObject[];
|
|
2297
|
-
}
|
|
2298
|
-
/**
|
|
2299
|
-
* Request body for fetching current prices for a list of markets.
|
|
2300
|
-
*
|
|
2301
|
-
* This is a lightweight alternative to fetching full {@link PerpetualsMarketData}
|
|
2302
|
-
* when only base/collateral prices are needed.
|
|
2303
|
-
*/
|
|
2304
|
-
export interface ApiPerpetualsMarketsPricesBody {
|
|
2305
|
-
marketIds: PerpetualsMarketId[];
|
|
2306
|
-
}
|
|
2307
|
-
/**
|
|
2308
|
-
* Response payload for {@link ApiPerpetualsMarketsPricesBody}.
|
|
2309
|
-
*
|
|
2310
|
-
* Returns base (index/oracle) and collateral prices used for valuation.
|
|
2311
|
-
*/
|
|
2312
|
-
export interface ApiPerpetualsMarketsPricesResponse {
|
|
2313
|
-
marketsPrices: {
|
|
2314
|
-
basePrice: number;
|
|
2315
|
-
collateralPrice: number;
|
|
2316
|
-
}[];
|
|
2317
|
-
}
|
|
2318
|
-
/**
|
|
2319
|
-
* Request body for granting an Agent Wallet on a perpetuals account.
|
|
2320
|
-
*
|
|
2321
|
-
* This corresponds to `POST /api/perpetuals/account/transactions/grant-agent-wallet`.
|
|
2322
|
-
*
|
|
2323
|
-
* The resulting on-chain transaction must be signed by the **account admin** wallet.
|
|
2324
|
-
* After execution, `recipientAddress` receives assistant-level permissions for `accountId`
|
|
2325
|
-
* (trading actions are allowed, but **withdrawing collateral** and managing other agent wallets are not).
|
|
2326
|
-
*/
|
|
2327
|
-
export type ApiPerpetualsGrantAgentWalletTxBody = {
|
|
2328
|
-
recipientAddress: SuiAddress;
|
|
2329
|
-
accountId: PerpetualsAccountId;
|
|
2330
|
-
txKind?: SerializedTransaction;
|
|
2331
|
-
};
|
|
2332
|
-
/**
|
|
2333
|
-
* Request body for revoking an Agent Wallet from a perpetuals account.
|
|
2334
|
-
*
|
|
2335
|
-
* This corresponds to `POST /api/perpetuals/account/transactions/revoke-agent-wallet`.
|
|
2336
|
-
*
|
|
2337
|
-
* The resulting on-chain transaction must be signed by the **account admin** wallet.
|
|
2338
|
-
* `accountCapId` is the object ID of the assistant capability to revoke.
|
|
2339
|
-
*/
|
|
2340
|
-
export type ApiPerpetualsRevokeAgentWalletTxBody = {
|
|
2341
|
-
accountId: PerpetualsAccountId;
|
|
2342
497
|
accountCapId: ObjectId;
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
* Must be a valid Sui address string.
|
|
2350
|
-
*/
|
|
2351
|
-
recipientAddress: SuiAddress;
|
|
2352
|
-
/**
|
|
2353
|
-
* Object ID of the capability to transfer.
|
|
2354
|
-
*
|
|
2355
|
-
* This should be the object ID of the cap being transferred (e.g., an account cap or vault cap).
|
|
2356
|
-
*/
|
|
2357
|
-
capObjectId: ObjectId;
|
|
2358
|
-
/**
|
|
2359
|
-
* Optional serialized (base64) Sui `TransactionKind` to extend.
|
|
2360
|
-
*
|
|
2361
|
-
* When provided, the transfer operation is appended to the existing transaction.
|
|
2362
|
-
*/
|
|
2363
|
-
txKind?: SerializedTransaction;
|
|
2364
|
-
};
|
|
2365
|
-
/**
|
|
2366
|
-
* Request body for fetching LP coin prices for a set of vaults.
|
|
2367
|
-
*
|
|
2368
|
-
* LP coin price is typically expressed in USD per 1 LP token (native units adjusted
|
|
2369
|
-
* using `lpCoinDecimals` on the vault object).
|
|
2370
|
-
*/
|
|
2371
|
-
export interface ApiPerpetualsVaultLpCoinPricesBody {
|
|
2372
|
-
vaultIds: ObjectId[];
|
|
2373
|
-
}
|
|
2374
|
-
/**
|
|
2375
|
-
* Response payload for {@link ApiPerpetualsVaultLpCoinPricesBody}.
|
|
2376
|
-
*
|
|
2377
|
-
* The response is index-aligned with the request `vaultIds` array.
|
|
2378
|
-
*/
|
|
2379
|
-
export interface ApiPerpetualsVaultLpCoinPricesResponse {
|
|
2380
|
-
lpCoinPrices: number[];
|
|
2381
|
-
}
|
|
2382
|
-
/**
|
|
2383
|
-
* Request body for fetching a wallet's owned LP coin objects across vaults.
|
|
2384
|
-
*/
|
|
2385
|
-
export interface ApiPerpetualsVaultOwnedLpCoinsBody {
|
|
2386
|
-
walletAddress: SuiAddress;
|
|
2387
|
-
}
|
|
2388
|
-
/**
|
|
2389
|
-
* Response payload listing owned LP coin objects (per vault).
|
|
2390
|
-
*/
|
|
2391
|
-
export interface ApiPerpetualsVaultOwnedLpCoinsResponse {
|
|
2392
|
-
ownedLpCoins: PerpetualsVaultLpCoin[];
|
|
2393
|
-
}
|
|
2394
|
-
/**
|
|
2395
|
-
* Request body for fetching vault capability objects owned by a wallet.
|
|
2396
|
-
*
|
|
2397
|
-
* Vault caps are typically owned by the vault creator/owner and are required
|
|
2398
|
-
* for privileged vault actions (processing withdrawals, updating parameters, etc.).
|
|
2399
|
-
*/
|
|
2400
|
-
export interface ApiPerpetualsOwnedVaultCapsBody {
|
|
2401
|
-
walletAddress: SuiAddress;
|
|
2402
|
-
}
|
|
2403
|
-
/**
|
|
2404
|
-
* Response payload listing all vault caps owned by the wallet.
|
|
2405
|
-
*/
|
|
2406
|
-
export interface ApiPerpetualsOwnedVaultCapsResponse {
|
|
2407
|
-
ownedVaultCaps: PerpetualsVaultCap[];
|
|
2408
|
-
}
|
|
2409
|
-
/**
|
|
2410
|
-
* API body to process forced withdrawals in a vault.
|
|
2411
|
-
*/
|
|
2412
|
-
export interface ApiPerpetualsVaultProcessForceWithdrawRequestTxBody {
|
|
2413
|
-
walletAddress: SuiAddress;
|
|
2414
|
-
vaultId: ObjectId;
|
|
2415
|
-
/** Per-market sizes to close as part of force withdraw. */
|
|
2416
|
-
sizesToClose: Record<PerpetualsMarketId, Balance>;
|
|
2417
|
-
recipientAddress?: SuiAddress;
|
|
2418
|
-
txKind?: SerializedTransaction;
|
|
2419
|
-
}
|
|
2420
|
-
/**
|
|
2421
|
-
* Response body for force-withdraw processing transactions.
|
|
2422
|
-
*
|
|
2423
|
-
* - `txKind` is a serialized transaction kind the client can sign/submit.
|
|
2424
|
-
* - `coinOutArg` (if present) is the transaction argument referencing the
|
|
2425
|
-
* withdrawn collateral coin output.
|
|
2426
|
-
*/
|
|
2427
|
-
export interface ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse {
|
|
2428
|
-
txKind: SerializedTransaction;
|
|
2429
|
-
coinOutArg: TransactionObjectArgument | undefined;
|
|
2430
|
-
}
|
|
2431
|
-
export interface ApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody {
|
|
2432
|
-
vaultId: ObjectId;
|
|
2433
|
-
txKind?: SerializedTransaction;
|
|
2434
|
-
}
|
|
2435
|
-
/**
|
|
2436
|
-
* API body to process regular withdraw requests for a vault.
|
|
2437
|
-
*/
|
|
2438
|
-
export interface ApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody {
|
|
2439
|
-
vaultId: ObjectId;
|
|
2440
|
-
userAddresses: SuiAddress[];
|
|
2441
|
-
txKind?: SerializedTransaction;
|
|
2442
|
-
}
|
|
2443
|
-
/**
|
|
2444
|
-
* API body to update slippage parameter for pending vault withdraw
|
|
2445
|
-
* request for a specific vault.
|
|
2446
|
-
*/
|
|
2447
|
-
export interface ApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody {
|
|
2448
|
-
vaultId: ObjectId;
|
|
2449
|
-
minCollateralAmountOut: Balance;
|
|
2450
|
-
txKind?: SerializedTransaction;
|
|
2451
|
-
}
|
|
2452
|
-
/**
|
|
2453
|
-
* API body to update the force-withdrawal delay in a vault.
|
|
2454
|
-
*/
|
|
2455
|
-
export interface ApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody {
|
|
2456
|
-
vaultId: ObjectId;
|
|
2457
|
-
forceWithdrawDelayMs: bigint;
|
|
2458
|
-
txKind?: SerializedTransaction;
|
|
2459
|
-
}
|
|
2460
|
-
/**
|
|
2461
|
-
* API body to update the lock period on a vault.
|
|
2462
|
-
*/
|
|
2463
|
-
export interface ApiPerpetualsVaultOwnerUpdateLockPeriodTxBody {
|
|
2464
|
-
vaultId: ObjectId;
|
|
2465
|
-
lockPeriodMs: bigint;
|
|
2466
|
-
txKind?: SerializedTransaction;
|
|
2467
|
-
}
|
|
2468
|
-
/**
|
|
2469
|
-
* API body to update the owner's fee percentage on a vault.
|
|
2470
|
-
*/
|
|
2471
|
-
export interface ApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody {
|
|
2472
|
-
vaultId: ObjectId;
|
|
2473
|
-
performanceFeePercentage: number;
|
|
2474
|
-
txKind?: SerializedTransaction;
|
|
2475
|
-
}
|
|
2476
|
-
/**
|
|
2477
|
-
* API body for the vault owner withdrawing collected fees.
|
|
2478
|
-
*/
|
|
2479
|
-
export interface ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody {
|
|
2480
|
-
vaultId: ObjectId;
|
|
2481
|
-
withdrawAmount: Balance;
|
|
2482
|
-
recipientAddress?: SuiAddress;
|
|
2483
|
-
txKind?: SerializedTransaction;
|
|
2484
|
-
}
|
|
2485
|
-
/**
|
|
2486
|
-
* Response for owner-fee withdrawal transactions.
|
|
2487
|
-
*/
|
|
2488
|
-
export interface ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse {
|
|
2489
|
-
txKind: SerializedTransaction;
|
|
2490
|
-
coinOutArg: TransactionObjectArgument | undefined;
|
|
2491
|
-
}
|
|
2492
|
-
/**
|
|
2493
|
-
* Request body for fetching all withdrawal requests for specific vaults.
|
|
2494
|
-
*/
|
|
2495
|
-
export interface ApiPerpetualsVaultsWithdrawRequestsBody {
|
|
2496
|
-
vaultIds: ObjectId[];
|
|
2497
|
-
}
|
|
2498
|
-
/**
|
|
2499
|
-
* Response payload listing withdrawal requests for the requested vaults.
|
|
2500
|
-
*
|
|
2501
|
-
* Depending on backend behavior, this may include all queued requests across
|
|
2502
|
-
* all specified vaults.
|
|
2503
|
-
*/
|
|
2504
|
-
export interface ApiPerpetualsVaultsWithdrawRequestsResponse {
|
|
2505
|
-
withdrawRequests: PerpetualsVaultWithdrawRequest[];
|
|
2506
|
-
}
|
|
2507
|
-
/**
|
|
2508
|
-
* Request body for fetching withdrawal requests for a given wallet across
|
|
2509
|
-
* its vault positions.
|
|
2510
|
-
*/
|
|
2511
|
-
export interface ApiPerpetualsVaultOwnedWithdrawRequestsBody {
|
|
2512
|
-
walletAddress: SuiAddress;
|
|
2513
|
-
}
|
|
2514
|
-
/**
|
|
2515
|
-
* Response payload listing withdrawal requests created by `walletAddress`.
|
|
2516
|
-
*/
|
|
2517
|
-
export interface ApiPerpetualsVaultOwnedWithdrawRequestsResponse {
|
|
2518
|
-
ownedWithdrawRequests: PerpetualsVaultWithdrawRequest[];
|
|
2519
|
-
}
|
|
2520
|
-
/**
|
|
2521
|
-
* API body for creating a single withdraw request from a vault.
|
|
2522
|
-
*/
|
|
2523
|
-
export interface ApiPerpetualsVaultCreateWithdrawRequestTxBody {
|
|
2524
|
-
vaultId: ObjectId;
|
|
2525
|
-
walletAddress: SuiAddress;
|
|
2526
|
-
lpWithdrawAmount: Balance;
|
|
2527
|
-
minCollateralAmountOut: Balance;
|
|
2528
|
-
txKind?: SerializedTransaction;
|
|
2529
|
-
}
|
|
2530
|
-
/**
|
|
2531
|
-
* API body for withdrawing collateral from a vault as owner.
|
|
2532
|
-
*/
|
|
2533
|
-
export interface ApiPerpetualsVaultOwnerWithdrawCollateralTxBody {
|
|
2534
|
-
vaultId: ObjectId;
|
|
2535
|
-
lpWithdrawAmount: Balance;
|
|
2536
|
-
minCollateralAmountOut: Balance;
|
|
2537
|
-
recipientAddress?: SuiAddress;
|
|
2538
|
-
txKind?: SerializedTransaction;
|
|
2539
|
-
}
|
|
2540
|
-
/**
|
|
2541
|
-
* Response body for vault owner withdraw-collateral transactions.
|
|
2542
|
-
*
|
|
2543
|
-
* The SDK typically uses `txKind` to reconstruct a transaction locally.
|
|
2544
|
-
*/
|
|
2545
|
-
export interface ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse {
|
|
2546
|
-
txKind: SerializedTransaction;
|
|
2547
|
-
coinOutArg: TransactionObjectArgument | undefined;
|
|
2548
|
-
}
|
|
2549
|
-
/**
|
|
2550
|
-
* API body for canceling withdrawal requests across vaults for a wallet.
|
|
2551
|
-
*/
|
|
2552
|
-
export interface ApiPerpetualsVaultCancelWithdrawRequestTxBody {
|
|
2553
|
-
vaultId: ObjectId;
|
|
2554
|
-
walletAddress: SuiAddress;
|
|
2555
|
-
txKind?: SerializedTransaction;
|
|
498
|
+
marketId: PerpetualsMarketId;
|
|
499
|
+
marketInitialSharedVersion: ObjectVersion;
|
|
500
|
+
orderId: PerpetualsOrderId;
|
|
501
|
+
collateralChange: Balance;
|
|
502
|
+
basePriceFeedId: ObjectId;
|
|
503
|
+
collateralPriceFeedId: ObjectId;
|
|
2556
504
|
}
|
|
2557
|
-
|
|
2558
|
-
* Request body for depositing into a vault.
|
|
2559
|
-
*
|
|
2560
|
-
* Deposit can be specified as a numeric amount or as an existing coin object.
|
|
2561
|
-
*/
|
|
2562
|
-
export type ApiPerpetualsVaultDepositTxBody = {
|
|
2563
|
-
vaultId: ObjectId;
|
|
505
|
+
export interface ApiPerpetualsCancelOrdersBody {
|
|
2564
506
|
walletAddress: SuiAddress;
|
|
2565
|
-
minLpAmountOut: Balance;
|
|
2566
|
-
txKind?: SerializedTransaction;
|
|
2567
|
-
isSponsoredTx?: boolean;
|
|
2568
|
-
} & ({
|
|
2569
|
-
depositAmount: Balance;
|
|
2570
507
|
collateralCoinType: CoinType;
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
}
|
|
2582
|
-
/**
|
|
2583
|
-
* Response body for vault withdrawal preview.
|
|
2584
|
-
*/
|
|
2585
|
-
export type ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse = {
|
|
2586
|
-
error: string;
|
|
2587
|
-
} | {
|
|
2588
|
-
collateralAmountOut: Balance;
|
|
2589
|
-
collateralPrice: number;
|
|
2590
|
-
};
|
|
2591
|
-
/**
|
|
2592
|
-
* Request body for previewing a vault owner collateral withdrawal.
|
|
2593
|
-
*/
|
|
2594
|
-
export interface ApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody {
|
|
2595
|
-
vaultId: ObjectId;
|
|
2596
|
-
lpWithdrawAmount: Balance;
|
|
2597
|
-
}
|
|
2598
|
-
/**
|
|
2599
|
-
* Response body for vault owner collateral withdrawal preview.
|
|
2600
|
-
*/
|
|
2601
|
-
export type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse = {
|
|
2602
|
-
error: string;
|
|
2603
|
-
} | {
|
|
2604
|
-
collateralAmountOut: Balance;
|
|
2605
|
-
collateralPrice: number;
|
|
2606
|
-
};
|
|
2607
|
-
/**
|
|
2608
|
-
* Request body for previewing a vault deposit.
|
|
2609
|
-
*/
|
|
2610
|
-
export interface ApiPerpetualsVaultPreviewDepositBody {
|
|
2611
|
-
vaultId: ObjectId;
|
|
2612
|
-
depositAmount: Balance;
|
|
2613
|
-
}
|
|
2614
|
-
/**
|
|
2615
|
-
* Response body for vault deposit preview.
|
|
2616
|
-
*/
|
|
2617
|
-
export type ApiPerpetualsVaultPreviewDepositResponse = {
|
|
2618
|
-
error: string;
|
|
2619
|
-
} | {
|
|
2620
|
-
lpAmountOut: Balance;
|
|
2621
|
-
collateralPrice: number;
|
|
2622
|
-
depositedAmountUsd: number;
|
|
2623
|
-
};
|
|
2624
|
-
/**
|
|
2625
|
-
* Request body for previewing forced withdraw processing for a vault.
|
|
2626
|
-
*/
|
|
2627
|
-
export interface ApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody {
|
|
2628
|
-
vaultId: ObjectId;
|
|
2629
|
-
walletAddress: SuiAddress;
|
|
508
|
+
accountCapId: ObjectId;
|
|
509
|
+
orderDatas: {
|
|
510
|
+
packageId: PackageId;
|
|
511
|
+
orderId: PerpetualsOrderId;
|
|
512
|
+
marketId: PerpetualsMarketId;
|
|
513
|
+
marketInitialSharedVersion: ObjectVersion;
|
|
514
|
+
collateralChange: Balance;
|
|
515
|
+
basePriceFeedId: ObjectId;
|
|
516
|
+
collateralPriceFeedId: ObjectId;
|
|
517
|
+
}[];
|
|
2630
518
|
}
|
|
2631
|
-
|
|
2632
|
-
* Response body for forced withdraw processing preview.
|
|
2633
|
-
*/
|
|
2634
|
-
export type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse = {
|
|
2635
|
-
error: string;
|
|
2636
|
-
} | {
|
|
2637
|
-
collateralAmountOut: Balance;
|
|
2638
|
-
collateralPrice: number;
|
|
2639
|
-
sizesToClose: Record<PerpetualsMarketId, bigint>;
|
|
2640
|
-
priceImpact: Percentage;
|
|
2641
|
-
performanceFeesChargedUsd: number;
|
|
2642
|
-
isWithinWithdrawRequestSlippage: boolean;
|
|
2643
|
-
minCollateralAmountOut: Balance;
|
|
2644
|
-
};
|
|
2645
|
-
export interface ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody {
|
|
2646
|
-
vaultId: ObjectId;
|
|
519
|
+
export interface ApiPerpetualsReduceOrdersBody {
|
|
2647
520
|
walletAddress: SuiAddress;
|
|
521
|
+
packageId: PackageId;
|
|
522
|
+
collateralCoinType: CoinType;
|
|
523
|
+
accountCapId: ObjectId;
|
|
524
|
+
marketId: PerpetualsMarketId;
|
|
525
|
+
marketInitialSharedVersion: ObjectVersion;
|
|
526
|
+
orderIds: PerpetualsOrderId[];
|
|
527
|
+
sizesToSubtract: bigint[];
|
|
528
|
+
basePriceFeedId: ObjectId;
|
|
529
|
+
collateralPriceFeedId: ObjectId;
|
|
530
|
+
collateralChange: Balance;
|
|
2648
531
|
}
|
|
2649
|
-
export type
|
|
2650
|
-
|
|
2651
|
-
} | {
|
|
2652
|
-
|
|
2653
|
-
minNextPauseTimestamp: bigint;
|
|
2654
|
-
};
|
|
2655
|
-
/**
|
|
2656
|
-
* Request body for previewing normal withdraw requests processing for a vault.
|
|
2657
|
-
*/
|
|
2658
|
-
export interface ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody {
|
|
2659
|
-
vaultId: ObjectId;
|
|
2660
|
-
userAddresses: SuiAddress[];
|
|
2661
|
-
}
|
|
2662
|
-
/**
|
|
2663
|
-
* Response body for previewing normal withdraw requests processing.
|
|
2664
|
-
*/
|
|
2665
|
-
export type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse = {
|
|
2666
|
-
error: string;
|
|
532
|
+
export type ApiPerpetualsSLTPOrderBody = ((ApiPerpetualsMarketOrderBody & {
|
|
533
|
+
marketPrice: PerpetualsOrderPrice;
|
|
534
|
+
}) | ApiPerpetualsLimitOrderBody) & ({
|
|
535
|
+
slPrice: PerpetualsOrderPrice;
|
|
2667
536
|
} | {
|
|
2668
|
-
|
|
2669
|
-
userAddress: SuiAddress;
|
|
2670
|
-
collateralAmountOut: Balance;
|
|
2671
|
-
}[];
|
|
2672
|
-
collateralPrice: number;
|
|
2673
|
-
};
|
|
2674
|
-
/**
|
|
2675
|
-
* Request body for previewing maximum performance fees withdrawable from a vault.
|
|
2676
|
-
*/
|
|
2677
|
-
export interface ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody {
|
|
2678
|
-
vaultId: ObjectId;
|
|
2679
|
-
}
|
|
2680
|
-
/**
|
|
2681
|
-
* Response body for previewing vault performance fee withdrawal.
|
|
2682
|
-
*/
|
|
2683
|
-
export type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse = {
|
|
2684
|
-
error: string;
|
|
537
|
+
tpPrice: PerpetualsOrderPrice;
|
|
2685
538
|
} | {
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
};
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
* This omits server-managed fields like `accountId`, `hasPosition`,
|
|
2693
|
-
* and serialized `txKind`, and exposes a client-friendly `slTp` wrapper.
|
|
2694
|
-
*/
|
|
2695
|
-
export type SdkPerpetualsPlaceMarketOrderInputs = Omit<ApiPerpetualsMarketOrderBody, "accountId" | "txKind" | "slTp" | "walletAddress"> & {
|
|
2696
|
-
tx?: Transaction;
|
|
2697
|
-
slTp?: {
|
|
2698
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
2699
|
-
isSponsoredTx?: boolean;
|
|
2700
|
-
size?: bigint;
|
|
2701
|
-
stopLossIndexPrice?: number;
|
|
2702
|
-
takeProfitIndexPrice?: number;
|
|
2703
|
-
};
|
|
2704
|
-
};
|
|
2705
|
-
/**
|
|
2706
|
-
* SDK-level inputs for placing a limit order from a client.
|
|
2707
|
-
*/
|
|
2708
|
-
export type SdkPerpetualsPlaceLimitOrderInputs = Omit<ApiPerpetualsLimitOrderBody, "accountId" | "txKind" | "slTp" | "walletAddress"> & {
|
|
2709
|
-
tx?: Transaction;
|
|
2710
|
-
slTp?: {
|
|
2711
|
-
gasCoinArg?: TransactionObjectArgument;
|
|
2712
|
-
isSponsoredTx?: boolean;
|
|
2713
|
-
size?: bigint;
|
|
2714
|
-
stopLossIndexPrice?: number;
|
|
2715
|
-
takeProfitIndexPrice?: number;
|
|
2716
|
-
};
|
|
2717
|
-
};
|
|
2718
|
-
/**
|
|
2719
|
-
* SDK-level inputs for previewing a market order.
|
|
2720
|
-
*/
|
|
2721
|
-
export type SdkPerpetualsPlaceMarketOrderPreviewInputs = Omit<ApiPerpetualsPreviewPlaceMarketOrderBody, "collateralCoinType" | "accountId">;
|
|
2722
|
-
/**
|
|
2723
|
-
* SDK-level inputs for previewing a limit order.
|
|
2724
|
-
*/
|
|
2725
|
-
export type SdkPerpetualsPlaceLimitOrderPreviewInputs = Omit<ApiPerpetualsPreviewPlaceLimitOrderBody, "collateralCoinType" | "accountId">;
|
|
2726
|
-
/**
|
|
2727
|
-
* SDK-level inputs for previewing order cancellations.
|
|
2728
|
-
*/
|
|
2729
|
-
export type SdkPerpetualsCancelOrdersPreviewInputs = Omit<ApiPerpetualsPreviewCancelOrdersBody, "collateralCoinType" | "accountId">;
|
|
2730
|
-
/**
|
|
2731
|
-
* Action for websocket subscription messages.
|
|
2732
|
-
*/
|
|
2733
|
-
export type PerpetualsWsUpdatesSubscriptionAction = "subscribe" | "unsubscribe";
|
|
2734
|
-
/**
|
|
2735
|
-
* Websocket subscription payload for subscribing to a specific market's
|
|
2736
|
-
* updates (orderbook, prices, etc.).
|
|
2737
|
-
*/
|
|
2738
|
-
export interface PerpetualsWsUpdatesMarketSubscriptionType {
|
|
2739
|
-
market: {
|
|
2740
|
-
marketId: PerpetualsMarketId;
|
|
2741
|
-
};
|
|
2742
|
-
}
|
|
2743
|
-
/**
|
|
2744
|
-
* Websocket subscription payload for subscribing to user/account updates,
|
|
2745
|
-
* optionally including stop-order data (via signature).
|
|
2746
|
-
*/
|
|
2747
|
-
export interface PerpetualsWsUpdatesUserSubscriptionType {
|
|
2748
|
-
user: {
|
|
2749
|
-
accountId: PerpetualsAccountId;
|
|
2750
|
-
withStopOrders: {
|
|
2751
|
-
walletAddress: SuiAddress;
|
|
2752
|
-
bytes: string;
|
|
2753
|
-
signature: string;
|
|
2754
|
-
} | undefined;
|
|
2755
|
-
};
|
|
2756
|
-
}
|
|
2757
|
-
/**
|
|
2758
|
-
* Websocket subscription payload for market oracle price updates.
|
|
2759
|
-
*/
|
|
2760
|
-
export interface PerpetualsWsUpdatesOracleSubscriptionType {
|
|
2761
|
-
oracle: {
|
|
2762
|
-
marketId: PerpetualsMarketId;
|
|
2763
|
-
};
|
|
2764
|
-
}
|
|
2765
|
-
/**
|
|
2766
|
-
* Websocket subscription payload for orderbook updates.
|
|
2767
|
-
*/
|
|
2768
|
-
export interface PerpetualsWsUpdatesOrderbookSubscriptionType {
|
|
2769
|
-
orderbook: {
|
|
2770
|
-
marketId: PerpetualsMarketId;
|
|
2771
|
-
};
|
|
2772
|
-
}
|
|
2773
|
-
/**
|
|
2774
|
-
* Websocket subscription payload for market orders stream.
|
|
2775
|
-
*/
|
|
2776
|
-
export interface PerpetualsWsUpdatesMarketOrdersSubscriptionType {
|
|
2777
|
-
marketOrders: {
|
|
2778
|
-
marketId: PerpetualsMarketId;
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
|
-
/**
|
|
2782
|
-
* Websocket subscription payload for user-specific order updates.
|
|
2783
|
-
*/
|
|
2784
|
-
export interface PerpetualsWsUpdatesUserOrdersSubscriptionType {
|
|
2785
|
-
userOrders: {
|
|
2786
|
-
accountId: PerpetualsAccountId;
|
|
2787
|
-
};
|
|
2788
|
-
}
|
|
2789
|
-
/**
|
|
2790
|
-
* Websocket subscription payload for user-specific collateral changes.
|
|
2791
|
-
*/
|
|
2792
|
-
export interface PerpetualsWsUpdatesUserCollateralChangesSubscriptionType {
|
|
2793
|
-
userCollateralChanges: {
|
|
2794
|
-
accountId: PerpetualsAccountId;
|
|
2795
|
-
};
|
|
2796
|
-
}
|
|
2797
|
-
/**
|
|
2798
|
-
* Union of all websocket subscription types for perpetuals updates.
|
|
2799
|
-
*/
|
|
2800
|
-
export type PerpetualsWsUpdatesSubscriptionType = PerpetualsWsUpdatesMarketSubscriptionType | PerpetualsWsUpdatesUserSubscriptionType | PerpetualsWsUpdatesOracleSubscriptionType | PerpetualsWsUpdatesOrderbookSubscriptionType | PerpetualsWsUpdatesMarketOrdersSubscriptionType | PerpetualsWsUpdatesUserOrdersSubscriptionType | PerpetualsWsUpdatesUserCollateralChangesSubscriptionType;
|
|
2801
|
-
/**
|
|
2802
|
-
* Websocket payload for oracle price updates.
|
|
2803
|
-
*/
|
|
2804
|
-
export interface PerpetualsWsUpdatesOraclePayload {
|
|
2805
|
-
marketId: PerpetualsMarketId;
|
|
2806
|
-
basePrice: number;
|
|
2807
|
-
collateralPrice: number;
|
|
2808
|
-
}
|
|
2809
|
-
/**
|
|
2810
|
-
* Websocket payload for market orders stream.
|
|
2811
|
-
*/
|
|
2812
|
-
export interface PerpetualsWsUpdatesMarketOrdersPayload {
|
|
2813
|
-
marketId: PerpetualsMarketId;
|
|
2814
|
-
orders: PerpetualsMarketOrderHistoryData[];
|
|
2815
|
-
}
|
|
2816
|
-
/**
|
|
2817
|
-
* Websocket payload for user-specific orders stream.
|
|
2818
|
-
*/
|
|
2819
|
-
export interface PerpetualsWsUpdatesUserOrdersPayload {
|
|
2820
|
-
accountId: PerpetualsAccountId;
|
|
2821
|
-
orders: PerpetualsAccountOrderHistoryData[];
|
|
2822
|
-
}
|
|
2823
|
-
/**
|
|
2824
|
-
* Websocket payload for user-specific collateral changes.
|
|
2825
|
-
*/
|
|
2826
|
-
export interface PerpetualsWsUpdatesUserCollateralChangesPayload {
|
|
2827
|
-
accountId: PerpetualsAccountId;
|
|
2828
|
-
collateralChanges: PerpetualsAccountCollateralChange[];
|
|
2829
|
-
}
|
|
2830
|
-
/**
|
|
2831
|
-
* Websocket payload for incremental orderbook updates.
|
|
2832
|
-
*/
|
|
2833
|
-
export interface PerpetualsWsUpdatesOrderbookPayload {
|
|
2834
|
-
marketId: PerpetualsMarketId;
|
|
2835
|
-
orderbookDeltas: PerpetualsOrderbookDeltas;
|
|
2836
|
-
}
|
|
2837
|
-
/**
|
|
2838
|
-
* Websocket payload for user account and stop-order updates.
|
|
2839
|
-
*/
|
|
2840
|
-
export interface PerpetualsWsUpdatesUserPayload {
|
|
2841
|
-
account: PerpetualsAccountObject;
|
|
2842
|
-
stopOrders: PerpetualsStopOrderData[] | undefined;
|
|
539
|
+
slPrice: PerpetualsOrderPrice;
|
|
540
|
+
tpPrice: PerpetualsOrderPrice;
|
|
541
|
+
});
|
|
542
|
+
export interface ApiPerpetualsMarket24hrVolumeResponse {
|
|
543
|
+
volumeBaseAssetAmount: number;
|
|
544
|
+
volumeUsd: number;
|
|
2843
545
|
}
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
*/
|
|
2848
|
-
export interface PerpetualsWsUpdatesSubscriptionMessage {
|
|
2849
|
-
action: PerpetualsWsUpdatesSubscriptionAction;
|
|
2850
|
-
subscriptionType: PerpetualsWsUpdatesSubscriptionType;
|
|
546
|
+
export interface ApiPerpetualsMarket24hrVolumeResponse {
|
|
547
|
+
volumeUsd: number;
|
|
548
|
+
volumeBaseAssetAmount: number;
|
|
2851
549
|
}
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
market: PerpetualsMarketData;
|
|
2859
|
-
} | {
|
|
2860
|
-
user: PerpetualsWsUpdatesUserPayload;
|
|
550
|
+
export type SdkPerpetualsMarketOrderInputs = Omit<ApiPerpetualsMarketOrderBody, "accountObjectId" | "accountObjectVersion" | "accountObjectDigest">;
|
|
551
|
+
export type SdkPerpetualsLimitOrderInputs = Omit<ApiPerpetualsLimitOrderBody, "accountObjectId" | "accountObjectVersion" | "accountObjectDigest">;
|
|
552
|
+
export type SdkPerpetualsSLTPOrderInputs = ((SdkPerpetualsMarketOrderInputs & {
|
|
553
|
+
marketPrice: PerpetualsOrderPrice;
|
|
554
|
+
}) | SdkPerpetualsLimitOrderInputs) & ({
|
|
555
|
+
slPrice: PerpetualsOrderPrice;
|
|
2861
556
|
} | {
|
|
2862
|
-
|
|
557
|
+
tpPrice: PerpetualsOrderPrice;
|
|
2863
558
|
} | {
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
559
|
+
slPrice: PerpetualsOrderPrice;
|
|
560
|
+
tpPrice: PerpetualsOrderPrice;
|
|
561
|
+
});
|
|
562
|
+
export declare const perpetualsRegistry: {
|
|
563
|
+
Account: import("@mysten/sui/bcs").BcsStruct<{
|
|
564
|
+
id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
565
|
+
accountId: BcsType<string, string | number | bigint, "u64">;
|
|
566
|
+
collateral: import("@mysten/sui/bcs").BcsStruct<{
|
|
567
|
+
value: BcsType<string, string | number | bigint, "u64">;
|
|
568
|
+
}, string>;
|
|
569
|
+
}, string>;
|
|
570
|
+
AdminCapability: import("@mysten/sui/bcs").BcsStruct<{
|
|
571
|
+
id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
572
|
+
}, string>;
|
|
573
|
+
BalanceStruct: import("@mysten/sui/bcs").BcsStruct<{
|
|
574
|
+
value: BcsType<string, string | number | bigint, "u64">;
|
|
575
|
+
}, string>;
|
|
576
|
+
Coin: import("@mysten/sui/bcs").BcsStruct<{
|
|
577
|
+
id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
578
|
+
balance: import("@mysten/sui/bcs").BcsStruct<{
|
|
579
|
+
value: BcsType<string, string | number | bigint, "u64">;
|
|
580
|
+
}, string>;
|
|
581
|
+
}, string>;
|
|
582
|
+
Field: typeof Field;
|
|
583
|
+
MarketKey: import("@mysten/sui/bcs").BcsStruct<{
|
|
584
|
+
marketId: BcsType<string, string | number | bigint, "u64">;
|
|
585
|
+
}, string>;
|
|
586
|
+
OrderInfo: import("@mysten/sui/bcs").BcsStruct<{
|
|
587
|
+
price: BcsType<string, string | number | bigint, "u64">;
|
|
588
|
+
size: BcsType<string, string | number | bigint, "u64">;
|
|
589
|
+
}, string>;
|
|
590
|
+
Position: import("@mysten/sui/bcs").BcsStruct<{
|
|
591
|
+
collateral: BcsType<string, string | number | bigint, "u256">;
|
|
592
|
+
baseAssetAmount: BcsType<string, string | number | bigint, "u256">;
|
|
593
|
+
quoteAssetNotionalAmount: BcsType<string, string | number | bigint, "u256">;
|
|
594
|
+
cumFundingRateLong: BcsType<string, string | number | bigint, "u256">;
|
|
595
|
+
cumFundingRateShort: BcsType<string, string | number | bigint, "u256">;
|
|
596
|
+
asksQuantity: BcsType<string, string | number | bigint, "u256">;
|
|
597
|
+
bidsQuantity: BcsType<string, string | number | bigint, "u256">;
|
|
598
|
+
pendingOrders: BcsType<string, string | number | bigint, "u64">;
|
|
599
|
+
makerFee: BcsType<string, string | number | bigint, "u256">;
|
|
600
|
+
takerFee: BcsType<string, string | number | bigint, "u256">;
|
|
601
|
+
}, string>;
|
|
602
|
+
PositionKey: import("@mysten/sui/bcs").BcsStruct<{
|
|
603
|
+
accountId: BcsType<string, string | number | bigint, "u64">;
|
|
604
|
+
}, string>;
|
|
605
|
+
Registry: import("@mysten/sui/bcs").BcsStruct<{
|
|
606
|
+
id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
607
|
+
activeCollaterals: BcsType<string[], Iterable<string> & {
|
|
608
|
+
length: number;
|
|
609
|
+
}, string>;
|
|
610
|
+
nextAccountId: BcsType<string, string | number | bigint, "u64">;
|
|
611
|
+
}, string>;
|
|
612
|
+
Vault: import("@mysten/sui/bcs").BcsStruct<{
|
|
613
|
+
id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
614
|
+
collateral_balance: import("@mysten/sui/bcs").BcsStruct<{
|
|
615
|
+
value: BcsType<string, string | number | bigint, "u64">;
|
|
616
|
+
}, string>;
|
|
617
|
+
insurance_fund_balance: import("@mysten/sui/bcs").BcsStruct<{
|
|
618
|
+
value: BcsType<string, string | number | bigint, "u64">;
|
|
619
|
+
}, string>;
|
|
620
|
+
scalingFactor: BcsType<string, string | number | bigint, "u64">;
|
|
621
|
+
}, string>;
|
|
2871
622
|
};
|
|
2872
|
-
|
|
2873
|
-
* Websocket response message carrying the last candle for a given market
|
|
2874
|
-
* and interval.
|
|
2875
|
-
*/
|
|
2876
|
-
export interface PerpetualsWsCandleResponseMessage {
|
|
2877
|
-
marketId: PerpetualsMarketId;
|
|
2878
|
-
lastCandle: PerpetualsMarketCandleDataPoint | undefined;
|
|
2879
|
-
}
|
|
623
|
+
export {};
|
|
2880
624
|
//# sourceMappingURL=perpetualsTypes.d.ts.map
|