@invisible-labs/sdk 0.9.0-devnet → 0.11.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 +25 -5
- package/dist/.invisible-sdk-build-target.json +2 -2
- package/dist/{chunk-RWKG7N7I.js → chunk-A4R3DHKN.js} +2 -2
- package/dist/chunk-A4R3DHKN.js.map +1 -0
- package/dist/{chunk-6AKBRYKO.js → chunk-DOTYDYVB.js} +3 -3
- package/dist/{chunk-6AKBRYKO.js.map → chunk-DOTYDYVB.js.map} +1 -1
- package/dist/{chunk-EOPZVOVP.js → chunk-LVCDODTN.js} +582 -19
- package/dist/chunk-LVCDODTN.js.map +1 -0
- package/dist/{chunk-QF5TSUQE.js → chunk-M45APS7S.js} +405 -51
- package/dist/chunk-M45APS7S.js.map +1 -0
- package/dist/{chunk-ISIWWGSR.js → chunk-NOKBFHDP.js} +5 -5
- package/dist/{chunk-ISIWWGSR.js.map → chunk-NOKBFHDP.js.map} +1 -1
- package/dist/{chunk-HWRMSK7E.js → chunk-TNLSUQGJ.js} +4 -4
- package/dist/{chunk-HWRMSK7E.js.map → chunk-TNLSUQGJ.js.map} +1 -1
- package/dist/{chunk-EPWTRF5U.js → chunk-TYTVF3A4.js} +3 -3
- package/dist/{chunk-EPWTRF5U.js.map → chunk-TYTVF3A4.js.map} +1 -1
- package/dist/{chunk-AIKC2XQS.js → chunk-YYTRFM2F.js} +3 -3
- package/dist/{chunk-AIKC2XQS.js.map → chunk-YYTRFM2F.js.map} +1 -1
- package/dist/coordinator-EQEL23A3.js +4 -0
- package/dist/{coordinator-DHL3AP7V.js.map → coordinator-EQEL23A3.js.map} +1 -1
- package/dist/events.js +3 -3
- 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 +46 -5
- package/dist/lp.js +675 -212
- package/dist/lp.js.map +1 -1
- package/dist/stats.js +1 -1
- package/dist/storage.js +2 -2
- package/dist/{types.generated-DrM2M4DZ.d.ts → types.generated-BpbFQlYB.d.ts} +75 -1
- package/dist/user.d.ts +9 -4
- package/dist/user.js +53 -22
- package/dist/user.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-EOPZVOVP.js.map +0 -1
- package/dist/chunk-QF5TSUQE.js.map +0 -1
- package/dist/chunk-RWKG7N7I.js.map +0 -1
- package/dist/coordinator-DHL3AP7V.js +0 -4
|
@@ -424,6 +424,23 @@ function isAllowedInState(current, kind, type) {
|
|
|
424
424
|
return transitionMap.has(triggerKey(current, kind, type));
|
|
425
425
|
}
|
|
426
426
|
|
|
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
|
+
|
|
427
444
|
// ../../protocol/src/coordinator/coordinator-envelope.schema.json
|
|
428
445
|
var coordinator_envelope_schema_default = {
|
|
429
446
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -518,19 +535,35 @@ var coordinator_envelope_schema_default = {
|
|
|
518
535
|
{
|
|
519
536
|
title: "LpCreateAuthorization request",
|
|
520
537
|
properties: {
|
|
521
|
-
kind: {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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
|
+
}
|
|
525
550
|
}
|
|
526
551
|
},
|
|
527
552
|
{
|
|
528
553
|
title: "LpCreateAuthorization response",
|
|
529
554
|
properties: {
|
|
530
|
-
kind: {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
+
}
|
|
534
567
|
}
|
|
535
568
|
},
|
|
536
569
|
{
|
|
@@ -1103,6 +1136,13 @@ var coordinator_envelope_schema_default = {
|
|
|
1103
1136
|
description: "Optional legacy absolute request deadline. Scheduled payout_spec.window_seconds selects the supported scheduled window.",
|
|
1104
1137
|
$ref: "#/$defs/positiveSafeUInt"
|
|
1105
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
|
+
},
|
|
1106
1146
|
payout_spec: {
|
|
1107
1147
|
$ref: "#/$defs/payoutSpec"
|
|
1108
1148
|
},
|
|
@@ -1168,14 +1208,22 @@ var coordinator_envelope_schema_default = {
|
|
|
1168
1208
|
},
|
|
1169
1209
|
lpCreateAuthorizationRequest: {
|
|
1170
1210
|
oneOf: [
|
|
1171
|
-
{
|
|
1172
|
-
|
|
1211
|
+
{
|
|
1212
|
+
$ref: "#/$defs/lpCreateAuthorizationChallengeRequest"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
$ref: "#/$defs/lpCreateAuthorizationProofRequest"
|
|
1216
|
+
}
|
|
1173
1217
|
]
|
|
1174
1218
|
},
|
|
1175
1219
|
lpCreateAuthorizationResponse: {
|
|
1176
1220
|
oneOf: [
|
|
1177
|
-
{
|
|
1178
|
-
|
|
1221
|
+
{
|
|
1222
|
+
$ref: "#/$defs/lpCreateAuthorizationChallengeResponse"
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
$ref: "#/$defs/lpCreateAuthorizationAuthorizedResponse"
|
|
1226
|
+
}
|
|
1179
1227
|
]
|
|
1180
1228
|
},
|
|
1181
1229
|
lpCreateAuthorizationChallengeRequest: {
|
|
@@ -1183,8 +1231,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1183
1231
|
additionalProperties: false,
|
|
1184
1232
|
required: ["case", "value"],
|
|
1185
1233
|
properties: {
|
|
1186
|
-
case: {
|
|
1187
|
-
|
|
1234
|
+
case: {
|
|
1235
|
+
const: "challenge"
|
|
1236
|
+
},
|
|
1237
|
+
value: {
|
|
1238
|
+
$ref: "#/$defs/lpCreateAuthorizationChallenge"
|
|
1239
|
+
}
|
|
1188
1240
|
}
|
|
1189
1241
|
},
|
|
1190
1242
|
lpCreateAuthorizationProofRequest: {
|
|
@@ -1192,8 +1244,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1192
1244
|
additionalProperties: false,
|
|
1193
1245
|
required: ["case", "value"],
|
|
1194
1246
|
properties: {
|
|
1195
|
-
case: {
|
|
1196
|
-
|
|
1247
|
+
case: {
|
|
1248
|
+
const: "proof"
|
|
1249
|
+
},
|
|
1250
|
+
value: {
|
|
1251
|
+
$ref: "#/$defs/lpCreateAuthorizationProof"
|
|
1252
|
+
}
|
|
1197
1253
|
}
|
|
1198
1254
|
},
|
|
1199
1255
|
lpCreateAuthorizationChallengeResponse: {
|
|
@@ -1201,8 +1257,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1201
1257
|
additionalProperties: false,
|
|
1202
1258
|
required: ["case", "value"],
|
|
1203
1259
|
properties: {
|
|
1204
|
-
case: {
|
|
1205
|
-
|
|
1260
|
+
case: {
|
|
1261
|
+
const: "challenge"
|
|
1262
|
+
},
|
|
1263
|
+
value: {
|
|
1264
|
+
$ref: "#/$defs/lpCreateAuthorizationChallengeResponseValue"
|
|
1265
|
+
}
|
|
1206
1266
|
}
|
|
1207
1267
|
},
|
|
1208
1268
|
lpCreateAuthorizationAuthorizedResponse: {
|
|
@@ -1210,8 +1270,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1210
1270
|
additionalProperties: false,
|
|
1211
1271
|
required: ["case", "value"],
|
|
1212
1272
|
properties: {
|
|
1213
|
-
case: {
|
|
1214
|
-
|
|
1273
|
+
case: {
|
|
1274
|
+
const: "authorized"
|
|
1275
|
+
},
|
|
1276
|
+
value: {
|
|
1277
|
+
$ref: "#/$defs/lpCreateAuthorizationAuthorized"
|
|
1278
|
+
}
|
|
1215
1279
|
}
|
|
1216
1280
|
},
|
|
1217
1281
|
lpCreateAuthorizationChallenge: {
|
|
@@ -1219,8 +1283,12 @@ var coordinator_envelope_schema_default = {
|
|
|
1219
1283
|
additionalProperties: false,
|
|
1220
1284
|
required: ["public_key", "intent"],
|
|
1221
1285
|
properties: {
|
|
1222
|
-
public_key: {
|
|
1223
|
-
|
|
1286
|
+
public_key: {
|
|
1287
|
+
$ref: "#/$defs/lpSolanaAddress"
|
|
1288
|
+
},
|
|
1289
|
+
intent: {
|
|
1290
|
+
$ref: "#/$defs/lpCreatePositionIntent"
|
|
1291
|
+
}
|
|
1224
1292
|
}
|
|
1225
1293
|
},
|
|
1226
1294
|
lpCreateAuthorizationProof: {
|
|
@@ -1228,10 +1296,18 @@ var coordinator_envelope_schema_default = {
|
|
|
1228
1296
|
additionalProperties: false,
|
|
1229
1297
|
required: ["authorization_id", "public_key", "message", "signature"],
|
|
1230
1298
|
properties: {
|
|
1231
|
-
authorization_id: {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
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
|
+
}
|
|
1235
1311
|
}
|
|
1236
1312
|
},
|
|
1237
1313
|
lpCreateAuthorizationChallengeResponseValue: {
|
|
@@ -1239,10 +1315,24 @@ var coordinator_envelope_schema_default = {
|
|
|
1239
1315
|
additionalProperties: false,
|
|
1240
1316
|
required: ["authorization_id", "message", "expires_at_ms", "valid_for_ms"],
|
|
1241
1317
|
properties: {
|
|
1242
|
-
authorization_id: {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
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
|
+
}
|
|
1246
1336
|
}
|
|
1247
1337
|
},
|
|
1248
1338
|
lpCreateAuthorizationAuthorized: {
|
|
@@ -1250,7 +1340,15 @@ var coordinator_envelope_schema_default = {
|
|
|
1250
1340
|
additionalProperties: false,
|
|
1251
1341
|
required: ["authorization_id"],
|
|
1252
1342
|
properties: {
|
|
1253
|
-
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
|
+
}
|
|
1254
1352
|
}
|
|
1255
1353
|
},
|
|
1256
1354
|
lpCreatePositionIntent: {
|
|
@@ -1263,10 +1361,18 @@ var coordinator_envelope_schema_default = {
|
|
|
1263
1361
|
"refill_threshold"
|
|
1264
1362
|
],
|
|
1265
1363
|
properties: {
|
|
1266
|
-
committed_lamports: {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
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
|
+
}
|
|
1270
1376
|
}
|
|
1271
1377
|
},
|
|
1272
1378
|
lpCreationRefillThreshold: {
|
|
@@ -1758,7 +1864,14 @@ var coordinator_envelope_schema_default = {
|
|
|
1758
1864
|
$ref: "#/$defs/string"
|
|
1759
1865
|
},
|
|
1760
1866
|
deposit_origin_address: {
|
|
1761
|
-
anyOf: [
|
|
1867
|
+
anyOf: [
|
|
1868
|
+
{
|
|
1869
|
+
type: "null"
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
$ref: "#/$defs/string"
|
|
1873
|
+
}
|
|
1874
|
+
]
|
|
1762
1875
|
},
|
|
1763
1876
|
status: {
|
|
1764
1877
|
$ref: "#/$defs/normalUserContractStatus"
|
|
@@ -2688,8 +2801,12 @@ var coordinator_envelope_schema_default = {
|
|
|
2688
2801
|
type: "object",
|
|
2689
2802
|
additionalProperties: false,
|
|
2690
2803
|
properties: {
|
|
2691
|
-
shard_start_index: {
|
|
2692
|
-
|
|
2804
|
+
shard_start_index: {
|
|
2805
|
+
$ref: "#/$defs/lpShardIndex"
|
|
2806
|
+
},
|
|
2807
|
+
shards_snapshot_hash: {
|
|
2808
|
+
$ref: "#/$defs/lpShardSnapshotHash"
|
|
2809
|
+
},
|
|
2693
2810
|
redemption_history_cursor: {
|
|
2694
2811
|
$ref: "#/$defs/lpRedemptionId"
|
|
2695
2812
|
}
|
|
@@ -2748,6 +2865,9 @@ var coordinator_envelope_schema_default = {
|
|
|
2748
2865
|
},
|
|
2749
2866
|
created_at_ms: {
|
|
2750
2867
|
$ref: "#/$defs/positiveSafeUInt"
|
|
2868
|
+
},
|
|
2869
|
+
fee_policy: {
|
|
2870
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
2751
2871
|
}
|
|
2752
2872
|
}
|
|
2753
2873
|
},
|
|
@@ -2823,14 +2943,14 @@ var coordinator_envelope_schema_default = {
|
|
|
2823
2943
|
shard_count: {
|
|
2824
2944
|
type: "integer",
|
|
2825
2945
|
minimum: 1,
|
|
2826
|
-
maximum:
|
|
2946
|
+
maximum: 200
|
|
2827
2947
|
},
|
|
2828
2948
|
shard_amount_lamports: {
|
|
2829
2949
|
$ref: "#/$defs/positiveSafeUInt"
|
|
2830
2950
|
},
|
|
2831
2951
|
addresses: {
|
|
2832
2952
|
type: "array",
|
|
2833
|
-
maxItems:
|
|
2953
|
+
maxItems: 200,
|
|
2834
2954
|
items: {
|
|
2835
2955
|
$ref: "#/$defs/lpAddress"
|
|
2836
2956
|
}
|
|
@@ -3105,10 +3225,19 @@ var coordinator_envelope_schema_default = {
|
|
|
3105
3225
|
allOf: [
|
|
3106
3226
|
{
|
|
3107
3227
|
if: {
|
|
3108
|
-
properties: {
|
|
3228
|
+
properties: {
|
|
3229
|
+
shards_snapshot_hash: {}
|
|
3230
|
+
},
|
|
3109
3231
|
required: ["shards_snapshot_hash"]
|
|
3110
3232
|
},
|
|
3111
|
-
then: {
|
|
3233
|
+
then: {
|
|
3234
|
+
properties: {
|
|
3235
|
+
shards: {
|
|
3236
|
+
type: "array",
|
|
3237
|
+
maxItems: 50
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3112
3241
|
}
|
|
3113
3242
|
],
|
|
3114
3243
|
required: [
|
|
@@ -3163,9 +3292,15 @@ var coordinator_envelope_schema_default = {
|
|
|
3163
3292
|
$ref: "#/$defs/lpShardView"
|
|
3164
3293
|
}
|
|
3165
3294
|
},
|
|
3166
|
-
shards_total_count: {
|
|
3167
|
-
|
|
3168
|
-
|
|
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
|
+
},
|
|
3169
3304
|
created_at_ms: {
|
|
3170
3305
|
$ref: "#/$defs/positiveSafeUInt"
|
|
3171
3306
|
},
|
|
@@ -3174,6 +3309,12 @@ var coordinator_envelope_schema_default = {
|
|
|
3174
3309
|
},
|
|
3175
3310
|
actor_sync: {
|
|
3176
3311
|
$ref: "#/$defs/lpActorSyncView"
|
|
3312
|
+
},
|
|
3313
|
+
fee_policy: {
|
|
3314
|
+
$ref: "#/$defs/lpFeePolicy"
|
|
3315
|
+
},
|
|
3316
|
+
lp_fee_policy_version: {
|
|
3317
|
+
const: 1
|
|
3177
3318
|
}
|
|
3178
3319
|
}
|
|
3179
3320
|
},
|
|
@@ -3217,6 +3358,13 @@ var coordinator_envelope_schema_default = {
|
|
|
3217
3358
|
"updated_at_ms"
|
|
3218
3359
|
],
|
|
3219
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
|
+
],
|
|
3220
3368
|
redeemable_principal_lamports: [
|
|
3221
3369
|
"redeemable_fee_lamports",
|
|
3222
3370
|
"lifetime_earned_lamports",
|
|
@@ -3246,7 +3394,45 @@ var coordinator_envelope_schema_default = {
|
|
|
3246
3394
|
"redeemable_fee_lamports",
|
|
3247
3395
|
"lifetime_earned_lamports",
|
|
3248
3396
|
"redeemable_principal_source_count"
|
|
3249
|
-
]
|
|
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"]
|
|
3250
3436
|
},
|
|
3251
3437
|
properties: {
|
|
3252
3438
|
economic_return: {
|
|
@@ -3264,6 +3450,9 @@ var coordinator_envelope_schema_default = {
|
|
|
3264
3450
|
redeemable_principal_lamports: {
|
|
3265
3451
|
$ref: "#/$defs/safeUInt"
|
|
3266
3452
|
},
|
|
3453
|
+
total_net_funds_lamports: {
|
|
3454
|
+
$ref: "#/$defs/safeUInt"
|
|
3455
|
+
},
|
|
3267
3456
|
redeemable_fee_lamports: {
|
|
3268
3457
|
$ref: "#/$defs/safeUInt"
|
|
3269
3458
|
},
|
|
@@ -3341,6 +3530,21 @@ var coordinator_envelope_schema_default = {
|
|
|
3341
3530
|
},
|
|
3342
3531
|
updated_at_ms: {
|
|
3343
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"
|
|
3344
3548
|
}
|
|
3345
3549
|
}
|
|
3346
3550
|
},
|
|
@@ -3449,7 +3653,20 @@ var coordinator_envelope_schema_default = {
|
|
|
3449
3653
|
},
|
|
3450
3654
|
updated_at_ms: {
|
|
3451
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"
|
|
3452
3665
|
}
|
|
3666
|
+
},
|
|
3667
|
+
dependentRequired: {
|
|
3668
|
+
fee_policy_hash: ["fee_basis_revision"],
|
|
3669
|
+
fee_basis_revision: ["fee_policy_hash"]
|
|
3453
3670
|
}
|
|
3454
3671
|
},
|
|
3455
3672
|
lpShardView: {
|
|
@@ -3547,7 +3764,20 @@ var coordinator_envelope_schema_default = {
|
|
|
3547
3764
|
},
|
|
3548
3765
|
requested_at_ms: {
|
|
3549
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"
|
|
3550
3776
|
}
|
|
3777
|
+
},
|
|
3778
|
+
dependentRequired: {
|
|
3779
|
+
fee_policy_hash: ["fee_basis_revision"],
|
|
3780
|
+
fee_basis_revision: ["fee_policy_hash"]
|
|
3551
3781
|
}
|
|
3552
3782
|
},
|
|
3553
3783
|
lpWithdrawalExecutionView: {
|
|
@@ -3581,7 +3811,20 @@ var coordinator_envelope_schema_default = {
|
|
|
3581
3811
|
},
|
|
3582
3812
|
accepted_earned_fee_lamports: {
|
|
3583
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"
|
|
3584
3823
|
}
|
|
3824
|
+
},
|
|
3825
|
+
dependentRequired: {
|
|
3826
|
+
fee_policy_hash: ["fee_basis_revision"],
|
|
3827
|
+
fee_basis_revision: ["fee_policy_hash"]
|
|
3585
3828
|
}
|
|
3586
3829
|
},
|
|
3587
3830
|
lpShardSnapshotHash: {
|
|
@@ -3641,6 +3884,60 @@ var coordinator_envelope_schema_default = {
|
|
|
3641
3884
|
$ref: "#/$defs/signedLamportTotalString"
|
|
3642
3885
|
}
|
|
3643
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
|
+
]
|
|
3644
3941
|
}
|
|
3645
3942
|
}
|
|
3646
3943
|
};
|
|
@@ -3694,6 +3991,8 @@ function safeEncode(env) {
|
|
|
3694
3991
|
if (!validateWireEnvelope(wire)) {
|
|
3695
3992
|
return { ok: false, error: schemaError(wire, validateWireEnvelope.errors ?? []) };
|
|
3696
3993
|
}
|
|
3994
|
+
const policyError = validateLpPolicyEvidence(wire);
|
|
3995
|
+
if (policyError) return { ok: false, error: policyError };
|
|
3697
3996
|
const economicReturnError = validateLpEconomicReturnSemantics(wire);
|
|
3698
3997
|
if (economicReturnError) return { ok: false, error: economicReturnError };
|
|
3699
3998
|
const encoded = textEncoder.encode(JSON.stringify(wire));
|
|
@@ -3766,7 +4065,8 @@ function validateLpCommandPreSchemaSemanticsForSigning(command) {
|
|
|
3766
4065
|
function validateLpCommandSemanticsForSigning(command) {
|
|
3767
4066
|
switch (command.payload.case) {
|
|
3768
4067
|
case "positionOpen": {
|
|
3769
|
-
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);
|
|
3770
4070
|
if (refill_threshold > shard_count) {
|
|
3771
4071
|
throw new CoordinatorError(
|
|
3772
4072
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
@@ -3874,6 +4174,8 @@ function decode(raw) {
|
|
|
3874
4174
|
if (!validateWireEnvelope(parsed)) {
|
|
3875
4175
|
return { ok: false, error: schemaError(parsed, validateWireEnvelope.errors ?? []) };
|
|
3876
4176
|
}
|
|
4177
|
+
const policyError = validateLpPolicyEvidence(parsed);
|
|
4178
|
+
if (policyError) return { ok: false, error: policyError };
|
|
3877
4179
|
const economicReturnError = validateLpEconomicReturnSemantics(parsed);
|
|
3878
4180
|
if (economicReturnError) return { ok: false, error: economicReturnError };
|
|
3879
4181
|
try {
|
|
@@ -4247,7 +4549,8 @@ function validateLpEconomicReturnSemantics(wire) {
|
|
|
4247
4549
|
const compensation = BigInt(summary.source_expense_compensation_lamports);
|
|
4248
4550
|
const loss = BigInt(summary.charged_reimbursement_loss_lamports);
|
|
4249
4551
|
const net = BigInt(summary.net_economic_return_lamports);
|
|
4250
|
-
|
|
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) {
|
|
4251
4554
|
return new CoordinatorError(
|
|
4252
4555
|
ErrorCode.ERR_INVALID_PAYLOAD,
|
|
4253
4556
|
"LP economic return invariant is invalid"
|
|
@@ -4255,7 +4558,58 @@ function validateLpEconomicReturnSemantics(wire) {
|
|
|
4255
4558
|
}
|
|
4256
4559
|
return void 0;
|
|
4257
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
|
+
}
|
|
4258
4612
|
|
|
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-
|
|
4261
|
-
//# 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-M45APS7S.js.map
|
|
4615
|
+
//# sourceMappingURL=chunk-M45APS7S.js.map
|