@invisible-labs/sdk 0.8.0-devnet → 0.10.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 +17 -3
- package/dist/.invisible-sdk-build-target.json +2 -2
- package/dist/{chunk-MZKJU3UA.js → chunk-6AGC3IOB.js} +16 -6
- package/dist/chunk-6AGC3IOB.js.map +1 -0
- 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-ANQMIQYS.js} +587 -19
- package/dist/chunk-ANQMIQYS.js.map +1 -0
- package/dist/{chunk-MPNVF727.js → chunk-DFBH5XLM.js} +569 -78
- package/dist/chunk-DFBH5XLM.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-K67FTCQU.js → chunk-JNNVPZEU.js} +3 -3
- package/dist/chunk-JNNVPZEU.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-T2B7253V.js +4 -0
- package/dist/{coordinator-E2TS6NR2.js.map → coordinator-T2B7253V.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 +4 -4
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/lp.d.ts +48 -1
- package/dist/lp.js +360 -82
- 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-CtMxCo9F.d.ts} +80 -2
- package/dist/user.d.ts +25 -11
- package/dist/user.js +124 -37
- package/dist/user.js.map +1 -1
- package/package.json +2 -2
- 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,29 @@ function isAllowedInState(current, kind, type) {
|
|
|
418
424
|
return transitionMap.has(triggerKey(current, kind, type));
|
|
419
425
|
}
|
|
420
426
|
|
|
421
|
-
//
|
|
427
|
+
// ../../protocol/src/coordinator/lp-fee-policy.ts
|
|
428
|
+
var LP_FEE_POLICY_VERSION = 1;
|
|
429
|
+
var LP_PARTNER_COMMISSION_BPS = 6e3;
|
|
430
|
+
var LP_BASIS_POINT_DENOMINATOR = 10000n;
|
|
431
|
+
var LP_FEE_POLICY_HASHES = {
|
|
432
|
+
internal: "53479c39d822899c0abe21990aeff40ea74681277b2744ef86234152cc94ca5a",
|
|
433
|
+
partner: "3e1a307504043bc0b25f03ccffdff1b42cd2b38699f000f7eb70ce9433a5b2a7"
|
|
434
|
+
};
|
|
435
|
+
function validateLpFeePolicySemantics(policy) {
|
|
436
|
+
if (policy.version !== LP_FEE_POLICY_VERSION || policy.commission_bps !== (policy.profile === "partner" ? LP_PARTNER_COMMISSION_BPS : 0) || policy.policy_hash !== LP_FEE_POLICY_HASHES[policy.profile]) {
|
|
437
|
+
throw new CoordinatorError(
|
|
438
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
439
|
+
"LP fee policy does not match the supported immutable profile"
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// ../../protocol/src/coordinator/coordinator-envelope.schema.json
|
|
422
445
|
var coordinator_envelope_schema_default = {
|
|
423
446
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
424
447
|
$id: "https://invisible.local/schemas/coordinator-envelope.v2.schema.json",
|
|
425
448
|
title: "Invisible Coordinator Envelope v2",
|
|
449
|
+
maxEncodedJsonBytes: 524288,
|
|
426
450
|
type: "object",
|
|
427
451
|
additionalProperties: false,
|
|
428
452
|
required: ["version", "kind", "type", "swap_id", "req_id", "timestamp_ms", "payload"],
|
|
@@ -511,19 +535,35 @@ var coordinator_envelope_schema_default = {
|
|
|
511
535
|
{
|
|
512
536
|
title: "LpCreateAuthorization request",
|
|
513
537
|
properties: {
|
|
514
|
-
kind: {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
538
|
+
kind: {
|
|
539
|
+
const: "request"
|
|
540
|
+
},
|
|
541
|
+
type: {
|
|
542
|
+
const: "LpCreateAuthorization"
|
|
543
|
+
},
|
|
544
|
+
swap_id: {
|
|
545
|
+
type: "null"
|
|
546
|
+
},
|
|
547
|
+
payload: {
|
|
548
|
+
$ref: "#/$defs/lpCreateAuthorizationRequest"
|
|
549
|
+
}
|
|
518
550
|
}
|
|
519
551
|
},
|
|
520
552
|
{
|
|
521
553
|
title: "LpCreateAuthorization response",
|
|
522
554
|
properties: {
|
|
523
|
-
kind: {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
555
|
+
kind: {
|
|
556
|
+
const: "response"
|
|
557
|
+
},
|
|
558
|
+
type: {
|
|
559
|
+
const: "LpCreateAuthorization"
|
|
560
|
+
},
|
|
561
|
+
swap_id: {
|
|
562
|
+
type: "null"
|
|
563
|
+
},
|
|
564
|
+
payload: {
|
|
565
|
+
$ref: "#/$defs/lpCreateAuthorizationResponse"
|
|
566
|
+
}
|
|
527
567
|
}
|
|
528
568
|
},
|
|
529
569
|
{
|
|
@@ -952,12 +992,12 @@ var coordinator_envelope_schema_default = {
|
|
|
952
992
|
lpShardIndex: {
|
|
953
993
|
type: "integer",
|
|
954
994
|
minimum: 0,
|
|
955
|
-
maximum:
|
|
995
|
+
maximum: 4294967294
|
|
956
996
|
},
|
|
957
997
|
lpShardCount: {
|
|
958
998
|
type: "integer",
|
|
959
999
|
minimum: 0,
|
|
960
|
-
maximum:
|
|
1000
|
+
maximum: 500
|
|
961
1001
|
},
|
|
962
1002
|
positiveU32: {
|
|
963
1003
|
type: "integer",
|
|
@@ -1096,6 +1136,13 @@ var coordinator_envelope_schema_default = {
|
|
|
1096
1136
|
description: "Optional legacy absolute request deadline. Scheduled payout_spec.window_seconds selects the supported scheduled window.",
|
|
1097
1137
|
$ref: "#/$defs/positiveSafeUInt"
|
|
1098
1138
|
},
|
|
1139
|
+
batch_exclusion_id: {
|
|
1140
|
+
description: "Opaque user-scoped grouping token. Same-ID user-owned liquidity cannot fund this contract; it is not an identity credential.",
|
|
1141
|
+
type: "string",
|
|
1142
|
+
minLength: 1,
|
|
1143
|
+
maxLength: 128,
|
|
1144
|
+
pattern: "^[A-Za-z0-9_-]+$"
|
|
1145
|
+
},
|
|
1099
1146
|
payout_spec: {
|
|
1100
1147
|
$ref: "#/$defs/payoutSpec"
|
|
1101
1148
|
},
|
|
@@ -1161,14 +1208,22 @@ var coordinator_envelope_schema_default = {
|
|
|
1161
1208
|
},
|
|
1162
1209
|
lpCreateAuthorizationRequest: {
|
|
1163
1210
|
oneOf: [
|
|
1164
|
-
{
|
|
1165
|
-
|
|
1211
|
+
{
|
|
1212
|
+
$ref: "#/$defs/lpCreateAuthorizationChallengeRequest"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
$ref: "#/$defs/lpCreateAuthorizationProofRequest"
|
|
1216
|
+
}
|
|
1166
1217
|
]
|
|
1167
1218
|
},
|
|
1168
1219
|
lpCreateAuthorizationResponse: {
|
|
1169
1220
|
oneOf: [
|
|
1170
|
-
{
|
|
1171
|
-
|
|
1221
|
+
{
|
|
1222
|
+
$ref: "#/$defs/lpCreateAuthorizationChallengeResponse"
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
$ref: "#/$defs/lpCreateAuthorizationAuthorizedResponse"
|
|
1226
|
+
}
|
|
1172
1227
|
]
|
|
1173
1228
|
},
|
|
1174
1229
|
lpCreateAuthorizationChallengeRequest: {
|
|
@@ -1176,8 +1231,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1176
1231
|
additionalProperties: false,
|
|
1177
1232
|
required: ["case", "value"],
|
|
1178
1233
|
properties: {
|
|
1179
|
-
case: {
|
|
1180
|
-
|
|
1234
|
+
case: {
|
|
1235
|
+
const: "challenge"
|
|
1236
|
+
},
|
|
1237
|
+
value: {
|
|
1238
|
+
$ref: "#/$defs/lpCreateAuthorizationChallenge"
|
|
1239
|
+
}
|
|
1181
1240
|
}
|
|
1182
1241
|
},
|
|
1183
1242
|
lpCreateAuthorizationProofRequest: {
|
|
@@ -1185,8 +1244,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1185
1244
|
additionalProperties: false,
|
|
1186
1245
|
required: ["case", "value"],
|
|
1187
1246
|
properties: {
|
|
1188
|
-
case: {
|
|
1189
|
-
|
|
1247
|
+
case: {
|
|
1248
|
+
const: "proof"
|
|
1249
|
+
},
|
|
1250
|
+
value: {
|
|
1251
|
+
$ref: "#/$defs/lpCreateAuthorizationProof"
|
|
1252
|
+
}
|
|
1190
1253
|
}
|
|
1191
1254
|
},
|
|
1192
1255
|
lpCreateAuthorizationChallengeResponse: {
|
|
@@ -1194,8 +1257,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1194
1257
|
additionalProperties: false,
|
|
1195
1258
|
required: ["case", "value"],
|
|
1196
1259
|
properties: {
|
|
1197
|
-
case: {
|
|
1198
|
-
|
|
1260
|
+
case: {
|
|
1261
|
+
const: "challenge"
|
|
1262
|
+
},
|
|
1263
|
+
value: {
|
|
1264
|
+
$ref: "#/$defs/lpCreateAuthorizationChallengeResponseValue"
|
|
1265
|
+
}
|
|
1199
1266
|
}
|
|
1200
1267
|
},
|
|
1201
1268
|
lpCreateAuthorizationAuthorizedResponse: {
|
|
@@ -1203,8 +1270,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1203
1270
|
additionalProperties: false,
|
|
1204
1271
|
required: ["case", "value"],
|
|
1205
1272
|
properties: {
|
|
1206
|
-
case: {
|
|
1207
|
-
|
|
1273
|
+
case: {
|
|
1274
|
+
const: "authorized"
|
|
1275
|
+
},
|
|
1276
|
+
value: {
|
|
1277
|
+
$ref: "#/$defs/lpCreateAuthorizationAuthorized"
|
|
1278
|
+
}
|
|
1208
1279
|
}
|
|
1209
1280
|
},
|
|
1210
1281
|
lpCreateAuthorizationChallenge: {
|
|
@@ -1212,8 +1283,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1212
1283
|
additionalProperties: false,
|
|
1213
1284
|
required: ["public_key", "intent"],
|
|
1214
1285
|
properties: {
|
|
1215
|
-
public_key: {
|
|
1216
|
-
|
|
1286
|
+
public_key: {
|
|
1287
|
+
$ref: "#/$defs/lpSolanaAddress"
|
|
1288
|
+
},
|
|
1289
|
+
intent: {
|
|
1290
|
+
$ref: "#/$defs/lpCreatePositionIntent"
|
|
1291
|
+
}
|
|
1217
1292
|
}
|
|
1218
1293
|
},
|
|
1219
1294
|
lpCreateAuthorizationProof: {
|
|
@@ -1221,10 +1296,18 @@ var coordinator_envelope_schema_default = {
|
|
|
1221
1296
|
additionalProperties: false,
|
|
1222
1297
|
required: ["authorization_id", "public_key", "message", "signature"],
|
|
1223
1298
|
properties: {
|
|
1224
|
-
authorization_id: {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1299
|
+
authorization_id: {
|
|
1300
|
+
$ref: "#/$defs/lpAuthorizationId"
|
|
1301
|
+
},
|
|
1302
|
+
public_key: {
|
|
1303
|
+
$ref: "#/$defs/lpSolanaAddress"
|
|
1304
|
+
},
|
|
1305
|
+
message: {
|
|
1306
|
+
$ref: "#/$defs/lpSiwsMessage"
|
|
1307
|
+
},
|
|
1308
|
+
signature: {
|
|
1309
|
+
$ref: "#/$defs/base64url64Bytes"
|
|
1310
|
+
}
|
|
1228
1311
|
}
|
|
1229
1312
|
},
|
|
1230
1313
|
lpCreateAuthorizationChallengeResponseValue: {
|
|
@@ -1232,10 +1315,24 @@ var coordinator_envelope_schema_default = {
|
|
|
1232
1315
|
additionalProperties: false,
|
|
1233
1316
|
required: ["authorization_id", "message", "expires_at_ms", "valid_for_ms"],
|
|
1234
1317
|
properties: {
|
|
1235
|
-
authorization_id: {
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1318
|
+
authorization_id: {
|
|
1319
|
+
$ref: "#/$defs/lpAuthorizationId"
|
|
1320
|
+
},
|
|
1321
|
+
message: {
|
|
1322
|
+
$ref: "#/$defs/lpSiwsMessage"
|
|
1323
|
+
},
|
|
1324
|
+
expires_at_ms: {
|
|
1325
|
+
$ref: "#/$defs/positiveSafeUInt"
|
|
1326
|
+
},
|
|
1327
|
+
valid_for_ms: {
|
|
1328
|
+
$ref: "#/$defs/positiveSafeUInt"
|
|
1329
|
+
},
|
|
1330
|
+
fee_policy: {
|
|
1331
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
1332
|
+
},
|
|
1333
|
+
lp_fee_policy_version: {
|
|
1334
|
+
const: 1
|
|
1335
|
+
}
|
|
1239
1336
|
}
|
|
1240
1337
|
},
|
|
1241
1338
|
lpCreateAuthorizationAuthorized: {
|
|
@@ -1243,7 +1340,15 @@ var coordinator_envelope_schema_default = {
|
|
|
1243
1340
|
additionalProperties: false,
|
|
1244
1341
|
required: ["authorization_id"],
|
|
1245
1342
|
properties: {
|
|
1246
|
-
authorization_id: {
|
|
1343
|
+
authorization_id: {
|
|
1344
|
+
$ref: "#/$defs/lpAuthorizationId"
|
|
1345
|
+
},
|
|
1346
|
+
fee_policy: {
|
|
1347
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
1348
|
+
},
|
|
1349
|
+
lp_fee_policy_version: {
|
|
1350
|
+
const: 1
|
|
1351
|
+
}
|
|
1247
1352
|
}
|
|
1248
1353
|
},
|
|
1249
1354
|
lpCreatePositionIntent: {
|
|
@@ -1256,16 +1361,24 @@ var coordinator_envelope_schema_default = {
|
|
|
1256
1361
|
"refill_threshold"
|
|
1257
1362
|
],
|
|
1258
1363
|
properties: {
|
|
1259
|
-
committed_lamports: {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1364
|
+
committed_lamports: {
|
|
1365
|
+
$ref: "#/$defs/positiveSafeUInt"
|
|
1366
|
+
},
|
|
1367
|
+
shard_count: {
|
|
1368
|
+
$ref: "#/$defs/lpShardCount"
|
|
1369
|
+
},
|
|
1370
|
+
shard_amount_lamports: {
|
|
1371
|
+
$ref: "#/$defs/positiveSafeUInt"
|
|
1372
|
+
},
|
|
1373
|
+
refill_threshold: {
|
|
1374
|
+
$ref: "#/$defs/lpCreationRefillThreshold"
|
|
1375
|
+
}
|
|
1263
1376
|
}
|
|
1264
1377
|
},
|
|
1265
1378
|
lpCreationRefillThreshold: {
|
|
1266
1379
|
type: "integer",
|
|
1267
1380
|
minimum: 0,
|
|
1268
|
-
maximum:
|
|
1381
|
+
maximum: 500
|
|
1269
1382
|
},
|
|
1270
1383
|
payoutSpec: {
|
|
1271
1384
|
oneOf: [
|
|
@@ -1369,6 +1482,10 @@ var coordinator_envelope_schema_default = {
|
|
|
1369
1482
|
}
|
|
1370
1483
|
],
|
|
1371
1484
|
properties: {
|
|
1485
|
+
economics: {
|
|
1486
|
+
description: "Sealed fee ownership and retry semantics. Missing predecessor snapshots are legacy.",
|
|
1487
|
+
enum: ["legacy", "zero_protocol_fees"]
|
|
1488
|
+
},
|
|
1372
1489
|
asset: {
|
|
1373
1490
|
const: "SOL"
|
|
1374
1491
|
},
|
|
@@ -1746,6 +1863,16 @@ var coordinator_envelope_schema_default = {
|
|
|
1746
1863
|
contract_id: {
|
|
1747
1864
|
$ref: "#/$defs/string"
|
|
1748
1865
|
},
|
|
1866
|
+
deposit_origin_address: {
|
|
1867
|
+
anyOf: [
|
|
1868
|
+
{
|
|
1869
|
+
type: "null"
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
$ref: "#/$defs/string"
|
|
1873
|
+
}
|
|
1874
|
+
]
|
|
1875
|
+
},
|
|
1749
1876
|
status: {
|
|
1750
1877
|
$ref: "#/$defs/normalUserContractStatus"
|
|
1751
1878
|
},
|
|
@@ -2141,6 +2268,9 @@ var coordinator_envelope_schema_default = {
|
|
|
2141
2268
|
"ERR_SWAP_NOT_REFUNDABLE",
|
|
2142
2269
|
"ERR_DKG_FAILURE",
|
|
2143
2270
|
"ERR_INTERNAL",
|
|
2271
|
+
"ERR_PRESEAL_ADMISSION_BUSY",
|
|
2272
|
+
"ERR_INITIALIZATION_BUSY",
|
|
2273
|
+
"ERR_ADMISSION_CAPACITY_FULL",
|
|
2144
2274
|
"ERR_INVALID_DEPOSIT",
|
|
2145
2275
|
"ERR_SETTLEMENT_FAILED"
|
|
2146
2276
|
]
|
|
@@ -2671,6 +2801,12 @@ var coordinator_envelope_schema_default = {
|
|
|
2671
2801
|
type: "object",
|
|
2672
2802
|
additionalProperties: false,
|
|
2673
2803
|
properties: {
|
|
2804
|
+
shard_start_index: {
|
|
2805
|
+
$ref: "#/$defs/lpShardIndex"
|
|
2806
|
+
},
|
|
2807
|
+
shards_snapshot_hash: {
|
|
2808
|
+
$ref: "#/$defs/lpShardSnapshotHash"
|
|
2809
|
+
},
|
|
2674
2810
|
redemption_history_cursor: {
|
|
2675
2811
|
$ref: "#/$defs/lpRedemptionId"
|
|
2676
2812
|
}
|
|
@@ -2710,7 +2846,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2710
2846
|
shard_count: {
|
|
2711
2847
|
type: "integer",
|
|
2712
2848
|
minimum: 1,
|
|
2713
|
-
maximum:
|
|
2849
|
+
maximum: 500
|
|
2714
2850
|
},
|
|
2715
2851
|
shard_amount_lamports: {
|
|
2716
2852
|
$ref: "#/$defs/positiveSafeUInt"
|
|
@@ -2718,17 +2854,20 @@ var coordinator_envelope_schema_default = {
|
|
|
2718
2854
|
refill_threshold: {
|
|
2719
2855
|
type: "integer",
|
|
2720
2856
|
minimum: 0,
|
|
2721
|
-
maximum:
|
|
2857
|
+
maximum: 500
|
|
2722
2858
|
},
|
|
2723
2859
|
addresses: {
|
|
2724
2860
|
type: "array",
|
|
2725
|
-
maxItems:
|
|
2861
|
+
maxItems: 500,
|
|
2726
2862
|
items: {
|
|
2727
2863
|
$ref: "#/$defs/lpAddress"
|
|
2728
2864
|
}
|
|
2729
2865
|
},
|
|
2730
2866
|
created_at_ms: {
|
|
2731
2867
|
$ref: "#/$defs/positiveSafeUInt"
|
|
2868
|
+
},
|
|
2869
|
+
fee_policy: {
|
|
2870
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
2732
2871
|
}
|
|
2733
2872
|
}
|
|
2734
2873
|
},
|
|
@@ -2786,7 +2925,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2786
2925
|
addresses: {
|
|
2787
2926
|
type: "array",
|
|
2788
2927
|
minItems: 1,
|
|
2789
|
-
maxItems:
|
|
2928
|
+
maxItems: 500,
|
|
2790
2929
|
items: {
|
|
2791
2930
|
$ref: "#/$defs/lpAddress"
|
|
2792
2931
|
}
|
|
@@ -2950,7 +3089,7 @@ var coordinator_envelope_schema_default = {
|
|
|
2950
3089
|
},
|
|
2951
3090
|
value: {
|
|
2952
3091
|
type: "array",
|
|
2953
|
-
maxItems:
|
|
3092
|
+
maxItems: 500,
|
|
2954
3093
|
items: {
|
|
2955
3094
|
$ref: "#/$defs/lpShardView"
|
|
2956
3095
|
}
|
|
@@ -3078,6 +3217,29 @@ var coordinator_envelope_schema_default = {
|
|
|
3078
3217
|
lpPositionView: {
|
|
3079
3218
|
type: "object",
|
|
3080
3219
|
additionalProperties: false,
|
|
3220
|
+
dependentRequired: {
|
|
3221
|
+
shards_total_count: ["shards_snapshot_hash"],
|
|
3222
|
+
shards_snapshot_hash: ["shards_total_count"],
|
|
3223
|
+
shards_next_index: ["shards_total_count", "shards_snapshot_hash"]
|
|
3224
|
+
},
|
|
3225
|
+
allOf: [
|
|
3226
|
+
{
|
|
3227
|
+
if: {
|
|
3228
|
+
properties: {
|
|
3229
|
+
shards_snapshot_hash: {}
|
|
3230
|
+
},
|
|
3231
|
+
required: ["shards_snapshot_hash"]
|
|
3232
|
+
},
|
|
3233
|
+
then: {
|
|
3234
|
+
properties: {
|
|
3235
|
+
shards: {
|
|
3236
|
+
type: "array",
|
|
3237
|
+
maxItems: 50
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
],
|
|
3081
3243
|
required: [
|
|
3082
3244
|
"lp_position_id",
|
|
3083
3245
|
"status",
|
|
@@ -3101,7 +3263,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3101
3263
|
target_shard_count: {
|
|
3102
3264
|
type: "integer",
|
|
3103
3265
|
minimum: 0,
|
|
3104
|
-
maximum:
|
|
3266
|
+
maximum: 4294967295
|
|
3105
3267
|
},
|
|
3106
3268
|
auth_public_key: {
|
|
3107
3269
|
$ref: "#/$defs/base64url32Bytes"
|
|
@@ -3121,15 +3283,24 @@ var coordinator_envelope_schema_default = {
|
|
|
3121
3283
|
refill_threshold: {
|
|
3122
3284
|
type: "integer",
|
|
3123
3285
|
minimum: 0,
|
|
3124
|
-
maximum:
|
|
3286
|
+
maximum: 500
|
|
3125
3287
|
},
|
|
3126
3288
|
shards: {
|
|
3127
3289
|
type: "array",
|
|
3128
|
-
maxItems:
|
|
3290
|
+
maxItems: 500,
|
|
3129
3291
|
items: {
|
|
3130
3292
|
$ref: "#/$defs/lpShardView"
|
|
3131
3293
|
}
|
|
3132
3294
|
},
|
|
3295
|
+
shards_total_count: {
|
|
3296
|
+
$ref: "#/$defs/u32"
|
|
3297
|
+
},
|
|
3298
|
+
shards_next_index: {
|
|
3299
|
+
$ref: "#/$defs/lpShardIndex"
|
|
3300
|
+
},
|
|
3301
|
+
shards_snapshot_hash: {
|
|
3302
|
+
$ref: "#/$defs/lpShardSnapshotHash"
|
|
3303
|
+
},
|
|
3133
3304
|
created_at_ms: {
|
|
3134
3305
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3135
3306
|
},
|
|
@@ -3138,6 +3309,12 @@ var coordinator_envelope_schema_default = {
|
|
|
3138
3309
|
},
|
|
3139
3310
|
actor_sync: {
|
|
3140
3311
|
$ref: "#/$defs/lpActorSyncView"
|
|
3312
|
+
},
|
|
3313
|
+
fee_policy: {
|
|
3314
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
3315
|
+
},
|
|
3316
|
+
lp_fee_policy_version: {
|
|
3317
|
+
const: 1
|
|
3141
3318
|
}
|
|
3142
3319
|
}
|
|
3143
3320
|
},
|
|
@@ -3181,6 +3358,13 @@ var coordinator_envelope_schema_default = {
|
|
|
3181
3358
|
"updated_at_ms"
|
|
3182
3359
|
],
|
|
3183
3360
|
dependentRequired: {
|
|
3361
|
+
total_net_funds_lamports: [
|
|
3362
|
+
"redeemable_principal_lamports",
|
|
3363
|
+
"redeemable_fee_lamports",
|
|
3364
|
+
"lifetime_earned_lamports",
|
|
3365
|
+
"redeemable_principal_source_count",
|
|
3366
|
+
"redeemable_fee_source_count"
|
|
3367
|
+
],
|
|
3184
3368
|
redeemable_principal_lamports: [
|
|
3185
3369
|
"redeemable_fee_lamports",
|
|
3186
3370
|
"lifetime_earned_lamports",
|
|
@@ -3210,9 +3394,50 @@ var coordinator_envelope_schema_default = {
|
|
|
3210
3394
|
"redeemable_fee_lamports",
|
|
3211
3395
|
"lifetime_earned_lamports",
|
|
3212
3396
|
"redeemable_principal_source_count"
|
|
3213
|
-
]
|
|
3397
|
+
],
|
|
3398
|
+
fee_policy: [
|
|
3399
|
+
"fee_basis_revision",
|
|
3400
|
+
"gross_fee_lamports",
|
|
3401
|
+
"protocol_commission_lamports",
|
|
3402
|
+
"waived_protocol_commission_lamports",
|
|
3403
|
+
"redeemable_principal_lamports",
|
|
3404
|
+
"redeemable_fee_lamports",
|
|
3405
|
+
"lifetime_earned_lamports",
|
|
3406
|
+
"economic_return"
|
|
3407
|
+
],
|
|
3408
|
+
fee_basis_revision: [
|
|
3409
|
+
"fee_policy",
|
|
3410
|
+
"gross_fee_lamports",
|
|
3411
|
+
"protocol_commission_lamports",
|
|
3412
|
+
"redeemable_principal_lamports",
|
|
3413
|
+
"redeemable_fee_lamports",
|
|
3414
|
+
"lifetime_earned_lamports",
|
|
3415
|
+
"economic_return"
|
|
3416
|
+
],
|
|
3417
|
+
gross_fee_lamports: [
|
|
3418
|
+
"fee_policy",
|
|
3419
|
+
"fee_basis_revision",
|
|
3420
|
+
"protocol_commission_lamports",
|
|
3421
|
+
"redeemable_principal_lamports",
|
|
3422
|
+
"redeemable_fee_lamports",
|
|
3423
|
+
"lifetime_earned_lamports",
|
|
3424
|
+
"economic_return"
|
|
3425
|
+
],
|
|
3426
|
+
protocol_commission_lamports: [
|
|
3427
|
+
"fee_policy",
|
|
3428
|
+
"fee_basis_revision",
|
|
3429
|
+
"gross_fee_lamports",
|
|
3430
|
+
"redeemable_principal_lamports",
|
|
3431
|
+
"redeemable_fee_lamports",
|
|
3432
|
+
"lifetime_earned_lamports",
|
|
3433
|
+
"economic_return"
|
|
3434
|
+
],
|
|
3435
|
+
waived_protocol_commission_lamports: ["fee_policy"]
|
|
3214
3436
|
},
|
|
3215
3437
|
properties: {
|
|
3438
|
+
economic_return: {
|
|
3439
|
+
$ref: "#/$defs/lpEconomicReturnSummary"
|
|
3440
|
+
},
|
|
3216
3441
|
lp_position_id: {
|
|
3217
3442
|
$ref: "#/$defs/lpId"
|
|
3218
3443
|
},
|
|
@@ -3225,6 +3450,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3225
3450
|
redeemable_principal_lamports: {
|
|
3226
3451
|
$ref: "#/$defs/safeUInt"
|
|
3227
3452
|
},
|
|
3453
|
+
total_net_funds_lamports: {
|
|
3454
|
+
$ref: "#/$defs/safeUInt"
|
|
3455
|
+
},
|
|
3228
3456
|
redeemable_fee_lamports: {
|
|
3229
3457
|
$ref: "#/$defs/safeUInt"
|
|
3230
3458
|
},
|
|
@@ -3278,9 +3506,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3278
3506
|
},
|
|
3279
3507
|
withdrawal_tx_hashes: {
|
|
3280
3508
|
type: "array",
|
|
3281
|
-
maxItems:
|
|
3509
|
+
maxItems: 500,
|
|
3282
3510
|
items: {
|
|
3283
|
-
$ref: "#/$defs/
|
|
3511
|
+
$ref: "#/$defs/lpViewTxSignature"
|
|
3284
3512
|
}
|
|
3285
3513
|
},
|
|
3286
3514
|
redemption_history: {
|
|
@@ -3288,7 +3516,8 @@ var coordinator_envelope_schema_default = {
|
|
|
3288
3516
|
maxItems: 32,
|
|
3289
3517
|
items: {
|
|
3290
3518
|
$ref: "#/$defs/lpRedemptionHistory"
|
|
3291
|
-
}
|
|
3519
|
+
},
|
|
3520
|
+
maxEncodedJsonBytes: 32768
|
|
3292
3521
|
},
|
|
3293
3522
|
redemption_history_has_more: {
|
|
3294
3523
|
type: "boolean"
|
|
@@ -3301,6 +3530,21 @@ var coordinator_envelope_schema_default = {
|
|
|
3301
3530
|
},
|
|
3302
3531
|
updated_at_ms: {
|
|
3303
3532
|
$ref: "#/$defs/safeUInt"
|
|
3533
|
+
},
|
|
3534
|
+
fee_policy: {
|
|
3535
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
3536
|
+
},
|
|
3537
|
+
fee_basis_revision: {
|
|
3538
|
+
$ref: "#/$defs/safeUInt"
|
|
3539
|
+
},
|
|
3540
|
+
gross_fee_lamports: {
|
|
3541
|
+
$ref: "#/$defs/safeUInt"
|
|
3542
|
+
},
|
|
3543
|
+
protocol_commission_lamports: {
|
|
3544
|
+
$ref: "#/$defs/safeUInt"
|
|
3545
|
+
},
|
|
3546
|
+
waived_protocol_commission_lamports: {
|
|
3547
|
+
$ref: "#/$defs/safeUInt"
|
|
3304
3548
|
}
|
|
3305
3549
|
}
|
|
3306
3550
|
},
|
|
@@ -3382,7 +3626,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3382
3626
|
minItems: 1,
|
|
3383
3627
|
maxItems: 1e3,
|
|
3384
3628
|
items: {
|
|
3385
|
-
$ref: "#/$defs/
|
|
3629
|
+
$ref: "#/$defs/lpViewAddress"
|
|
3386
3630
|
}
|
|
3387
3631
|
},
|
|
3388
3632
|
destination_count: {
|
|
@@ -3392,7 +3636,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3392
3636
|
type: "array",
|
|
3393
3637
|
maxItems: 32,
|
|
3394
3638
|
items: {
|
|
3395
|
-
$ref: "#/$defs/
|
|
3639
|
+
$ref: "#/$defs/lpViewTxSignature"
|
|
3396
3640
|
}
|
|
3397
3641
|
},
|
|
3398
3642
|
tx_signature_count: {
|
|
@@ -3409,7 +3653,20 @@ var coordinator_envelope_schema_default = {
|
|
|
3409
3653
|
},
|
|
3410
3654
|
updated_at_ms: {
|
|
3411
3655
|
$ref: "#/$defs/safeUInt"
|
|
3656
|
+
},
|
|
3657
|
+
fee_policy_hash: {
|
|
3658
|
+
type: "string",
|
|
3659
|
+
pattern: "^[0-9a-f]{64}$",
|
|
3660
|
+
minLength: 64,
|
|
3661
|
+
maxLength: 64
|
|
3662
|
+
},
|
|
3663
|
+
fee_basis_revision: {
|
|
3664
|
+
$ref: "#/$defs/safeUInt"
|
|
3412
3665
|
}
|
|
3666
|
+
},
|
|
3667
|
+
dependentRequired: {
|
|
3668
|
+
fee_policy_hash: ["fee_basis_revision"],
|
|
3669
|
+
fee_basis_revision: ["fee_policy_hash"]
|
|
3413
3670
|
}
|
|
3414
3671
|
},
|
|
3415
3672
|
lpShardView: {
|
|
@@ -3421,13 +3678,13 @@ var coordinator_envelope_schema_default = {
|
|
|
3421
3678
|
$ref: "#/$defs/lpId"
|
|
3422
3679
|
},
|
|
3423
3680
|
shard_id: {
|
|
3424
|
-
$ref: "#/$defs/
|
|
3681
|
+
$ref: "#/$defs/lpViewShardId"
|
|
3425
3682
|
},
|
|
3426
3683
|
index: {
|
|
3427
3684
|
$ref: "#/$defs/lpShardIndex"
|
|
3428
3685
|
},
|
|
3429
3686
|
address: {
|
|
3430
|
-
$ref: "#/$defs/
|
|
3687
|
+
$ref: "#/$defs/lpViewAddress"
|
|
3431
3688
|
},
|
|
3432
3689
|
amount_lamports: {
|
|
3433
3690
|
$ref: "#/$defs/safeUInt"
|
|
@@ -3454,7 +3711,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3454
3711
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3455
3712
|
},
|
|
3456
3713
|
payout_tx_signature: {
|
|
3457
|
-
$ref: "#/$defs/
|
|
3714
|
+
$ref: "#/$defs/lpViewTxSignature"
|
|
3458
3715
|
}
|
|
3459
3716
|
}
|
|
3460
3717
|
},
|
|
@@ -3507,7 +3764,20 @@ var coordinator_envelope_schema_default = {
|
|
|
3507
3764
|
},
|
|
3508
3765
|
requested_at_ms: {
|
|
3509
3766
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3767
|
+
},
|
|
3768
|
+
fee_policy_hash: {
|
|
3769
|
+
type: "string",
|
|
3770
|
+
pattern: "^[0-9a-f]{64}$",
|
|
3771
|
+
minLength: 64,
|
|
3772
|
+
maxLength: 64
|
|
3773
|
+
},
|
|
3774
|
+
fee_basis_revision: {
|
|
3775
|
+
$ref: "#/$defs/safeUInt"
|
|
3510
3776
|
}
|
|
3777
|
+
},
|
|
3778
|
+
dependentRequired: {
|
|
3779
|
+
fee_policy_hash: ["fee_basis_revision"],
|
|
3780
|
+
fee_basis_revision: ["fee_policy_hash"]
|
|
3511
3781
|
}
|
|
3512
3782
|
},
|
|
3513
3783
|
lpWithdrawalExecutionView: {
|
|
@@ -3528,7 +3798,7 @@ var coordinator_envelope_schema_default = {
|
|
|
3528
3798
|
},
|
|
3529
3799
|
tx_signatures: {
|
|
3530
3800
|
type: "array",
|
|
3531
|
-
maxItems:
|
|
3801
|
+
maxItems: 500,
|
|
3532
3802
|
items: {
|
|
3533
3803
|
$ref: "#/$defs/lpTxSignature"
|
|
3534
3804
|
}
|
|
@@ -3541,27 +3811,167 @@ var coordinator_envelope_schema_default = {
|
|
|
3541
3811
|
},
|
|
3542
3812
|
accepted_earned_fee_lamports: {
|
|
3543
3813
|
$ref: "#/$defs/safeUInt"
|
|
3814
|
+
},
|
|
3815
|
+
fee_policy_hash: {
|
|
3816
|
+
type: "string",
|
|
3817
|
+
pattern: "^[0-9a-f]{64}$",
|
|
3818
|
+
minLength: 64,
|
|
3819
|
+
maxLength: 64
|
|
3820
|
+
},
|
|
3821
|
+
fee_basis_revision: {
|
|
3822
|
+
$ref: "#/$defs/safeUInt"
|
|
3544
3823
|
}
|
|
3824
|
+
},
|
|
3825
|
+
dependentRequired: {
|
|
3826
|
+
fee_policy_hash: ["fee_basis_revision"],
|
|
3827
|
+
fee_basis_revision: ["fee_policy_hash"]
|
|
3545
3828
|
}
|
|
3829
|
+
},
|
|
3830
|
+
lpShardSnapshotHash: {
|
|
3831
|
+
type: "string",
|
|
3832
|
+
minLength: 64,
|
|
3833
|
+
maxLength: 64,
|
|
3834
|
+
pattern: "^[0-9a-f]{64}$"
|
|
3835
|
+
},
|
|
3836
|
+
lpViewShardId: {
|
|
3837
|
+
type: "string",
|
|
3838
|
+
minLength: 1,
|
|
3839
|
+
maxLength: 113,
|
|
3840
|
+
pattern: "^[A-Za-z0-9_:-]+$"
|
|
3841
|
+
},
|
|
3842
|
+
lpViewAddress: {
|
|
3843
|
+
type: "string",
|
|
3844
|
+
minLength: 1,
|
|
3845
|
+
maxLength: 44
|
|
3846
|
+
},
|
|
3847
|
+
lpViewTxSignature: {
|
|
3848
|
+
type: "string",
|
|
3849
|
+
minLength: 1,
|
|
3850
|
+
maxLength: 88
|
|
3851
|
+
},
|
|
3852
|
+
unsignedLamportTotalString: {
|
|
3853
|
+
type: "string",
|
|
3854
|
+
minLength: 1,
|
|
3855
|
+
maxLength: 39,
|
|
3856
|
+
pattern: "^(0|[1-9][0-9]*)$"
|
|
3857
|
+
},
|
|
3858
|
+
signedLamportTotalString: {
|
|
3859
|
+
type: "string",
|
|
3860
|
+
minLength: 1,
|
|
3861
|
+
maxLength: 40,
|
|
3862
|
+
pattern: "^(0|-?[1-9][0-9]*)$"
|
|
3863
|
+
},
|
|
3864
|
+
lpEconomicReturnSummary: {
|
|
3865
|
+
type: "object",
|
|
3866
|
+
additionalProperties: false,
|
|
3867
|
+
required: [
|
|
3868
|
+
"provider_reward_lamports",
|
|
3869
|
+
"source_expense_compensation_lamports",
|
|
3870
|
+
"charged_reimbursement_loss_lamports",
|
|
3871
|
+
"net_economic_return_lamports"
|
|
3872
|
+
],
|
|
3873
|
+
properties: {
|
|
3874
|
+
provider_reward_lamports: {
|
|
3875
|
+
$ref: "#/$defs/unsignedLamportTotalString"
|
|
3876
|
+
},
|
|
3877
|
+
source_expense_compensation_lamports: {
|
|
3878
|
+
$ref: "#/$defs/unsignedLamportTotalString"
|
|
3879
|
+
},
|
|
3880
|
+
charged_reimbursement_loss_lamports: {
|
|
3881
|
+
$ref: "#/$defs/unsignedLamportTotalString"
|
|
3882
|
+
},
|
|
3883
|
+
net_economic_return_lamports: {
|
|
3884
|
+
$ref: "#/$defs/signedLamportTotalString"
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
},
|
|
3888
|
+
lpFeePolicy: {
|
|
3889
|
+
type: "object",
|
|
3890
|
+
additionalProperties: false,
|
|
3891
|
+
required: ["version", "profile", "commission_bps", "policy_hash"],
|
|
3892
|
+
properties: {
|
|
3893
|
+
version: {
|
|
3894
|
+
const: 1
|
|
3895
|
+
},
|
|
3896
|
+
profile: {
|
|
3897
|
+
enum: ["internal", "partner"]
|
|
3898
|
+
},
|
|
3899
|
+
commission_bps: {
|
|
3900
|
+
enum: [0, 6e3]
|
|
3901
|
+
},
|
|
3902
|
+
policy_hash: {
|
|
3903
|
+
type: "string",
|
|
3904
|
+
pattern: "^[0-9a-f]{64}$",
|
|
3905
|
+
minLength: 64,
|
|
3906
|
+
maxLength: 64
|
|
3907
|
+
}
|
|
3908
|
+
},
|
|
3909
|
+
allOf: [
|
|
3910
|
+
{
|
|
3911
|
+
oneOf: [
|
|
3912
|
+
{
|
|
3913
|
+
properties: {
|
|
3914
|
+
profile: {
|
|
3915
|
+
const: "internal"
|
|
3916
|
+
},
|
|
3917
|
+
commission_bps: {
|
|
3918
|
+
const: 0
|
|
3919
|
+
},
|
|
3920
|
+
policy_hash: {
|
|
3921
|
+
const: "53479c39d822899c0abe21990aeff40ea74681277b2744ef86234152cc94ca5a"
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
},
|
|
3925
|
+
{
|
|
3926
|
+
properties: {
|
|
3927
|
+
profile: {
|
|
3928
|
+
const: "partner"
|
|
3929
|
+
},
|
|
3930
|
+
commission_bps: {
|
|
3931
|
+
const: 6e3
|
|
3932
|
+
},
|
|
3933
|
+
policy_hash: {
|
|
3934
|
+
const: "3e1a307504043bc0b25f03ccffdff1b42cd2b38699f000f7eb70ce9433a5b2a7"
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
]
|
|
3939
|
+
}
|
|
3940
|
+
]
|
|
3546
3941
|
}
|
|
3547
3942
|
}
|
|
3548
3943
|
};
|
|
3549
3944
|
|
|
3550
|
-
//
|
|
3945
|
+
// ../../protocol/src/coordinator/envelope.ts
|
|
3551
3946
|
var ENVELOPE_VERSION = 2;
|
|
3552
|
-
var MAX_FRAME_SIZE =
|
|
3947
|
+
var MAX_FRAME_SIZE = 512 * 1024;
|
|
3553
3948
|
var COORDINATOR_ENVELOPE_SCHEMA = coordinator_envelope_schema_default;
|
|
3554
|
-
var
|
|
3949
|
+
var LP_MAX_TOTAL_SHARDS = 4294967295;
|
|
3555
3950
|
var LP_WITHDRAW_REQUEST_PATH = "lp_command.withdrawRequest";
|
|
3556
3951
|
var UNKNOWN_SWAP_ID = "<unknown>";
|
|
3557
3952
|
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
3953
|
var textEncoder = new TextEncoder();
|
|
3564
3954
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
3955
|
+
var MAX_ENCODED_JSON_BYTES_KEYWORD = "maxEncodedJsonBytes";
|
|
3956
|
+
function createCoordinatorSchemaValidator() {
|
|
3957
|
+
const ajv = new Ajv2020({ allErrors: true, strict: true });
|
|
3958
|
+
ajv.addKeyword({
|
|
3959
|
+
keyword: MAX_ENCODED_JSON_BYTES_KEYWORD,
|
|
3960
|
+
schemaType: "number",
|
|
3961
|
+
metaSchema: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
|
|
3962
|
+
validate: (limit, value) => {
|
|
3963
|
+
try {
|
|
3964
|
+
const encoded = JSON.stringify(value);
|
|
3965
|
+
return encoded !== void 0 && textEncoder.encode(encoded).byteLength <= limit;
|
|
3966
|
+
} catch {
|
|
3967
|
+
return false;
|
|
3968
|
+
}
|
|
3969
|
+
},
|
|
3970
|
+
errors: false
|
|
3971
|
+
});
|
|
3972
|
+
return ajv.compile(coordinator_envelope_schema_default);
|
|
3973
|
+
}
|
|
3974
|
+
var validateWireEnvelope = createCoordinatorSchemaValidator();
|
|
3565
3975
|
function encode(env) {
|
|
3566
3976
|
return textEncoder.encode(JSON.stringify(toWireEnvelope(env)));
|
|
3567
3977
|
}
|
|
@@ -3581,6 +3991,10 @@ function safeEncode(env) {
|
|
|
3581
3991
|
if (!validateWireEnvelope(wire)) {
|
|
3582
3992
|
return { ok: false, error: schemaError(wire, validateWireEnvelope.errors ?? []) };
|
|
3583
3993
|
}
|
|
3994
|
+
const policyError = validateLpPolicyEvidence(wire);
|
|
3995
|
+
if (policyError) return { ok: false, error: policyError };
|
|
3996
|
+
const economicReturnError = validateLpEconomicReturnSemantics(wire);
|
|
3997
|
+
if (economicReturnError) return { ok: false, error: economicReturnError };
|
|
3584
3998
|
const encoded = textEncoder.encode(JSON.stringify(wire));
|
|
3585
3999
|
if (encoded.byteLength > MAX_FRAME_SIZE) {
|
|
3586
4000
|
return {
|
|
@@ -3651,7 +4065,8 @@ function validateLpCommandPreSchemaSemanticsForSigning(command) {
|
|
|
3651
4065
|
function validateLpCommandSemanticsForSigning(command) {
|
|
3652
4066
|
switch (command.payload.case) {
|
|
3653
4067
|
case "positionOpen": {
|
|
3654
|
-
const { addresses, refill_threshold, shard_count } = command.payload.value;
|
|
4068
|
+
const { addresses, refill_threshold, shard_count, fee_policy } = command.payload.value;
|
|
4069
|
+
if (fee_policy !== void 0) validateLpFeePolicySemantics(fee_policy);
|
|
3655
4070
|
if (refill_threshold > shard_count) {
|
|
3656
4071
|
throw new CoordinatorError(
|
|
3657
4072
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
@@ -3721,10 +4136,10 @@ function validateUniqueLpAddresses(path, addresses) {
|
|
|
3721
4136
|
function validateLpDkgFinalizeRange(path, startIndex, addressCount) {
|
|
3722
4137
|
if (addressCount === 0) return;
|
|
3723
4138
|
const lastIndex = startIndex + addressCount - 1;
|
|
3724
|
-
if (lastIndex >=
|
|
4139
|
+
if (lastIndex >= LP_MAX_TOTAL_SHARDS) {
|
|
3725
4140
|
throw new CoordinatorError(
|
|
3726
4141
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
3727
|
-
`${path}.addresses end index (${lastIndex}) must be <= ${
|
|
4142
|
+
`${path}.addresses end index (${lastIndex}) must be <= ${LP_MAX_TOTAL_SHARDS - 1}`
|
|
3728
4143
|
);
|
|
3729
4144
|
}
|
|
3730
4145
|
}
|
|
@@ -3759,6 +4174,10 @@ function decode(raw) {
|
|
|
3759
4174
|
if (!validateWireEnvelope(parsed)) {
|
|
3760
4175
|
return { ok: false, error: schemaError(parsed, validateWireEnvelope.errors ?? []) };
|
|
3761
4176
|
}
|
|
4177
|
+
const policyError = validateLpPolicyEvidence(parsed);
|
|
4178
|
+
if (policyError) return { ok: false, error: policyError };
|
|
4179
|
+
const economicReturnError = validateLpEconomicReturnSemantics(parsed);
|
|
4180
|
+
if (economicReturnError) return { ok: false, error: economicReturnError };
|
|
3762
4181
|
try {
|
|
3763
4182
|
return { ok: true, value: fromWireEnvelope(parsed) };
|
|
3764
4183
|
} catch (error) {
|
|
@@ -4118,7 +4537,79 @@ var asErrorPayload = (e) => {
|
|
|
4118
4537
|
}
|
|
4119
4538
|
return payload;
|
|
4120
4539
|
};
|
|
4540
|
+
var LP_ECONOMIC_UNSIGNED_TOTAL_MAX = (1n << 128n) - 1n;
|
|
4541
|
+
var LP_ECONOMIC_SIGNED_TOTAL_MIN = -(1n << 127n);
|
|
4542
|
+
var LP_ECONOMIC_SIGNED_TOTAL_MAX = (1n << 127n) - 1n;
|
|
4543
|
+
function validateLpEconomicReturnSemantics(wire) {
|
|
4544
|
+
const payload = wire.payload;
|
|
4545
|
+
if (!payload || payload.case !== "position") return void 0;
|
|
4546
|
+
const summary = payload.value?.actor_sync?.economic_return;
|
|
4547
|
+
if (!summary) return void 0;
|
|
4548
|
+
const reward = BigInt(summary.provider_reward_lamports);
|
|
4549
|
+
const compensation = BigInt(summary.source_expense_compensation_lamports);
|
|
4550
|
+
const loss = BigInt(summary.charged_reimbursement_loss_lamports);
|
|
4551
|
+
const net = BigInt(summary.net_economic_return_lamports);
|
|
4552
|
+
const commission = BigInt(payload.value?.actor_sync?.protocol_commission_lamports ?? 0);
|
|
4553
|
+
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 - commission) {
|
|
4554
|
+
return new CoordinatorError(
|
|
4555
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4556
|
+
"LP economic return invariant is invalid"
|
|
4557
|
+
);
|
|
4558
|
+
}
|
|
4559
|
+
return void 0;
|
|
4560
|
+
}
|
|
4561
|
+
function validateLpPolicyEvidence(wire) {
|
|
4562
|
+
try {
|
|
4563
|
+
const payload = wire.payload;
|
|
4564
|
+
if (payload.case !== "position" && wire.type !== CoordinatorMessageType.LpCreateAuthorization)
|
|
4565
|
+
return;
|
|
4566
|
+
const value = payload.value;
|
|
4567
|
+
if (!value) return;
|
|
4568
|
+
const policy = value.fee_policy;
|
|
4569
|
+
if (policy !== void 0) {
|
|
4570
|
+
validateLpFeePolicySemantics(policy);
|
|
4571
|
+
if (value.lp_fee_policy_version !== LP_FEE_POLICY_VERSION)
|
|
4572
|
+
throw new CoordinatorError(
|
|
4573
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4574
|
+
"LP fee policy capability is missing"
|
|
4575
|
+
);
|
|
4576
|
+
}
|
|
4577
|
+
if (payload.case === "position") {
|
|
4578
|
+
const sync = value.actor_sync;
|
|
4579
|
+
if (policy !== void 0 || sync?.fee_policy !== void 0) {
|
|
4580
|
+
if (!policy || !sync?.fee_policy)
|
|
4581
|
+
throw new CoordinatorError(
|
|
4582
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4583
|
+
"LP fee policy actor evidence is missing"
|
|
4584
|
+
);
|
|
4585
|
+
validateLpFeePolicySemantics(
|
|
4586
|
+
sync.fee_policy
|
|
4587
|
+
);
|
|
4588
|
+
if (sync.lp_position_id !== value.lp_position_id)
|
|
4589
|
+
throw new CoordinatorError(
|
|
4590
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4591
|
+
"LP fee policy actor subject does not match position"
|
|
4592
|
+
);
|
|
4593
|
+
const positionPolicy = policy;
|
|
4594
|
+
if (BigInt(sync.protocol_commission_lamports) + BigInt(sync.waived_protocol_commission_lamports) !== BigInt(sync.gross_fee_lamports) * BigInt(positionPolicy.commission_bps) / LP_BASIS_POINT_DENOMINATOR) {
|
|
4595
|
+
throw new CoordinatorError(
|
|
4596
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4597
|
+
"LP fee policy commission projection is invalid"
|
|
4598
|
+
);
|
|
4599
|
+
}
|
|
4600
|
+
if (sync.fee_policy.policy_hash !== positionPolicy.policy_hash)
|
|
4601
|
+
throw new CoordinatorError(
|
|
4602
|
+
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4603
|
+
"LP fee policy actor evidence does not match position"
|
|
4604
|
+
);
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
} catch (error) {
|
|
4608
|
+
if (error instanceof CoordinatorError) return error;
|
|
4609
|
+
return new CoordinatorError(ErrorCode.ERR_INVALID_PAYLOAD, "LP fee policy evidence is invalid");
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4121
4612
|
|
|
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-
|
|
4613
|
+
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, LP_FEE_POLICY_HASHES, LP_FEE_POLICY_VERSION, LP_PARTNER_COMMISSION_BPS, 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, validateLpFeePolicySemantics };
|
|
4614
|
+
//# sourceMappingURL=chunk-DFBH5XLM.js.map
|
|
4615
|
+
//# sourceMappingURL=chunk-DFBH5XLM.js.map
|