@invisible-labs/sdk 0.9.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.
@@ -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: { const: "request" },
522
- type: { const: "LpCreateAuthorization" },
523
- swap_id: { type: "null" },
524
- payload: { $ref: "#/$defs/lpCreateAuthorizationRequest" }
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: { const: "response" },
531
- type: { const: "LpCreateAuthorization" },
532
- swap_id: { type: "null" },
533
- payload: { $ref: "#/$defs/lpCreateAuthorizationResponse" }
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
- { $ref: "#/$defs/lpCreateAuthorizationChallengeRequest" },
1172
- { $ref: "#/$defs/lpCreateAuthorizationProofRequest" }
1211
+ {
1212
+ $ref: "#/$defs/lpCreateAuthorizationChallengeRequest"
1213
+ },
1214
+ {
1215
+ $ref: "#/$defs/lpCreateAuthorizationProofRequest"
1216
+ }
1173
1217
  ]
1174
1218
  },
1175
1219
  lpCreateAuthorizationResponse: {
1176
1220
  oneOf: [
1177
- { $ref: "#/$defs/lpCreateAuthorizationChallengeResponse" },
1178
- { $ref: "#/$defs/lpCreateAuthorizationAuthorizedResponse" }
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: { const: "challenge" },
1187
- value: { $ref: "#/$defs/lpCreateAuthorizationChallenge" }
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: { const: "proof" },
1196
- value: { $ref: "#/$defs/lpCreateAuthorizationProof" }
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: { const: "challenge" },
1205
- value: { $ref: "#/$defs/lpCreateAuthorizationChallengeResponseValue" }
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: { const: "authorized" },
1214
- value: { $ref: "#/$defs/lpCreateAuthorizationAuthorized" }
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: { $ref: "#/$defs/lpSolanaAddress" },
1223
- intent: { $ref: "#/$defs/lpCreatePositionIntent" }
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: { $ref: "#/$defs/lpAuthorizationId" },
1232
- public_key: { $ref: "#/$defs/lpSolanaAddress" },
1233
- message: { $ref: "#/$defs/lpSiwsMessage" },
1234
- signature: { $ref: "#/$defs/base64url64Bytes" }
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: { $ref: "#/$defs/lpAuthorizationId" },
1243
- message: { $ref: "#/$defs/lpSiwsMessage" },
1244
- expires_at_ms: { $ref: "#/$defs/positiveSafeUInt" },
1245
- valid_for_ms: { $ref: "#/$defs/positiveSafeUInt" }
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: { $ref: "#/$defs/lpAuthorizationId" }
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: { $ref: "#/$defs/positiveSafeUInt" },
1267
- shard_count: { $ref: "#/$defs/lpShardCount" },
1268
- shard_amount_lamports: { $ref: "#/$defs/positiveSafeUInt" },
1269
- refill_threshold: { $ref: "#/$defs/lpCreationRefillThreshold" }
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: [{ type: "null" }, { $ref: "#/$defs/string" }]
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: { $ref: "#/$defs/lpShardIndex" },
2692
- shards_snapshot_hash: { $ref: "#/$defs/lpShardSnapshotHash" },
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
  },
@@ -3105,10 +3225,19 @@ var coordinator_envelope_schema_default = {
3105
3225
  allOf: [
3106
3226
  {
3107
3227
  if: {
3108
- properties: { shards_snapshot_hash: {} },
3228
+ properties: {
3229
+ shards_snapshot_hash: {}
3230
+ },
3109
3231
  required: ["shards_snapshot_hash"]
3110
3232
  },
3111
- then: { properties: { shards: { type: "array", maxItems: 50 } } }
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: { $ref: "#/$defs/u32" },
3167
- shards_next_index: { $ref: "#/$defs/lpShardIndex" },
3168
- shards_snapshot_hash: { $ref: "#/$defs/lpShardSnapshotHash" },
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
- 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) {
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-QF5TSUQE.js.map
4261
- //# sourceMappingURL=chunk-QF5TSUQE.js.map
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