@win-trader/bindings 0.0.1 → 0.0.3

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.
@@ -14,15 +14,9 @@ export declare const PositionManagerError: {
14
14
  3: {
15
15
  message: string;
16
16
  };
17
- /**
18
- * New trade would push vault utilization past MaxUtilizationRatio (85%).
19
- */
20
17
  4: {
21
18
  message: string;
22
19
  };
23
- /**
24
- * decrease_position called before MinPositionLifetime has elapsed.
25
- */
26
20
  5: {
27
21
  message: string;
28
22
  };
@@ -35,271 +29,371 @@ export declare const PositionManagerError: {
35
29
  8: {
36
30
  message: string;
37
31
  };
38
- /**
39
- * liquidate_position called but the position is still healthy.
40
- */
41
32
  9: {
42
33
  message: string;
43
34
  };
44
- /**
45
- * deleverage_position called but ADL trigger conditions are not met.
46
- */
47
35
  10: {
48
36
  message: string;
49
37
  };
50
- /**
51
- * Position leverage exceeds the per-market max leverage.
52
- */
53
38
  11: {
54
39
  message: string;
55
40
  };
56
- /**
57
- * No max leverage configured for this market symbol.
58
- */
59
41
  12: {
60
42
  message: string;
61
43
  };
62
- /**
63
- * execute_order called but neither TP nor SL trigger condition is met.
64
- */
65
44
  13: {
66
45
  message: string;
67
46
  };
68
- /**
69
- * Invalid take-profit or stop-loss price for the position direction.
70
- */
71
47
  14: {
72
48
  message: string;
73
49
  };
74
- /**
75
- * increase_position called with `is_long` opposite to the existing position's direction.
76
- */
77
50
  15: {
78
51
  message: string;
79
52
  };
80
- /**
81
- * Collateral below the protocol's min_collateral limit.
82
- */
83
53
  16: {
84
54
  message: string;
85
55
  };
86
- /**
87
- * ADL target position is not profitable (PnL <= 0).
88
- */
89
56
  17: {
90
57
  message: string;
91
58
  };
92
- /**
93
- * Max leverage exceeds the absolute safety cap (200x).
94
- */
95
59
  18: {
96
60
  message: string;
97
61
  };
98
- /**
99
- * Mark price at execution time exceeded the trader's `acceptable_price`.
100
- */
101
62
  19: {
102
63
  message: string;
103
64
  };
104
- /**
105
- * `set_max_leverage` called with a value below `MIN_LEVERAGE`. Use
106
- * `disable_market` to take a market offline instead.
107
- */
108
65
  20: {
109
66
  message: string;
110
67
  };
111
68
  /**
112
- * Trading is disabled for this market — `enable_market` re-opens it.
69
+ * The contract is operationally paused (distinct from a risk state).
113
70
  */
114
71
  21: {
115
72
  message: string;
116
73
  };
117
74
  /**
118
- * `decrease_position` called with `size_delta > pos.size`. Use
119
- * `pos.size` (or simply close fully) instead of over-closing.
75
+ * An accounting invariant broke — e.g. a negative pending fee, which
76
+ * means a decreasing index or corrupted debt baseline (§11.2).
120
77
  */
121
78
  22: {
122
79
  message: string;
123
80
  };
124
81
  /**
125
- * `upgrade` rejected — no `propose_upgrade` was made before commit.
82
+ * `upgrade` called with no pending proposal.
126
83
  */
127
84
  23: {
128
85
  message: string;
129
86
  };
130
87
  /**
131
- * `upgrade` rejected — timelock has not elapsed yet.
88
+ * `upgrade` called before the proposal's timelock eta.
132
89
  */
133
90
  24: {
134
91
  message: string;
135
92
  };
136
93
  /**
137
- * `upgrade` rejected — `new_wasm_hash` does not match the proposed
138
- * `PendingUpgrade.wasm_hash`.
94
+ * `upgrade` called with a hash that differs from the proposal.
139
95
  */
140
96
  25: {
141
97
  message: string;
142
98
  };
143
99
  };
144
- export type StorageKey = {
145
- tag: "Initialized";
100
+ /**
101
+ * Which collection routed revenue through the split (§13).
102
+ */
103
+ export type FeeSource = {
104
+ tag: "Opening";
146
105
  values: void;
147
106
  } | {
148
- tag: "VaultAddress";
107
+ tag: "Borrow";
108
+ values: void;
109
+ };
110
+ /**
111
+ * Why a position left the book.
112
+ */
113
+ export type CloseReason = {
114
+ tag: "Trader";
149
115
  values: void;
150
116
  } | {
151
- tag: "ConfigManager";
117
+ tag: "Liquidation";
152
118
  values: void;
153
119
  } | {
154
- tag: "OracleRouter";
120
+ tag: "Deleverage";
155
121
  values: void;
156
122
  } | {
157
- tag: "IsPaused";
123
+ tag: "Order";
124
+ values: void;
125
+ };
126
+ /**
127
+ * §5.1 global state: the five non-LP claim totals, the risk counters, and
128
+ * the global accrual state (borrow index + receiver-funding flow).
129
+ */
130
+ export interface Ledger {
131
+ borrow_index: i128;
132
+ borrow_index_remainder: i128;
133
+ /**
134
+ * `INDEX_PRECISION`-scaled bps/day rate for the current interval.
135
+ */
136
+ current_borrow_rate: i128;
137
+ execution_budget_total: i128;
138
+ last_global_checkpoint: u64;
139
+ lp_blocked_side_count: u32;
140
+ open_position_count: u64;
141
+ pending_receiver_funding_total: i128;
142
+ position_collateral_total: i128;
143
+ protocol_claimable_total: i128;
144
+ receiver_accrual_remainder: i128;
145
+ /**
146
+ * Sum of every market's receiver flow, cash/second at `INDEX_PRECISION`.
147
+ */
148
+ receiver_flow_per_second: i128;
149
+ risk_keeper_reserve_total: i128;
150
+ total_risk_units: i128;
151
+ }
152
+ export type Key = {
153
+ tag: "ConfigManager";
158
154
  values: void;
159
155
  } | {
160
- tag: "Version";
156
+ tag: "OracleRouter";
161
157
  values: void;
162
158
  } | {
163
- tag: "RealizedPnl";
159
+ tag: "Vault";
164
160
  values: void;
165
161
  } | {
166
- tag: "TotalUnrealizedPnl";
162
+ tag: "GlobalConfig";
167
163
  values: void;
168
164
  } | {
169
- tag: "MarketUnrealizedPnl";
170
- values: readonly [string];
165
+ tag: "Initialized";
166
+ values: void;
171
167
  } | {
172
- tag: "FundingPool";
173
- values: readonly [string];
168
+ tag: "Paused";
169
+ values: void;
174
170
  } | {
175
- tag: "LastUnpauseTime";
171
+ tag: "NextPositionId";
176
172
  values: void;
177
173
  } | {
178
- tag: "LastPauseTime";
174
+ tag: "ActiveMarkets";
179
175
  values: void;
180
176
  } | {
181
- tag: "MaxLeverage";
182
- values: readonly [string];
177
+ tag: "Ledger";
178
+ values: void;
183
179
  } | {
184
- tag: "MarketDisabled";
185
- values: readonly [string];
180
+ tag: "Version";
181
+ values: void;
186
182
  } | {
187
183
  tag: "Position";
188
- values: readonly [PositionKey];
184
+ values: readonly [u64];
189
185
  } | {
190
186
  tag: "Market";
191
187
  values: readonly [string];
192
188
  } | {
193
- tag: "MarketRegistry";
194
- values: void;
189
+ tag: "MarketDisabled";
190
+ values: readonly [string];
195
191
  };
196
192
  /**
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.
193
+ * Authoritative per-market state: the side aggregates, the funding indices,
194
+ * the current funding flows, and the market configuration.
195
+ *
196
+ * Soroban limits UDT field names to 30 characters, so where a doc glossary
197
+ * term is longer the field drops the redundant qualifier and its doc
198
+ * comment carries the full term (e.g. `receiver_backed_index_long` is the
199
+ * doc's `receiver_backed_payer_index` for the long side).
205
200
  */
206
- export interface Position {
201
+ export interface Market {
202
+ config: MarketConfig;
207
203
  /**
208
- * USDC collateral deposited by the trader.
204
+ * `INDEX_PRECISION`-scaled bps/day payer rate for the current interval.
209
205
  */
210
- collateral: i128;
206
+ current_payer_rate: i128;
207
+ current_payer_side: PayerSide;
208
+ last_funding_checkpoint: u64;
209
+ long: MarketSide;
211
210
  /**
212
- * Global borrow accumulator index at position open (for lazy fee calc).
211
+ * Cumulative payer fee per unit of dominant-side size that is LP
212
+ * revenue on collection (§8.2).
213
213
  */
214
- entry_borrow_index: i128;
214
+ lp_backed_index_long: i128;
215
+ lp_backed_index_short: i128;
215
216
  /**
216
- * Global funding accumulator index at position open (for lazy fee calc).
217
+ * LP-allocated remainder of the payer flow, cash/second at
218
+ * `INDEX_PRECISION` (§8.1).
217
219
  */
218
- entry_funding_index: i128;
220
+ lp_flow_per_second: i128;
221
+ lp_payer_remainder: i128;
219
222
  /**
220
- * Oracle price at the time the position was opened (scaled by 1e7).
223
+ * Cumulative payer fee per unit of dominant-side size whose collection
224
+ * restores cash backing an already-accrued receiver claim (§8.2).
221
225
  */
222
- entry_price: i128;
226
+ receiver_backed_index_long: i128;
227
+ receiver_backed_index_short: i128;
223
228
  /**
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.
229
+ * Receiver-allocated share of the payer flow, cash/second at
230
+ * `INDEX_PRECISION` (§8.1).
225
231
  */
226
- execution_fee_escrow: i128;
232
+ receiver_flow_per_second: i128;
233
+ receiver_flow_remainder: i128;
227
234
  /**
228
- * True for a long position, false for a short.
235
+ * Cumulative funding credit per unit of light-side size (§8.2).
229
236
  */
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;
237
+ receiver_index_long: i128;
238
+ receiver_index_remainder: i128;
239
+ receiver_index_short: i128;
240
+ receiver_payer_remainder: i128;
241
+ short: MarketSide;
242
+ }
243
+ export interface LpConfig {
244
+ lp_request_delay: u64;
245
+ max_withdraw_utilization_bps: u32;
246
+ min_deposit_nav_factor_bps: u32;
247
247
  }
248
248
  /**
249
- * Global market state for a single tradeable asset symbol.
249
+ * Represents a single trader's open leveraged position.
250
250
  */
251
- export interface MarketInfo {
251
+ export interface Position {
252
252
  /**
253
- * Cumulative borrow fee index (grows monotonically with time).
253
+ * Asset units at `PRICE_PRECISION`.
254
254
  */
255
- acc_borrow_index: i128;
255
+ base_exposure: i128;
256
+ borrow_debt: i128;
256
257
  /**
257
- * Cumulative funding rate index (signed; positive = longs pay shorts).
258
+ * Cash owned by an optional-order executor.
258
259
  */
259
- acc_funding_index: i128;
260
+ execution_budget: i128;
261
+ funding_paid_to_lps_debt: i128;
262
+ funding_paid_to_receivers_debt: i128;
263
+ funding_received_debt: i128;
264
+ id: u64;
265
+ is_long: boolean;
266
+ last_increased_time: u64;
267
+ market: string;
268
+ owner: string;
260
269
  /**
261
- * Volume-weighted average entry price of all active long positions.
270
+ * Fixed gross capacity assigned when risk opens.
262
271
  */
263
- global_long_avg_price: i128;
272
+ risk_units: i128;
264
273
  /**
265
- * Volume-weighted average entry price of all active short positions.
274
+ * USD notional at `PRICE_PRECISION`.
266
275
  */
267
- global_short_avg_price: i128;
276
+ size: i128;
268
277
  /**
269
- * Timestamp of the last keeper index update.
278
+ * Trigger price for the optional stop-loss order; `0` = none.
270
279
  */
271
- last_index_update: u64;
280
+ stop_loss: i128;
272
281
  /**
273
- * Total notional size of all open long positions.
282
+ * Trader-owned collateral recorded in contract state (the doc's
283
+ * "stored collateral"). Effective collateral — stored collateral after
284
+ * pending fees and funding credits — is always derived, never stored.
274
285
  */
275
- long_open_interest: i128;
286
+ stored_collateral: i128;
276
287
  /**
277
- * Total notional size of all open short positions.
288
+ * Trigger price for the optional take-profit order; `0` = none.
278
289
  */
279
- short_open_interest: i128;
290
+ take_profit: i128;
291
+ }
292
+ export interface LpRequest {
293
+ amount: i128;
294
+ execute_after: u64;
295
+ id: u64;
296
+ kind: LpRequestKind;
297
+ owner: string;
298
+ request_time: u64;
299
+ status: LpRequestStatus;
300
+ }
301
+ /**
302
+ * Which side currently pays funding (§8.1: the side with more base
303
+ * exposure). `None` when the market is balanced or empty.
304
+ */
305
+ export type PayerSide = {
306
+ tag: "None";
307
+ values: void;
308
+ } | {
309
+ tag: "Long";
310
+ values: void;
311
+ } | {
312
+ tag: "Short";
313
+ values: void;
314
+ };
315
+ export type RiskState = {
316
+ tag: "Normal";
317
+ values: void;
318
+ } | {
319
+ tag: "Warning";
320
+ values: void;
321
+ } | {
322
+ tag: "Adl";
323
+ values: void;
324
+ } | {
325
+ tag: "HardCap";
326
+ values: void;
327
+ };
328
+ export interface MarketSide {
329
+ base_exposure: i128;
330
+ risk_state: RiskState;
331
+ risk_units: i128;
332
+ size_open_interest: i128;
333
+ stored_collateral_total: i128;
334
+ }
335
+ export interface RoundPrice {
336
+ price: i128;
337
+ symbol: string;
338
+ }
339
+ export interface OracleRound {
340
+ id: u64;
341
+ previous_id: u64;
342
+ previous_timestamp: u64;
343
+ prices: Array<RoundPrice>;
344
+ timestamp: u64;
345
+ }
346
+ export interface GlobalConfig {
347
+ base_borrow_rate_bps_day: i128;
348
+ hard_cap_factor_limit_bps: u32;
349
+ lp_revenue_share_bps: u32;
350
+ max_active_markets: u32;
351
+ max_adl_reward: i128;
352
+ max_insolvent_touch_reward: i128;
353
+ max_variable_borrow_bps_day: i128;
354
+ min_collateral: i128;
355
+ min_position_lifetime: u64;
356
+ risk_capacity_limit_bps: u32;
357
+ risk_keeper_revenue_share_bps: u32;
358
+ }
359
+ export interface MarketConfig {
360
+ adl_pnl_factor_bps: u32;
361
+ adl_reward_bps: u32;
362
+ hard_cap_pnl_factor_bps: u32;
363
+ liquidation_reward_bps: u32;
364
+ maintenance_margin_bps: u32;
365
+ market_risk_factor_bps: u32;
366
+ max_funding_rate_bps_day: i128;
367
+ max_long_base_exposure: i128;
368
+ max_long_size_open_interest: i128;
369
+ max_short_base_exposure: i128;
370
+ max_short_size_open_interest: i128;
371
+ open_fee_high_bps: u32;
372
+ open_fee_low_bps: u32;
373
+ recovery_pnl_factor_bps: u32;
374
+ warning_pnl_factor_bps: u32;
280
375
  }
281
376
  /**
282
377
  * Global safety thresholds for price validation.
283
378
  */
284
379
  export interface OracleConfig {
285
380
  /**
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).
381
+ * How long a cached aggregated price remains valid after the router
382
+ * fetch (in seconds). A cache hit also requires every source timestamp
383
+ * used for the cached median to remain within `staleness_threshold`.
384
+ * Must be > 0 and <= `staleness_threshold`.
291
385
  */
292
386
  cache_duration: u64;
293
387
  /**
294
388
  * Maximum allowed spread between oracle sources in basis points
295
- * (e.g., 100 = 1%). Bounded at `shared::constants::MAX_DEVIATION_BPS_CEILING`.
389
+ * (e.g., 100 = 1%). Bounded at `crate::constants::MAX_DEVIATION_BPS_CEILING`.
296
390
  */
297
391
  max_deviation_bps: i128;
298
392
  /**
299
393
  * Minimum number of source responses that must agree within
300
394
  * `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`.
395
+ * `crate::constants::MIN_REQUIRED_SOURCES_FLOOR`, ceilinged at
396
+ * `crate::constants::MAX_ORACLE_SOURCES`.
303
397
  */
304
398
  min_required_sources: u32;
305
399
  /**
@@ -308,6 +402,13 @@ export interface OracleConfig {
308
402
  */
309
403
  staleness_threshold: u64;
310
404
  }
405
+ export type LpRequestKind = {
406
+ tag: "Deposit";
407
+ values: void;
408
+ } | {
409
+ tag: "Withdrawal";
410
+ values: void;
411
+ };
311
412
  /**
312
413
  * Data required during a WASM migration. Single definition for all contracts.
313
414
  */
@@ -317,15 +418,54 @@ export interface MigrationData {
317
418
  /**
318
419
  * Pending WASM upgrade — set by `propose_upgrade`, consumed by `upgrade`
319
420
  * (cleared atomically on a successful install), or cleared by `cancel_upgrade`.
320
- * Single shape across every protocol contract; all four contracts store it at
421
+ * Single shape across every protocol contract. Contracts store it at
321
422
  * the shared `pending_upgrade` Symbol key in their own instance storage (see
322
- * `interfaces::upgrade::pending_upgrade_key`). `upgrade` refuses to install
423
+ * `crate::upgrade::pending_upgrade_key`). `upgrade` refuses to install
323
424
  * unless `pending.wasm_hash` matches the supplied hash and `now >= eta`.
324
425
  */
325
426
  export interface PendingUpgrade {
326
427
  eta: u64;
327
428
  wasm_hash: Buffer;
328
429
  }
430
+ export type LpRequestStatus = {
431
+ tag: "Pending";
432
+ values: void;
433
+ } | {
434
+ tag: "Settled";
435
+ values: void;
436
+ } | {
437
+ tag: "Failed";
438
+ values: void;
439
+ } | {
440
+ tag: "Expired";
441
+ values: void;
442
+ };
443
+ export interface SettlementResult {
444
+ /**
445
+ * Shares minted for a deposit or assets paid for a withdrawal.
446
+ */
447
+ amount: i128;
448
+ status: SettlementStatus;
449
+ }
450
+ export type SettlementStatus = {
451
+ tag: "Settled";
452
+ values: void;
453
+ } | {
454
+ tag: "Failed";
455
+ values: void;
456
+ };
457
+ export interface AccountingSnapshot {
458
+ cash_lp_equity: i128;
459
+ cash_shortfall: i128;
460
+ free_lp_capital: i128;
461
+ lp_blocked_side_count: u32;
462
+ non_lp_claims: i128;
463
+ open_position_count: u64;
464
+ physical_cash: i128;
465
+ required_risk_backing: i128;
466
+ total_risk_units: i128;
467
+ vault_nav: i128;
468
+ }
329
469
  export declare const UpgradeableError: {
330
470
  /**
331
471
  * When migration is attempted but not allowed due to upgrade state.
@@ -432,48 +572,6 @@ export type PausableStorageKey = {
432
572
  tag: "Paused";
433
573
  values: void;
434
574
  };
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
575
  export interface Client {
478
576
  /**
479
577
  * 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.
@@ -504,81 +602,110 @@ export interface Client {
504
602
  /**
505
603
  * 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
604
  */
507
- set_tp_sl: ({ trader, symbol, take_profit, stop_loss }: {
508
- trader: string;
509
- symbol: string;
605
+ set_tp_sl: ({ position_id, take_profit, stop_loss }: {
606
+ position_id: u64;
510
607
  take_profit: i128;
511
608
  stop_loss: i128;
512
609
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
513
610
  /**
514
611
  * 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
612
  */
520
- set_vault: ({ caller, vault_address }: {
613
+ set_vault: ({ caller, vault }: {
521
614
  caller: string;
522
- vault_address: string;
615
+ vault: string;
523
616
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
524
617
  /**
525
618
  * 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
619
  */
527
- get_market: ({ symbol }: {
528
- symbol: string;
529
- }, options?: MethodOptions) => Promise<AssembledTransaction<MarketInfo>>;
620
+ get_market: ({ market }: {
621
+ market: string;
622
+ }, options?: MethodOptions) => Promise<AssembledTransaction<Market>>;
530
623
  /**
531
624
  * 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
625
  */
533
- get_position: ({ trader, symbol }: {
534
- trader: string;
535
- symbol: string;
626
+ get_position: ({ position_id }: {
627
+ position_id: u64;
536
628
  }, options?: MethodOptions) => Promise<AssembledTransaction<Position>>;
537
629
  /**
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.
630
+ * Construct and simulate a recapitalize 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
631
  */
540
- realized_pnl: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
632
+ recapitalize: ({ contributor, amount }: {
633
+ contributor: string;
634
+ amount: i128;
635
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
541
636
  /**
542
637
  * 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
638
  */
544
- bump_position: ({ user_address, symbol }: {
545
- user_address: string;
546
- symbol: string;
639
+ bump_position: ({ position_id }: {
640
+ position_id: u64;
547
641
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
548
642
  /**
549
643
  * 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
644
  */
551
- enable_market: ({ caller, symbol }: {
645
+ enable_market: ({ caller, market }: {
552
646
  caller: string;
553
- symbol: string;
647
+ market: string;
554
648
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
555
649
  /**
556
650
  * 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
651
  */
558
- execute_order: ({ caller, trader, symbol }: {
652
+ execute_order: ({ caller, position_id }: {
559
653
  caller: string;
560
- trader: string;
561
- symbol: string;
654
+ position_id: u64;
562
655
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
656
+ /**
657
+ * Construct and simulate a global_config 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
+ global_config: (options?: MethodOptions) => Promise<AssembledTransaction<GlobalConfig>>;
660
+ /**
661
+ * Construct and simulate a non_lp_claims 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.
662
+ */
663
+ non_lp_claims: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
664
+ /**
665
+ * Construct and simulate a open_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.
666
+ */
667
+ open_position: ({ owner, market_symbol, is_long, size, collateral, execution_budget, take_profit, stop_loss, acceptable_price }: {
668
+ owner: string;
669
+ market_symbol: string;
670
+ is_long: boolean;
671
+ size: i128;
672
+ collateral: i128;
673
+ execution_budget: i128;
674
+ take_profit: i128;
675
+ stop_loss: i128;
676
+ acceptable_price: i128;
677
+ }, options?: MethodOptions) => Promise<AssembledTransaction<u64>>;
678
+ /**
679
+ * Construct and simulate a active_markets 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.
680
+ */
681
+ active_markets: (options?: MethodOptions) => Promise<AssembledTransaction<Array<string>>>;
563
682
  /**
564
683
  * 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
684
  */
566
685
  cancel_upgrade: ({ caller }: {
567
686
  caller: string;
568
687
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
688
+ /**
689
+ * Construct and simulate a claim_protocol 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.
690
+ */
691
+ claim_protocol: ({ caller, recipient, amount }: {
692
+ caller: string;
693
+ recipient: string;
694
+ amount: i128;
695
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
569
696
  /**
570
697
  * 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
698
  */
572
- disable_market: ({ caller, symbol }: {
699
+ disable_market: ({ caller, market }: {
573
700
  caller: string;
574
- symbol: string;
701
+ market: string;
575
702
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
576
703
  /**
577
704
  * 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
705
  */
579
- update_indices: ({ caller, symbol }: {
706
+ update_indices: ({ caller, market_symbol }: {
580
707
  caller: string;
581
- symbol: string;
708
+ market_symbol: string;
582
709
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
583
710
  /**
584
711
  * 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.
@@ -588,85 +715,122 @@ export interface Client {
588
715
  wasm_hash: Buffer;
589
716
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
590
717
  /**
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.
718
+ * 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.
592
719
  */
593
- get_max_leverage: ({ symbol }: {
594
- symbol: string;
595
- }, options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
720
+ decrease_position: ({ position_id, size_removed, collateral_withdrawn, acceptable_price }: {
721
+ position_id: u64;
722
+ size_removed: i128;
723
+ collateral_withdrawn: i128;
724
+ acceptable_price: i128;
725
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
596
726
  /**
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.
727
+ * 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.
598
728
  */
599
- set_max_leverage: ({ caller, symbol, max_leverage }: {
600
- caller: string;
601
- symbol: string;
602
- max_leverage: i128;
729
+ increase_position: ({ position_id, size_added, collateral_added, acceptable_price }: {
730
+ position_id: u64;
731
+ size_added: i128;
732
+ collateral_added: i128;
733
+ acceptable_price: i128;
603
734
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
604
735
  /**
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.
736
+ * Construct and simulate a set_global_config 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
737
  */
607
- decrease_position: ({ trader, symbol, size_delta, acceptable_price }: {
608
- trader: string;
609
- symbol: string;
610
- size_delta: i128;
611
- acceptable_price: i128;
738
+ set_global_config: ({ caller, config }: {
739
+ caller: string;
740
+ config: GlobalConfig;
612
741
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
613
742
  /**
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.
743
+ * Construct and simulate a set_market_config 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
744
  */
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;
745
+ set_market_config: ({ caller, market_symbol, config }: {
746
+ caller: string;
747
+ market_symbol: string;
748
+ config: MarketConfig;
625
749
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
626
750
  /**
627
751
  * 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
752
  */
629
- is_market_disabled: ({ symbol }: {
630
- symbol: string;
753
+ is_market_disabled: ({ market }: {
754
+ market: string;
631
755
  }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
632
756
  /**
633
757
  * 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
758
  */
635
- liquidate_position: ({ caller, trader, symbol }: {
759
+ liquidate_position: ({ caller, position_id }: {
636
760
  caller: string;
637
- trader: string;
638
- symbol: string;
761
+ position_id: u64;
639
762
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
763
+ /**
764
+ * Construct and simulate a accounting_snapshot 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.
765
+ */
766
+ accounting_snapshot: ({ round, physical }: {
767
+ round: OracleRound;
768
+ physical: i128;
769
+ }, options?: MethodOptions) => Promise<AssembledTransaction<AccountingSnapshot>>;
640
770
  /**
641
771
  * 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
772
  */
643
- deleverage_position: ({ caller, trader, symbol }: {
773
+ deleverage_position: ({ caller, position_id }: {
644
774
  caller: string;
645
- trader: string;
646
- symbol: string;
775
+ position_id: u64;
647
776
  }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
648
777
  /**
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.
778
+ * Construct and simulate a prepare_lp_snapshot 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.
779
+ */
780
+ prepare_lp_snapshot: ({ caller, round, physical }: {
781
+ caller: string;
782
+ round: OracleRound;
783
+ physical: i128;
784
+ }, options?: MethodOptions) => Promise<AssembledTransaction<AccountingSnapshot>>;
785
+ /**
786
+ * Construct and simulate a refresh_borrow_rate 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
787
  */
651
- sync_unrealized_pnl: (options?: MethodOptions) => Promise<AssembledTransaction<null>>;
788
+ refresh_borrow_rate: ({ caller, physical }: {
789
+ caller: string;
790
+ physical: i128;
791
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
652
792
  /**
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.
793
+ * Construct and simulate a can_create_lp_request 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
794
  */
655
- total_unrealized_pnl: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
795
+ can_create_lp_request: ({ caller, physical }: {
796
+ caller: string;
797
+ physical: i128;
798
+ }, options?: MethodOptions) => Promise<AssembledTransaction<boolean>>;
799
+ /**
800
+ * Construct and simulate a fund_execution_budget 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.
801
+ */
802
+ fund_execution_budget: ({ position_id, amount }: {
803
+ position_id: u64;
804
+ amount: i128;
805
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
806
+ /**
807
+ * Construct and simulate a protocol_claimable_total 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.
808
+ */
809
+ protocol_claimable_total: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
810
+ /**
811
+ * Construct and simulate a risk_keeper_reserve_total 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.
812
+ */
813
+ risk_keeper_reserve_total: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
814
+ /**
815
+ * Construct and simulate a withdraw_execution_budget 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.
816
+ */
817
+ withdraw_execution_budget: ({ position_id, amount }: {
818
+ position_id: u64;
819
+ amount: i128;
820
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
656
821
  /**
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.
822
+ * Construct and simulate a pending_receiver_funding_total 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
823
  */
659
- market_unrealized_pnl: ({ symbol }: {
660
- symbol: string;
661
- }, options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
824
+ pending_receiver_funding_total: (options?: MethodOptions) => Promise<AssembledTransaction<i128>>;
662
825
  }
663
826
  export declare class Client extends ContractClient {
664
827
  readonly options: ContractClientOptions;
665
828
  static deploy<T = Client>(
666
829
  /** Constructor/Initialization Args for the contract's `__constructor` method */
667
- { config_manager, oracle_router }: {
830
+ { config_manager, oracle_router, config }: {
668
831
  config_manager: string;
669
832
  oracle_router: string;
833
+ config: GlobalConfig;
670
834
  },
671
835
  /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
672
836
  options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
@@ -685,25 +849,36 @@ export declare class Client extends ContractClient {
685
849
  upgrade: (json: string) => AssembledTransaction<null>;
686
850
  set_tp_sl: (json: string) => AssembledTransaction<null>;
687
851
  set_vault: (json: string) => AssembledTransaction<null>;
688
- get_market: (json: string) => AssembledTransaction<MarketInfo>;
852
+ get_market: (json: string) => AssembledTransaction<Market>;
689
853
  get_position: (json: string) => AssembledTransaction<Position>;
690
- realized_pnl: (json: string) => AssembledTransaction<bigint>;
854
+ recapitalize: (json: string) => AssembledTransaction<null>;
691
855
  bump_position: (json: string) => AssembledTransaction<null>;
692
856
  enable_market: (json: string) => AssembledTransaction<null>;
693
857
  execute_order: (json: string) => AssembledTransaction<null>;
858
+ global_config: (json: string) => AssembledTransaction<GlobalConfig>;
859
+ non_lp_claims: (json: string) => AssembledTransaction<bigint>;
860
+ open_position: (json: string) => AssembledTransaction<bigint>;
861
+ active_markets: (json: string) => AssembledTransaction<string[]>;
694
862
  cancel_upgrade: (json: string) => AssembledTransaction<null>;
863
+ claim_protocol: (json: string) => AssembledTransaction<null>;
695
864
  disable_market: (json: string) => AssembledTransaction<null>;
696
865
  update_indices: (json: string) => AssembledTransaction<null>;
697
866
  propose_upgrade: (json: string) => AssembledTransaction<null>;
698
- get_max_leverage: (json: string) => AssembledTransaction<bigint>;
699
- set_max_leverage: (json: string) => AssembledTransaction<null>;
700
867
  decrease_position: (json: string) => AssembledTransaction<null>;
701
868
  increase_position: (json: string) => AssembledTransaction<null>;
869
+ set_global_config: (json: string) => AssembledTransaction<null>;
870
+ set_market_config: (json: string) => AssembledTransaction<null>;
702
871
  is_market_disabled: (json: string) => AssembledTransaction<boolean>;
703
872
  liquidate_position: (json: string) => AssembledTransaction<null>;
873
+ accounting_snapshot: (json: string) => AssembledTransaction<AccountingSnapshot>;
704
874
  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>;
875
+ prepare_lp_snapshot: (json: string) => AssembledTransaction<AccountingSnapshot>;
876
+ refresh_borrow_rate: (json: string) => AssembledTransaction<null>;
877
+ can_create_lp_request: (json: string) => AssembledTransaction<boolean>;
878
+ fund_execution_budget: (json: string) => AssembledTransaction<null>;
879
+ protocol_claimable_total: (json: string) => AssembledTransaction<bigint>;
880
+ risk_keeper_reserve_total: (json: string) => AssembledTransaction<bigint>;
881
+ withdraw_execution_budget: (json: string) => AssembledTransaction<null>;
882
+ pending_receiver_funding_total: (json: string) => AssembledTransaction<bigint>;
708
883
  };
709
884
  }