@invisible-labs/sdk 0.8.0-devnet → 0.9.0-devnet
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/README.md +7 -0
- package/dist/.invisible-sdk-build-target.json +1 -1
- package/dist/{chunk-HJFMDMPY.js → chunk-6AKBRYKO.js} +3 -3
- package/dist/{chunk-HJFMDMPY.js.map → chunk-6AKBRYKO.js.map} +1 -1
- package/dist/{chunk-DCTYBUY3.js → chunk-AIKC2XQS.js} +3 -3
- package/dist/{chunk-DCTYBUY3.js.map → chunk-AIKC2XQS.js.map} +1 -1
- package/dist/{chunk-Y7AK6RBV.js → chunk-EOPZVOVP.js} +11 -6
- package/dist/chunk-EOPZVOVP.js.map +1 -0
- package/dist/{chunk-EBWTAXNT.js → chunk-EPWTRF5U.js} +3 -3
- package/dist/{chunk-EBWTAXNT.js.map → chunk-EPWTRF5U.js.map} +1 -1
- package/dist/{chunk-IG6JJFR2.js → chunk-HWRMSK7E.js} +8 -6
- package/dist/chunk-HWRMSK7E.js.map +1 -0
- package/dist/{chunk-MZKJU3UA.js → chunk-ISIWWGSR.js} +16 -6
- package/dist/chunk-ISIWWGSR.js.map +1 -0
- package/dist/{chunk-K67FTCQU.js → chunk-JNNVPZEU.js} +3 -3
- package/dist/chunk-JNNVPZEU.js.map +1 -0
- package/dist/{chunk-MPNVF727.js → chunk-QF5TSUQE.js} +178 -41
- package/dist/chunk-QF5TSUQE.js.map +1 -0
- package/dist/{chunk-QRN46R3F.js → chunk-RWKG7N7I.js} +10 -3
- package/dist/chunk-RWKG7N7I.js.map +1 -0
- package/dist/coordinator-DHL3AP7V.js +4 -0
- package/dist/{coordinator-E2TS6NR2.js.map → coordinator-DHL3AP7V.js.map} +1 -1
- package/dist/dkgWorker.js +1 -1
- package/dist/events.js +3 -3
- package/dist/frostRuntime-JESDHN6O.js +4 -0
- package/dist/{frostRuntime-6FTPKUCP.js.map → frostRuntime-JESDHN6O.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/lp.d.ts +10 -1
- package/dist/lp.js +178 -65
- package/dist/lp.js.map +1 -1
- package/dist/stats.js +1 -1
- package/dist/storage.js +2 -2
- package/dist/{types.generated-YhFu9ZBR.d.ts → types.generated-DrM2M4DZ.d.ts} +6 -2
- package/dist/user.d.ts +18 -9
- package/dist/user.js +86 -30
- package/dist/user.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-IG6JJFR2.js.map +0 -1
- package/dist/chunk-K67FTCQU.js.map +0 -1
- package/dist/chunk-MPNVF727.js.map +0 -1
- package/dist/chunk-MZKJU3UA.js.map +0 -1
- package/dist/chunk-QRN46R3F.js.map +0 -1
- package/dist/chunk-Y7AK6RBV.js.map +0 -1
- package/dist/coordinator-E2TS6NR2.js +0 -4
- package/dist/frostRuntime-6FTPKUCP.js +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// ../../protocol/src/coordinator/errors.ts
|
|
4
4
|
var ErrorCode = {
|
|
5
5
|
/** Decoding failed (JSON parse, missing field, wrong type). */
|
|
6
6
|
ERR_INVALID_PAYLOAD: "ERR_INVALID_PAYLOAD",
|
|
@@ -18,6 +18,12 @@ var ErrorCode = {
|
|
|
18
18
|
ERR_DKG_FAILURE: "ERR_DKG_FAILURE",
|
|
19
19
|
/** Catch-all for unexpected coordinator-side failures. */
|
|
20
20
|
ERR_INTERNAL: "ERR_INTERNAL",
|
|
21
|
+
/** Admission lock acquisition timed out before any sealed write; the SDK may retry. */
|
|
22
|
+
ERR_PRESEAL_ADMISSION_BUSY: "ERR_PRESEAL_ADMISSION_BUSY",
|
|
23
|
+
/** A known initialization boundary did not commit; resume the same authenticated command. */
|
|
24
|
+
ERR_INITIALIZATION_BUSY: "ERR_INITIALIZATION_BUSY",
|
|
25
|
+
/** Global transfer capacity is full; reject without retrying or writing sealed state. */
|
|
26
|
+
ERR_ADMISSION_CAPACITY_FULL: "ERR_ADMISSION_CAPACITY_FULL",
|
|
21
27
|
/** Deposit did not satisfy coordinator validation or funding policy. */
|
|
22
28
|
ERR_INVALID_DEPOSIT: "ERR_INVALID_DEPOSIT",
|
|
23
29
|
/** Autonomous payout/refund signing failed after the swap was accepted. */
|
|
@@ -43,7 +49,7 @@ var CoordinatorError = class extends Error {
|
|
|
43
49
|
}
|
|
44
50
|
};
|
|
45
51
|
|
|
46
|
-
//
|
|
52
|
+
// ../../protocol/src/coordinator/messages.ts
|
|
47
53
|
var EnvelopeKind = {
|
|
48
54
|
REQUEST: "request",
|
|
49
55
|
RESPONSE: "response",
|
|
@@ -154,7 +160,7 @@ var DIRECTION_BY_TYPE = {
|
|
|
154
160
|
Error: MessageDirection.BIDIRECTIONAL
|
|
155
161
|
};
|
|
156
162
|
|
|
157
|
-
//
|
|
163
|
+
// ../../protocol/src/coordinator/schema.generated.ts
|
|
158
164
|
var COORDINATOR_BINARY_FIELD_NAMES = [
|
|
159
165
|
"auth_public_key",
|
|
160
166
|
"coordinator_attestation_hash",
|
|
@@ -207,7 +213,7 @@ var COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES = {
|
|
|
207
213
|
"error:Error": "error"
|
|
208
214
|
};
|
|
209
215
|
|
|
210
|
-
//
|
|
216
|
+
// ../../protocol/src/coordinator/payloads.ts
|
|
211
217
|
var VALID_SWAP_STATES = /* @__PURE__ */ new Set([
|
|
212
218
|
"new",
|
|
213
219
|
"awaiting_dkg",
|
|
@@ -227,7 +233,7 @@ function payloadCategory(kind, type) {
|
|
|
227
233
|
return COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES[key] ?? null;
|
|
228
234
|
}
|
|
229
235
|
|
|
230
|
-
//
|
|
236
|
+
// ../../protocol/src/coordinator/payout-windows.json
|
|
231
237
|
var payout_windows_default = [
|
|
232
238
|
{
|
|
233
239
|
id: "instant",
|
|
@@ -255,7 +261,7 @@ var payout_windows_default = [
|
|
|
255
261
|
}
|
|
256
262
|
];
|
|
257
263
|
|
|
258
|
-
//
|
|
264
|
+
// ../../protocol/src/coordinator/payoutWindows.ts
|
|
259
265
|
var DEFAULT_PAYOUT_WINDOW_ID = "instant";
|
|
260
266
|
function isRecord(value) {
|
|
261
267
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -319,7 +325,7 @@ function scheduledPayoutWindowSeconds() {
|
|
|
319
325
|
return scheduledPayoutWindowOptions().map((option) => option.window_seconds);
|
|
320
326
|
}
|
|
321
327
|
|
|
322
|
-
//
|
|
328
|
+
// ../../protocol/src/coordinator/state.ts
|
|
323
329
|
var INITIAL_STATE = "new";
|
|
324
330
|
var TERMINAL_STATES = /* @__PURE__ */ new Set([
|
|
325
331
|
"completed",
|
|
@@ -418,11 +424,12 @@ function isAllowedInState(current, kind, type) {
|
|
|
418
424
|
return transitionMap.has(triggerKey(current, kind, type));
|
|
419
425
|
}
|
|
420
426
|
|
|
421
|
-
//
|
|
427
|
+
// ../../protocol/src/coordinator/coordinator-envelope.schema.json
|
|
422
428
|
var coordinator_envelope_schema_default = {
|
|
423
429
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
424
430
|
$id: "https://invisible.local/schemas/coordinator-envelope.v2.schema.json",
|
|
425
431
|
title: "Invisible Coordinator Envelope v2",
|
|
432
|
+
maxEncodedJsonBytes: 524288,
|
|
426
433
|
type: "object",
|
|
427
434
|
additionalProperties: false,
|
|
428
435
|
required: ["version", "kind", "type", "swap_id", "req_id", "timestamp_ms", "payload"],
|
|
@@ -952,12 +959,12 @@ var coordinator_envelope_schema_default = {
|
|
|
952
959
|
lpShardIndex: {
|
|
953
960
|
type: "integer",
|
|
954
961
|
minimum: 0,
|
|
955
|
-
maximum:
|
|
962
|
+
maximum: 4294967294
|
|
956
963
|
},
|
|
957
964
|
lpShardCount: {
|
|
958
965
|
type: "integer",
|
|
959
966
|
minimum: 0,
|
|
960
|
-
maximum:
|
|
967
|
+
maximum: 500
|
|
961
968
|
},
|
|
962
969
|
positiveU32: {
|
|
963
970
|
type: "integer",
|
|
@@ -1265,7 +1272,7 @@ var coordinator_envelope_schema_default = {
|
|
|
1265
1272
|
lpCreationRefillThreshold: {
|
|
1266
1273
|
type: "integer",
|
|
1267
1274
|
minimum: 0,
|
|
1268
|
-
maximum:
|
|
1275
|
+
maximum: 500
|
|
1269
1276
|
},
|
|
1270
1277
|
payoutSpec: {
|
|
1271
1278
|
oneOf: [
|
|
@@ -1369,6 +1376,10 @@ var coordinator_envelope_schema_default = {
|
|
|
1369
1376
|
}
|
|
1370
1377
|
],
|
|
1371
1378
|
properties: {
|
|
1379
|
+
economics: {
|
|
1380
|
+
description: "Sealed fee ownership and retry semantics. Missing predecessor snapshots are legacy.",
|
|
1381
|
+
enum: ["legacy", "zero_protocol_fees"]
|
|
1382
|
+
},
|
|
1372
1383
|
asset: {
|
|
1373
1384
|
const: "SOL"
|
|
1374
1385
|
},
|
|
@@ -1746,6 +1757,9 @@ var coordinator_envelope_schema_default = {
|
|
|
1746
1757
|
contract_id: {
|
|
1747
1758
|
$ref: "#/$defs/string"
|
|
1748
1759
|
},
|
|
1760
|
+
deposit_origin_address: {
|
|
1761
|
+
anyOf: [{ type: "null" }, { $ref: "#/$defs/string" }]
|
|
1762
|
+
},
|
|
1749
1763
|
status: {
|
|
1750
1764
|
$ref: "#/$defs/normalUserContractStatus"
|
|
1751
1765
|
},
|
|
@@ -2141,6 +2155,9 @@ var coordinator_envelope_schema_default = {
|
|
|
2141
2155
|
"ERR_SWAP_NOT_REFUNDABLE",
|
|
2142
2156
|
"ERR_DKG_FAILURE",
|
|
2143
2157
|
"ERR_INTERNAL",
|
|
2158
|
+
"ERR_PRESEAL_ADMISSION_BUSY",
|
|
2159
|
+
"ERR_INITIALIZATION_BUSY",
|
|
2160
|
+
"ERR_ADMISSION_CAPACITY_FULL",
|
|
2144
2161
|
"ERR_INVALID_DEPOSIT",
|
|
2145
2162
|
"ERR_SETTLEMENT_FAILED"
|
|
2146
2163
|
]
|
|
@@ -2671,6 +2688,8 @@ var coordinator_envelope_schema_default = {
|
|
|
2671
2688
|
type: "object",
|
|
2672
2689
|
additionalProperties: false,
|
|
2673
2690
|
properties: {
|
|
2691
|
+
shard_start_index: { $ref: "#/$defs/lpShardIndex" },
|
|
2692
|
+
shards_snapshot_hash: { $ref: "#/$defs/lpShardSnapshotHash" },
|
|
2674
2693
|
redemption_history_cursor: {
|
|
2675
2694
|
$ref: "#/$defs/lpRedemptionId"
|
|
2676
2695
|
}
|
|
@@ -2710,7 +2729,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2710
2729
|
shard_count: {
|
|
2711
2730
|
type: "integer",
|
|
2712
2731
|
minimum: 1,
|
|
2713
|
-
maximum:
|
|
2732
|
+
maximum: 500
|
|
2714
2733
|
},
|
|
2715
2734
|
shard_amount_lamports: {
|
|
2716
2735
|
$ref: "#/$defs/positiveSafeUInt"
|
|
@@ -2718,11 +2737,11 @@ var coordinator_envelope_schema_default = {
|
|
|
2718
2737
|
refill_threshold: {
|
|
2719
2738
|
type: "integer",
|
|
2720
2739
|
minimum: 0,
|
|
2721
|
-
maximum:
|
|
2740
|
+
maximum: 500
|
|
2722
2741
|
},
|
|
2723
2742
|
addresses: {
|
|
2724
2743
|
type: "array",
|
|
2725
|
-
maxItems:
|
|
2744
|
+
maxItems: 500,
|
|
2726
2745
|
items: {
|
|
2727
2746
|
$ref: "#/$defs/lpAddress"
|
|
2728
2747
|
}
|
|
@@ -2786,7 +2805,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2786
2805
|
addresses: {
|
|
2787
2806
|
type: "array",
|
|
2788
2807
|
minItems: 1,
|
|
2789
|
-
maxItems:
|
|
2808
|
+
maxItems: 500,
|
|
2790
2809
|
items: {
|
|
2791
2810
|
$ref: "#/$defs/lpAddress"
|
|
2792
2811
|
}
|
|
@@ -2950,7 +2969,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2950
2969
|
},
|
|
2951
2970
|
value: {
|
|
2952
2971
|
type: "array",
|
|
2953
|
-
maxItems:
|
|
2972
|
+
maxItems: 500,
|
|
2954
2973
|
items: {
|
|
2955
2974
|
$ref: "#/$defs/lpShardView"
|
|
2956
2975
|
}
|
|
@@ -3078,6 +3097,20 @@ var coordinator_envelope_schema_default = {
|
|
|
3078
3097
|
lpPositionView: {
|
|
3079
3098
|
type: "object",
|
|
3080
3099
|
additionalProperties: false,
|
|
3100
|
+
dependentRequired: {
|
|
3101
|
+
shards_total_count: ["shards_snapshot_hash"],
|
|
3102
|
+
shards_snapshot_hash: ["shards_total_count"],
|
|
3103
|
+
shards_next_index: ["shards_total_count", "shards_snapshot_hash"]
|
|
3104
|
+
},
|
|
3105
|
+
allOf: [
|
|
3106
|
+
{
|
|
3107
|
+
if: {
|
|
3108
|
+
properties: { shards_snapshot_hash: {} },
|
|
3109
|
+
required: ["shards_snapshot_hash"]
|
|
3110
|
+
},
|
|
3111
|
+
then: { properties: { shards: { type: "array", maxItems: 50 } } }
|
|
3112
|
+
}
|
|
3113
|
+
],
|
|
3081
3114
|
required: [
|
|
3082
3115
|
"lp_position_id",
|
|
3083
3116
|
"status",
|
|
@@ -3101,7 +3134,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3101
3134
|
target_shard_count: {
|
|
3102
3135
|
type: "integer",
|
|
3103
3136
|
minimum: 0,
|
|
3104
|
-
maximum:
|
|
3137
|
+
maximum: 4294967295
|
|
3105
3138
|
},
|
|
3106
3139
|
auth_public_key: {
|
|
3107
3140
|
$ref: "#/$defs/base64url32Bytes"
|
|
@@ -3121,15 +3154,18 @@ var coordinator_envelope_schema_default = {
|
|
|
3121
3154
|
refill_threshold: {
|
|
3122
3155
|
type: "integer",
|
|
3123
3156
|
minimum: 0,
|
|
3124
|
-
maximum:
|
|
3157
|
+
maximum: 500
|
|
3125
3158
|
},
|
|
3126
3159
|
shards: {
|
|
3127
3160
|
type: "array",
|
|
3128
|
-
maxItems:
|
|
3161
|
+
maxItems: 500,
|
|
3129
3162
|
items: {
|
|
3130
3163
|
$ref: "#/$defs/lpShardView"
|
|
3131
3164
|
}
|
|
3132
3165
|
},
|
|
3166
|
+
shards_total_count: { $ref: "#/$defs/u32" },
|
|
3167
|
+
shards_next_index: { $ref: "#/$defs/lpShardIndex" },
|
|
3168
|
+
shards_snapshot_hash: { $ref: "#/$defs/lpShardSnapshotHash" },
|
|
3133
3169
|
created_at_ms: {
|
|
3134
3170
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3135
3171
|
},
|
|
@@ -3213,6 +3249,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3213
3249
|
]
|
|
3214
3250
|
},
|
|
3215
3251
|
properties: {
|
|
3252
|
+
economic_return: {
|
|
3253
|
+
$ref: "#/$defs/lpEconomicReturnSummary"
|
|
3254
|
+
},
|
|
3216
3255
|
lp_position_id: {
|
|
3217
3256
|
$ref: "#/$defs/lpId"
|
|
3218
3257
|
},
|
|
@@ -3278,9 +3317,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3278
3317
|
},
|
|
3279
3318
|
withdrawal_tx_hashes: {
|
|
3280
3319
|
type: "array",
|
|
3281
|
-
maxItems:
|
|
3320
|
+
maxItems: 500,
|
|
3282
3321
|
items: {
|
|
3283
|
-
$ref: "#/$defs/
|
|
3322
|
+
$ref: "#/$defs/lpViewTxSignature"
|
|
3284
3323
|
}
|
|
3285
3324
|
},
|
|
3286
3325
|
redemption_history: {
|
|
@@ -3288,7 +3327,8 @@ var coordinator_envelope_schema_default = {
|
|
|
3288
3327
|
maxItems: 32,
|
|
3289
3328
|
items: {
|
|
3290
3329
|
$ref: "#/$defs/lpRedemptionHistory"
|
|
3291
|
-
}
|
|
3330
|
+
},
|
|
3331
|
+
maxEncodedJsonBytes: 32768
|
|
3292
3332
|
},
|
|
3293
3333
|
redemption_history_has_more: {
|
|
3294
3334
|
type: "boolean"
|
|
@@ -3382,7 +3422,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3382
3422
|
minItems: 1,
|
|
3383
3423
|
maxItems: 1e3,
|
|
3384
3424
|
items: {
|
|
3385
|
-
$ref: "#/$defs/
|
|
3425
|
+
$ref: "#/$defs/lpViewAddress"
|
|
3386
3426
|
}
|
|
3387
3427
|
},
|
|
3388
3428
|
destination_count: {
|
|
@@ -3392,7 +3432,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3392
3432
|
type: "array",
|
|
3393
3433
|
maxItems: 32,
|
|
3394
3434
|
items: {
|
|
3395
|
-
$ref: "#/$defs/
|
|
3435
|
+
$ref: "#/$defs/lpViewTxSignature"
|
|
3396
3436
|
}
|
|
3397
3437
|
},
|
|
3398
3438
|
tx_signature_count: {
|
|
@@ -3421,13 +3461,13 @@ var coordinator_envelope_schema_default = {
|
|
|
3421
3461
|
$ref: "#/$defs/lpId"
|
|
3422
3462
|
},
|
|
3423
3463
|
shard_id: {
|
|
3424
|
-
$ref: "#/$defs/
|
|
3464
|
+
$ref: "#/$defs/lpViewShardId"
|
|
3425
3465
|
},
|
|
3426
3466
|
index: {
|
|
3427
3467
|
$ref: "#/$defs/lpShardIndex"
|
|
3428
3468
|
},
|
|
3429
3469
|
address: {
|
|
3430
|
-
$ref: "#/$defs/
|
|
3470
|
+
$ref: "#/$defs/lpViewAddress"
|
|
3431
3471
|
},
|
|
3432
3472
|
amount_lamports: {
|
|
3433
3473
|
$ref: "#/$defs/safeUInt"
|
|
@@ -3454,7 +3494,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3454
3494
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3455
3495
|
},
|
|
3456
3496
|
payout_tx_signature: {
|
|
3457
|
-
$ref: "#/$defs/
|
|
3497
|
+
$ref: "#/$defs/lpViewTxSignature"
|
|
3458
3498
|
}
|
|
3459
3499
|
}
|
|
3460
3500
|
},
|
|
@@ -3528,7 +3568,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3528
3568
|
},
|
|
3529
3569
|
tx_signatures: {
|
|
3530
3570
|
type: "array",
|
|
3531
|
-
maxItems:
|
|
3571
|
+
maxItems: 500,
|
|
3532
3572
|
items: {
|
|
3533
3573
|
$ref: "#/$defs/lpTxSignature"
|
|
3534
3574
|
}
|
|
@@ -3543,25 +3583,98 @@ var coordinator_envelope_schema_default = {
|
|
|
3543
3583
|
$ref: "#/$defs/safeUInt"
|
|
3544
3584
|
}
|
|
3545
3585
|
}
|
|
3586
|
+
},
|
|
3587
|
+
lpShardSnapshotHash: {
|
|
3588
|
+
type: "string",
|
|
3589
|
+
minLength: 64,
|
|
3590
|
+
maxLength: 64,
|
|
3591
|
+
pattern: "^[0-9a-f]{64}$"
|
|
3592
|
+
},
|
|
3593
|
+
lpViewShardId: {
|
|
3594
|
+
type: "string",
|
|
3595
|
+
minLength: 1,
|
|
3596
|
+
maxLength: 113,
|
|
3597
|
+
pattern: "^[A-Za-z0-9_:-]+$"
|
|
3598
|
+
},
|
|
3599
|
+
lpViewAddress: {
|
|
3600
|
+
type: "string",
|
|
3601
|
+
minLength: 1,
|
|
3602
|
+
maxLength: 44
|
|
3603
|
+
},
|
|
3604
|
+
lpViewTxSignature: {
|
|
3605
|
+
type: "string",
|
|
3606
|
+
minLength: 1,
|
|
3607
|
+
maxLength: 88
|
|
3608
|
+
},
|
|
3609
|
+
unsignedLamportTotalString: {
|
|
3610
|
+
type: "string",
|
|
3611
|
+
minLength: 1,
|
|
3612
|
+
maxLength: 39,
|
|
3613
|
+
pattern: "^(0|[1-9][0-9]*)$"
|
|
3614
|
+
},
|
|
3615
|
+
signedLamportTotalString: {
|
|
3616
|
+
type: "string",
|
|
3617
|
+
minLength: 1,
|
|
3618
|
+
maxLength: 40,
|
|
3619
|
+
pattern: "^(0|-?[1-9][0-9]*)$"
|
|
3620
|
+
},
|
|
3621
|
+
lpEconomicReturnSummary: {
|
|
3622
|
+
type: "object",
|
|
3623
|
+
additionalProperties: false,
|
|
3624
|
+
required: [
|
|
3625
|
+
"provider_reward_lamports",
|
|
3626
|
+
"source_expense_compensation_lamports",
|
|
3627
|
+
"charged_reimbursement_loss_lamports",
|
|
3628
|
+
"net_economic_return_lamports"
|
|
3629
|
+
],
|
|
3630
|
+
properties: {
|
|
3631
|
+
provider_reward_lamports: {
|
|
3632
|
+
$ref: "#/$defs/unsignedLamportTotalString"
|
|
3633
|
+
},
|
|
3634
|
+
source_expense_compensation_lamports: {
|
|
3635
|
+
$ref: "#/$defs/unsignedLamportTotalString"
|
|
3636
|
+
},
|
|
3637
|
+
charged_reimbursement_loss_lamports: {
|
|
3638
|
+
$ref: "#/$defs/unsignedLamportTotalString"
|
|
3639
|
+
},
|
|
3640
|
+
net_economic_return_lamports: {
|
|
3641
|
+
$ref: "#/$defs/signedLamportTotalString"
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3546
3644
|
}
|
|
3547
3645
|
}
|
|
3548
3646
|
};
|
|
3549
3647
|
|
|
3550
|
-
//
|
|
3648
|
+
// ../../protocol/src/coordinator/envelope.ts
|
|
3551
3649
|
var ENVELOPE_VERSION = 2;
|
|
3552
|
-
var MAX_FRAME_SIZE =
|
|
3650
|
+
var MAX_FRAME_SIZE = 512 * 1024;
|
|
3553
3651
|
var COORDINATOR_ENVELOPE_SCHEMA = coordinator_envelope_schema_default;
|
|
3554
|
-
var
|
|
3652
|
+
var LP_MAX_TOTAL_SHARDS = 4294967295;
|
|
3555
3653
|
var LP_WITHDRAW_REQUEST_PATH = "lp_command.withdrawRequest";
|
|
3556
3654
|
var UNKNOWN_SWAP_ID = "<unknown>";
|
|
3557
3655
|
var binaryFieldNames = new Set(COORDINATOR_BINARY_FIELD_NAMES);
|
|
3558
|
-
var ajv = new Ajv2020({
|
|
3559
|
-
allErrors: true,
|
|
3560
|
-
strict: true
|
|
3561
|
-
});
|
|
3562
|
-
var validateWireEnvelope = ajv.compile(coordinator_envelope_schema_default);
|
|
3563
3656
|
var textEncoder = new TextEncoder();
|
|
3564
3657
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
3658
|
+
var MAX_ENCODED_JSON_BYTES_KEYWORD = "maxEncodedJsonBytes";
|
|
3659
|
+
function createCoordinatorSchemaValidator() {
|
|
3660
|
+
const ajv = new Ajv2020({ allErrors: true, strict: true });
|
|
3661
|
+
ajv.addKeyword({
|
|
3662
|
+
keyword: MAX_ENCODED_JSON_BYTES_KEYWORD,
|
|
3663
|
+
schemaType: "number",
|
|
3664
|
+
metaSchema: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
3665
|
+
validate: (limit, value) => {
|
|
3666
|
+
try {
|
|
3667
|
+
const encoded = JSON.stringify(value);
|
|
3668
|
+
return encoded !== void 0 && textEncoder.encode(encoded).byteLength <= limit;
|
|
3669
|
+
} catch {
|
|
3670
|
+
return false;
|
|
3671
|
+
}
|
|
3672
|
+
},
|
|
3673
|
+
errors: false
|
|
3674
|
+
});
|
|
3675
|
+
return ajv.compile(coordinator_envelope_schema_default);
|
|
3676
|
+
}
|
|
3677
|
+
var validateWireEnvelope = createCoordinatorSchemaValidator();
|
|
3565
3678
|
function encode(env) {
|
|
3566
3679
|
return textEncoder.encode(JSON.stringify(toWireEnvelope(env)));
|
|
3567
3680
|
}
|
|
@@ -3581,6 +3694,8 @@ function safeEncode(env) {
|
|
|
3581
3694
|
if (!validateWireEnvelope(wire)) {
|
|
3582
3695
|
return { ok: false, error: schemaError(wire, validateWireEnvelope.errors ?? []) };
|
|
3583
3696
|
}
|
|
3697
|
+
const economicReturnError = validateLpEconomicReturnSemantics(wire);
|
|
3698
|
+
if (economicReturnError) return { ok: false, error: economicReturnError };
|
|
3584
3699
|
const encoded = textEncoder.encode(JSON.stringify(wire));
|
|
3585
3700
|
if (encoded.byteLength > MAX_FRAME_SIZE) {
|
|
3586
3701
|
return {
|
|
@@ -3721,10 +3836,10 @@ function validateUniqueLpAddresses(path, addresses) {
|
|
|
3721
3836
|
function validateLpDkgFinalizeRange(path, startIndex, addressCount) {
|
|
3722
3837
|
if (addressCount === 0) return;
|
|
3723
3838
|
const lastIndex = startIndex + addressCount - 1;
|
|
3724
|
-
if (lastIndex >=
|
|
3839
|
+
if (lastIndex >= LP_MAX_TOTAL_SHARDS) {
|
|
3725
3840
|
throw new CoordinatorError(
|
|
3726
3841
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3727
|
-
`${path}.addresses end index (${lastIndex}) must be <= ${
|
|
3842
|
+
`${path}.addresses end index (${lastIndex}) must be <= ${LP_MAX_TOTAL_SHARDS - 1}`
|
|
3728
3843
|
);
|
|
3729
3844
|
}
|
|
3730
3845
|
}
|
|
@@ -3759,6 +3874,8 @@ function decode(raw) {
|
|
|
3759
3874
|
if (!validateWireEnvelope(parsed)) {
|
|
3760
3875
|
return { ok: false, error: schemaError(parsed, validateWireEnvelope.errors ?? []) };
|
|
3761
3876
|
}
|
|
3877
|
+
const economicReturnError = validateLpEconomicReturnSemantics(parsed);
|
|
3878
|
+
if (economicReturnError) return { ok: false, error: economicReturnError };
|
|
3762
3879
|
try {
|
|
3763
3880
|
return { ok: true, value: fromWireEnvelope(parsed) };
|
|
3764
3881
|
} catch (error) {
|
|
@@ -4118,7 +4235,27 @@ var asErrorPayload = (e) => {
|
|
|
4118
4235
|
}
|
|
4119
4236
|
return payload;
|
|
4120
4237
|
};
|
|
4238
|
+
var LP_ECONOMIC_UNSIGNED_TOTAL_MAX = (1n << 128n) - 1n;
|
|
4239
|
+
var LP_ECONOMIC_SIGNED_TOTAL_MIN = -(1n << 127n);
|
|
4240
|
+
var LP_ECONOMIC_SIGNED_TOTAL_MAX = (1n << 127n) - 1n;
|
|
4241
|
+
function validateLpEconomicReturnSemantics(wire) {
|
|
4242
|
+
const payload = wire.payload;
|
|
4243
|
+
if (!payload || payload.case !== "position") return void 0;
|
|
4244
|
+
const summary = payload.value?.actor_sync?.economic_return;
|
|
4245
|
+
if (!summary) return void 0;
|
|
4246
|
+
const reward = BigInt(summary.provider_reward_lamports);
|
|
4247
|
+
const compensation = BigInt(summary.source_expense_compensation_lamports);
|
|
4248
|
+
const loss = BigInt(summary.charged_reimbursement_loss_lamports);
|
|
4249
|
+
const net = BigInt(summary.net_economic_return_lamports);
|
|
4250
|
+
if (reward > LP_ECONOMIC_UNSIGNED_TOTAL_MAX || compensation > LP_ECONOMIC_UNSIGNED_TOTAL_MAX || loss > LP_ECONOMIC_UNSIGNED_TOTAL_MAX || net < LP_ECONOMIC_SIGNED_TOTAL_MIN || net > LP_ECONOMIC_SIGNED_TOTAL_MAX || net !== reward - loss) {
|
|
4251
|
+
return new CoordinatorError(
|
|
4252
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4253
|
+
"LP economic return invariant is invalid"
|
|
4254
|
+
);
|
|
4255
|
+
}
|
|
4256
|
+
return void 0;
|
|
4257
|
+
}
|
|
4121
4258
|
|
|
4122
|
-
export { COORDINATOR_BINARY_FIELD_NAMES, COORDINATOR_ENVELOPE_SCHEMA, COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES, CoordinatorError, CoordinatorMessageType, DEFAULT_PAYOUT_WINDOW_ID, DIRECTION_BY_TYPE, ENVELOPE_VERSION, EnvelopeKind, ErrorCode, INITIAL_STATE, MAX_FRAME_SIZE, MessageDirection, PAYOUT_WINDOW_OPTIONS, TERMINAL_STATES, TRANSITIONS, VALID_SWAP_STATES, asDelegateAckPayload, asDelegateSharePayload, asDelegateShareResponsePayload, asDepositConfirmedPayload, asDkgCompletePayload, asDkgInitPayload, asDkgInitResponsePayload, asDkgRound1Payload, asDkgRound1ResponsePayload, asDkgRound2Payload, asDkgRound2ResponsePayload, asErrorPayload, asLpCommandResponsePayload, asPayoutExecutedPayload, asSwapRequestPayload, asSwapRequestResponsePayload, asSyncRequiredPayload, asSyncUserRequestPayload, asSyncUserResponsePayload, asWithdrawAcceptedPayload, asWithdrawExecutedPayload, asWithdrawRequestPayload, decode, encode, encodeLpCommandForSigning, encodeValidated, isAllowedInState, isAllowedKindForType, isPayoutWindowId, isValidEnvelopeKind, isValidErrorCode, isValidMessageType, isValidSwapState, lpSignedCommandEnvelope, nextState, payloadCategory, payoutWindowLabelForId, payoutWindowOptionById, safeEncode, scheduledPayoutWindowOptions, scheduledPayoutWindowSeconds };
|
|
4123
|
-
//# sourceMappingURL=chunk-
|
|
4124
|
-
//# sourceMappingURL=chunk-
|
|
4259
|
+
export { COORDINATOR_BINARY_FIELD_NAMES, COORDINATOR_ENVELOPE_SCHEMA, COORDINATOR_SCHEMA_PAYLOAD_CATEGORIES, CoordinatorError, CoordinatorMessageType, DEFAULT_PAYOUT_WINDOW_ID, DIRECTION_BY_TYPE, ENVELOPE_VERSION, EnvelopeKind, ErrorCode, INITIAL_STATE, MAX_ENCODED_JSON_BYTES_KEYWORD, MAX_FRAME_SIZE, MessageDirection, PAYOUT_WINDOW_OPTIONS, TERMINAL_STATES, TRANSITIONS, VALID_SWAP_STATES, asDelegateAckPayload, asDelegateSharePayload, asDelegateShareResponsePayload, asDepositConfirmedPayload, asDkgCompletePayload, asDkgInitPayload, asDkgInitResponsePayload, asDkgRound1Payload, asDkgRound1ResponsePayload, asDkgRound2Payload, asDkgRound2ResponsePayload, asErrorPayload, asLpCommandResponsePayload, asPayoutExecutedPayload, asSwapRequestPayload, asSwapRequestResponsePayload, asSyncRequiredPayload, asSyncUserRequestPayload, asSyncUserResponsePayload, asWithdrawAcceptedPayload, asWithdrawExecutedPayload, asWithdrawRequestPayload, createCoordinatorSchemaValidator, decode, encode, encodeLpCommandForSigning, encodeValidated, isAllowedInState, isAllowedKindForType, isPayoutWindowId, isValidEnvelopeKind, isValidErrorCode, isValidMessageType, isValidSwapState, lpSignedCommandEnvelope, nextState, payloadCategory, payoutWindowLabelForId, payoutWindowOptionById, safeEncode, scheduledPayoutWindowOptions, scheduledPayoutWindowSeconds };
|
|
4260
|
+
//# sourceMappingURL=chunk-QF5TSUQE.js.map
|
|
4261
|
+
//# sourceMappingURL=chunk-QF5TSUQE.js.map
|