@win-trader/bindings 0.0.2 → 0.0.4
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 +226 -300
- package/config-manager/dist/index.js +28 -142
- package/mock-token/dist/index.d.ts +1 -1
- package/mock-token/dist/index.js +1 -1
- package/oracle/dist/index.d.ts +222 -88
- package/oracle/dist/index.js +19 -9
- package/oracle-router/dist/index.d.ts +278 -92
- package/oracle-router/dist/index.js +36 -14
- package/package.json +13 -11
- package/position-manager/dist/index.d.ts +441 -245
- package/position-manager/dist/index.js +122 -124
- package/request-router/dist/index.d.ts +546 -0
- package/request-router/dist/index.js +154 -0
- package/vault/dist/index.d.ts +296 -367
- package/vault/dist/index.js +72 -128
|
@@ -14,189 +14,37 @@ export declare const ConfigManagerError: {
|
|
|
14
14
|
3: {
|
|
15
15
|
message: string;
|
|
16
16
|
};
|
|
17
|
-
/**
|
|
18
|
-
* `set_upgrade_timelock` called with seconds below `MIN_UPGRADE_TIMELOCK`.
|
|
19
|
-
*/
|
|
20
17
|
6: {
|
|
21
18
|
message: string;
|
|
22
19
|
};
|
|
23
|
-
/**
|
|
24
|
-
* `propose_admin(caller, new_admin)` rejected because `caller == new_admin`.
|
|
25
|
-
*/
|
|
26
20
|
7: {
|
|
27
21
|
message: string;
|
|
28
22
|
};
|
|
29
|
-
/**
|
|
30
|
-
* `accept_admin` rejected — caller is not the currently pending admin.
|
|
31
|
-
*/
|
|
32
23
|
8: {
|
|
33
24
|
message: string;
|
|
34
25
|
};
|
|
35
|
-
/**
|
|
36
|
-
* `accept_admin` rejected — there is no pending admin proposal.
|
|
37
|
-
*/
|
|
38
26
|
9: {
|
|
39
27
|
message: string;
|
|
40
28
|
};
|
|
41
|
-
/**
|
|
42
|
-
* `upgrade` rejected — no `propose_upgrade` was made before commit.
|
|
43
|
-
* The two-step upgrade flow requires a prior proposal.
|
|
44
|
-
*/
|
|
45
29
|
10: {
|
|
46
30
|
message: string;
|
|
47
31
|
};
|
|
48
|
-
/**
|
|
49
|
-
* `upgrade` rejected — timelock has not elapsed yet.
|
|
50
|
-
*/
|
|
51
32
|
11: {
|
|
52
33
|
message: string;
|
|
53
34
|
};
|
|
54
|
-
/**
|
|
55
|
-
* `upgrade` rejected — `new_wasm_hash` does not match the proposed
|
|
56
|
-
* `PendingUpgrade.wasm_hash`.
|
|
57
|
-
*/
|
|
58
35
|
12: {
|
|
59
36
|
message: string;
|
|
60
37
|
};
|
|
61
|
-
/**
|
|
62
|
-
* `accept_admin` rejected — the proposal is older than
|
|
63
|
-
* `ADMIN_PROPOSAL_TTL_SECS`.
|
|
64
|
-
*/
|
|
65
38
|
13: {
|
|
66
39
|
message: string;
|
|
67
40
|
};
|
|
68
|
-
/**
|
|
69
|
-
* `set_upgrade_timelock` called with seconds above
|
|
70
|
-
* `MAX_UPGRADE_TIMELOCK_SECS`.
|
|
71
|
-
*/
|
|
72
41
|
14: {
|
|
73
42
|
message: string;
|
|
74
43
|
};
|
|
75
|
-
/**
|
|
76
|
-
* FeeSplits components (lp/dev/staker) do not sum to exactly BPS.
|
|
77
|
-
*/
|
|
78
|
-
22: {
|
|
79
|
-
message: string;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* `min_collateral` is not strictly positive.
|
|
83
|
-
*/
|
|
84
|
-
30: {
|
|
85
|
-
message: string;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* `max_utilization_ratio` is out of (0, BPS] range.
|
|
89
|
-
*/
|
|
90
|
-
31: {
|
|
91
|
-
message: string;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* `funding_cut_bps` exceeds `MAX_FUNDING_CUT_BPS`.
|
|
95
|
-
*/
|
|
96
|
-
32: {
|
|
97
|
-
message: string;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* `adl_pnl_bps` is below `MIN_ADL_PNL_BPS` or above BPS.
|
|
101
|
-
*/
|
|
102
|
-
33: {
|
|
103
|
-
message: string;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* `adl_utilization_bps` is out of (0, BPS] range.
|
|
107
|
-
*/
|
|
108
|
-
34: {
|
|
109
|
-
message: string;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* `liquidation_threshold_bps` is below `MIN_LIQUIDATION_THRESHOLD_BPS`
|
|
113
|
-
* or exceeds 10% of collateral.
|
|
114
|
-
*/
|
|
115
|
-
35: {
|
|
116
|
-
message: string;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* `cooldown_duration` exceeds `MAX_COOLDOWN_DURATION`.
|
|
120
|
-
*/
|
|
121
|
-
36: {
|
|
122
|
-
message: string;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* `min_position_lifetime` exceeds `MAX_MIN_POSITION_LIFETIME_SECS`.
|
|
126
|
-
*/
|
|
127
|
-
37: {
|
|
128
|
-
message: string;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* A BorrowRateConfig rate is negative.
|
|
132
|
-
*/
|
|
133
|
-
40: {
|
|
134
|
-
message: string;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* `optimal_utilization_bps` is out of (0, BPS] range.
|
|
138
|
-
*/
|
|
139
|
-
41: {
|
|
140
|
-
message: string;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* `slope2_bps < slope1_bps` — kink curve must be non-decreasing.
|
|
144
|
-
*/
|
|
145
|
-
42: {
|
|
146
|
-
message: string;
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* `slope2_bps` exceeds `MAX_SLOPE2_BPS`.
|
|
150
|
-
*/
|
|
151
|
-
43: {
|
|
152
|
-
message: string;
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* `open_fee_bps` exceeds `MAX_OPEN_FEE_BPS`.
|
|
156
|
-
*/
|
|
157
|
-
44: {
|
|
158
|
-
message: string;
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* `liquidation_bounty_bps` exceeds `MAX_LIQUIDATION_BOUNTY_BPS`.
|
|
162
|
-
*/
|
|
163
|
-
45: {
|
|
164
|
-
message: string;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* `tp_sl_execution_fee` is negative or exceeds `MAX_TP_SL_EXECUTION_FEE`.
|
|
168
|
-
*/
|
|
169
|
-
46: {
|
|
170
|
-
message: string;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* `base_borrow_rate_bps` exceeds `MAX_BASE_BORROW_RATE_BPS`.
|
|
174
|
-
*/
|
|
175
|
-
47: {
|
|
176
|
-
message: string;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* `base_funding_rate_bps` exceeds `MAX_BASE_FUNDING_RATE_BPS`.
|
|
180
|
-
*/
|
|
181
|
-
48: {
|
|
182
|
-
message: string;
|
|
183
|
-
};
|
|
184
44
|
};
|
|
185
45
|
export type StorageKey = {
|
|
186
46
|
tag: "Initialized";
|
|
187
47
|
values: void;
|
|
188
|
-
} | {
|
|
189
|
-
tag: "FeeSplits";
|
|
190
|
-
values: void;
|
|
191
|
-
} | {
|
|
192
|
-
tag: "FeeConfig";
|
|
193
|
-
values: void;
|
|
194
|
-
} | {
|
|
195
|
-
tag: "ProtocolLimits";
|
|
196
|
-
values: void;
|
|
197
|
-
} | {
|
|
198
|
-
tag: "BorrowRateConfig";
|
|
199
|
-
values: void;
|
|
200
48
|
} | {
|
|
201
49
|
tag: "UpgradeTimelock";
|
|
202
50
|
values: void;
|
|
@@ -207,10 +55,6 @@ export type StorageKey = {
|
|
|
207
55
|
tag: "Version";
|
|
208
56
|
values: void;
|
|
209
57
|
};
|
|
210
|
-
/**
|
|
211
|
-
* Pending admin transfer awaiting `accept_admin`. The proposal timestamp
|
|
212
|
-
* bounds its lifetime to `ADMIN_PROPOSAL_TTL_SECS`.
|
|
213
|
-
*/
|
|
214
58
|
export interface PendingAdminProposal {
|
|
215
59
|
admin: string;
|
|
216
60
|
proposed_at: u64;
|
|
@@ -315,105 +159,235 @@ export type OwnableStorageKey = {
|
|
|
315
159
|
values: void;
|
|
316
160
|
};
|
|
317
161
|
/**
|
|
318
|
-
*
|
|
162
|
+
* Authoritative per-market state: the side aggregates, the funding indices,
|
|
163
|
+
* the funding EMA, and the market configuration.
|
|
164
|
+
*
|
|
165
|
+
* Soroban limits UDT field names to 30 characters, so where a doc glossary
|
|
166
|
+
* term is longer the field drops the redundant qualifier and its doc
|
|
167
|
+
* comment carries the full term (e.g. `receiver_backed_index_long` is the
|
|
168
|
+
* doc's `receiver_backed_payer_index` for the long side).
|
|
319
169
|
*/
|
|
320
|
-
export interface
|
|
170
|
+
export interface Market {
|
|
171
|
+
config: MarketConfig;
|
|
321
172
|
/**
|
|
322
|
-
*
|
|
173
|
+
* `INDEX_PRECISION`-scaled bps/day payer rate as of the last refresh.
|
|
323
174
|
*/
|
|
324
|
-
|
|
175
|
+
current_payer_rate: i128;
|
|
176
|
+
current_payer_side: PayerSide;
|
|
177
|
+
last_funding_checkpoint: u64;
|
|
178
|
+
long: MarketSide;
|
|
325
179
|
/**
|
|
326
|
-
*
|
|
180
|
+
* Cumulative payer fee per unit of dominant-side size that is LP
|
|
181
|
+
* revenue on collection (§8.2).
|
|
327
182
|
*/
|
|
328
|
-
|
|
183
|
+
lp_backed_index_long: i128;
|
|
184
|
+
lp_backed_index_short: i128;
|
|
185
|
+
lp_payer_remainder: i128;
|
|
329
186
|
/**
|
|
330
|
-
*
|
|
187
|
+
* Sub-stroop carry of the receiver-liability accrual (§8.3).
|
|
331
188
|
*/
|
|
332
|
-
|
|
189
|
+
pending_remainder: i128;
|
|
333
190
|
/**
|
|
334
|
-
*
|
|
191
|
+
* Cumulative payer fee per unit of dominant-side size whose collection
|
|
192
|
+
* restores cash backing an already-accrued receiver claim (§8.2).
|
|
335
193
|
*/
|
|
336
|
-
|
|
194
|
+
receiver_backed_index_long: i128;
|
|
195
|
+
receiver_backed_index_short: i128;
|
|
337
196
|
/**
|
|
338
|
-
*
|
|
197
|
+
* Cumulative funding credit per unit of light-side size (§8.2).
|
|
339
198
|
*/
|
|
340
|
-
|
|
199
|
+
receiver_index_long: i128;
|
|
200
|
+
receiver_index_remainder: i128;
|
|
201
|
+
receiver_index_short: i128;
|
|
202
|
+
receiver_payer_remainder: i128;
|
|
203
|
+
short: MarketSide;
|
|
204
|
+
/**
|
|
205
|
+
* §8.1 signed EMA of the instantaneous skew: a fraction of one at
|
|
206
|
+
* `INDEX_PRECISION` scale, positive when history says longs dominate.
|
|
207
|
+
* Decays toward the current skew with the global half-life.
|
|
208
|
+
*/
|
|
209
|
+
skew_ema: i128;
|
|
210
|
+
}
|
|
211
|
+
export interface LpConfig {
|
|
212
|
+
lp_request_delay: u64;
|
|
213
|
+
max_withdraw_utilization_bps: u32;
|
|
214
|
+
min_deposit_nav_factor_bps: u32;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Represents a single trader's open leveraged position.
|
|
218
|
+
*/
|
|
219
|
+
export interface Position {
|
|
341
220
|
/**
|
|
342
|
-
*
|
|
221
|
+
* Asset units at `PRICE_PRECISION`.
|
|
343
222
|
*/
|
|
344
|
-
|
|
223
|
+
base_exposure: i128;
|
|
224
|
+
borrow_debt: i128;
|
|
345
225
|
/**
|
|
346
|
-
*
|
|
226
|
+
* Cash owned by an optional-order executor.
|
|
347
227
|
*/
|
|
228
|
+
execution_budget: i128;
|
|
229
|
+
funding_paid_to_lps_debt: i128;
|
|
230
|
+
funding_paid_to_receivers_debt: i128;
|
|
231
|
+
funding_received_debt: i128;
|
|
232
|
+
id: u64;
|
|
233
|
+
is_long: boolean;
|
|
348
234
|
last_increased_time: u64;
|
|
235
|
+
market: string;
|
|
236
|
+
owner: string;
|
|
349
237
|
/**
|
|
350
|
-
*
|
|
238
|
+
* Fixed gross capacity assigned when risk opens.
|
|
239
|
+
*/
|
|
240
|
+
risk_units: i128;
|
|
241
|
+
/**
|
|
242
|
+
* USD notional at `PRICE_PRECISION`.
|
|
351
243
|
*/
|
|
352
244
|
size: i128;
|
|
353
245
|
/**
|
|
354
|
-
*
|
|
246
|
+
* Trigger price for the optional stop-loss order; `0` = none.
|
|
355
247
|
*/
|
|
356
248
|
stop_loss: i128;
|
|
357
249
|
/**
|
|
358
|
-
*
|
|
250
|
+
* Trader-owned collateral recorded in contract state (the doc's
|
|
251
|
+
* "stored collateral"). Effective collateral — stored collateral after
|
|
252
|
+
* pending fees and funding credits — is always derived, never stored.
|
|
253
|
+
*/
|
|
254
|
+
stored_collateral: i128;
|
|
255
|
+
/**
|
|
256
|
+
* Trigger price for the optional take-profit order; `0` = none.
|
|
359
257
|
*/
|
|
360
258
|
take_profit: i128;
|
|
361
259
|
}
|
|
260
|
+
export interface LpRequest {
|
|
261
|
+
amount: i128;
|
|
262
|
+
execute_after: u64;
|
|
263
|
+
id: u64;
|
|
264
|
+
kind: LpRequestKind;
|
|
265
|
+
owner: string;
|
|
266
|
+
request_time: u64;
|
|
267
|
+
status: LpRequestStatus;
|
|
268
|
+
}
|
|
362
269
|
/**
|
|
363
|
-
*
|
|
270
|
+
* Which side currently pays funding (§8.1: the side the blended integral
|
|
271
|
+
* skew points at — under the EMA this can be the *lighter* side for a
|
|
272
|
+
* while after the book flips). `None` when the blend is exactly zero.
|
|
364
273
|
*/
|
|
365
|
-
export
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
274
|
+
export type PayerSide = {
|
|
275
|
+
tag: "None";
|
|
276
|
+
values: void;
|
|
277
|
+
} | {
|
|
278
|
+
tag: "Long";
|
|
279
|
+
values: void;
|
|
280
|
+
} | {
|
|
281
|
+
tag: "Short";
|
|
282
|
+
values: void;
|
|
283
|
+
};
|
|
284
|
+
export type RiskState = {
|
|
285
|
+
tag: "Normal";
|
|
286
|
+
values: void;
|
|
287
|
+
} | {
|
|
288
|
+
tag: "Warning";
|
|
289
|
+
values: void;
|
|
290
|
+
} | {
|
|
291
|
+
tag: "Adl";
|
|
292
|
+
values: void;
|
|
293
|
+
} | {
|
|
294
|
+
tag: "HardCap";
|
|
295
|
+
values: void;
|
|
296
|
+
};
|
|
297
|
+
export interface MarketSide {
|
|
298
|
+
base_exposure: i128;
|
|
299
|
+
risk_state: RiskState;
|
|
300
|
+
risk_units: i128;
|
|
301
|
+
size_open_interest: i128;
|
|
302
|
+
stored_collateral_total: i128;
|
|
303
|
+
}
|
|
304
|
+
export interface RoundPrice {
|
|
305
|
+
price: i128;
|
|
306
|
+
symbol: string;
|
|
307
|
+
}
|
|
308
|
+
export interface OracleRound {
|
|
309
|
+
id: u64;
|
|
310
|
+
previous_id: u64;
|
|
311
|
+
previous_timestamp: u64;
|
|
312
|
+
prices: Array<RoundPrice>;
|
|
313
|
+
timestamp: u64;
|
|
314
|
+
}
|
|
315
|
+
export interface GlobalConfig {
|
|
316
|
+
base_borrow_rate_bps_day: i128;
|
|
370
317
|
/**
|
|
371
|
-
*
|
|
318
|
+
* §8.1 half-life of the funding skew EMA, seconds (global: one memory
|
|
319
|
+
* horizon for every market).
|
|
372
320
|
*/
|
|
373
|
-
|
|
321
|
+
funding_half_life_seconds: u64;
|
|
322
|
+
hard_cap_factor_limit_bps: u32;
|
|
323
|
+
lp_revenue_share_bps: u32;
|
|
324
|
+
max_active_markets: u32;
|
|
325
|
+
max_adl_reward: i128;
|
|
326
|
+
max_insolvent_touch_reward: i128;
|
|
327
|
+
max_variable_borrow_bps_day: i128;
|
|
328
|
+
min_collateral: i128;
|
|
329
|
+
min_position_lifetime: u64;
|
|
330
|
+
risk_capacity_limit_bps: u32;
|
|
331
|
+
risk_keeper_revenue_share_bps: u32;
|
|
332
|
+
}
|
|
333
|
+
export interface MarketConfig {
|
|
334
|
+
adl_pnl_factor_bps: u32;
|
|
335
|
+
adl_reward_bps: u32;
|
|
374
336
|
/**
|
|
375
|
-
*
|
|
337
|
+
* §11.1 closing-fee tier when the close worsens skew.
|
|
376
338
|
*/
|
|
377
|
-
|
|
339
|
+
close_fee_high_bps: u32;
|
|
378
340
|
/**
|
|
379
|
-
*
|
|
341
|
+
* §11.1 closing-fee tier when the close improves or preserves skew.
|
|
380
342
|
*/
|
|
381
|
-
|
|
343
|
+
close_fee_low_bps: u32;
|
|
344
|
+
hard_cap_pnl_factor_bps: u32;
|
|
382
345
|
/**
|
|
383
|
-
*
|
|
346
|
+
* Margin required to open or add risk (§12.3). Divides max leverage:
|
|
347
|
+
* a position may not be created closer to liquidation than this.
|
|
384
348
|
*/
|
|
385
|
-
|
|
349
|
+
initial_margin_bps: u32;
|
|
386
350
|
/**
|
|
387
|
-
*
|
|
351
|
+
* §8.1 weight of the instantaneous skew in the funding blend, in bps;
|
|
352
|
+
* the rest is the half-life EMA. `BPS` reproduces pure instant skew.
|
|
388
353
|
*/
|
|
389
|
-
|
|
354
|
+
instant_weight_bps: u32;
|
|
355
|
+
liquidation_reward_bps: u32;
|
|
390
356
|
/**
|
|
391
|
-
*
|
|
357
|
+
* Margin below which the position is liquidatable (§12.3). Must not
|
|
358
|
+
* exceed `initial_margin_bps`; the gap is the entry buffer.
|
|
392
359
|
*/
|
|
393
|
-
|
|
360
|
+
maintenance_margin_bps: u32;
|
|
361
|
+
market_risk_factor_bps: u32;
|
|
362
|
+
max_funding_rate_bps_day: i128;
|
|
363
|
+
max_long_base_exposure: i128;
|
|
364
|
+
max_long_size_open_interest: i128;
|
|
365
|
+
max_short_base_exposure: i128;
|
|
366
|
+
max_short_size_open_interest: i128;
|
|
367
|
+
recovery_pnl_factor_bps: u32;
|
|
368
|
+
warning_pnl_factor_bps: u32;
|
|
394
369
|
}
|
|
395
370
|
/**
|
|
396
371
|
* Global safety thresholds for price validation.
|
|
397
372
|
*/
|
|
398
373
|
export interface OracleConfig {
|
|
399
374
|
/**
|
|
400
|
-
* How long a cached aggregated price remains valid
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* source price and serve stale data).
|
|
375
|
+
* How long a cached aggregated price remains valid after the router
|
|
376
|
+
* fetch (in seconds). A cache hit also requires every source timestamp
|
|
377
|
+
* used for the cached median to remain within `staleness_threshold`.
|
|
378
|
+
* Must be > 0 and <= `staleness_threshold`.
|
|
405
379
|
*/
|
|
406
380
|
cache_duration: u64;
|
|
407
381
|
/**
|
|
408
382
|
* Maximum allowed spread between oracle sources in basis points
|
|
409
|
-
* (e.g., 100 = 1%). Bounded at `
|
|
383
|
+
* (e.g., 100 = 1%). Bounded at `crate::constants::MAX_DEVIATION_BPS_CEILING`.
|
|
410
384
|
*/
|
|
411
385
|
max_deviation_bps: i128;
|
|
412
386
|
/**
|
|
413
387
|
* Minimum number of source responses that must agree within
|
|
414
388
|
* `max_deviation_bps` for OracleRouter to return a price. Floored at
|
|
415
|
-
* `
|
|
416
|
-
* `
|
|
389
|
+
* `crate::constants::MIN_REQUIRED_SOURCES_FLOOR`, ceilinged at
|
|
390
|
+
* `crate::constants::MAX_ORACLE_SOURCES`.
|
|
417
391
|
*/
|
|
418
392
|
min_required_sources: u32;
|
|
419
393
|
/**
|
|
@@ -422,6 +396,13 @@ export interface OracleConfig {
|
|
|
422
396
|
*/
|
|
423
397
|
staleness_threshold: u64;
|
|
424
398
|
}
|
|
399
|
+
export type LpRequestKind = {
|
|
400
|
+
tag: "Deposit";
|
|
401
|
+
values: void;
|
|
402
|
+
} | {
|
|
403
|
+
tag: "Withdrawal";
|
|
404
|
+
values: void;
|
|
405
|
+
};
|
|
425
406
|
/**
|
|
426
407
|
* Data required during a WASM migration. Single definition for all contracts.
|
|
427
408
|
*/
|
|
@@ -431,15 +412,54 @@ export interface MigrationData {
|
|
|
431
412
|
/**
|
|
432
413
|
* Pending WASM upgrade — set by `propose_upgrade`, consumed by `upgrade`
|
|
433
414
|
* (cleared atomically on a successful install), or cleared by `cancel_upgrade`.
|
|
434
|
-
* Single shape across every protocol contract
|
|
415
|
+
* Single shape across every protocol contract. Contracts store it at
|
|
435
416
|
* the shared `pending_upgrade` Symbol key in their own instance storage (see
|
|
436
|
-
* `
|
|
417
|
+
* `crate::upgrade::pending_upgrade_key`). `upgrade` refuses to install
|
|
437
418
|
* unless `pending.wasm_hash` matches the supplied hash and `now >= eta`.
|
|
438
419
|
*/
|
|
439
420
|
export interface PendingUpgrade {
|
|
440
421
|
eta: u64;
|
|
441
422
|
wasm_hash: Buffer;
|
|
442
423
|
}
|
|
424
|
+
export type LpRequestStatus = {
|
|
425
|
+
tag: "Pending";
|
|
426
|
+
values: void;
|
|
427
|
+
} | {
|
|
428
|
+
tag: "Settled";
|
|
429
|
+
values: void;
|
|
430
|
+
} | {
|
|
431
|
+
tag: "Failed";
|
|
432
|
+
values: void;
|
|
433
|
+
} | {
|
|
434
|
+
tag: "Expired";
|
|
435
|
+
values: void;
|
|
436
|
+
};
|
|
437
|
+
export interface SettlementResult {
|
|
438
|
+
/**
|
|
439
|
+
* Shares minted for a deposit or assets paid for a withdrawal.
|
|
440
|
+
*/
|
|
441
|
+
amount: i128;
|
|
442
|
+
status: SettlementStatus;
|
|
443
|
+
}
|
|
444
|
+
export type SettlementStatus = {
|
|
445
|
+
tag: "Settled";
|
|
446
|
+
values: void;
|
|
447
|
+
} | {
|
|
448
|
+
tag: "Failed";
|
|
449
|
+
values: void;
|
|
450
|
+
};
|
|
451
|
+
export interface AccountingSnapshot {
|
|
452
|
+
cash_lp_equity: i128;
|
|
453
|
+
cash_shortfall: i128;
|
|
454
|
+
free_lp_capital: i128;
|
|
455
|
+
lp_blocked_side_count: u32;
|
|
456
|
+
non_lp_claims: i128;
|
|
457
|
+
open_position_count: u64;
|
|
458
|
+
physical_cash: i128;
|
|
459
|
+
required_risk_backing: i128;
|
|
460
|
+
total_risk_units: i128;
|
|
461
|
+
vault_nav: i128;
|
|
462
|
+
}
|
|
443
463
|
export declare const UpgradeableError: {
|
|
444
464
|
/**
|
|
445
465
|
* When migration is attempted but not allowed due to upgrade state.
|
|
@@ -546,54 +566,12 @@ export type PausableStorageKey = {
|
|
|
546
566
|
tag: "Paused";
|
|
547
567
|
values: void;
|
|
548
568
|
};
|
|
549
|
-
/**
|
|
550
|
-
* Execution-bounty and open-fee parameters charged to traders.
|
|
551
|
-
* `open_fee_bps` and `liquidation_bounty_bps` are in basis points;
|
|
552
|
-
* `tp_sl_execution_fee` is a flat USDC amount at PRECISION scale.
|
|
553
|
-
*/
|
|
554
|
-
export interface FeeConfig {
|
|
555
|
-
liquidation_bounty_bps: u32;
|
|
556
|
-
open_fee_bps: u32;
|
|
557
|
-
tp_sl_execution_fee: i128;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Defines how protocol revenue is split between parties.
|
|
561
|
-
* All values are in basis points (bps). Must sum to 10_000.
|
|
562
|
-
*/
|
|
563
|
-
export interface FeeSplits {
|
|
564
|
-
dev_bps: u32;
|
|
565
|
-
lp_bps: u32;
|
|
566
|
-
staker_bps: u32;
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Global protocol risk and timing parameters.
|
|
570
|
-
*/
|
|
571
|
-
export interface ProtocolLimits {
|
|
572
|
-
adl_pnl_bps: u32;
|
|
573
|
-
adl_utilization_bps: u32;
|
|
574
|
-
cooldown_duration: u64;
|
|
575
|
-
funding_cut_bps: u32;
|
|
576
|
-
liquidation_threshold_bps: u32;
|
|
577
|
-
max_utilization_ratio: i128;
|
|
578
|
-
min_collateral: i128;
|
|
579
|
-
min_position_lifetime: u64;
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Borrow rate kink curve and funding rate parameters (all in basis points).
|
|
583
|
-
*/
|
|
584
|
-
export interface BorrowRateConfig {
|
|
585
|
-
base_borrow_rate_bps: i128;
|
|
586
|
-
base_funding_rate_bps: i128;
|
|
587
|
-
optimal_utilization_bps: i128;
|
|
588
|
-
slope1_bps: i128;
|
|
589
|
-
slope2_bps: i128;
|
|
590
|
-
}
|
|
591
569
|
export interface Client {
|
|
592
570
|
/**
|
|
593
571
|
* 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.
|
|
594
572
|
*/
|
|
595
|
-
migrate: ({
|
|
596
|
-
|
|
573
|
+
migrate: ({ data, operator }: {
|
|
574
|
+
data: MigrationData;
|
|
597
575
|
operator: string;
|
|
598
576
|
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
599
577
|
/**
|
|
@@ -645,21 +623,6 @@ export interface Client {
|
|
|
645
623
|
cancel_upgrade: ({ caller }: {
|
|
646
624
|
caller: string;
|
|
647
625
|
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
648
|
-
/**
|
|
649
|
-
* Construct and simulate a get_fee_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.
|
|
650
|
-
*/
|
|
651
|
-
get_fee_config: (options?: MethodOptions) => Promise<AssembledTransaction<FeeConfig>>;
|
|
652
|
-
/**
|
|
653
|
-
* Construct and simulate a get_fee_splits 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
|
-
get_fee_splits: (options?: MethodOptions) => Promise<AssembledTransaction<FeeSplits>>;
|
|
656
|
-
/**
|
|
657
|
-
* Construct and simulate a set_fee_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
|
-
set_fee_config: ({ caller, config }: {
|
|
660
|
-
caller: string;
|
|
661
|
-
config: FeeConfig;
|
|
662
|
-
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
663
626
|
/**
|
|
664
627
|
* 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.
|
|
665
628
|
*/
|
|
@@ -675,17 +638,6 @@ export interface Client {
|
|
|
675
638
|
* Construct and simulate a get_pending_admin 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.
|
|
676
639
|
*/
|
|
677
640
|
get_pending_admin: (options?: MethodOptions) => Promise<AssembledTransaction<Option<string>>>;
|
|
678
|
-
/**
|
|
679
|
-
* Construct and simulate a update_fee_splits 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
|
-
update_fee_splits: ({ caller, fee_splits }: {
|
|
682
|
-
caller: string;
|
|
683
|
-
fee_splits: FeeSplits;
|
|
684
|
-
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
685
|
-
/**
|
|
686
|
-
* Construct and simulate a get_protocol_limits 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.
|
|
687
|
-
*/
|
|
688
|
-
get_protocol_limits: (options?: MethodOptions) => Promise<AssembledTransaction<ProtocolLimits>>;
|
|
689
641
|
/**
|
|
690
642
|
* Construct and simulate a get_upgrade_timelock 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.
|
|
691
643
|
*/
|
|
@@ -703,31 +655,13 @@ export interface Client {
|
|
|
703
655
|
cancel_admin_proposal: ({ caller }: {
|
|
704
656
|
caller: string;
|
|
705
657
|
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
706
|
-
/**
|
|
707
|
-
* Construct and simulate a get_borrow_rate_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.
|
|
708
|
-
*/
|
|
709
|
-
get_borrow_rate_config: (options?: MethodOptions) => Promise<AssembledTransaction<BorrowRateConfig>>;
|
|
710
|
-
/**
|
|
711
|
-
* Construct and simulate a update_protocol_limits 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.
|
|
712
|
-
*/
|
|
713
|
-
update_protocol_limits: ({ caller, limits }: {
|
|
714
|
-
caller: string;
|
|
715
|
-
limits: ProtocolLimits;
|
|
716
|
-
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
717
|
-
/**
|
|
718
|
-
* Construct and simulate a update_borrow_rate_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.
|
|
719
|
-
*/
|
|
720
|
-
update_borrow_rate_config: ({ caller, config }: {
|
|
721
|
-
caller: string;
|
|
722
|
-
config: BorrowRateConfig;
|
|
723
|
-
}, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
|
|
724
658
|
}
|
|
725
659
|
export declare class Client extends ContractClient {
|
|
726
660
|
readonly options: ContractClientOptions;
|
|
727
661
|
static deploy<T = Client>(
|
|
728
662
|
/** Constructor/Initialization Args for the contract's `__constructor` method */
|
|
729
|
-
{
|
|
730
|
-
|
|
663
|
+
{ admin }: {
|
|
664
|
+
admin: string;
|
|
731
665
|
},
|
|
732
666
|
/** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
|
|
733
667
|
options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
|
|
@@ -748,19 +682,11 @@ export declare class Client extends ContractClient {
|
|
|
748
682
|
accept_admin: (json: string) => AssembledTransaction<null>;
|
|
749
683
|
propose_admin: (json: string) => AssembledTransaction<null>;
|
|
750
684
|
cancel_upgrade: (json: string) => AssembledTransaction<null>;
|
|
751
|
-
get_fee_config: (json: string) => AssembledTransaction<FeeConfig>;
|
|
752
|
-
get_fee_splits: (json: string) => AssembledTransaction<FeeSplits>;
|
|
753
|
-
set_fee_config: (json: string) => AssembledTransaction<null>;
|
|
754
685
|
propose_upgrade: (json: string) => AssembledTransaction<null>;
|
|
755
686
|
bump_config_state: (json: string) => AssembledTransaction<null>;
|
|
756
687
|
get_pending_admin: (json: string) => AssembledTransaction<Option<string>>;
|
|
757
|
-
update_fee_splits: (json: string) => AssembledTransaction<null>;
|
|
758
|
-
get_protocol_limits: (json: string) => AssembledTransaction<ProtocolLimits>;
|
|
759
688
|
get_upgrade_timelock: (json: string) => AssembledTransaction<bigint>;
|
|
760
689
|
set_upgrade_timelock: (json: string) => AssembledTransaction<null>;
|
|
761
690
|
cancel_admin_proposal: (json: string) => AssembledTransaction<null>;
|
|
762
|
-
get_borrow_rate_config: (json: string) => AssembledTransaction<BorrowRateConfig>;
|
|
763
|
-
update_protocol_limits: (json: string) => AssembledTransaction<null>;
|
|
764
|
-
update_borrow_rate_config: (json: string) => AssembledTransaction<null>;
|
|
765
691
|
};
|
|
766
692
|
}
|