@the-situation/abi 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/amm.d.ts ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * AMM contract ABI types and function names.
3
+ *
4
+ * These match the latest `normal_amm` interface.
5
+ *
6
+ * @module
7
+ */
8
+ import type { NormalDistributionRaw, SQ128x128Raw } from '@the-situation/core';
9
+ import type { AmmConfigRaw, AmmParamsRaw, ClaimResultRaw, FeeConfigRaw, LPInfoRaw, MarketStatusRaw, NormalSqrtHintsRaw, PositionCloseResultRaw, PositionCompactRaw, PositionExtendedRaw, TradeExecutionRaw } from './common';
10
+ /**
11
+ * All AMM contract function names.
12
+ */
13
+ export declare const AMM_FUNCTION_NAMES: readonly ["get_params", "get_config", "get_distribution", "get_market_status", "get_owner", "get_admin", "get_position_extended", "get_position_compact", "get_lp_info", "get_distribution_hints", "get_lp_shares", "get_position_settlement_status", "get_extension", "get_extension_call_points", "get_market_key", "get_metadata_hash", "get_math_class_hash", "get_fee_config", "get_accumulated_protocol_fees", "get_token_balance", "execute_trade", "check_close_position", "close_position", "close_position_guarded", "claim", "add_liquidity", "remove_liquidity", "initialize", "pause", "unpause", "settle", "update_parameters", "transfer_ownership", "update_admin", "update_math_class_hash", "withdraw_protocol_fees", "emergency_withdraw", "clear_tokens"];
14
+ export type AmmFunctionName = (typeof AMM_FUNCTION_NAMES)[number];
15
+ /**
16
+ * Input for execute_trade.
17
+ */
18
+ export interface TradeInput {
19
+ readonly candidate: NormalDistributionRaw;
20
+ readonly xStar: SQ128x128Raw;
21
+ readonly suppliedCollateral: SQ128x128Raw;
22
+ readonly candidateHints: NormalSqrtHintsRaw;
23
+ }
24
+ /**
25
+ * Input for update_parameters.
26
+ */
27
+ export interface UpdateParametersInput {
28
+ readonly tolerance: SQ128x128Raw;
29
+ readonly minTradeCollateral: SQ128x128Raw;
30
+ }
31
+ /**
32
+ * Return type mapping for AMM view functions.
33
+ */
34
+ export interface AmmViewReturns {
35
+ get_params: AmmParamsRaw;
36
+ get_config: AmmConfigRaw;
37
+ get_distribution: NormalDistributionRaw;
38
+ get_market_status: MarketStatusRaw;
39
+ get_owner: string;
40
+ get_admin: string;
41
+ get_position_extended: PositionExtendedRaw;
42
+ get_position_compact: PositionCompactRaw;
43
+ get_lp_info: LPInfoRaw;
44
+ get_distribution_hints: NormalSqrtHintsRaw;
45
+ get_lp_shares: SQ128x128Raw;
46
+ get_position_settlement_status: unknown;
47
+ get_extension: string;
48
+ get_extension_call_points: unknown;
49
+ get_market_key: bigint;
50
+ get_metadata_hash: string;
51
+ get_math_class_hash: string;
52
+ get_fee_config: FeeConfigRaw;
53
+ get_accumulated_protocol_fees: bigint;
54
+ get_token_balance: bigint;
55
+ }
56
+ /**
57
+ * Return type mapping for AMM close position functions.
58
+ */
59
+ export interface AmmCloseReturns {
60
+ check_close_position: PositionCloseResultRaw;
61
+ close_position: PositionCloseResultRaw;
62
+ close_position_guarded: PositionCloseResultRaw;
63
+ }
64
+ /**
65
+ * Return type mapping for AMM trade functions.
66
+ */
67
+ export interface AmmTradeReturns {
68
+ execute_trade: TradeExecutionRaw;
69
+ }
70
+ /**
71
+ * Return type mapping for AMM LP functions.
72
+ */
73
+ export interface AmmLPReturns {
74
+ add_liquidity: bigint;
75
+ remove_liquidity: bigint;
76
+ }
77
+ /**
78
+ * Return type mapping for AMM settlement functions.
79
+ */
80
+ export interface AmmSettlementReturns {
81
+ claim: ClaimResultRaw;
82
+ }
83
+ //# sourceMappingURL=amm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amm.d.ts","sourceRoot":"","sources":["../src/amm.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,SAAS,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A6B,EAAE,MAAM,CAAC;IACtC,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oBAAoB,EAAE,sBAAsB,CAAC;IAC7C,cAAc,EAAE,sBAAsB,CAAC;IACvC,sBAAsB,EAAE,sBAAsB,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,iBAAiB,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,cAAc,CAAC;CACvB"}
package/dist/amm.js ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * AMM contract ABI types and function names.
3
+ *
4
+ * These match the latest `normal_amm` interface.
5
+ *
6
+ * @module
7
+ */
8
+ // ============================================================================
9
+ // Function Names
10
+ // ============================================================================
11
+ /**
12
+ * All AMM contract function names.
13
+ */
14
+ export const AMM_FUNCTION_NAMES = [
15
+ // View functions
16
+ 'get_params',
17
+ 'get_config',
18
+ 'get_distribution',
19
+ 'get_market_status',
20
+ 'get_owner',
21
+ 'get_admin',
22
+ 'get_position_extended',
23
+ 'get_position_compact',
24
+ 'get_lp_info',
25
+ 'get_distribution_hints',
26
+ 'get_lp_shares',
27
+ 'get_position_settlement_status',
28
+ 'get_extension',
29
+ 'get_extension_call_points',
30
+ 'get_market_key',
31
+ 'get_metadata_hash',
32
+ 'get_math_class_hash',
33
+ 'get_fee_config',
34
+ 'get_accumulated_protocol_fees',
35
+ 'get_token_balance',
36
+ // Trade / close
37
+ 'execute_trade',
38
+ 'check_close_position',
39
+ 'close_position',
40
+ 'close_position_guarded',
41
+ // Position settlement
42
+ 'claim',
43
+ // LP
44
+ 'add_liquidity',
45
+ 'remove_liquidity',
46
+ // Lifecycle + admin
47
+ 'initialize',
48
+ 'pause',
49
+ 'unpause',
50
+ 'settle',
51
+ 'update_parameters',
52
+ 'transfer_ownership',
53
+ 'update_admin',
54
+ 'update_math_class_hash',
55
+ // Fee / emergency
56
+ 'withdraw_protocol_fees',
57
+ 'emergency_withdraw',
58
+ 'clear_tokens',
59
+ ];
60
+ //# sourceMappingURL=amm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amm.js","sourceRoot":"","sources":["../src/amm.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,iBAAiB;IACjB,YAAY;IACZ,YAAY;IACZ,kBAAkB;IAClB,mBAAmB;IACnB,WAAW;IACX,WAAW;IACX,uBAAuB;IACvB,sBAAsB;IACtB,aAAa;IACb,wBAAwB;IACxB,eAAe;IACf,gCAAgC;IAChC,eAAe;IACf,2BAA2B;IAC3B,gBAAgB;IAChB,mBAAmB;IACnB,qBAAqB;IACrB,gBAAgB;IAChB,+BAA+B;IAC/B,mBAAmB;IAEnB,gBAAgB;IAChB,eAAe;IACf,sBAAsB;IACtB,gBAAgB;IAChB,wBAAwB;IAExB,sBAAsB;IACtB,OAAO;IAEP,KAAK;IACL,eAAe;IACf,kBAAkB;IAElB,oBAAoB;IACpB,YAAY;IACZ,OAAO;IACP,SAAS;IACT,QAAQ;IACR,mBAAmB;IACnB,oBAAoB;IACpB,cAAc;IACd,wBAAwB;IAExB,kBAAkB;IAClB,wBAAwB;IACxB,oBAAoB;IACpB,cAAc;CACN,CAAC"}
@@ -0,0 +1,403 @@
1
+ /**
2
+ * Common ABI types for The Situation contracts.
3
+ *
4
+ * These types match the Cairo `onchain::common` module and provide
5
+ * the serialization boundary between TypeScript and Starknet contracts.
6
+ *
7
+ * @module
8
+ */
9
+ import type { NormalDistributionRaw, NormalSqrtHintsRaw, SQ128x128Raw } from '@the-situation/core';
10
+ /** Maximum total fee in basis points (10% = 1000 bps) */
11
+ export declare const MAX_FEE_BPS = 1000;
12
+ /**
13
+ * Fee configuration for a market (all values in basis points, 1 bps = 0.01%).
14
+ */
15
+ export interface FeeConfigRaw {
16
+ /** Fee on trades that benefits LPs (stays in pool) */
17
+ readonly lpFeeBps: number;
18
+ /** Fee on trades that goes to protocol/factory */
19
+ readonly protocolFeeBps: number;
20
+ /** Fee on trader winnings at settlement */
21
+ readonly settlementFeeBps: number;
22
+ }
23
+ /**
24
+ * Validates fee configuration.
25
+ */
26
+ export declare function isValidFeeConfigRaw(config: FeeConfigRaw): boolean;
27
+ /**
28
+ * Creates a validated fee configuration.
29
+ */
30
+ export declare function createFeeConfigRaw(lpFeeBps: number, protocolFeeBps: number, settlementFeeBps: number): FeeConfigRaw | null;
31
+ /**
32
+ * AMM parameters configuration.
33
+ */
34
+ export interface AmmParamsRaw {
35
+ /** L2 norm constraint: ||f||_2 = k */
36
+ readonly k: SQ128x128Raw;
37
+ /** Initial backing requirement */
38
+ readonly backing: SQ128x128Raw;
39
+ /** Numerical tolerance for verification */
40
+ readonly tolerance: SQ128x128Raw;
41
+ /** Minimum collateral required per trade */
42
+ readonly minTradeCollateral: SQ128x128Raw;
43
+ }
44
+ /**
45
+ * Creates AMM parameters.
46
+ */
47
+ export declare function createAmmParamsRaw(k: SQ128x128Raw, backing: SQ128x128Raw, tolerance: SQ128x128Raw, minTradeCollateral: SQ128x128Raw): AmmParamsRaw;
48
+ /**
49
+ * Market status information.
50
+ */
51
+ export interface MarketStatusRaw {
52
+ readonly isInitialized: boolean;
53
+ readonly isPaused: boolean;
54
+ readonly isSettled: boolean;
55
+ readonly settlementValue: SQ128x128Raw;
56
+ }
57
+ /**
58
+ * Creates market status.
59
+ */
60
+ export declare function createMarketStatusRaw(isInitialized: boolean, isPaused: boolean, isSettled: boolean, settlementValue: SQ128x128Raw): MarketStatusRaw;
61
+ /**
62
+ * Trader position information.
63
+ */
64
+ export interface PositionRaw {
65
+ readonly distribution: NormalDistributionRaw;
66
+ readonly collateralLocked: SQ128x128Raw;
67
+ readonly exists: boolean;
68
+ }
69
+ /**
70
+ * Extended position with delta tracking.
71
+ *
72
+ * Note on terminology:
73
+ * - `deltaCount`: Total historical deltas (not "current position size"). Each trade creates
74
+ * a delta, and closing a position creates an offsetting delta. This number only increases.
75
+ * - `exists`: Means "has ever traded in this market", not "has open position".
76
+ * A trader who opened and closed their position still has `exists: true`.
77
+ * - `earlySettled`: Set when trader calls `close_position()` before market settlement.
78
+ * They receive their payout immediately and cannot claim again at settlement.
79
+ * - `claimed`: Set when trader calls `claim()` after market settlement.
80
+ */
81
+ export interface PositionExtendedRaw {
82
+ /** Number of position deltas for this trader (cumulative, only increases) */
83
+ readonly deltaCount: number;
84
+ /** Total collateral locked across all deltas */
85
+ readonly totalCollateralLocked: SQ128x128Raw;
86
+ /** Whether the position has been claimed after market settlement */
87
+ readonly claimed: boolean;
88
+ /** Whether the trader closed their position before market settlement (early exit) */
89
+ readonly earlySettled: boolean;
90
+ /** Whether the trader has ever traded in this market */
91
+ readonly exists: boolean;
92
+ }
93
+ /**
94
+ * Position delta information (old format - deprecated).
95
+ * @deprecated Use PositionDeltaV2Raw for new code
96
+ */
97
+ export interface PositionDeltaRaw {
98
+ readonly distribution: NormalDistributionRaw;
99
+ readonly collateralLocked: SQ128x128Raw;
100
+ readonly timestamp: bigint;
101
+ }
102
+ /**
103
+ * Position delta information (v0.5.0+ format).
104
+ *
105
+ * Each delta records a trade transition from one distribution to another.
106
+ * For the FIRST delta (index 0), `from_*` contains the ORIGINAL market
107
+ * distribution when the trader entered.
108
+ */
109
+ export interface PositionDeltaV2Raw {
110
+ /** Market mean before this trade */
111
+ readonly from_mean: SQ128x128Raw;
112
+ /** Market variance before this trade */
113
+ readonly from_variance: SQ128x128Raw;
114
+ /** Market sigma before this trade */
115
+ readonly from_sigma: SQ128x128Raw;
116
+ /** Market lambda (k/||p||_2) before this trade */
117
+ readonly from_lambda: SQ128x128Raw;
118
+ /** Market mean after this trade */
119
+ readonly to_mean: SQ128x128Raw;
120
+ /** Market variance after this trade */
121
+ readonly to_variance: SQ128x128Raw;
122
+ /** Market sigma after this trade */
123
+ readonly to_sigma: SQ128x128Raw;
124
+ /** Market lambda after this trade */
125
+ readonly to_lambda: SQ128x128Raw;
126
+ /** Collateral locked in this delta */
127
+ readonly collateral_locked: SQ128x128Raw;
128
+ }
129
+ /**
130
+ * Scaled backing validation results.
131
+ */
132
+ export interface ScaledBackingCheckRaw {
133
+ readonly maxValueUpper: SQ128x128Raw;
134
+ readonly isValid: boolean;
135
+ readonly computationSucceeded: boolean;
136
+ }
137
+ /**
138
+ * Collateral verification results.
139
+ */
140
+ export interface CollateralVerificationRaw {
141
+ readonly sideValid: boolean;
142
+ readonly stationaryValid: boolean;
143
+ readonly curvatureValid: boolean;
144
+ readonly computedCollateral: SQ128x128Raw;
145
+ readonly collateralSufficient: boolean;
146
+ readonly computationValid: boolean;
147
+ }
148
+ /**
149
+ * Trade validation results.
150
+ */
151
+ export interface TradeCheckRaw {
152
+ readonly backingCheck: ScaledBackingCheckRaw;
153
+ readonly verification: CollateralVerificationRaw;
154
+ readonly minTradeCollateral: SQ128x128Raw;
155
+ readonly collateralAboveMin: boolean;
156
+ readonly isValid: boolean;
157
+ }
158
+ /**
159
+ * Trade execution result with token amount.
160
+ */
161
+ export interface TradeExecutionRaw {
162
+ readonly check: TradeCheckRaw;
163
+ /** Token amount transferred (in token decimals) */
164
+ readonly tokenAmount: bigint;
165
+ /** Index of the created position delta */
166
+ readonly deltaIndex: number;
167
+ }
168
+ /**
169
+ * Claim result after settlement.
170
+ */
171
+ export interface ClaimResultRaw {
172
+ /** Computed position value at settlement */
173
+ readonly positionValue: SQ128x128Raw;
174
+ /** Total collateral that was locked */
175
+ readonly collateralReturned: SQ128x128Raw;
176
+ /** Token amount paid out (in token decimals) */
177
+ readonly tokenPayout: bigint;
178
+ /** Whether the claim was successful */
179
+ readonly success: boolean;
180
+ }
181
+ /**
182
+ * LP pool information.
183
+ */
184
+ export interface LPInfoRaw {
185
+ /** Total LP shares outstanding */
186
+ readonly totalShares: SQ128x128Raw;
187
+ /** Total backing deposited by LPs */
188
+ readonly totalBackingDeposited: SQ128x128Raw;
189
+ }
190
+ /**
191
+ * Precomputed sqrt hints for normal distribution operations.
192
+ */
193
+ export type { NormalSqrtHintsRaw };
194
+ /**
195
+ * Full AMM configuration.
196
+ */
197
+ export interface AmmConfigRaw {
198
+ /** Collateral token address */
199
+ readonly collateralToken: string;
200
+ /** Token decimals (native token precision) */
201
+ readonly tokenDecimals: number;
202
+ /** Internal decimals (precision for SQ128x128 math, <= 7) */
203
+ readonly internalDecimals: number;
204
+ /** Decimal shift (tokenDecimals - internalDecimals) */
205
+ readonly decimalShift: number;
206
+ /** Market parameters */
207
+ readonly params: AmmParamsRaw;
208
+ }
209
+ /**
210
+ * PDF norm validation results.
211
+ */
212
+ export interface PdfNormCheckRaw {
213
+ readonly sigma: SQ128x128Raw;
214
+ readonly computedNorm: SQ128x128Raw;
215
+ readonly targetNorm: SQ128x128Raw;
216
+ readonly isValid: boolean;
217
+ readonly computationSucceeded: boolean;
218
+ }
219
+ /**
220
+ * Reason for trade rejection.
221
+ *
222
+ * Maps to Cairo `TradeRejectReason` enum.
223
+ */
224
+ export declare enum TradeRejectReason {
225
+ /** Backing constraint check failed */
226
+ BackingConstraintFailed = "BackingConstraintFailed",
227
+ /** Invalid hints provided */
228
+ InvalidHints = "InvalidHints",
229
+ /** Insufficient collateral supplied */
230
+ InsufficientCollateral = "InsufficientCollateral",
231
+ /** Collateral verification failed */
232
+ VerificationFailed = "VerificationFailed",
233
+ /** Invalid candidate distribution */
234
+ InvalidDistribution = "InvalidDistribution"
235
+ }
236
+ /**
237
+ * Trade rejected event data.
238
+ *
239
+ * Emitted when a trade is rejected with a specific reason.
240
+ */
241
+ export interface TradeRejectedEvent {
242
+ /** Trader address */
243
+ readonly trader: string;
244
+ /** Candidate distribution that was rejected */
245
+ readonly candidate: NormalDistributionRaw;
246
+ /** Collateral that was supplied */
247
+ readonly suppliedCollateral: SQ128x128Raw;
248
+ /** Hints that were provided */
249
+ readonly candidateHints: NormalSqrtHintsRaw;
250
+ /** Reason for rejection */
251
+ readonly reason: TradeRejectReason;
252
+ }
253
+ /**
254
+ * Settlement status from contract.
255
+ *
256
+ * Maps to Cairo `SettlementStatus` enum returned by
257
+ * `get_position_settlement_status()`.
258
+ *
259
+ * This is the native contract enum, distinct from the SDK's computed
260
+ * `SettlementState` which provides additional states like 'never_traded'.
261
+ */
262
+ export declare enum SettlementStatusRaw {
263
+ /** Position has not been settled (neither claimed nor early settled) */
264
+ NotSettled = "NotSettled",
265
+ /** Position was closed before market settlement via close_position() */
266
+ EarlySettled = "EarlySettled",
267
+ /** Position was claimed after market settlement via claim() */
268
+ Claimed = "Claimed"
269
+ }
270
+ /**
271
+ * Reason for close position rejection.
272
+ *
273
+ * Maps to Cairo `CloseRejection` enum.
274
+ */
275
+ export declare enum CloseRejectionReason {
276
+ None = "None",
277
+ NoPosition = "NoPosition",
278
+ MarketSettled = "MarketSettled",
279
+ MarketPaused = "MarketPaused",
280
+ AlreadyClosed = "AlreadyClosed",
281
+ AlreadyClaimed = "AlreadyClaimed",
282
+ InvalidAdditionalCollateral = "InvalidAdditionalCollateral",
283
+ InvalidPositionState = "InvalidPositionState",
284
+ InvalidHints = "InvalidHints",
285
+ BackingFail = "BackingFail",
286
+ LowCollateral = "LowCollateral",
287
+ VerificationFailed = "VerificationFailed",
288
+ CollateralTooLarge = "CollateralTooLarge",
289
+ InvalidState = "InvalidState"
290
+ }
291
+ /**
292
+ * Compact position information from get_position_compact.
293
+ *
294
+ * Contains the trader's original distribution (the market state before their first trade)
295
+ * plus position flags. Used for close_position operations.
296
+ *
297
+ * NOTE: Field names are camelCase because responses are normalized from snake_case.
298
+ */
299
+ export interface PositionCompactRaw {
300
+ /** Original mean when trader first entered (market state before first trade) */
301
+ readonly originalMean: SQ128x128Raw;
302
+ /** Original variance when trader first entered */
303
+ readonly originalVariance: SQ128x128Raw;
304
+ /** Original sigma when trader first entered */
305
+ readonly originalSigma: SQ128x128Raw;
306
+ /** Original lambda when trader first entered */
307
+ readonly originalLambda: SQ128x128Raw;
308
+ /** Effective mean after all trades */
309
+ readonly effectiveMean: SQ128x128Raw;
310
+ /** Effective variance after all trades */
311
+ readonly effectiveVariance: SQ128x128Raw;
312
+ /** Effective sigma after all trades */
313
+ readonly effectiveSigma: SQ128x128Raw;
314
+ /** Effective lambda after all trades */
315
+ readonly effectiveLambda: SQ128x128Raw;
316
+ /** Close market mean (current market state for closing) */
317
+ readonly closeMarketMean: SQ128x128Raw;
318
+ /** Close market variance */
319
+ readonly closeMarketVariance: SQ128x128Raw;
320
+ /** Close market sigma */
321
+ readonly closeMarketSigma: SQ128x128Raw;
322
+ /** Close market lambda */
323
+ readonly closeMarketLambda: SQ128x128Raw;
324
+ /** Total collateral locked in position */
325
+ readonly totalCollateral: SQ128x128Raw;
326
+ /** Bitmask flags: bit 0 = exists, bit 1 = claimed, bit 2 = early_settled */
327
+ readonly flags: bigint;
328
+ }
329
+ /**
330
+ * Raw close position preview result.
331
+ *
332
+ * Contains all information about what would happen if a position is closed.
333
+ */
334
+ export interface ClosePreviewRaw {
335
+ /** Effective distribution after close */
336
+ readonly effectiveDistribution: NormalDistributionRaw;
337
+ /** Target distribution for the close trade */
338
+ readonly targetDistribution: NormalDistributionRaw;
339
+ /** Resulting market distribution */
340
+ readonly marketDistribution: NormalDistributionRaw;
341
+ /** Whether position would be completely flat */
342
+ readonly wouldBeFlat: boolean;
343
+ /** Total collateral required for the close */
344
+ readonly collateralRequired: SQ128x128Raw;
345
+ /** Existing collateral locked in position */
346
+ readonly existingCollateral: SQ128x128Raw;
347
+ /** Additional collateral required (if any) */
348
+ readonly additionalRequired: SQ128x128Raw;
349
+ /** Estimated payout on close (in token decimals) */
350
+ readonly estimatedPayout: bigint;
351
+ /** LP fee for the close trade (in token decimals) */
352
+ readonly lpFee: bigint;
353
+ /** Protocol fee for the close trade (in token decimals) */
354
+ readonly protocolFee: bigint;
355
+ /** Whether the position can be closed */
356
+ readonly canClose: boolean;
357
+ /** Reason for rejection if canClose is false */
358
+ readonly rejectionReason: CloseRejectionReason;
359
+ }
360
+ /**
361
+ * Raw position close execution result.
362
+ *
363
+ * Contains the result of executing a close position operation.
364
+ */
365
+ export interface PositionCloseResultRaw {
366
+ /** Whether a trade was executed to close */
367
+ readonly tradeExecuted: boolean;
368
+ /** Trade execution result if trade was executed */
369
+ readonly tradeResult: TradeExecutionRaw;
370
+ /** Whether position is now completely flat */
371
+ readonly isFlat: boolean;
372
+ /** Immediate payout to trader (in token decimals) */
373
+ readonly immediatePayout: bigint;
374
+ /** Collateral that was required */
375
+ readonly collateralRequired: SQ128x128Raw;
376
+ /** Existing collateral that was locked */
377
+ readonly existingCollateral: SQ128x128Raw;
378
+ /** Additional collateral that was supplied */
379
+ readonly additionalRequired: SQ128x128Raw;
380
+ /** Net additional collateral (after accounting for existing locked collateral) */
381
+ readonly netAdditionalCollateral: SQ128x128Raw;
382
+ /** LP fee paid (in token decimals) */
383
+ readonly lpFee: bigint;
384
+ /** Protocol fee paid (in token decimals) */
385
+ readonly protocolFee: bigint;
386
+ /** Rejection reason when trade execution did not proceed */
387
+ readonly rejectionReason: CloseRejectionReason;
388
+ }
389
+ /**
390
+ * Guard parameters for `close_position_guarded`.
391
+ *
392
+ * Guards constrain execution against stale market state and collateral drift.
393
+ */
394
+ export interface CloseExecutionGuardsRaw {
395
+ readonly expectedMarketDist: NormalDistributionRaw;
396
+ readonly expectedBacking: SQ128x128Raw;
397
+ readonly expectedTolerance: SQ128x128Raw;
398
+ readonly expectedMinTradeCollateral: SQ128x128Raw;
399
+ readonly maxRequiredCollateral: SQ128x128Raw;
400
+ readonly maxAdditionalCollateral: SQ128x128Raw;
401
+ readonly maxAdditionalTokenAmount: bigint;
402
+ }
403
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","source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ED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Common ABI types for The Situation contracts.
3
+ *
4
+ * These types match the Cairo `onchain::common` module and provide
5
+ * the serialization boundary between TypeScript and Starknet contracts.
6
+ *
7
+ * @module
8
+ */
9
+ // ============================================================================
10
+ // Constants
11
+ // ============================================================================
12
+ /** Maximum total fee in basis points (10% = 1000 bps) */
13
+ export const MAX_FEE_BPS = 1000;
14
+ /**
15
+ * Validates fee configuration.
16
+ */
17
+ export function isValidFeeConfigRaw(config) {
18
+ const total = config.lpFeeBps + config.protocolFeeBps + config.settlementFeeBps;
19
+ return total <= MAX_FEE_BPS;
20
+ }
21
+ /**
22
+ * Creates a validated fee configuration.
23
+ */
24
+ export function createFeeConfigRaw(lpFeeBps, protocolFeeBps, settlementFeeBps) {
25
+ const config = { lpFeeBps, protocolFeeBps, settlementFeeBps };
26
+ return isValidFeeConfigRaw(config) ? config : null;
27
+ }
28
+ /**
29
+ * Creates AMM parameters.
30
+ */
31
+ export function createAmmParamsRaw(k, backing, tolerance, minTradeCollateral) {
32
+ return { k, backing, tolerance, minTradeCollateral };
33
+ }
34
+ /**
35
+ * Creates market status.
36
+ */
37
+ export function createMarketStatusRaw(isInitialized, isPaused, isSettled, settlementValue) {
38
+ return { isInitialized, isPaused, isSettled, settlementValue };
39
+ }
40
+ // ============================================================================
41
+ // Trade Rejection Types
42
+ // ============================================================================
43
+ /**
44
+ * Reason for trade rejection.
45
+ *
46
+ * Maps to Cairo `TradeRejectReason` enum.
47
+ */
48
+ export var TradeRejectReason;
49
+ (function (TradeRejectReason) {
50
+ /** Backing constraint check failed */
51
+ TradeRejectReason["BackingConstraintFailed"] = "BackingConstraintFailed";
52
+ /** Invalid hints provided */
53
+ TradeRejectReason["InvalidHints"] = "InvalidHints";
54
+ /** Insufficient collateral supplied */
55
+ TradeRejectReason["InsufficientCollateral"] = "InsufficientCollateral";
56
+ /** Collateral verification failed */
57
+ TradeRejectReason["VerificationFailed"] = "VerificationFailed";
58
+ /** Invalid candidate distribution */
59
+ TradeRejectReason["InvalidDistribution"] = "InvalidDistribution";
60
+ })(TradeRejectReason || (TradeRejectReason = {}));
61
+ // ============================================================================
62
+ // Settlement Status Types (v0.4.0)
63
+ // ============================================================================
64
+ /**
65
+ * Settlement status from contract.
66
+ *
67
+ * Maps to Cairo `SettlementStatus` enum returned by
68
+ * `get_position_settlement_status()`.
69
+ *
70
+ * This is the native contract enum, distinct from the SDK's computed
71
+ * `SettlementState` which provides additional states like 'never_traded'.
72
+ */
73
+ export var SettlementStatusRaw;
74
+ (function (SettlementStatusRaw) {
75
+ /** Position has not been settled (neither claimed nor early settled) */
76
+ SettlementStatusRaw["NotSettled"] = "NotSettled";
77
+ /** Position was closed before market settlement via close_position() */
78
+ SettlementStatusRaw["EarlySettled"] = "EarlySettled";
79
+ /** Position was claimed after market settlement via claim() */
80
+ SettlementStatusRaw["Claimed"] = "Claimed";
81
+ })(SettlementStatusRaw || (SettlementStatusRaw = {}));
82
+ // ============================================================================
83
+ // Close Position Types (v0.1.4)
84
+ // ============================================================================
85
+ /**
86
+ * Reason for close position rejection.
87
+ *
88
+ * Maps to Cairo `CloseRejection` enum.
89
+ */
90
+ export var CloseRejectionReason;
91
+ (function (CloseRejectionReason) {
92
+ CloseRejectionReason["None"] = "None";
93
+ CloseRejectionReason["NoPosition"] = "NoPosition";
94
+ CloseRejectionReason["MarketSettled"] = "MarketSettled";
95
+ CloseRejectionReason["MarketPaused"] = "MarketPaused";
96
+ CloseRejectionReason["AlreadyClosed"] = "AlreadyClosed";
97
+ CloseRejectionReason["AlreadyClaimed"] = "AlreadyClaimed";
98
+ CloseRejectionReason["InvalidAdditionalCollateral"] = "InvalidAdditionalCollateral";
99
+ CloseRejectionReason["InvalidPositionState"] = "InvalidPositionState";
100
+ CloseRejectionReason["InvalidHints"] = "InvalidHints";
101
+ CloseRejectionReason["BackingFail"] = "BackingFail";
102
+ CloseRejectionReason["LowCollateral"] = "LowCollateral";
103
+ CloseRejectionReason["VerificationFailed"] = "VerificationFailed";
104
+ CloseRejectionReason["CollateralTooLarge"] = "CollateralTooLarge";
105
+ CloseRejectionReason["InvalidState"] = "InvalidState";
106
+ })(CloseRejectionReason || (CloseRejectionReason = {}));
107
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,yDAAyD;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAkBhC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAoB;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAChF,OAAO,KAAK,IAAI,WAAW,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,cAAsB,EACtB,gBAAwB;IAExB,MAAM,MAAM,GAAiB,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;IAC5E,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC;AAoBD;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,CAAe,EACf,OAAqB,EACrB,SAAuB,EACvB,kBAAgC;IAEhC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;AACvD,CAAC;AAgBD;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,aAAsB,EACtB,QAAiB,EACjB,SAAkB,EAClB,eAA6B;IAE7B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACjE,CAAC;AAyMD,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAN,IAAY,iBAWX;AAXD,WAAY,iBAAiB;IAC3B,sCAAsC;IACtC,wEAAmD,CAAA;IACnD,6BAA6B;IAC7B,kDAA6B,CAAA;IAC7B,uCAAuC;IACvC,sEAAiD,CAAA;IACjD,qCAAqC;IACrC,8DAAyC,CAAA;IACzC,qCAAqC;IACrC,gEAA2C,CAAA;AAC7C,CAAC,EAXW,iBAAiB,KAAjB,iBAAiB,QAW5B;AAoBD,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,wEAAwE;IACxE,gDAAyB,CAAA;IACzB,wEAAwE;IACxE,oDAA6B,CAAA;IAC7B,+DAA+D;IAC/D,0CAAmB,CAAA;AACrB,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B;AAED,+EAA+E;AAC/E,gCAAgC;AAChC,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAN,IAAY,oBAeX;AAfD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,iDAAyB,CAAA;IACzB,uDAA+B,CAAA;IAC/B,qDAA6B,CAAA;IAC7B,uDAA+B,CAAA;IAC/B,yDAAiC,CAAA;IACjC,mFAA2D,CAAA;IAC3D,qEAA6C,CAAA;IAC7C,qDAA6B,CAAA;IAC7B,mDAA2B,CAAA;IAC3B,uDAA+B,CAAA;IAC/B,iEAAyC,CAAA;IACzC,iEAAyC,CAAA;IACzC,qDAA6B,CAAA;AAC/B,CAAC,EAfW,oBAAoB,KAApB,oBAAoB,QAe/B"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Factory contract ABI types and function names.
3
+ *
4
+ * These match the latest `normal_factory` Cairo interface.
5
+ *
6
+ * @module
7
+ */
8
+ import type { FeeConfigRaw, NormalSqrtHintsRaw } from './common';
9
+ import type { NormalDistributionRaw, SQ128x128Raw } from '@the-situation/core';
10
+ /**
11
+ * All factory contract function names.
12
+ */
13
+ export declare const FACTORY_FUNCTION_NAMES: readonly ["get_amm_class_hash", "get_math_class_hash", "get_owner", "is_paused", "is_extension_approved", "deploy_normal_market", "approve_extension", "revoke_extension", "update_class_hash", "update_math_class_hash", "transfer_ownership", "pause", "unpause", "withdraw_protocol_fees"];
14
+ export type FactoryFunctionName = (typeof FACTORY_FUNCTION_NAMES)[number];
15
+ /**
16
+ * Parameters for deploying a normal market via the factory.
17
+ */
18
+ export interface NormalMarketDeploymentParamsRaw {
19
+ readonly salt: string | bigint;
20
+ readonly marketOwner: string;
21
+ readonly marketAdmin: string;
22
+ readonly collateralToken: string;
23
+ readonly tokenDecimals: number;
24
+ readonly internalDecimals: number;
25
+ readonly initialDistribution: NormalDistributionRaw;
26
+ readonly k: SQ128x128Raw;
27
+ readonly backing: SQ128x128Raw;
28
+ readonly tolerance: SQ128x128Raw;
29
+ readonly minTradeCollateral: SQ128x128Raw;
30
+ readonly initialHints: NormalSqrtHintsRaw;
31
+ readonly feeConfig: FeeConfigRaw;
32
+ readonly extension: string;
33
+ readonly extensionCallPoints: number;
34
+ readonly metadataHash: string;
35
+ }
36
+ /**
37
+ * Return type mapping for factory view functions.
38
+ */
39
+ export interface FactoryViewReturns {
40
+ get_amm_class_hash: string;
41
+ get_math_class_hash: string;
42
+ get_owner: string;
43
+ is_paused: boolean;
44
+ is_extension_approved: boolean;
45
+ }
46
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAM/E;;GAEG;AACH,eAAO,MAAM,sBAAsB,+RAwBzB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAM1E;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;IACpD,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAC1C,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAMD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,qBAAqB,EAAE,OAAO,CAAC;CAChC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Factory contract ABI types and function names.
3
+ *
4
+ * These match the latest `normal_factory` Cairo interface.
5
+ *
6
+ * @module
7
+ */
8
+ // ============================================================================
9
+ // Function Names
10
+ // ============================================================================
11
+ /**
12
+ * All factory contract function names.
13
+ */
14
+ export const FACTORY_FUNCTION_NAMES = [
15
+ // View functions
16
+ 'get_amm_class_hash',
17
+ 'get_math_class_hash',
18
+ 'get_owner',
19
+ 'is_paused',
20
+ 'is_extension_approved',
21
+ // Deployment
22
+ 'deploy_normal_market',
23
+ // Extension admin
24
+ 'approve_extension',
25
+ 'revoke_extension',
26
+ // Contract admin
27
+ 'update_class_hash',
28
+ 'update_math_class_hash',
29
+ 'transfer_ownership',
30
+ 'pause',
31
+ 'unpause',
32
+ // Fee operations
33
+ 'withdraw_protocol_fees',
34
+ ];
35
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,iBAAiB;IACjB,oBAAoB;IACpB,qBAAqB;IACrB,WAAW;IACX,WAAW;IACX,uBAAuB;IAEvB,aAAa;IACb,sBAAsB;IAEtB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAElB,iBAAiB;IACjB,mBAAmB;IACnB,wBAAwB;IACxB,oBAAoB;IACpB,OAAO;IACP,SAAS;IAET,iBAAiB;IACjB,wBAAwB;CAChB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * ABI types for The Situation contracts.
3
+ *
4
+ * This module provides TypeScript types that match the Cairo contract ABIs,
5
+ * enabling type-safe interactions with Starknet contracts.
6
+ *
7
+ * @module
8
+ */
9
+ export { AMM_FUNCTION_NAMES, type AmmCloseReturns, type AmmFunctionName, type AmmLPReturns, type AmmSettlementReturns, type AmmTradeReturns, type AmmViewReturns, type TradeInput, type UpdateParametersInput, } from './amm';
10
+ export { type AmmConfigRaw, type AmmParamsRaw, type ClaimResultRaw, type ClosePreviewRaw, CloseRejectionReason, type CollateralVerificationRaw, createAmmParamsRaw, createFeeConfigRaw, createMarketStatusRaw, type FeeConfigRaw, isValidFeeConfigRaw, type LPInfoRaw, MAX_FEE_BPS, type MarketStatusRaw, type NormalSqrtHintsRaw, type PdfNormCheckRaw, type CloseExecutionGuardsRaw, type PositionCloseResultRaw, type PositionDeltaRaw, type PositionDeltaV2Raw, type PositionCompactRaw, type PositionExtendedRaw, type PositionRaw, type ScaledBackingCheckRaw, SettlementStatusRaw, type TradeCheckRaw, type TradeExecutionRaw, type TradeRejectedEvent, TradeRejectReason, } from './common';
11
+ export { FACTORY_FUNCTION_NAMES, type FactoryFunctionName, type FactoryViewReturns, type NormalMarketDeploymentParamsRaw, } from './factory';
12
+ export { type CheckClosePositionCompactViewInput, MATH_LIBRARY_FUNCTION_NAMES, type CheckTradeViewInput, type ComputePositionValueViewInput, type MathLibraryFunctionName, type MathLibraryViewReturns, type PreviewAddLiquidityViewInput, type PreviewClaimViewInput, type PreviewRemoveLiquidityViewInput, } from './math-library';
13
+ export { ORACLE_FUNCTION_NAMES, type Cumulative256Raw, type MarketKeyInput, type OracleFunctionName, type OracleViewReturns, type SnapshotRaw, } from './oracle';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,qBAAqB,GAC3B,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EAErB,KAAK,YAAY,EACjB,mBAAmB,EAEnB,KAAK,SAAS,EAEd,WAAW,EAEX,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAEvB,KAAK,eAAe,EAEpB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EAExB,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC1B,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,+BAA+B,GACrC,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,KAAK,kCAAkC,EACvC,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,GACrC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * ABI types for The Situation contracts.
3
+ *
4
+ * This module provides TypeScript types that match the Cairo contract ABIs,
5
+ * enabling type-safe interactions with Starknet contracts.
6
+ *
7
+ * @module
8
+ */
9
+ // AMM contract types
10
+ export { AMM_FUNCTION_NAMES, } from './amm';
11
+ // Common types shared across contracts
12
+ export { CloseRejectionReason, createAmmParamsRaw, createFeeConfigRaw, createMarketStatusRaw, isValidFeeConfigRaw,
13
+ // Constants
14
+ MAX_FEE_BPS, SettlementStatusRaw, TradeRejectReason, } from './common';
15
+ // Factory contract types
16
+ export { FACTORY_FUNCTION_NAMES, } from './factory';
17
+ // MathLibrary contract types (v0.3.0)
18
+ export { MATH_LIBRARY_FUNCTION_NAMES, } from './math-library';
19
+ // Oracle contract types
20
+ export { ORACLE_FUNCTION_NAMES, } from './oracle';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qBAAqB;AACrB,OAAO,EACL,kBAAkB,GASnB,MAAM,OAAO,CAAC;AACf,uCAAuC;AACvC,OAAO,EASL,oBAAoB,EAEpB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EAGrB,mBAAmB;AAGnB,YAAY;AACZ,WAAW,EAkBX,mBAAmB,EAInB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,yBAAyB;AACzB,OAAO,EACL,sBAAsB,GAIvB,MAAM,WAAW,CAAC;AAEnB,sCAAsC;AACtC,OAAO,EAEL,2BAA2B,GAQ5B,MAAM,gBAAgB,CAAC;AAExB,wBAAwB;AACxB,OAAO,EACL,qBAAqB,GAMtB,MAAM,UAAU,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Math library ABI-facing types and function names.
3
+ *
4
+ * These match the v0.6.0 `INormalMathLibrary` interface.
5
+ *
6
+ * @module
7
+ */
8
+ import type { NormalDistributionRaw, SQ128x128Raw } from '@the-situation/core';
9
+ import type { AmmParamsRaw, ClaimResultRaw, FeeConfigRaw, NormalSqrtHintsRaw, PositionCloseResultRaw, PositionCompactRaw, PositionDeltaV2Raw, TradeCheckRaw } from './common';
10
+ /**
11
+ * All supported view entrypoints on the math library.
12
+ */
13
+ export declare const MATH_LIBRARY_FUNCTION_NAMES: readonly ["compute_hints_view", "check_trade_view", "compute_position_value_view", "preview_claim_view", "check_close_position_compact_view", "preview_add_liquidity_view", "preview_remove_liquidity_view"];
14
+ export type MathLibraryFunctionName = (typeof MATH_LIBRARY_FUNCTION_NAMES)[number];
15
+ /**
16
+ * Input for `check_trade_view`.
17
+ */
18
+ export interface CheckTradeViewInput {
19
+ readonly currentDistribution: NormalDistributionRaw;
20
+ readonly candidateDistribution: NormalDistributionRaw;
21
+ readonly xStar: SQ128x128Raw;
22
+ readonly suppliedCollateral: SQ128x128Raw;
23
+ readonly params: AmmParamsRaw;
24
+ readonly currentHints: NormalSqrtHintsRaw;
25
+ readonly candidateHints: NormalSqrtHintsRaw;
26
+ }
27
+ /**
28
+ * Input for `compute_position_value_view`.
29
+ */
30
+ export interface ComputePositionValueViewInput {
31
+ readonly deltas: readonly PositionDeltaV2Raw[];
32
+ readonly outcome: SQ128x128Raw;
33
+ }
34
+ /**
35
+ * Input for `preview_claim_view`.
36
+ */
37
+ export interface PreviewClaimViewInput {
38
+ readonly deltas: readonly PositionDeltaV2Raw[];
39
+ readonly settlementValue: SQ128x128Raw;
40
+ readonly totalCollateral: SQ128x128Raw;
41
+ readonly internalDecimals: number;
42
+ readonly decimalShift: number;
43
+ readonly settlementFeeBps: number;
44
+ }
45
+ /**
46
+ * Input for `check_close_position_compact_view`.
47
+ */
48
+ export interface CheckClosePositionCompactViewInput {
49
+ readonly position: PositionCompactRaw;
50
+ readonly marketDistribution: NormalDistributionRaw;
51
+ readonly xStar: SQ128x128Raw;
52
+ readonly additionalCollateral: SQ128x128Raw;
53
+ readonly params: AmmParamsRaw;
54
+ readonly currentHints: NormalSqrtHintsRaw;
55
+ readonly targetHints: NormalSqrtHintsRaw;
56
+ readonly internalDecimals: number;
57
+ readonly decimalShift: number;
58
+ readonly feeConfig: FeeConfigRaw;
59
+ }
60
+ /**
61
+ * Input for `preview_add_liquidity_view`.
62
+ */
63
+ export interface PreviewAddLiquidityViewInput {
64
+ readonly shareAmount: SQ128x128Raw;
65
+ readonly totalShares: SQ128x128Raw;
66
+ readonly totalBacking: SQ128x128Raw;
67
+ readonly internalDecimals: number;
68
+ readonly decimalShift: number;
69
+ }
70
+ /**
71
+ * Input for `preview_remove_liquidity_view`.
72
+ */
73
+ export interface PreviewRemoveLiquidityViewInput {
74
+ readonly shareAmount: SQ128x128Raw;
75
+ readonly totalShares: SQ128x128Raw;
76
+ readonly totalBacking: SQ128x128Raw;
77
+ readonly internalDecimals: number;
78
+ readonly decimalShift: number;
79
+ }
80
+ /**
81
+ * Return type mapping for math library entrypoints.
82
+ */
83
+ export interface MathLibraryViewReturns {
84
+ compute_hints_view: NormalSqrtHintsRaw | null;
85
+ check_trade_view: TradeCheckRaw;
86
+ compute_position_value_view: SQ128x128Raw | null;
87
+ preview_claim_view: ClaimResultRaw;
88
+ check_close_position_compact_view: PositionCloseResultRaw;
89
+ preview_add_liquidity_view: bigint;
90
+ preview_remove_liquidity_view: bigint;
91
+ }
92
+ //# sourceMappingURL=math-library.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math-library.d.ts","sourceRoot":"","sources":["../src/math-library.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,eAAO,MAAM,2BAA2B,8MAQ9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;IACpD,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC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Q,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,gBAAgB,EAAE,aAAa,CAAC;IAChC,2BAA2B,EAAE,YAAY,GAAG,IAAI,CAAC;IACjD,kBAAkB,EAAE,cAAc,CAAC;IACnC,iCAAiC,EAAE,sBAAsB,CAAC;IAC1D,0BAA0B,EAAE,MAAM,CAAC;IACnC,6BAA6B,EAAE,MAAM,CAAC;CACvC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Math library ABI-facing types and function names.
3
+ *
4
+ * These match the v0.6.0 `INormalMathLibrary` interface.
5
+ *
6
+ * @module
7
+ */
8
+ /**
9
+ * All supported view entrypoints on the math library.
10
+ */
11
+ export const MATH_LIBRARY_FUNCTION_NAMES = [
12
+ 'compute_hints_view',
13
+ 'check_trade_view',
14
+ 'compute_position_value_view',
15
+ 'preview_claim_view',
16
+ 'check_close_position_compact_view',
17
+ 'preview_add_liquidity_view',
18
+ 'preview_remove_liquidity_view',
19
+ ];
20
+ //# sourceMappingURL=math-library.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math-library.js","sourceRoot":"","sources":["../src/math-library.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAcH;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,oBAAoB;IACpB,kBAAkB;IAClB,6BAA6B;IAC7B,oBAAoB;IACpB,mCAAmC;IACnC,4BAA4B;IAC5B,+BAA+B;CACvB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Oracle contract ABI types and function names.
3
+ *
4
+ * These match the IOracle interface from Cairo contracts.
5
+ *
6
+ * @module
7
+ */
8
+ import type { NormalDistributionRaw, SQ128x128Raw } from '@the-situation/core';
9
+ /**
10
+ * 256-bit cumulative value for TWAP calculations.
11
+ *
12
+ * Uses the same limb representation as SQ128x128Raw for consistency.
13
+ */
14
+ export interface Cumulative256Raw {
15
+ readonly limb0: bigint;
16
+ readonly limb1: bigint;
17
+ readonly limb2: bigint;
18
+ readonly limb3: bigint;
19
+ readonly neg: boolean;
20
+ }
21
+ /**
22
+ * Oracle snapshot stored for TWAP calculations.
23
+ */
24
+ export interface SnapshotRaw {
25
+ readonly blockTimestamp: bigint;
26
+ readonly meanCumulative: Cumulative256Raw;
27
+ readonly varianceCumulative: Cumulative256Raw;
28
+ }
29
+ /**
30
+ * Market key for identifying a unique market.
31
+ *
32
+ * This uniquely identifies a market by its immutable parameters.
33
+ */
34
+ export interface MarketKeyInput {
35
+ readonly collateralToken: string;
36
+ readonly initialDistribution: NormalDistributionRaw;
37
+ readonly k: SQ128x128Raw;
38
+ readonly initialBacking: SQ128x128Raw;
39
+ readonly extension: string;
40
+ /** Metadata hash for market identification (v0.1.4) */
41
+ readonly metadataHash: string;
42
+ }
43
+ /**
44
+ * All Oracle contract function names.
45
+ */
46
+ export declare const ORACLE_FUNCTION_NAMES: readonly ["get_average_mean_over_period", "get_average_mean_over_last", "get_average_variance_over_period", "get_average_variance_over_last", "get_earliest_observation_time", "get_latest_observation_time", "get_snapshot_count", "get_snapshot", "get_amm"];
47
+ export type OracleFunctionName = (typeof ORACLE_FUNCTION_NAMES)[number];
48
+ /**
49
+ * Return type mapping for Oracle view functions.
50
+ */
51
+ export interface OracleViewReturns {
52
+ get_average_mean_over_period: SQ128x128Raw;
53
+ get_average_mean_over_last: SQ128x128Raw;
54
+ get_average_variance_over_period: SQ128x128Raw;
55
+ get_average_variance_over_last: SQ128x128Raw;
56
+ get_earliest_observation_time: bigint;
57
+ get_latest_observation_time: bigint;
58
+ get_snapshot_count: bigint;
59
+ get_snapshot: SnapshotRaw;
60
+ get_amm: string;
61
+ }
62
+ //# sourceMappingURL=oracle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../src/oracle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAM/E;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,gBAAgB,CAAC;IAC1C,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;CAC/C;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;IACpD,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAMD;;GAEG;AACH,eAAO,MAAM,qBAAqB,gQAWxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMxE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEhC,4BAA4B,EAAE,YAAY,CAAC;IAE3C,0BAA0B,EAAE,YAAY,CAAC;IAEzC,gCAAgC,EAAE,YAAY,CAAC;IAE/C,8BAA8B,EAAE,YAAY,CAAC;IAE7C,6BAA6B,EAAE,MAAM,CAAC;IAEtC,2BAA2B,EAAE,MAAM,CAAC;IAEpC,kBAAkB,EAAE,MAAM,CAAC;IAE3B,YAAY,EAAE,WAAW,CAAC;IAE1B,OAAO,EAAE,MAAM,CAAC;CACjB"}
package/dist/oracle.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Oracle contract ABI types and function names.
3
+ *
4
+ * These match the IOracle interface from Cairo contracts.
5
+ *
6
+ * @module
7
+ */
8
+ // ============================================================================
9
+ // Function Names
10
+ // ============================================================================
11
+ /**
12
+ * All Oracle contract function names.
13
+ */
14
+ export const ORACLE_FUNCTION_NAMES = [
15
+ // View functions
16
+ 'get_average_mean_over_period',
17
+ 'get_average_mean_over_last',
18
+ 'get_average_variance_over_period',
19
+ 'get_average_variance_over_last',
20
+ 'get_earliest_observation_time',
21
+ 'get_latest_observation_time',
22
+ 'get_snapshot_count',
23
+ 'get_snapshot',
24
+ 'get_amm',
25
+ ];
26
+ //# sourceMappingURL=oracle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle.js","sourceRoot":"","sources":["../src/oracle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6CH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB;IACjB,8BAA8B;IAC9B,4BAA4B;IAC5B,kCAAkC;IAClC,gCAAgC;IAChC,+BAA+B;IAC/B,6BAA6B;IAC7B,oBAAoB;IACpB,cAAc;IACd,SAAS;CACD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@the-situation/abi",
3
+ "version": "0.5.0-alpha.0",
4
+ "description": "ABI type definitions for The Situation contracts",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": ["dist"],
15
+ "scripts": {
16
+ "build": "tsc -b",
17
+ "typecheck": "tsc -b",
18
+ "test": "bun test src/ 2>/dev/null || true",
19
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
20
+ },
21
+ "dependencies": {
22
+ "@the-situation/core": "0.5.0-alpha.0"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.4.0",
26
+ "@types/bun": "^1.1.0"
27
+ },
28
+ "license": "MIT"
29
+ }