@the-situation/starknet 0.5.0-alpha.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.
- package/dist/contracts/amm-types.d.ts +319 -0
- package/dist/contracts/amm-types.d.ts.map +1 -0
- package/dist/contracts/amm-types.js +59 -0
- package/dist/contracts/amm-types.js.map +1 -0
- package/dist/contracts/amm.d.ts +551 -0
- package/dist/contracts/amm.d.ts.map +1 -0
- package/dist/contracts/amm.js +1202 -0
- package/dist/contracts/amm.js.map +1 -0
- package/dist/contracts/base.d.ts +124 -0
- package/dist/contracts/base.d.ts.map +1 -0
- package/dist/contracts/base.js +187 -0
- package/dist/contracts/base.js.map +1 -0
- package/dist/contracts/factory.d.ts +74 -0
- package/dist/contracts/factory.d.ts.map +1 -0
- package/dist/contracts/factory.js +158 -0
- package/dist/contracts/factory.js.map +1 -0
- package/dist/contracts/index.d.ts +11 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +11 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/math-library.d.ts +47 -0
- package/dist/contracts/math-library.d.ts.map +1 -0
- package/dist/contracts/math-library.js +225 -0
- package/dist/contracts/math-library.js.map +1 -0
- package/dist/contracts/oracle.d.ts +137 -0
- package/dist/contracts/oracle.d.ts.map +1 -0
- package/dist/contracts/oracle.js +220 -0
- package/dist/contracts/oracle.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/account.d.ts +46 -0
- package/dist/providers/account.d.ts.map +1 -0
- package/dist/providers/account.js +57 -0
- package/dist/providers/account.js.map +1 -0
- package/dist/providers/base.d.ts +75 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +92 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +8 -0
- package/dist/providers/index.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for AMM contract interactions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { NormalSqrtHintsRaw } from '@the-situation/abi';
|
|
7
|
+
import { NormalDistribution, SQ128x128, type SQ128x128Raw } from '@the-situation/core';
|
|
8
|
+
/**
|
|
9
|
+
* Parsed AMM parameters with SQ128x128 values.
|
|
10
|
+
*/
|
|
11
|
+
export interface AmmParams {
|
|
12
|
+
readonly k: SQ128x128;
|
|
13
|
+
readonly backing: SQ128x128;
|
|
14
|
+
readonly tolerance: SQ128x128;
|
|
15
|
+
readonly minTradeCollateral: SQ128x128;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parsed market status.
|
|
19
|
+
*/
|
|
20
|
+
export interface MarketStatus {
|
|
21
|
+
readonly isInitialized: boolean;
|
|
22
|
+
readonly isPaused: boolean;
|
|
23
|
+
readonly isSettled: boolean;
|
|
24
|
+
readonly settlementValue: SQ128x128 | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parsed AMM configuration.
|
|
28
|
+
*/
|
|
29
|
+
export interface AmmConfig {
|
|
30
|
+
readonly collateralToken: string;
|
|
31
|
+
readonly tokenDecimals: number;
|
|
32
|
+
readonly internalDecimals: number;
|
|
33
|
+
readonly decimalShift: number;
|
|
34
|
+
readonly params: AmmParams;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parsed position data.
|
|
38
|
+
*/
|
|
39
|
+
export interface Position {
|
|
40
|
+
readonly distribution: NormalDistribution;
|
|
41
|
+
readonly collateralLocked: SQ128x128;
|
|
42
|
+
readonly exists: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compact position information with original distribution.
|
|
46
|
+
*
|
|
47
|
+
* Contains the trader's original distribution (the market state before their first trade)
|
|
48
|
+
* plus position flags. Used for close_position operations.
|
|
49
|
+
*/
|
|
50
|
+
export interface PositionCompact {
|
|
51
|
+
/** Original mean when trader first entered */
|
|
52
|
+
readonly originalMean: SQ128x128;
|
|
53
|
+
/** Original variance when trader first entered */
|
|
54
|
+
readonly originalVariance: SQ128x128;
|
|
55
|
+
/** Original sigma when trader first entered */
|
|
56
|
+
readonly originalSigma: SQ128x128;
|
|
57
|
+
/** Whether the trader has ever traded in this market */
|
|
58
|
+
readonly exists: boolean;
|
|
59
|
+
/** Whether the position has been claimed after market settlement */
|
|
60
|
+
readonly claimed: boolean;
|
|
61
|
+
/** Whether the trader closed their position before market settlement */
|
|
62
|
+
readonly earlySettled: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parsed LP pool information.
|
|
66
|
+
*/
|
|
67
|
+
export interface LPInfo {
|
|
68
|
+
readonly totalShares: SQ128x128;
|
|
69
|
+
readonly totalBackingDeposited: SQ128x128;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Fee configuration (in basis points).
|
|
73
|
+
*/
|
|
74
|
+
export interface FeeConfig {
|
|
75
|
+
readonly lpFeeBps: number;
|
|
76
|
+
readonly protocolFeeBps: number;
|
|
77
|
+
readonly settlementFeeBps: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Trade parameters for check_trade and execute_trade.
|
|
81
|
+
*/
|
|
82
|
+
export interface TradeParams {
|
|
83
|
+
/** Candidate distribution mean */
|
|
84
|
+
readonly candidateMean: SQ128x128Raw;
|
|
85
|
+
/** Candidate distribution variance */
|
|
86
|
+
readonly candidateVariance: SQ128x128Raw;
|
|
87
|
+
/** Candidate distribution sigma (sqrt of variance) */
|
|
88
|
+
readonly candidateSigma: SQ128x128Raw;
|
|
89
|
+
/** x* value for collateral computation */
|
|
90
|
+
readonly xStar: SQ128x128Raw;
|
|
91
|
+
/** Collateral supplied by trader */
|
|
92
|
+
readonly suppliedCollateral: SQ128x128Raw;
|
|
93
|
+
/** Precomputed sqrt hints */
|
|
94
|
+
readonly hints: NormalSqrtHintsRaw;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parsed backing check result.
|
|
98
|
+
*/
|
|
99
|
+
export interface BackingCheck {
|
|
100
|
+
readonly maxValueUpper: SQ128x128;
|
|
101
|
+
readonly isValid: boolean;
|
|
102
|
+
readonly computationSucceeded: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Parsed collateral verification result.
|
|
106
|
+
*/
|
|
107
|
+
export interface CollateralVerification {
|
|
108
|
+
readonly sideValid: boolean;
|
|
109
|
+
readonly stationaryValid: boolean;
|
|
110
|
+
readonly curvatureValid: boolean;
|
|
111
|
+
readonly computedCollateral: SQ128x128;
|
|
112
|
+
readonly collateralSufficient: boolean;
|
|
113
|
+
readonly computationValid: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Parsed trade check result.
|
|
117
|
+
*/
|
|
118
|
+
export interface TradeCheck {
|
|
119
|
+
readonly backingCheck: BackingCheck;
|
|
120
|
+
readonly verification: CollateralVerification;
|
|
121
|
+
readonly minTradeCollateral: SQ128x128;
|
|
122
|
+
readonly collateralAboveMin: boolean;
|
|
123
|
+
readonly isValid: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parsed trade execution result.
|
|
127
|
+
*/
|
|
128
|
+
export interface TradeExecution {
|
|
129
|
+
readonly check: TradeCheck;
|
|
130
|
+
readonly tokenAmount: bigint;
|
|
131
|
+
readonly deltaIndex: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Result of execute_trade with clear success/rejection semantics.
|
|
135
|
+
*
|
|
136
|
+
* **IMPORTANT (v0.4.0 change):** The contract NOW REVERTS on invalid trades.
|
|
137
|
+
* This type is returned only for SUCCESSFUL trades. For rejected trades,
|
|
138
|
+
* the transaction will throw with one of these error messages:
|
|
139
|
+
* - `'INVALID_DISTRIBUTION'` - candidate distribution is invalid (negative variance, sigma mismatch)
|
|
140
|
+
* - `'INVALID_HINTS'` - sqrt hints computation failed
|
|
141
|
+
* - `'BACKING_CONSTRAINT_FAILED'` - trade violates backing invariant
|
|
142
|
+
* - `'INSUFFICIENT_COLLATERAL'` - collateral below required amount
|
|
143
|
+
* - `'VERIFICATION_FAILED'` - collateral verification failed
|
|
144
|
+
*
|
|
145
|
+
* Use MathLibrary.check_trade_view() to preview trade validity before executing.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* try {
|
|
150
|
+
* const result = await amm.execute_trade(...);
|
|
151
|
+
* // Trade succeeded - result.success is always true here
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* // Trade rejected - parse error message for rejection reason
|
|
154
|
+
* console.log('Trade rejected:', error.message);
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export interface TradeResult {
|
|
159
|
+
/** Always true if returned (v0.4.0+ reverts on failure) */
|
|
160
|
+
readonly success: true;
|
|
161
|
+
/** The trade execution details */
|
|
162
|
+
readonly execution: TradeExecution;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Details about why a trade was rejected.
|
|
166
|
+
*
|
|
167
|
+
* Populated when `TradeResult.success` is false.
|
|
168
|
+
*/
|
|
169
|
+
export interface TradeRejectionInfo {
|
|
170
|
+
/** Human-readable reason for rejection */
|
|
171
|
+
readonly reason: string;
|
|
172
|
+
/** The trade check that failed */
|
|
173
|
+
readonly check: TradeCheck;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Determines the reason for trade rejection from a TradeCheck.
|
|
177
|
+
*/
|
|
178
|
+
export declare function getTradeRejectionReason(check: TradeCheck): string;
|
|
179
|
+
/**
|
|
180
|
+
* Settlement state of a position.
|
|
181
|
+
*
|
|
182
|
+
* Provides clear semantics for position lifecycle:
|
|
183
|
+
* - `never_traded`: Trader has never participated in this market
|
|
184
|
+
* - `active`: Trader has an open position (net deltas != 0)
|
|
185
|
+
* - `flat`: Trader has traded but net position is zero (not yet settled)
|
|
186
|
+
* - `early_settled`: Trader called close_position() before market settlement
|
|
187
|
+
* - `claimed`: Trader called claim() after market settlement
|
|
188
|
+
*/
|
|
189
|
+
export type SettlementState = 'never_traded' | 'active' | 'flat' | 'early_settled' | 'claimed';
|
|
190
|
+
/**
|
|
191
|
+
* Extended position information with settlement state.
|
|
192
|
+
*/
|
|
193
|
+
export interface PositionExtended {
|
|
194
|
+
/** Number of position deltas (cumulative, only increases) */
|
|
195
|
+
readonly deltaCount: number;
|
|
196
|
+
/** Total collateral locked across all deltas */
|
|
197
|
+
readonly totalCollateralLocked: SQ128x128;
|
|
198
|
+
/** Whether the position has been claimed after market settlement */
|
|
199
|
+
readonly claimed: boolean;
|
|
200
|
+
/** Whether the trader closed their position before market settlement */
|
|
201
|
+
readonly earlySettled: boolean;
|
|
202
|
+
/** Whether the trader has ever traded in this market */
|
|
203
|
+
readonly exists: boolean;
|
|
204
|
+
/** Computed settlement state */
|
|
205
|
+
readonly settlementState: SettlementState;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Reason for close position rejection.
|
|
209
|
+
*/
|
|
210
|
+
export declare enum CloseRejection {
|
|
211
|
+
None = "None",
|
|
212
|
+
NoPosition = "NoPosition",
|
|
213
|
+
MarketSettled = "MarketSettled",
|
|
214
|
+
MarketPaused = "MarketPaused",
|
|
215
|
+
AlreadyClosed = "AlreadyClosed",
|
|
216
|
+
AlreadyClaimed = "AlreadyClaimed",
|
|
217
|
+
InvalidAdditionalCollateral = "InvalidAdditionalCollateral",
|
|
218
|
+
InvalidPositionState = "InvalidPositionState",
|
|
219
|
+
InvalidHints = "InvalidHints",
|
|
220
|
+
BackingFail = "BackingFail",
|
|
221
|
+
LowCollateral = "LowCollateral",
|
|
222
|
+
VerificationFailed = "VerificationFailed",
|
|
223
|
+
CollateralTooLarge = "CollateralTooLarge",
|
|
224
|
+
InvalidState = "InvalidState"
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Parsed close position preview.
|
|
228
|
+
*/
|
|
229
|
+
export interface ClosePreview {
|
|
230
|
+
readonly effectiveDistribution: NormalDistribution;
|
|
231
|
+
readonly targetDistribution: NormalDistribution;
|
|
232
|
+
readonly marketDistribution: NormalDistribution;
|
|
233
|
+
readonly wouldBeFlat: boolean;
|
|
234
|
+
readonly collateralRequired: SQ128x128;
|
|
235
|
+
readonly existingCollateral: SQ128x128;
|
|
236
|
+
readonly additionalRequired: SQ128x128;
|
|
237
|
+
readonly estimatedPayout: bigint;
|
|
238
|
+
readonly lpFee: bigint;
|
|
239
|
+
readonly protocolFee: bigint;
|
|
240
|
+
readonly canClose: boolean;
|
|
241
|
+
readonly rejectionReason: CloseRejection;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Parsed position close result.
|
|
245
|
+
*/
|
|
246
|
+
export interface PositionCloseResult {
|
|
247
|
+
readonly tradeExecuted: boolean;
|
|
248
|
+
readonly tradeResult: TradeExecution | null;
|
|
249
|
+
readonly isFlat: boolean;
|
|
250
|
+
readonly immediatePayout: bigint;
|
|
251
|
+
readonly collateralRequired: SQ128x128;
|
|
252
|
+
readonly existingCollateral: SQ128x128;
|
|
253
|
+
readonly additionalRequired: SQ128x128;
|
|
254
|
+
readonly netAdditionalCollateral: SQ128x128;
|
|
255
|
+
readonly lpFee: bigint;
|
|
256
|
+
readonly protocolFee: bigint;
|
|
257
|
+
readonly rejectionReason: CloseRejection;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Parameters for closing a position.
|
|
261
|
+
*/
|
|
262
|
+
export interface ClosePositionParams {
|
|
263
|
+
/** x* value for collateral computation */
|
|
264
|
+
readonly xStar: SQ128x128Raw;
|
|
265
|
+
/** Additional collateral to supply (if needed) */
|
|
266
|
+
readonly additionalCollateral: SQ128x128Raw;
|
|
267
|
+
/** Precomputed hints for target distribution */
|
|
268
|
+
readonly targetHints: NormalSqrtHintsRaw;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Raw call points from contract (snake_case).
|
|
272
|
+
*/
|
|
273
|
+
export interface CallPointsRaw {
|
|
274
|
+
readonly before_initialize: boolean;
|
|
275
|
+
readonly after_initialize: boolean;
|
|
276
|
+
readonly before_trade: boolean;
|
|
277
|
+
readonly after_trade: boolean;
|
|
278
|
+
readonly before_add_liquidity: boolean;
|
|
279
|
+
readonly after_add_liquidity: boolean;
|
|
280
|
+
readonly before_remove_liquidity: boolean;
|
|
281
|
+
readonly after_remove_liquidity: boolean;
|
|
282
|
+
readonly before_claim: boolean;
|
|
283
|
+
readonly after_claim: boolean;
|
|
284
|
+
readonly before_settle: boolean;
|
|
285
|
+
readonly after_settle: boolean;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Parsed call points for an extension (camelCase).
|
|
289
|
+
*
|
|
290
|
+
* Each flag indicates whether the extension has registered to receive
|
|
291
|
+
* the corresponding hook callback from the AMM.
|
|
292
|
+
*/
|
|
293
|
+
export interface CallPointsResult {
|
|
294
|
+
/** Called before market initialization */
|
|
295
|
+
readonly beforeInitialize: boolean;
|
|
296
|
+
/** Called after market initialization */
|
|
297
|
+
readonly afterInitialize: boolean;
|
|
298
|
+
/** Called before each trade execution */
|
|
299
|
+
readonly beforeTrade: boolean;
|
|
300
|
+
/** Called after each trade execution */
|
|
301
|
+
readonly afterTrade: boolean;
|
|
302
|
+
/** Called before liquidity is added */
|
|
303
|
+
readonly beforeAddLiquidity: boolean;
|
|
304
|
+
/** Called after liquidity is added */
|
|
305
|
+
readonly afterAddLiquidity: boolean;
|
|
306
|
+
/** Called before liquidity is removed */
|
|
307
|
+
readonly beforeRemoveLiquidity: boolean;
|
|
308
|
+
/** Called after liquidity is removed */
|
|
309
|
+
readonly afterRemoveLiquidity: boolean;
|
|
310
|
+
/** Called before a position is claimed */
|
|
311
|
+
readonly beforeClaim: boolean;
|
|
312
|
+
/** Called after a position is claimed */
|
|
313
|
+
readonly afterClaim: boolean;
|
|
314
|
+
/** Called before market settlement */
|
|
315
|
+
readonly beforeSettle: boolean;
|
|
316
|
+
/** Called after market settlement */
|
|
317
|
+
readonly afterSettle: boolean;
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=amm-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-types.d.ts","sourceRoot":"","sources":["../../src/contracts/amm-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMvF;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,SAAS,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,YAA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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for AMM contract interactions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Determines the reason for trade rejection from a TradeCheck.
|
|
8
|
+
*/
|
|
9
|
+
export function getTradeRejectionReason(check) {
|
|
10
|
+
if (!check.backingCheck.computationSucceeded) {
|
|
11
|
+
return 'Backing computation failed';
|
|
12
|
+
}
|
|
13
|
+
if (!check.backingCheck.isValid) {
|
|
14
|
+
return 'Backing constraint violated';
|
|
15
|
+
}
|
|
16
|
+
if (!check.verification.computationValid) {
|
|
17
|
+
return 'Collateral verification computation failed';
|
|
18
|
+
}
|
|
19
|
+
if (!check.verification.sideValid) {
|
|
20
|
+
return 'Side constraint violated (position direction)';
|
|
21
|
+
}
|
|
22
|
+
if (!check.verification.stationaryValid) {
|
|
23
|
+
return 'Stationary constraint violated';
|
|
24
|
+
}
|
|
25
|
+
if (!check.verification.curvatureValid) {
|
|
26
|
+
return 'Curvature constraint violated';
|
|
27
|
+
}
|
|
28
|
+
if (!check.verification.collateralSufficient) {
|
|
29
|
+
return 'Insufficient collateral supplied';
|
|
30
|
+
}
|
|
31
|
+
if (!check.collateralAboveMin) {
|
|
32
|
+
return 'Collateral below minimum trade amount';
|
|
33
|
+
}
|
|
34
|
+
return 'Unknown rejection reason';
|
|
35
|
+
}
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Close Position Types (v0.1.4)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Reason for close position rejection.
|
|
41
|
+
*/
|
|
42
|
+
export var CloseRejection;
|
|
43
|
+
(function (CloseRejection) {
|
|
44
|
+
CloseRejection["None"] = "None";
|
|
45
|
+
CloseRejection["NoPosition"] = "NoPosition";
|
|
46
|
+
CloseRejection["MarketSettled"] = "MarketSettled";
|
|
47
|
+
CloseRejection["MarketPaused"] = "MarketPaused";
|
|
48
|
+
CloseRejection["AlreadyClosed"] = "AlreadyClosed";
|
|
49
|
+
CloseRejection["AlreadyClaimed"] = "AlreadyClaimed";
|
|
50
|
+
CloseRejection["InvalidAdditionalCollateral"] = "InvalidAdditionalCollateral";
|
|
51
|
+
CloseRejection["InvalidPositionState"] = "InvalidPositionState";
|
|
52
|
+
CloseRejection["InvalidHints"] = "InvalidHints";
|
|
53
|
+
CloseRejection["BackingFail"] = "BackingFail";
|
|
54
|
+
CloseRejection["LowCollateral"] = "LowCollateral";
|
|
55
|
+
CloseRejection["VerificationFailed"] = "VerificationFailed";
|
|
56
|
+
CloseRejection["CollateralTooLarge"] = "CollateralTooLarge";
|
|
57
|
+
CloseRejection["InvalidState"] = "InvalidState";
|
|
58
|
+
})(CloseRejection || (CloseRejection = {}));
|
|
59
|
+
//# sourceMappingURL=amm-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-types.js","sourceRoot":"","sources":["../../src/contracts/amm-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsMH;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAiB;IACvD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC;QAC7C,OAAO,4BAA4B,CAAC;IACtC,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,OAAO,6BAA6B,CAAC;IACvC,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC;QACzC,OAAO,4CAA4C,CAAC;IACtD,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;QAClC,OAAO,+CAA+C,CAAC;IACzD,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;QACxC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;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