@win-trader/bindings 0.0.4 → 0.3.0

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.
@@ -0,0 +1,660 @@
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, Option } 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 MarketGovernorError: {
8
+ 500: {
9
+ message: string;
10
+ };
11
+ 510: {
12
+ message: string;
13
+ };
14
+ 520: {
15
+ message: string;
16
+ };
17
+ 521: {
18
+ message: string;
19
+ };
20
+ 530: {
21
+ message: string;
22
+ };
23
+ 531: {
24
+ message: string;
25
+ };
26
+ 540: {
27
+ message: string;
28
+ };
29
+ 541: {
30
+ message: string;
31
+ };
32
+ 542: {
33
+ message: string;
34
+ };
35
+ };
36
+ export type Key = {
37
+ tag: "ConfigManager";
38
+ values: void;
39
+ } | {
40
+ tag: "PositionManager";
41
+ values: void;
42
+ } | {
43
+ tag: "PendingGlobalConfig";
44
+ values: void;
45
+ } | {
46
+ tag: "PendingMarketConfig";
47
+ values: readonly [string];
48
+ } | {
49
+ tag: "PendingPriceFeed";
50
+ values: void;
51
+ } | {
52
+ tag: "Version";
53
+ values: void;
54
+ };
55
+ /**
56
+ * SEP-40 asset identifier. Markets are quoted as `Other(market symbol)`.
57
+ */
58
+ export type Asset = {
59
+ tag: "Stellar";
60
+ values: readonly [string];
61
+ } | {
62
+ tag: "Other";
63
+ values: readonly [string];
64
+ };
65
+ export interface PriceData {
66
+ price: i128;
67
+ timestamp: u64;
68
+ }
69
+ export interface StampedPrice {
70
+ observed_at: u64;
71
+ price: i128;
72
+ }
73
+ export interface Market {
74
+ config: MarketConfig;
75
+ current_payer_rate: i128;
76
+ current_payer_side: PayerSide;
77
+ last_funding_checkpoint: u64;
78
+ long: MarketSide;
79
+ long_payer_remainders: RemainderGroup;
80
+ lp_backed_index_long: i128;
81
+ lp_backed_index_short: i128;
82
+ pending_receiver_funding: i128;
83
+ receiver_backed_index_long: i128;
84
+ receiver_backed_index_short: i128;
85
+ receiver_index_long: i128;
86
+ receiver_index_short: i128;
87
+ short: MarketSide;
88
+ short_payer_remainders: RemainderGroup;
89
+ skew_ema: i128;
90
+ }
91
+ export type Trigger = {
92
+ tag: "None";
93
+ values: void;
94
+ } | {
95
+ tag: "Attached";
96
+ values: readonly [TriggerInstruction];
97
+ };
98
+ export interface LpConfig {
99
+ lp_request_delay_seconds: u64;
100
+ max_withdraw_utilization_bps: u32;
101
+ min_deposit_nav_factor_bps: u32;
102
+ }
103
+ export interface Position {
104
+ base_exposure: i128;
105
+ borrow_index_snapshot: i128;
106
+ id: u64;
107
+ is_long: boolean;
108
+ lp_payer_index_snapshot: i128;
109
+ market: string;
110
+ opened_at: u64;
111
+ owner: string;
112
+ pending_mutation_action_id: Option<u64>;
113
+ receiver_index_snapshot: i128;
114
+ receiver_payer_index_snapshot: i128;
115
+ risk_units: i128;
116
+ size: i128;
117
+ stop_loss: Trigger;
118
+ stored_collateral: i128;
119
+ stored_minimum_borrow_fee: i128;
120
+ take_profit: Trigger;
121
+ }
122
+ export interface LpRequest {
123
+ amount: i128;
124
+ execute_after: u64;
125
+ id: u64;
126
+ kind: LpRequestKind;
127
+ owner: string;
128
+ request_time: u64;
129
+ /**
130
+ * The resolve reward fixed when the request was made.
131
+ */
132
+ reward: i128;
133
+ status: LpRequestStatus;
134
+ }
135
+ export type PayerSide = {
136
+ tag: "None";
137
+ values: void;
138
+ } | {
139
+ tag: "Long";
140
+ values: void;
141
+ } | {
142
+ tag: "Short";
143
+ values: void;
144
+ };
145
+ export type RiskState = {
146
+ tag: "Normal";
147
+ values: void;
148
+ } | {
149
+ tag: "Warning";
150
+ values: void;
151
+ } | {
152
+ tag: "Adl";
153
+ values: void;
154
+ } | {
155
+ tag: "HardCap";
156
+ values: void;
157
+ };
158
+ export type ActionKind = {
159
+ tag: "MarketOpen";
160
+ values: void;
161
+ } | {
162
+ tag: "LimitOpen";
163
+ values: void;
164
+ } | {
165
+ tag: "Decrease";
166
+ values: void;
167
+ } | {
168
+ tag: "Close";
169
+ values: void;
170
+ };
171
+ export interface MarketSide {
172
+ base_exposure: i128;
173
+ hard_cap_payout_factor: i128;
174
+ hard_cap_reference_pnl: i128;
175
+ risk_state: RiskState;
176
+ risk_units: i128;
177
+ size_open_interest: i128;
178
+ stored_collateral_total: i128;
179
+ }
180
+ export interface OpenPayload {
181
+ acceptable_price: i128;
182
+ expires_at: u64;
183
+ is_long: boolean;
184
+ size: i128;
185
+ stop_loss: i128;
186
+ submitted_collateral: i128;
187
+ take_profit: i128;
188
+ }
189
+ export interface ClosePayload {
190
+ acceptable_price: i128;
191
+ position_id: u64;
192
+ }
193
+ export interface GlobalConfig {
194
+ base_borrow_rate_bps_day: i128;
195
+ borrow_lp_revenue_share_bps: u32;
196
+ config_timelock_seconds: u64;
197
+ fee_lp_revenue_share_bps: u32;
198
+ funding_half_life_seconds: u64;
199
+ global_hard_cap_limit_bps: u32;
200
+ hard_cap_relatch_band_bps: u32;
201
+ keeper_rewards: KeeperRewards;
202
+ max_active_markets: u32;
203
+ max_market_order_lifetime: u64;
204
+ max_order_lifetime_seconds: u64;
205
+ max_price_age_seconds: u64;
206
+ max_variable_borrow_bps_day: i128;
207
+ min_borrow_fee_seconds: u64;
208
+ min_collateral: i128;
209
+ min_position_lifetime: u64;
210
+ risk_capacity_limit_bps: u32;
211
+ }
212
+ export interface MarketConfig {
213
+ adl_pnl_factor_bps: u32;
214
+ close_pnl_fee_bps: u32;
215
+ close_size_fee_bps: u32;
216
+ hard_cap_pnl_factor_bps: u32;
217
+ initial_margin_bps: u32;
218
+ instant_weight_bps: u32;
219
+ maintenance_margin_bps: u32;
220
+ market_risk_factor_bps: u32;
221
+ max_funding_rate_bps_day: i128;
222
+ max_long_base_exposure: i128;
223
+ max_long_size_open_interest: i128;
224
+ max_short_base_exposure: i128;
225
+ max_short_size_open_interest: i128;
226
+ open_fee_bps: u32;
227
+ order_execution_delay_seconds: u64;
228
+ recovery_pnl_factor_bps: u32;
229
+ warning_pnl_factor_bps: u32;
230
+ }
231
+ export type ActionOutcome = {
232
+ tag: "Executed";
233
+ values: void;
234
+ } | {
235
+ tag: "Failed";
236
+ values: void;
237
+ } | {
238
+ tag: "Cancelled";
239
+ values: void;
240
+ } | {
241
+ tag: "Expired";
242
+ values: void;
243
+ } | {
244
+ tag: "Superseded";
245
+ values: void;
246
+ } | {
247
+ tag: "NotReady";
248
+ values: void;
249
+ } | {
250
+ tag: "Pending";
251
+ values: void;
252
+ } | {
253
+ tag: "RequiresLiquidation";
254
+ values: void;
255
+ };
256
+ export type ActionPayload = {
257
+ tag: "MarketOpen";
258
+ values: readonly [OpenPayload];
259
+ } | {
260
+ tag: "LimitOpen";
261
+ values: readonly [OpenPayload, TriggerCondition];
262
+ } | {
263
+ tag: "Decrease";
264
+ values: readonly [DecreasePayload];
265
+ } | {
266
+ tag: "Close";
267
+ values: readonly [ClosePayload];
268
+ };
269
+ export type FailureReason = {
270
+ tag: "PriceBoundExceeded";
271
+ values: void;
272
+ } | {
273
+ tag: "CapacityExceeded";
274
+ values: void;
275
+ } | {
276
+ tag: "ExposureCapExceeded";
277
+ values: void;
278
+ } | {
279
+ tag: "SideRestricted";
280
+ values: void;
281
+ } | {
282
+ tag: "InsufficientCollateral";
283
+ values: void;
284
+ } | {
285
+ tag: "UnpayableProfit";
286
+ values: void;
287
+ } | {
288
+ tag: "PositionGone";
289
+ values: void;
290
+ } | {
291
+ tag: "MarketPaused";
292
+ values: void;
293
+ } | {
294
+ tag: "SizeTooSmall";
295
+ values: void;
296
+ };
297
+ export interface KeeperRewards {
298
+ adl: i128;
299
+ close: i128;
300
+ decrease: i128;
301
+ expiry: i128;
302
+ limit_order: i128;
303
+ liquidation: i128;
304
+ lp_resolve: i128;
305
+ open: i128;
306
+ sl: i128;
307
+ tp: i128;
308
+ }
309
+ export type LpRequestKind = {
310
+ tag: "Deposit";
311
+ values: void;
312
+ } | {
313
+ tag: "Withdrawal";
314
+ values: void;
315
+ };
316
+ export interface MigrationData {
317
+ version: u32;
318
+ }
319
+ export interface PendingAction {
320
+ action_id: u64;
321
+ commit_observed_at: u64;
322
+ created_at: u64;
323
+ escrowed_collateral: i128;
324
+ execute_after: u64;
325
+ kind: ActionKind;
326
+ market_id: string;
327
+ owner: string;
328
+ payload: ActionPayload;
329
+ }
330
+ export interface PendingUpgrade {
331
+ eta: u64;
332
+ wasm_hash: Buffer;
333
+ }
334
+ export interface RemainderGroup {
335
+ distribution_remainder: i128;
336
+ lp_payer_remainder: i128;
337
+ receiver_liability_remainder: i128;
338
+ receiver_payer_remainder: i128;
339
+ }
340
+ export interface DecreasePayload {
341
+ acceptable_price: i128;
342
+ position_id: u64;
343
+ size_removed: i128;
344
+ }
345
+ export type LpRequestStatus = {
346
+ tag: "Pending";
347
+ values: void;
348
+ } | {
349
+ tag: "Settled";
350
+ values: void;
351
+ } | {
352
+ tag: "Failed";
353
+ values: void;
354
+ };
355
+ export interface PendingFeesView {
356
+ borrow: i128;
357
+ funding_paid_to_lps: i128;
358
+ funding_paid_to_receivers: i128;
359
+ funding_received: i128;
360
+ }
361
+ export interface PendingPriceFeed {
362
+ effective_at: u64;
363
+ price_feed: string;
364
+ }
365
+ export interface SettlementResult {
366
+ amount: i128;
367
+ reward: i128;
368
+ status: SettlementStatus;
369
+ }
370
+ export type SettlementStatus = {
371
+ tag: "Settled";
372
+ values: void;
373
+ } | {
374
+ tag: "Failed";
375
+ values: void;
376
+ } | {
377
+ tag: "NotReady";
378
+ values: void;
379
+ };
380
+ export interface TriggerCondition {
381
+ trigger_above: boolean;
382
+ trigger_price: i128;
383
+ }
384
+ export interface AccountingSnapshot {
385
+ cash_lp_equity: i128;
386
+ cash_shortfall: i128;
387
+ deleveraging_side_count: u32;
388
+ free_lp_capital: i128;
389
+ min_equity_clear_of_adl: i128;
390
+ non_lp_claims: i128;
391
+ open_position_count: u64;
392
+ physical_cash: i128;
393
+ required_risk_backing: i128;
394
+ restricted_side_count: u32;
395
+ total_risk_units: i128;
396
+ vault_nav: i128;
397
+ }
398
+ export interface TriggerInstruction {
399
+ acceptable_price: i128;
400
+ commit_observed_at: u64;
401
+ committed_at: u64;
402
+ execute_after: u64;
403
+ trigger_price: i128;
404
+ }
405
+ export interface PendingGlobalConfig {
406
+ config: GlobalConfig;
407
+ effective_at: u64;
408
+ }
409
+ export interface PendingMarketConfig {
410
+ config: MarketConfig;
411
+ effective_at: u64;
412
+ }
413
+ export interface EventHeader {
414
+ actor: string;
415
+ event_version: u32;
416
+ ledger_timestamp: u64;
417
+ market: string;
418
+ }
419
+ export declare const UpgradeableError: {
420
+ /**
421
+ * When migration is attempted but not allowed due to upgrade state.
422
+ */
423
+ 1100: {
424
+ message: string;
425
+ };
426
+ };
427
+ export declare const MerkleDistributorError: {
428
+ /**
429
+ * The merkle root is not set.
430
+ */
431
+ 1300: {
432
+ message: string;
433
+ };
434
+ /**
435
+ * The provided index was already claimed.
436
+ */
437
+ 1301: {
438
+ message: string;
439
+ };
440
+ /**
441
+ * The proof is invalid.
442
+ */
443
+ 1302: {
444
+ message: string;
445
+ };
446
+ };
447
+ /**
448
+ * Rounding direction for division operations
449
+ */
450
+ export type Rounding = {
451
+ tag: "Floor";
452
+ values: void;
453
+ } | {
454
+ tag: "Ceil";
455
+ values: void;
456
+ } | {
457
+ tag: "Truncate";
458
+ values: void;
459
+ };
460
+ export declare const SorobanFixedPointError: {
461
+ /**
462
+ * Arithmetic overflow occurred
463
+ */
464
+ 1500: {
465
+ message: string;
466
+ };
467
+ /**
468
+ * Division by zero
469
+ */
470
+ 1501: {
471
+ message: string;
472
+ };
473
+ };
474
+ export declare const PausableError: {
475
+ /**
476
+ * The operation failed because the contract is paused.
477
+ */
478
+ 1000: {
479
+ message: string;
480
+ };
481
+ /**
482
+ * The operation failed because the contract is not paused.
483
+ */
484
+ 1001: {
485
+ message: string;
486
+ };
487
+ };
488
+ /**
489
+ * Storage keys for the data associated with `MerkleDistributor`
490
+ */
491
+ export type MerkleDistributorStorageKey = {
492
+ tag: "Root";
493
+ values: void;
494
+ } | {
495
+ tag: "Claimed";
496
+ values: readonly [u32];
497
+ };
498
+ export declare const CryptoError: {
499
+ /**
500
+ * The merkle proof length is out of bounds.
501
+ */
502
+ 1400: {
503
+ message: string;
504
+ };
505
+ /**
506
+ * The index of the leaf is out of bounds.
507
+ */
508
+ 1401: {
509
+ message: string;
510
+ };
511
+ /**
512
+ * No data in hasher state.
513
+ */
514
+ 1402: {
515
+ message: string;
516
+ };
517
+ };
518
+ /**
519
+ * Storage key for the pausable state
520
+ */
521
+ export type PausableStorageKey = {
522
+ tag: "Paused";
523
+ values: void;
524
+ };
525
+ export interface Client {
526
+ /**
527
+ * 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.
528
+ */
529
+ migrate: ({ data, operator }: {
530
+ data: MigrationData;
531
+ operator: string;
532
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
533
+ /**
534
+ * 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.
535
+ */
536
+ upgrade: ({ new_wasm_hash, operator }: {
537
+ new_wasm_hash: Buffer;
538
+ operator: string;
539
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
540
+ /**
541
+ * 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.
542
+ */
543
+ cancel_upgrade: ({ caller }: {
544
+ caller: string;
545
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
546
+ /**
547
+ * 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.
548
+ */
549
+ propose_upgrade: ({ caller, wasm_hash }: {
550
+ caller: string;
551
+ wasm_hash: Buffer;
552
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
553
+ /**
554
+ * Construct and simulate a apply_price_feed 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.
555
+ */
556
+ apply_price_feed: ({ caller }: {
557
+ caller: string;
558
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
559
+ /**
560
+ * Construct and simulate a position_manager 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.
561
+ */
562
+ position_manager: (options?: MethodOptions) => Promise<AssembledTransaction<string>>;
563
+ /**
564
+ * Construct and simulate a cancel_price_feed 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_price_feed: ({ caller }: {
567
+ caller: string;
568
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
569
+ /**
570
+ * Construct and simulate a deregister_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
+ deregister_market: ({ caller, market_symbol }: {
573
+ caller: string;
574
+ market_symbol: string;
575
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
576
+ /**
577
+ * Construct and simulate a propose_price_feed 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
+ propose_price_feed: ({ caller, price_feed }: {
580
+ caller: string;
581
+ price_feed: string;
582
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
583
+ /**
584
+ * Construct and simulate a apply_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.
585
+ */
586
+ apply_global_config: ({ caller }: {
587
+ caller: string;
588
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
589
+ /**
590
+ * Construct and simulate a apply_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.
591
+ */
592
+ apply_market_config: ({ caller, market_symbol }: {
593
+ caller: string;
594
+ market_symbol: string;
595
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
596
+ /**
597
+ * Construct and simulate a cancel_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.
598
+ */
599
+ cancel_global_config: ({ caller }: {
600
+ caller: string;
601
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
602
+ /**
603
+ * Construct and simulate a cancel_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.
604
+ */
605
+ cancel_market_config: ({ caller, market_symbol }: {
606
+ caller: string;
607
+ market_symbol: string;
608
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
609
+ /**
610
+ * Construct and simulate a propose_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.
611
+ */
612
+ propose_global_config: ({ caller, config }: {
613
+ caller: string;
614
+ config: GlobalConfig;
615
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
616
+ /**
617
+ * Construct and simulate a propose_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.
618
+ */
619
+ propose_market_config: ({ caller, market_symbol, config }: {
620
+ caller: string;
621
+ market_symbol: string;
622
+ config: MarketConfig;
623
+ }, options?: MethodOptions) => Promise<AssembledTransaction<null>>;
624
+ }
625
+ export declare class Client extends ContractClient {
626
+ readonly options: ContractClientOptions;
627
+ static deploy<T = Client>(
628
+ /** Constructor/Initialization Args for the contract's `__constructor` method */
629
+ { config_manager, position_manager }: {
630
+ config_manager: string;
631
+ position_manager: string;
632
+ },
633
+ /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */
634
+ options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
635
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
636
+ wasmHash: Buffer | string;
637
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
638
+ salt?: Buffer | Uint8Array;
639
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
640
+ format?: "hex" | "base64";
641
+ }): Promise<AssembledTransaction<T>>;
642
+ constructor(options: ContractClientOptions);
643
+ readonly fromJSON: {
644
+ migrate: (json: string) => AssembledTransaction<null>;
645
+ upgrade: (json: string) => AssembledTransaction<null>;
646
+ cancel_upgrade: (json: string) => AssembledTransaction<null>;
647
+ propose_upgrade: (json: string) => AssembledTransaction<null>;
648
+ apply_price_feed: (json: string) => AssembledTransaction<null>;
649
+ position_manager: (json: string) => AssembledTransaction<string>;
650
+ cancel_price_feed: (json: string) => AssembledTransaction<null>;
651
+ deregister_market: (json: string) => AssembledTransaction<null>;
652
+ propose_price_feed: (json: string) => AssembledTransaction<null>;
653
+ apply_global_config: (json: string) => AssembledTransaction<null>;
654
+ apply_market_config: (json: string) => AssembledTransaction<null>;
655
+ cancel_global_config: (json: string) => AssembledTransaction<null>;
656
+ cancel_market_config: (json: string) => AssembledTransaction<null>;
657
+ propose_global_config: (json: string) => AssembledTransaction<null>;
658
+ propose_market_config: (json: string) => AssembledTransaction<null>;
659
+ };
660
+ }