@win-trader/bindings 0.0.1
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/config-manager/dist/index.d.ts +766 -0
- package/config-manager/dist/index.js +313 -0
- package/mock-token/dist/index.d.ts +1448 -0
- package/mock-token/dist/index.js +635 -0
- package/oracle/dist/index.d.ts +421 -0
- package/oracle/dist/index.js +140 -0
- package/oracle-router/dist/index.d.ts +487 -0
- package/oracle-router/dist/index.js +186 -0
- package/package.json +36 -0
- package/position-manager/dist/index.d.ts +709 -0
- package/position-manager/dist/index.js +256 -0
- package/vault/dist/index.d.ts +1914 -0
- package/vault/dist/index.js +776 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { Buffer } from "buffer";
|
|
2
|
+
import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions } from "@stellar/stellar-sdk/contract";
|
|
3
|
+
import type { u32, u64, i128 } from "@stellar/stellar-sdk/contract";
|
|
4
|
+
export * from "@stellar/stellar-sdk";
|
|
5
|
+
export * as contract from "@stellar/stellar-sdk/contract";
|
|
6
|
+
export * as rpc from "@stellar/stellar-sdk/rpc";
|
|
7
|
+
export declare const PositionManagerError: {
|
|
8
|
+
1: {
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
2: {
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
3: {
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* New trade would push vault utilization past MaxUtilizationRatio (85%).
|
|
19
|
+
*/
|
|
20
|
+
4: {
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* decrease_position called before MinPositionLifetime has elapsed.
|
|
25
|
+
*/
|
|
26
|
+
5: {
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
6: {
|
|
30
|
+
message: string;
|
|
31
|
+
};
|
|
32
|
+
7: {
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
8: {
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* liquidate_position called but the position is still healthy.
|
|
40
|
+
*/
|
|
41
|
+
9: {
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* deleverage_position called but ADL trigger conditions are not met.
|
|
46
|
+
*/
|
|
47
|
+
10: {
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Position leverage exceeds the per-market max leverage.
|
|
52
|
+
*/
|
|
53
|
+
11: {
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* No max leverage configured for this market symbol.
|
|
58
|
+
*/
|
|
59
|
+
12: {
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* execute_order called but neither TP nor SL trigger condition is met.
|
|
64
|
+
*/
|
|
65
|
+
13: {
|
|
66
|
+
message: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Invalid take-profit or stop-loss price for the position direction.
|
|
70
|
+
*/
|
|
71
|
+
14: {
|
|
72
|
+
message: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* increase_position called with `is_long` opposite to the existing position's direction.
|
|
76
|
+
*/
|
|
77
|
+
15: {
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Collateral below the protocol's min_collateral limit.
|
|
82
|
+
*/
|
|
83
|
+
16: {
|
|
84
|
+
message: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* ADL target position is not profitable (PnL <= 0).
|
|
88
|
+
*/
|
|
89
|
+
17: {
|
|
90
|
+
message: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Max leverage exceeds the absolute safety cap (200x).
|
|
94
|
+
*/
|
|
95
|
+
18: {
|
|
96
|
+
message: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Mark price at execution time exceeded the trader's `acceptable_price`.
|
|
100
|
+
*/
|
|
101
|
+
19: {
|
|
102
|
+
message: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* `set_max_leverage` called with a value below `MIN_LEVERAGE`. Use
|
|
106
|
+
* `disable_market` to take a market offline instead.
|
|
107
|
+
*/
|
|
108
|
+
20: {
|
|
109
|
+
message: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Trading is disabled for this market — `enable_market` re-opens it.
|
|
113
|
+
*/
|
|
114
|
+
21: {
|
|
115
|
+
message: string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* `decrease_position` called with `size_delta > pos.size`. Use
|
|
119
|
+
* `pos.size` (or simply close fully) instead of over-closing.
|
|
120
|
+
*/
|
|
121
|
+
22: {
|
|
122
|
+
message: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* `upgrade` rejected — no `propose_upgrade` was made before commit.
|
|
126
|
+
*/
|
|
127
|
+
23: {
|
|
128
|
+
message: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* `upgrade` rejected — timelock has not elapsed yet.
|
|
132
|
+
*/
|
|
133
|
+
24: {
|
|
134
|
+
message: string;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* `upgrade` rejected — `new_wasm_hash` does not match the proposed
|
|
138
|
+
* `PendingUpgrade.wasm_hash`.
|
|
139
|
+
*/
|
|
140
|
+
25: {
|
|
141
|
+
message: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
export type StorageKey = {
|
|
145
|
+
tag: "Initialized";
|
|
146
|
+
values: void;
|
|
147
|
+
} | {
|
|
148
|
+
tag: "VaultAddress";
|
|
149
|
+
values: void;
|
|
150
|
+
} | {
|
|
151
|
+
tag: "ConfigManager";
|
|
152
|
+
values: void;
|
|
153
|
+
} | {
|
|
154
|
+
tag: "OracleRouter";
|
|
155
|
+
values: void;
|
|
156
|
+
} | {
|
|
157
|
+
tag: "IsPaused";
|
|
158
|
+
values: void;
|
|
159
|
+
} | {
|
|
160
|
+
tag: "Version";
|
|
161
|
+
values: void;
|
|
162
|
+
} | {
|
|
163
|
+
tag: "RealizedPnl";
|
|
164
|
+
values: void;
|
|
165
|
+
} | {
|
|
166
|
+
tag: "TotalUnrealizedPnl";
|
|
167
|
+
values: void;
|
|
168
|
+
} | {
|
|
169
|
+
tag: "MarketUnrealizedPnl";
|
|
170
|
+
values: readonly [string];
|
|
171
|
+
} | {
|
|
172
|
+
tag: "FundingPool";
|
|
173
|
+
values: readonly [string];
|
|
174
|
+
} | {
|
|
175
|
+
tag: "LastUnpauseTime";
|
|
176
|
+
values: void;
|
|
177
|
+
} | {
|
|
178
|
+
tag: "LastPauseTime";
|
|
179
|
+
values: void;
|
|
180
|
+
} | {
|
|
181
|
+
tag: "MaxLeverage";
|
|
182
|
+
values: readonly [string];
|
|
183
|
+
} | {
|
|
184
|
+
tag: "MarketDisabled";
|
|
185
|
+
values: readonly [string];
|
|
186
|
+
} | {
|
|
187
|
+
tag: "Position";
|
|
188
|
+
values: readonly [PositionKey];
|
|
189
|
+
} | {
|
|
190
|
+
tag: "Market";
|
|
191
|
+
values: readonly [string];
|
|
192
|
+
} | {
|
|
193
|
+
tag: "MarketRegistry";
|
|
194
|
+
values: void;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Composite key for looking up a position by trader address and asset symbol.
|
|
198
|
+
*/
|
|
199
|
+
export interface PositionKey {
|
|
200
|
+
symbol: string;
|
|
201
|
+
trader: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Represents a single trader's open leveraged position.
|
|
205
|
+
*/
|
|
206
|
+
export interface Position {
|
|
207
|
+
/**
|
|
208
|
+
* USDC collateral deposited by the trader.
|
|
209
|
+
*/
|
|
210
|
+
collateral: i128;
|
|
211
|
+
/**
|
|
212
|
+
* Global borrow accumulator index at position open (for lazy fee calc).
|
|
213
|
+
*/
|
|
214
|
+
entry_borrow_index: i128;
|
|
215
|
+
/**
|
|
216
|
+
* Global funding accumulator index at position open (for lazy fee calc).
|
|
217
|
+
*/
|
|
218
|
+
entry_funding_index: i128;
|
|
219
|
+
/**
|
|
220
|
+
* Oracle price at the time the position was opened (scaled by 1e7).
|
|
221
|
+
*/
|
|
222
|
+
entry_price: i128;
|
|
223
|
+
/**
|
|
224
|
+
* Flat USDC fee escrowed when TP or SL is set. Paid to executor on trigger, refunded on user close / ADL, forfeited to revenue on liquidation.
|
|
225
|
+
*/
|
|
226
|
+
execution_fee_escrow: i128;
|
|
227
|
+
/**
|
|
228
|
+
* True for a long position, false for a short.
|
|
229
|
+
*/
|
|
230
|
+
is_long: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Block timestamp when the position was last increased (anti-front-running lock).
|
|
233
|
+
*/
|
|
234
|
+
last_increased_time: u64;
|
|
235
|
+
/**
|
|
236
|
+
* Notional size of the position in USDC.
|
|
237
|
+
*/
|
|
238
|
+
size: i128;
|
|
239
|
+
/**
|
|
240
|
+
* Stop-loss price (scaled by 1e7). 0 = not set.
|
|
241
|
+
*/
|
|
242
|
+
stop_loss: i128;
|
|
243
|
+
/**
|
|
244
|
+
* Take-profit price (scaled by 1e7). 0 = not set.
|
|
245
|
+
*/
|
|
246
|
+
take_profit: i128;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Global market state for a single tradeable asset symbol.
|
|
250
|
+
*/
|
|
251
|
+
export interface MarketInfo {
|
|
252
|
+
/**
|
|
253
|
+
* Cumulative borrow fee index (grows monotonically with time).
|
|
254
|
+
*/
|
|
255
|
+
acc_borrow_index: i128;
|
|
256
|
+
/**
|
|
257
|
+
* Cumulative funding rate index (signed; positive = longs pay shorts).
|
|
258
|
+
*/
|
|
259
|
+
acc_funding_index: i128;
|
|
260
|
+
/**
|
|
261
|
+
* Volume-weighted average entry price of all active long positions.
|
|
262
|
+
*/
|
|
263
|
+
global_long_avg_price: i128;
|
|
264
|
+
/**
|
|
265
|
+
* Volume-weighted average entry price of all active short positions.
|
|
266
|
+
*/
|
|
267
|
+
global_short_avg_price: i128;
|
|
268
|
+
/**
|
|
269
|
+
* Timestamp of the last keeper index update.
|
|
270
|
+
*/
|
|
271
|
+
last_index_update: u64;
|
|
272
|
+
/**
|
|
273
|
+
* Total notional size of all open long positions.
|
|
274
|
+
*/
|
|
275
|
+
long_open_interest: i128;
|
|
276
|
+
/**
|
|
277
|
+
* Total notional size of all open short positions.
|
|
278
|
+
*/
|
|
279
|
+
short_open_interest: i128;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Global safety thresholds for price validation.
|
|
283
|
+
*/
|
|
284
|
+
export interface OracleConfig {
|
|
285
|
+
/**
|
|
286
|
+
* How long a cached aggregated price remains valid (in seconds). A
|
|
287
|
+
* `get_price` call within this window of the last fetch returns the
|
|
288
|
+
* cached value without re-querying sources. Must be > 0 and
|
|
289
|
+
* <= `staleness_threshold` (otherwise the cache could outlive a fresh
|
|
290
|
+
* source price and serve stale data).
|
|
291
|
+
*/
|
|
292
|
+
cache_duration: u64;
|
|
293
|
+
/**
|
|
294
|
+
* Maximum allowed spread between oracle sources in basis points
|
|
295
|
+
* (e.g., 100 = 1%). Bounded at `shared::constants::MAX_DEVIATION_BPS_CEILING`.
|
|
296
|
+
*/
|
|
297
|
+
max_deviation_bps: i128;
|
|
298
|
+
/**
|
|
299
|
+
* Minimum number of source responses that must agree within
|
|
300
|
+
* `max_deviation_bps` for OracleRouter to return a price. Floored at
|
|
301
|
+
* `shared::constants::MIN_REQUIRED_SOURCES_FLOOR`, ceilinged at
|
|
302
|
+
* `shared::constants::MAX_ORACLE_SOURCES`.
|
|
303
|
+
*/
|
|
304
|
+
min_required_sources: u32;
|
|
305
|
+
/**
|
|
306
|
+
* Maximum age of an external SEP-40 price feed before it is rejected
|
|
307
|
+
* as stale (in seconds).
|
|
308
|
+
*/
|
|
309
|
+
staleness_threshold: u64;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Data required during a WASM migration. Single definition for all contracts.
|
|
313
|
+
*/
|
|
314
|
+
export interface MigrationData {
|
|
315
|
+
version: u32;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Pending WASM upgrade — set by `propose_upgrade`, consumed by `upgrade`
|
|
319
|
+
* (cleared atomically on a successful install), or cleared by `cancel_upgrade`.
|
|
320
|
+
* Single shape across every protocol contract; all four contracts store it at
|
|
321
|
+
* the shared `pending_upgrade` Symbol key in their own instance storage (see
|
|
322
|
+
* `interfaces::upgrade::pending_upgrade_key`). `upgrade` refuses to install
|
|
323
|
+
* unless `pending.wasm_hash` matches the supplied hash and `now >= eta`.
|
|
324
|
+
*/
|
|
325
|
+
export interface PendingUpgrade {
|
|
326
|
+
eta: u64;
|
|
327
|
+
wasm_hash: Buffer;
|
|
328
|
+
}
|
|
329
|
+
export declare const UpgradeableError: {
|
|
330
|
+
/**
|
|
331
|
+
* When migration is attempted but not allowed due to upgrade state.
|
|
332
|
+
*/
|
|
333
|
+
1100: {
|
|
334
|
+
message: string;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
export declare const MerkleDistributorError: {
|
|
338
|
+
/**
|
|
339
|
+
* The merkle root is not set.
|
|
340
|
+
*/
|
|
341
|
+
1300: {
|
|
342
|
+
message: string;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* The provided index was already claimed.
|
|
346
|
+
*/
|
|
347
|
+
1301: {
|
|
348
|
+
message: string;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* The proof is invalid.
|
|
352
|
+
*/
|
|
353
|
+
1302: {
|
|
354
|
+
message: string;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Storage keys for the data associated with `MerkleDistributor`
|
|
359
|
+
*/
|
|
360
|
+
export type MerkleDistributorStorageKey = {
|
|
361
|
+
tag: "Root";
|
|
362
|
+
values: void;
|
|
363
|
+
} | {
|
|
364
|
+
tag: "Claimed";
|
|
365
|
+
values: readonly [u32];
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Rounding direction for division operations
|
|
369
|
+
*/
|
|
370
|
+
export type Rounding = {
|
|
371
|
+
tag: "Floor";
|
|
372
|
+
values: void;
|
|
373
|
+
} | {
|
|
374
|
+
tag: "Ceil";
|
|
375
|
+
values: void;
|
|
376
|
+
} | {
|
|
377
|
+
tag: "Truncate";
|
|
378
|
+
values: void;
|
|
379
|
+
};
|
|
380
|
+
export declare const SorobanFixedPointError: {
|
|
381
|
+
/**
|
|
382
|
+
* Arithmetic overflow occurred
|
|
383
|
+
*/
|
|
384
|
+
1500: {
|
|
385
|
+
message: string;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Division by zero
|
|
389
|
+
*/
|
|
390
|
+
1501: {
|
|
391
|
+
message: string;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
export declare const CryptoError: {
|
|
395
|
+
/**
|
|
396
|
+
* The merkle proof length is out of bounds.
|
|
397
|
+
*/
|
|
398
|
+
1400: {
|
|
399
|
+
message: string;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* The index of the leaf is out of bounds.
|
|
403
|
+
*/
|
|
404
|
+
1401: {
|
|
405
|
+
message: string;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* No data in hasher state.
|
|
409
|
+
*/
|
|
410
|
+
1402: {
|
|
411
|
+
message: string;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
export declare const PausableError: {
|
|
415
|
+
/**
|
|
416
|
+
* The operation failed because the contract is paused.
|
|
417
|
+
*/
|
|
418
|
+
1000: {
|
|
419
|
+
message: string;
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* The operation failed because the contract is not paused.
|
|
423
|
+
*/
|
|
424
|
+
1001: {
|
|
425
|
+
message: string;
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Storage key for the pausable state
|
|
430
|
+
*/
|
|
431
|
+
export type PausableStorageKey = {
|
|
432
|
+
tag: "Paused";
|
|
433
|
+
values: void;
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* Execution-bounty and open-fee parameters charged to traders.
|
|
437
|
+
* `open_fee_bps` and `liquidation_bounty_bps` are in basis points;
|
|
438
|
+
* `tp_sl_execution_fee` is a flat USDC amount at PRECISION scale.
|
|
439
|
+
*/
|
|
440
|
+
export interface FeeConfig {
|
|
441
|
+
liquidation_bounty_bps: u32;
|
|
442
|
+
open_fee_bps: u32;
|
|
443
|
+
tp_sl_execution_fee: i128;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Defines how protocol revenue is split between parties.
|
|
447
|
+
* All values are in basis points (bps). Must sum to 10_000.
|
|
448
|
+
*/
|
|
449
|
+
export interface FeeSplits {
|
|
450
|
+
dev_bps: u32;
|
|
451
|
+
lp_bps: u32;
|
|
452
|
+
staker_bps: u32;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Global protocol risk and timing parameters.
|
|
456
|
+
*/
|
|
457
|
+
export interface ProtocolLimits {
|
|
458
|
+
adl_pnl_bps: u32;
|
|
459
|
+
adl_utilization_bps: u32;
|
|
460
|
+
cooldown_duration: u64;
|
|
461
|
+
funding_cut_bps: u32;
|
|
462
|
+
liquidation_threshold_bps: u32;
|
|
463
|
+
max_utilization_ratio: i128;
|
|
464
|
+
min_collateral: i128;
|
|
465
|
+
min_position_lifetime: u64;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Borrow rate kink curve and funding rate parameters (all in basis points).
|
|
469
|
+
*/
|
|
470
|
+
export interface BorrowRateConfig {
|
|
471
|
+
base_borrow_rate_bps: i128;
|
|
472
|
+
base_funding_rate_bps: i128;
|
|
473
|
+
optimal_utilization_bps: i128;
|
|
474
|
+
slope1_bps: i128;
|
|
475
|
+
slope2_bps: i128;
|
|
476
|
+
}
|
|
477
|
+
export interface Client {
|
|
478
|
+
/**
|
|
479
|
+
* Construct and simulate a pause transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
480
|
+
*/
|
|
481
|
+
pause: ({ caller }: {
|
|
482
|
+
caller: string;
|
|
483
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
484
|
+
/**
|
|
485
|
+
* Construct and simulate a migrate transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
486
|
+
*/
|
|
487
|
+
migrate: ({ migration_data, operator }: {
|
|
488
|
+
migration_data: MigrationData;
|
|
489
|
+
operator: string;
|
|
490
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
491
|
+
/**
|
|
492
|
+
* Construct and simulate a unpause transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
493
|
+
*/
|
|
494
|
+
unpause: ({ caller }: {
|
|
495
|
+
caller: string;
|
|
496
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
497
|
+
/**
|
|
498
|
+
* Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
499
|
+
*/
|
|
500
|
+
upgrade: ({ new_wasm_hash, operator }: {
|
|
501
|
+
new_wasm_hash: Buffer;
|
|
502
|
+
operator: string;
|
|
503
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
504
|
+
/**
|
|
505
|
+
* Construct and simulate a set_tp_sl transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
506
|
+
*/
|
|
507
|
+
set_tp_sl: ({ trader, symbol, take_profit, stop_loss }: {
|
|
508
|
+
trader: string;
|
|
509
|
+
symbol: string;
|
|
510
|
+
take_profit: i128;
|
|
511
|
+
stop_loss: i128;
|
|
512
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
513
|
+
/**
|
|
514
|
+
* Construct and simulate a set_vault transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
515
|
+
* Wire the linked Vault. ADMIN-only and one-shot: reverts with
|
|
516
|
+
* `AlreadyInitialized` once the Vault is set, so the trusted Vault link
|
|
517
|
+
* is immutable after deploy. Called once by the deployer immediately
|
|
518
|
+
* after the Vault is deployed.
|
|
519
|
+
*/
|
|
520
|
+
set_vault: ({ caller, vault_address }: {
|
|
521
|
+
caller: string;
|
|
522
|
+
vault_address: string;
|
|
523
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
524
|
+
/**
|
|
525
|
+
* Construct and simulate a get_market transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
526
|
+
*/
|
|
527
|
+
get_market: ({ symbol }: {
|
|
528
|
+
symbol: string;
|
|
529
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<MarketInfo>>;
|
|
530
|
+
/**
|
|
531
|
+
* Construct and simulate a get_position transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
532
|
+
*/
|
|
533
|
+
get_position: ({ trader, symbol }: {
|
|
534
|
+
trader: string;
|
|
535
|
+
symbol: string;
|
|
536
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<Position>>;
|
|
537
|
+
/**
|
|
538
|
+
* Construct and simulate a realized_pnl transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
539
|
+
*/
|
|
540
|
+
realized_pnl: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
|
|
541
|
+
/**
|
|
542
|
+
* Construct and simulate a bump_position transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
543
|
+
*/
|
|
544
|
+
bump_position: ({ user_address, symbol }: {
|
|
545
|
+
user_address: string;
|
|
546
|
+
symbol: string;
|
|
547
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
548
|
+
/**
|
|
549
|
+
* Construct and simulate a enable_market transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
550
|
+
*/
|
|
551
|
+
enable_market: ({ caller, symbol }: {
|
|
552
|
+
caller: string;
|
|
553
|
+
symbol: string;
|
|
554
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
555
|
+
/**
|
|
556
|
+
* Construct and simulate a execute_order transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
557
|
+
*/
|
|
558
|
+
execute_order: ({ caller, trader, symbol }: {
|
|
559
|
+
caller: string;
|
|
560
|
+
trader: string;
|
|
561
|
+
symbol: string;
|
|
562
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
563
|
+
/**
|
|
564
|
+
* Construct and simulate a cancel_upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
565
|
+
*/
|
|
566
|
+
cancel_upgrade: ({ caller }: {
|
|
567
|
+
caller: string;
|
|
568
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
569
|
+
/**
|
|
570
|
+
* Construct and simulate a disable_market transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
571
|
+
*/
|
|
572
|
+
disable_market: ({ caller, symbol }: {
|
|
573
|
+
caller: string;
|
|
574
|
+
symbol: string;
|
|
575
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
576
|
+
/**
|
|
577
|
+
* Construct and simulate a update_indices transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
578
|
+
*/
|
|
579
|
+
update_indices: ({ caller, symbol }: {
|
|
580
|
+
caller: string;
|
|
581
|
+
symbol: string;
|
|
582
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
583
|
+
/**
|
|
584
|
+
* Construct and simulate a propose_upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
585
|
+
*/
|
|
586
|
+
propose_upgrade: ({ caller, wasm_hash }: {
|
|
587
|
+
caller: string;
|
|
588
|
+
wasm_hash: Buffer;
|
|
589
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
590
|
+
/**
|
|
591
|
+
* Construct and simulate a get_max_leverage transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
592
|
+
*/
|
|
593
|
+
get_max_leverage: ({ symbol }: {
|
|
594
|
+
symbol: string;
|
|
595
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
|
|
596
|
+
/**
|
|
597
|
+
* Construct and simulate a set_max_leverage transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
598
|
+
*/
|
|
599
|
+
set_max_leverage: ({ caller, symbol, max_leverage }: {
|
|
600
|
+
caller: string;
|
|
601
|
+
symbol: string;
|
|
602
|
+
max_leverage: i128;
|
|
603
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
604
|
+
/**
|
|
605
|
+
* Construct and simulate a decrease_position transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
606
|
+
*/
|
|
607
|
+
decrease_position: ({ trader, symbol, size_delta, acceptable_price }: {
|
|
608
|
+
trader: string;
|
|
609
|
+
symbol: string;
|
|
610
|
+
size_delta: i128;
|
|
611
|
+
acceptable_price: i128;
|
|
612
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
613
|
+
/**
|
|
614
|
+
* Construct and simulate a increase_position transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
615
|
+
*/
|
|
616
|
+
increase_position: ({ trader, symbol, size, collateral, is_long, take_profit, stop_loss, acceptable_price }: {
|
|
617
|
+
trader: string;
|
|
618
|
+
symbol: string;
|
|
619
|
+
size: i128;
|
|
620
|
+
collateral: i128;
|
|
621
|
+
is_long: boolean;
|
|
622
|
+
take_profit: i128;
|
|
623
|
+
stop_loss: i128;
|
|
624
|
+
acceptable_price: i128;
|
|
625
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
626
|
+
/**
|
|
627
|
+
* Construct and simulate a is_market_disabled transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
628
|
+
*/
|
|
629
|
+
is_market_disabled: ({ symbol }: {
|
|
630
|
+
symbol: string;
|
|
631
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
|
|
632
|
+
/**
|
|
633
|
+
* Construct and simulate a liquidate_position transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
634
|
+
*/
|
|
635
|
+
liquidate_position: ({ caller, trader, symbol }: {
|
|
636
|
+
caller: string;
|
|
637
|
+
trader: string;
|
|
638
|
+
symbol: string;
|
|
639
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
640
|
+
/**
|
|
641
|
+
* Construct and simulate a deleverage_position transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
642
|
+
*/
|
|
643
|
+
deleverage_position: ({ caller, trader, symbol }: {
|
|
644
|
+
caller: string;
|
|
645
|
+
trader: string;
|
|
646
|
+
symbol: string;
|
|
647
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
648
|
+
/**
|
|
649
|
+
* Construct and simulate a sync_unrealized_pnl transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
650
|
+
*/
|
|
651
|
+
sync_unrealized_pnl: (options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
652
|
+
/**
|
|
653
|
+
* Construct and simulate a total_unrealized_pnl transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
654
|
+
*/
|
|
655
|
+
total_unrealized_pnl: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
|
|
656
|
+
/**
|
|
657
|
+
* Construct and simulate a market_unrealized_pnl transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.
|
|
658
|
+
*/
|
|
659
|
+
market_unrealized_pnl: ({ symbol }: {
|
|
660
|
+
symbol: string;
|
|
661
|
+
}, options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
|
|
662
|
+
}
|
|
663
|
+
export declare class Client extends ContractClient {
|
|
664
|
+
readonly options: ContractClientOptions;
|
|
665
|
+
static deploy<T = Client>(
|
|
666
|
+
/** Constructor/Initialization Args for the contract's `__constructor` method */
|
|
667
|
+
{ config_manager, oracle_router }: {
|
|
668
|
+
config_manager: string;
|
|
669
|
+
oracle_router: string;
|
|
670
|
+
},
|
|
671
|
+
/** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
|
|
672
|
+
options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
|
|
673
|
+
/** The hash of the Wasm blob, which must already be installed on-chain. */
|
|
674
|
+
wasmHash: Buffer | string;
|
|
675
|
+
/** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
|
|
676
|
+
salt?: Buffer | Uint8Array;
|
|
677
|
+
/** The format used to decode `wasmHash`, if it's provided as a string. */
|
|
678
|
+
format?: "hex" | "base64";
|
|
679
|
+
}): Promise<AssembledTransaction<T>>;
|
|
680
|
+
constructor(options: ContractClientOptions);
|
|
681
|
+
readonly fromJSON: {
|
|
682
|
+
pause: (json: string) => AssembledTransaction<null>;
|
|
683
|
+
migrate: (json: string) => AssembledTransaction<null>;
|
|
684
|
+
unpause: (json: string) => AssembledTransaction<null>;
|
|
685
|
+
upgrade: (json: string) => AssembledTransaction<null>;
|
|
686
|
+
set_tp_sl: (json: string) => AssembledTransaction<null>;
|
|
687
|
+
set_vault: (json: string) => AssembledTransaction<null>;
|
|
688
|
+
get_market: (json: string) => AssembledTransaction<MarketInfo>;
|
|
689
|
+
get_position: (json: string) => AssembledTransaction<Position>;
|
|
690
|
+
realized_pnl: (json: string) => AssembledTransaction<bigint>;
|
|
691
|
+
bump_position: (json: string) => AssembledTransaction<null>;
|
|
692
|
+
enable_market: (json: string) => AssembledTransaction<null>;
|
|
693
|
+
execute_order: (json: string) => AssembledTransaction<null>;
|
|
694
|
+
cancel_upgrade: (json: string) => AssembledTransaction<null>;
|
|
695
|
+
disable_market: (json: string) => AssembledTransaction<null>;
|
|
696
|
+
update_indices: (json: string) => AssembledTransaction<null>;
|
|
697
|
+
propose_upgrade: (json: string) => AssembledTransaction<null>;
|
|
698
|
+
get_max_leverage: (json: string) => AssembledTransaction<bigint>;
|
|
699
|
+
set_max_leverage: (json: string) => AssembledTransaction<null>;
|
|
700
|
+
decrease_position: (json: string) => AssembledTransaction<null>;
|
|
701
|
+
increase_position: (json: string) => AssembledTransaction<null>;
|
|
702
|
+
is_market_disabled: (json: string) => AssembledTransaction<boolean>;
|
|
703
|
+
liquidate_position: (json: string) => AssembledTransaction<null>;
|
|
704
|
+
deleverage_position: (json: string) => AssembledTransaction<null>;
|
|
705
|
+
sync_unrealized_pnl: (json: string) => AssembledTransaction<null>;
|
|
706
|
+
total_unrealized_pnl: (json: string) => AssembledTransaction<bigint>;
|
|
707
|
+
market_unrealized_pnl: (json: string) => AssembledTransaction<bigint>;
|
|
708
|
+
};
|
|
709
|
+
}
|