@gearbox-protocol/sdk 15.1.0-next.22 → 15.1.0-next.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/opportunities.schema.js +3 -5
- package/dist/cjs/new-sdk/prepare/PrepareApi.js +4 -4
- package/dist/cjs/sdk/accounts/intents/index.js +57 -28
- package/dist/cjs/sdk/accounts/intents/plan.js +40 -2
- package/dist/cjs/sdk/accounts/intents/realize.js +22 -12
- package/dist/cjs/sdk/accounts/intents/tail.js +120 -0
- package/dist/cjs/sdk/accounts/intents/utils/index.js +1 -0
- package/dist/cjs/sdk/accounts/intents/utils/router-path.js +32 -0
- package/dist/cjs/sdk/index.js +4 -1
- package/dist/cjs/sdk/market/credit/CreditSuite.js +10 -8
- package/dist/cjs/sdk/market/index.js +4 -1
- package/dist/cjs/sdk/market/math.js +71 -17
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/opportunities.schema.js +3 -5
- package/dist/esm/new-sdk/prepare/PrepareApi.js +4 -4
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/intents/index.js +58 -29
- package/dist/esm/sdk/accounts/intents/plan.js +40 -3
- package/dist/esm/sdk/accounts/intents/realize.js +22 -12
- package/dist/esm/sdk/accounts/intents/tail.js +118 -0
- package/dist/esm/sdk/accounts/intents/utils/index.js +2 -2
- package/dist/esm/sdk/accounts/intents/utils/router-path.js +32 -1
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +3 -3
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/index.js +2 -2
- package/dist/esm/sdk/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/sdk/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditSuite.js +11 -9
- package/dist/esm/sdk/market/index.js +2 -2
- package/dist/esm/sdk/market/math.js +68 -17
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/opportunities.d.ts +9 -25
- package/dist/types/model/opportunities.schema.d.ts +12 -204
- package/dist/types/new-sdk/prepare/types.d.ts +22 -8
- package/dist/types/sdk/accounts/intents/index.d.ts +13 -6
- package/dist/types/sdk/accounts/intents/plan.d.ts +18 -2
- package/dist/types/sdk/accounts/intents/realize.d.ts +7 -0
- package/dist/types/sdk/accounts/intents/tail.d.ts +52 -0
- package/dist/types/sdk/accounts/intents/types.d.ts +46 -10
- package/dist/types/sdk/accounts/intents/utils/index.d.ts +2 -2
- package/dist/types/sdk/accounts/intents/utils/router-path.d.ts +15 -1
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +1 -5
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/math.d.ts +64 -13
- package/package.json +1 -1
|
@@ -363,58 +363,10 @@ declare const strategyOpportunitySchema: z.ZodObject<{
|
|
|
363
363
|
}, z.core.$strip>>;
|
|
364
364
|
}, z.core.$strip>], "kind">>>;
|
|
365
365
|
}, z.core.$strip>>;
|
|
366
|
-
|
|
367
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
368
|
-
organicApy: z.ZodNumber;
|
|
369
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
370
|
-
kind: z.ZodLiteral<"token">;
|
|
371
|
-
token: z.ZodObject<{
|
|
372
|
-
chainId: z.ZodNumber;
|
|
373
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
374
|
-
symbol: z.ZodString;
|
|
375
|
-
name: z.ZodString;
|
|
376
|
-
decimals: z.ZodNumber;
|
|
377
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
378
|
-
}, z.core.$strip>;
|
|
379
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
380
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
381
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
382
|
-
kind: z.ZodLiteral<"point">;
|
|
383
|
-
points: z.ZodArray<z.ZodObject<{
|
|
384
|
-
id: z.ZodString;
|
|
385
|
-
name: z.ZodString;
|
|
386
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
387
|
-
}, z.core.$strip>>;
|
|
388
|
-
}, z.core.$strip>], "kind">>>;
|
|
389
|
-
}, z.core.$strip>>;
|
|
390
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
391
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
392
|
-
organicApy: z.ZodNumber;
|
|
393
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
394
|
-
kind: z.ZodLiteral<"token">;
|
|
395
|
-
token: z.ZodObject<{
|
|
396
|
-
chainId: z.ZodNumber;
|
|
397
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
398
|
-
symbol: z.ZodString;
|
|
399
|
-
name: z.ZodString;
|
|
400
|
-
decimals: z.ZodNumber;
|
|
401
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
402
|
-
}, z.core.$strip>;
|
|
403
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
404
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
405
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
406
|
-
kind: z.ZodLiteral<"point">;
|
|
407
|
-
points: z.ZodArray<z.ZodObject<{
|
|
408
|
-
id: z.ZodString;
|
|
409
|
-
name: z.ZodString;
|
|
410
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
411
|
-
}, z.core.$strip>>;
|
|
412
|
-
}, z.core.$strip>], "kind">>>;
|
|
413
|
-
}, z.core.$strip>>;
|
|
414
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
366
|
+
borrowApy: z.ZodNumber;
|
|
415
367
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
416
|
-
|
|
417
|
-
|
|
368
|
+
quotaRate: z.ZodNumber;
|
|
369
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
418
370
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
419
371
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
420
372
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -654,58 +606,10 @@ declare const opportunitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
654
606
|
}, z.core.$strip>>;
|
|
655
607
|
}, z.core.$strip>], "kind">>>;
|
|
656
608
|
}, z.core.$strip>>;
|
|
657
|
-
|
|
658
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
659
|
-
organicApy: z.ZodNumber;
|
|
660
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
661
|
-
kind: z.ZodLiteral<"token">;
|
|
662
|
-
token: z.ZodObject<{
|
|
663
|
-
chainId: z.ZodNumber;
|
|
664
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
665
|
-
symbol: z.ZodString;
|
|
666
|
-
name: z.ZodString;
|
|
667
|
-
decimals: z.ZodNumber;
|
|
668
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
669
|
-
}, z.core.$strip>;
|
|
670
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
671
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
672
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
673
|
-
kind: z.ZodLiteral<"point">;
|
|
674
|
-
points: z.ZodArray<z.ZodObject<{
|
|
675
|
-
id: z.ZodString;
|
|
676
|
-
name: z.ZodString;
|
|
677
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
678
|
-
}, z.core.$strip>>;
|
|
679
|
-
}, z.core.$strip>], "kind">>>;
|
|
680
|
-
}, z.core.$strip>>;
|
|
681
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
682
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
683
|
-
organicApy: z.ZodNumber;
|
|
684
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
685
|
-
kind: z.ZodLiteral<"token">;
|
|
686
|
-
token: z.ZodObject<{
|
|
687
|
-
chainId: z.ZodNumber;
|
|
688
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
689
|
-
symbol: z.ZodString;
|
|
690
|
-
name: z.ZodString;
|
|
691
|
-
decimals: z.ZodNumber;
|
|
692
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
693
|
-
}, z.core.$strip>;
|
|
694
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
695
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
696
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
697
|
-
kind: z.ZodLiteral<"point">;
|
|
698
|
-
points: z.ZodArray<z.ZodObject<{
|
|
699
|
-
id: z.ZodString;
|
|
700
|
-
name: z.ZodString;
|
|
701
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
702
|
-
}, z.core.$strip>>;
|
|
703
|
-
}, z.core.$strip>], "kind">>>;
|
|
704
|
-
}, z.core.$strip>>;
|
|
705
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
609
|
+
borrowApy: z.ZodNumber;
|
|
706
610
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
707
|
-
|
|
708
|
-
|
|
611
|
+
quotaRate: z.ZodNumber;
|
|
612
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
709
613
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
710
614
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
711
615
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1105,58 +1009,10 @@ declare const strategyOpportunityDetailSchema: z.ZodObject<{
|
|
|
1105
1009
|
}, z.core.$strip>>;
|
|
1106
1010
|
}, z.core.$strip>], "kind">>>;
|
|
1107
1011
|
}, z.core.$strip>>;
|
|
1108
|
-
|
|
1109
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1110
|
-
organicApy: z.ZodNumber;
|
|
1111
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1112
|
-
kind: z.ZodLiteral<"token">;
|
|
1113
|
-
token: z.ZodObject<{
|
|
1114
|
-
chainId: z.ZodNumber;
|
|
1115
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1116
|
-
symbol: z.ZodString;
|
|
1117
|
-
name: z.ZodString;
|
|
1118
|
-
decimals: z.ZodNumber;
|
|
1119
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1120
|
-
}, z.core.$strip>;
|
|
1121
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1122
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1123
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1124
|
-
kind: z.ZodLiteral<"point">;
|
|
1125
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1126
|
-
id: z.ZodString;
|
|
1127
|
-
name: z.ZodString;
|
|
1128
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1129
|
-
}, z.core.$strip>>;
|
|
1130
|
-
}, z.core.$strip>], "kind">>>;
|
|
1131
|
-
}, z.core.$strip>>;
|
|
1132
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
1133
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1134
|
-
organicApy: z.ZodNumber;
|
|
1135
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1136
|
-
kind: z.ZodLiteral<"token">;
|
|
1137
|
-
token: z.ZodObject<{
|
|
1138
|
-
chainId: z.ZodNumber;
|
|
1139
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1140
|
-
symbol: z.ZodString;
|
|
1141
|
-
name: z.ZodString;
|
|
1142
|
-
decimals: z.ZodNumber;
|
|
1143
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1144
|
-
}, z.core.$strip>;
|
|
1145
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1146
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1147
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1148
|
-
kind: z.ZodLiteral<"point">;
|
|
1149
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1150
|
-
id: z.ZodString;
|
|
1151
|
-
name: z.ZodString;
|
|
1152
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1153
|
-
}, z.core.$strip>>;
|
|
1154
|
-
}, z.core.$strip>], "kind">>>;
|
|
1155
|
-
}, z.core.$strip>>;
|
|
1156
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
1012
|
+
borrowApy: z.ZodNumber;
|
|
1157
1013
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1158
|
-
|
|
1159
|
-
|
|
1014
|
+
quotaRate: z.ZodNumber;
|
|
1015
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1160
1016
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
1161
1017
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1162
1018
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1448,58 +1304,10 @@ declare const opportunityDetailSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1448
1304
|
}, z.core.$strip>>;
|
|
1449
1305
|
}, z.core.$strip>], "kind">>>;
|
|
1450
1306
|
}, z.core.$strip>>;
|
|
1451
|
-
|
|
1452
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1453
|
-
organicApy: z.ZodNumber;
|
|
1454
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1455
|
-
kind: z.ZodLiteral<"token">;
|
|
1456
|
-
token: z.ZodObject<{
|
|
1457
|
-
chainId: z.ZodNumber;
|
|
1458
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1459
|
-
symbol: z.ZodString;
|
|
1460
|
-
name: z.ZodString;
|
|
1461
|
-
decimals: z.ZodNumber;
|
|
1462
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1463
|
-
}, z.core.$strip>;
|
|
1464
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1465
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1466
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1467
|
-
kind: z.ZodLiteral<"point">;
|
|
1468
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1469
|
-
id: z.ZodString;
|
|
1470
|
-
name: z.ZodString;
|
|
1471
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1472
|
-
}, z.core.$strip>>;
|
|
1473
|
-
}, z.core.$strip>], "kind">>>;
|
|
1474
|
-
}, z.core.$strip>>;
|
|
1475
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
1476
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1477
|
-
organicApy: z.ZodNumber;
|
|
1478
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1479
|
-
kind: z.ZodLiteral<"token">;
|
|
1480
|
-
token: z.ZodObject<{
|
|
1481
|
-
chainId: z.ZodNumber;
|
|
1482
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1483
|
-
symbol: z.ZodString;
|
|
1484
|
-
name: z.ZodString;
|
|
1485
|
-
decimals: z.ZodNumber;
|
|
1486
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1487
|
-
}, z.core.$strip>;
|
|
1488
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1489
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1490
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1491
|
-
kind: z.ZodLiteral<"point">;
|
|
1492
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1493
|
-
id: z.ZodString;
|
|
1494
|
-
name: z.ZodString;
|
|
1495
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1496
|
-
}, z.core.$strip>>;
|
|
1497
|
-
}, z.core.$strip>], "kind">>>;
|
|
1498
|
-
}, z.core.$strip>>;
|
|
1499
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
1307
|
+
borrowApy: z.ZodNumber;
|
|
1500
1308
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1501
|
-
|
|
1502
|
-
|
|
1309
|
+
quotaRate: z.ZodNumber;
|
|
1310
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1503
1311
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
1504
1312
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1505
1313
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -73,10 +73,12 @@ type StrategySimulate = {
|
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* What the leading half of a delayed operation would yield: the request
|
|
76
|
-
* transaction, plus what it recorded for the tail.
|
|
76
|
+
* transaction, plus what it recorded for the tail and where that tail leads.
|
|
77
77
|
*
|
|
78
78
|
* Shaped like {@link StrategySimulate} with one field more, so the instant and
|
|
79
|
-
* the delayed route of the same request are compared side by side
|
|
79
|
+
* the delayed route of the same request are compared side by side — and they
|
|
80
|
+
* are meant to be compared on the same footing, so `preview` is the end of the
|
|
81
|
+
* operation in both, not the end of the transaction.
|
|
80
82
|
**/
|
|
81
83
|
type DelayedStrategySimulate = {
|
|
82
84
|
ok: true;
|
|
@@ -85,9 +87,14 @@ type DelayedStrategySimulate = {
|
|
|
85
87
|
**/
|
|
86
88
|
operations: AccountCalculatorOperation[];
|
|
87
89
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
90
|
+
* Where the operation ends: the account once the redemption has matured,
|
|
91
|
+
* been claimed and the tail has run — the same place the instant route
|
|
92
|
+
* reaches in one transaction, which is what makes the two comparable.
|
|
93
|
+
*
|
|
94
|
+
* The tail's half of it is an estimate priced by the oracle: the funds it
|
|
95
|
+
* trades do not exist yet, so no route can be quoted for them. The state
|
|
96
|
+
* the request alone lands in — source spent, withdrawal position in its
|
|
97
|
+
* place, debt untouched — is `delayed.afterRequest`.
|
|
91
98
|
**/
|
|
92
99
|
preview: OperationState;
|
|
93
100
|
/**
|
|
@@ -398,7 +405,13 @@ interface OpportunitiesPrepare {
|
|
|
398
405
|
* many-to-one route, the debt is settled in full and every balance left goes
|
|
399
406
|
* to `to`. `tokenOut` is ignored, since the proceeds are already the
|
|
400
407
|
* underlying (unwrapped on an RWA market). The account stays open with
|
|
401
|
-
* nothing on it.
|
|
408
|
+
* nothing on it.
|
|
409
|
+
*
|
|
410
|
+
* An exit has both routes as well, which is what lets an account whose
|
|
411
|
+
* position only redeems through its issuer leave at all: the delayed route
|
|
412
|
+
* redeems `sourceToken` whole and records the exit, and {@link finalize}
|
|
413
|
+
* rebuilds it against the account the claim finds — the debt as it stands by
|
|
414
|
+
* then, whatever else is on the account, everything sold in one route.
|
|
402
415
|
*
|
|
403
416
|
* @see withdrawCollateral to move an asset out without touching debt, which
|
|
404
417
|
* raises leverage instead.
|
|
@@ -463,8 +476,9 @@ interface OpportunitiesPrepare {
|
|
|
463
476
|
/**
|
|
464
477
|
* The tail of a delayed route: claim the matured withdrawal, then whatever the
|
|
465
478
|
* operation that requested it still owes — repaying debt and paying the wallet
|
|
466
|
-
* out for a withdrawal, repaying alone for a deleveraging,
|
|
467
|
-
*
|
|
479
|
+
* out for a withdrawal, repaying alone for a deleveraging, selling the rest of
|
|
480
|
+
* the account and settling the loan for an exit, nothing beyond the claim for
|
|
481
|
+
* the rest.
|
|
468
482
|
*
|
|
469
483
|
* The route is requested by {@link withdrawStrategy} or
|
|
470
484
|
* {@link adjustLeverage}, whose `delayed` branch is the transaction that
|
|
@@ -75,10 +75,16 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
75
75
|
* {@link intentRoutes}; this is the one to call when the delayed route is the
|
|
76
76
|
* only one of interest.
|
|
77
77
|
*
|
|
78
|
+
* `preview` is where the intent ends — the account once the redemption has
|
|
79
|
+
* matured, been claimed and the tail has run — because that is what the
|
|
80
|
+
* caller asked for; the half-way state the request itself lands in is
|
|
81
|
+
* `delayed.afterRequest`. Both are validated, so a request whose tail could
|
|
82
|
+
* not be completed is refused instead of started.
|
|
83
|
+
*
|
|
78
84
|
* @param props - Intent plus account slice, quota reserve and slippage
|
|
79
|
-
* @returns The request transaction
|
|
80
|
-
* `{ ok: false, reason }` — `noDelayedRoute` when this route
|
|
81
|
-
* for the account at all
|
|
85
|
+
* @returns The request transaction, the state it ends in and what it recorded
|
|
86
|
+
* for the tail, or `{ ok: false, reason }` — `noDelayedRoute` when this route
|
|
87
|
+
* does not exist for the account at all
|
|
82
88
|
*/
|
|
83
89
|
startDelayedIntent(props: StartIntentProps & {
|
|
84
90
|
intent: DelayableIntent;
|
|
@@ -109,9 +115,10 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
109
115
|
* Previews the tail of a delayed intent, once the withdrawal it started has
|
|
110
116
|
* matured: the claim, then whatever the intent still owes.
|
|
111
117
|
*
|
|
112
|
-
* Serves the
|
|
113
|
-
* withdrawal and
|
|
114
|
-
* the tokens land on the account and only their quota has to
|
|
118
|
+
* Serves the three operations that can genuinely be interrupted by a delay —
|
|
119
|
+
* a withdrawal, a deleveraging and an exit. For the rest, the claim is the
|
|
120
|
+
* whole tail: the tokens land on the account and only their quota has to
|
|
121
|
+
* catch up.
|
|
115
122
|
*
|
|
116
123
|
* @param props - The recorded intent, the account slice as it stands now, and
|
|
117
124
|
* the matured claimable
|
|
@@ -153,7 +153,8 @@ declare function planWithdraw(intent: Omit<WithdrawStrategyIntent, "type">, view
|
|
|
153
153
|
*
|
|
154
154
|
* The tail is planned at claim time by {@link planFinishWithdraw}, from the
|
|
155
155
|
* intent this request records — only then is the claimed amount, and the token
|
|
156
|
-
* it arrived in, known.
|
|
156
|
+
* it arrived in, known. An exit records {@link planFinishCloseAccount}'s intent
|
|
157
|
+
* instead, and rebuilds itself from the account rather than from the request.
|
|
157
158
|
*/
|
|
158
159
|
declare function planWithdrawDelayed(intent: Omit<WithdrawStrategyIntent, "type">, view: AccountView): Step[];
|
|
159
160
|
/**
|
|
@@ -185,7 +186,22 @@ declare function planFinishWithdraw(intent: {
|
|
|
185
186
|
token: Address;
|
|
186
187
|
amount: bigint;
|
|
187
188
|
}, view: AccountView): Step[];
|
|
189
|
+
/**
|
|
190
|
+
* The tail of an exit: the claim lands, everything the account holds is sold
|
|
191
|
+
* into the underlying, the loan is settled out of the proceeds and the rest
|
|
192
|
+
* goes to the wallet. The account survives it, empty and owing nothing.
|
|
193
|
+
*
|
|
194
|
+
* Nothing is quoted from the request — the same shape {@link planWithdraw}
|
|
195
|
+
* builds for an instant exit is rebuilt here against the account as it stands
|
|
196
|
+
* now, which is the only state that can name these amounts.
|
|
197
|
+
*/
|
|
198
|
+
declare function planFinishCloseAccount(intent: {
|
|
199
|
+
to: Address;
|
|
200
|
+
}, claimable: ClaimableWithdrawal, claimed: {
|
|
201
|
+
token: Address;
|
|
202
|
+
amount: bigint;
|
|
203
|
+
}, view: AccountView): Step[];
|
|
188
204
|
/** Nothing is owed beyond the claim: the tokens land and quotas catch up. */
|
|
189
205
|
declare function planFinishClaimOnly(claimable: ClaimableWithdrawal): Step[];
|
|
190
206
|
//#endregion
|
|
191
|
-
export { AccountView, Amount, RAISED, Step, planAddCollateral, planAdjustLeverage, planAdjustLeverageDelayed, planDeposit, planFinishClaimOnly, planFinishDecreaseLeverage, planFinishWithdraw, planRepay, planWithdraw, planWithdrawAsset, planWithdrawDelayed };
|
|
207
|
+
export { AccountView, Amount, RAISED, Step, planAddCollateral, planAdjustLeverage, planAdjustLeverageDelayed, planDeposit, planFinishClaimOnly, planFinishCloseAccount, planFinishDecreaseLeverage, planFinishWithdraw, planRepay, planWithdraw, planWithdrawAsset, planWithdrawDelayed };
|
|
@@ -4,6 +4,7 @@ import { CreditAccountSlice, DelayedStart, OperationState } from "./types.js";
|
|
|
4
4
|
import { AccountCalculatorOperation } from "./operations.js";
|
|
5
5
|
import "../../index.js";
|
|
6
6
|
import { Step } from "./plan.js";
|
|
7
|
+
import { RouterPaths } from "./utils/router-path.js";
|
|
7
8
|
//#region src/sdk/accounts/intents/realize.d.ts
|
|
8
9
|
interface RealizeProps {
|
|
9
10
|
creditAccount: CreditAccountSlice;
|
|
@@ -12,6 +13,12 @@ interface RealizeProps {
|
|
|
12
13
|
slippage: number;
|
|
13
14
|
/** Extra quota headroom in PERCENTAGE_FORMAT. */
|
|
14
15
|
quotaReserve: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Where routed legs are quoted. Defaults to the pathfinder, which is what
|
|
18
|
+
* anything that will be sent needs; a walk that only projects a state passes
|
|
19
|
+
* `createOraclePaths` instead.
|
|
20
|
+
*/
|
|
21
|
+
paths?: RouterPaths;
|
|
15
22
|
}
|
|
16
23
|
interface Realized {
|
|
17
24
|
operations: AccountCalculatorOperation[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ClaimableWithdrawal } from "../withdrawal-compressor/types.js";
|
|
2
|
+
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
3
|
+
import { CreditAccountSlice, DelayedStart, OperationState, ResumableIntent } from "./types.js";
|
|
4
|
+
import { AccountCalculatorOperation, StartDelayedWithdrawalOperation } from "./operations.js";
|
|
5
|
+
import "../../index.js";
|
|
6
|
+
import { AccountView, Step } from "./plan.js";
|
|
7
|
+
//#region src/sdk/accounts/intents/tail.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* The second half of a delayed intent: the claim, then whatever the intent
|
|
10
|
+
* still owes.
|
|
11
|
+
*
|
|
12
|
+
* Shared by the two callers that need it and must not disagree — the tail as
|
|
13
|
+
* it is previewed days later against the account that really exists, and the
|
|
14
|
+
* tail as it is projected the moment the request is made.
|
|
15
|
+
*/
|
|
16
|
+
declare function planTail(args: {
|
|
17
|
+
intent: ResumableIntent;
|
|
18
|
+
claimable: ClaimableWithdrawal;
|
|
19
|
+
view: AccountView;
|
|
20
|
+
}): Step[];
|
|
21
|
+
/**
|
|
22
|
+
* Where a delayed intent ends up, worked out at the moment it is started.
|
|
23
|
+
*
|
|
24
|
+
* A request is only half a withdrawal, so the state it lands in is not the
|
|
25
|
+
* answer to "what does this do to my position": the debt is still there, the
|
|
26
|
+
* payout has not been made, and the position sits in a phantom token. What the
|
|
27
|
+
* caller means is the far side — and that side can be walked now, because the
|
|
28
|
+
* request already fixes the claim it will be finished from.
|
|
29
|
+
*
|
|
30
|
+
* So the same tail {@link planTail} builds at claim time is built here against
|
|
31
|
+
* the account as the request leaves it, with the claim it is expected to bring,
|
|
32
|
+
* and walked by the same realiser — with one substitution: routed legs are
|
|
33
|
+
* priced by the oracle rather than the pathfinder, since the funds they trade
|
|
34
|
+
* do not exist yet and no calldata is being produced. The result is an
|
|
35
|
+
* estimate that the engine's guards are nevertheless applied to, so a request
|
|
36
|
+
* that would strand the account is refused before it is sent rather than
|
|
37
|
+
* discovered days later.
|
|
38
|
+
*/
|
|
39
|
+
declare function projectTail(args: {
|
|
40
|
+
/** The request as realised: the source spent, the phantom it produced. */
|
|
41
|
+
request: StartDelayedWithdrawalOperation;
|
|
42
|
+
delayed: DelayedStart;
|
|
43
|
+
/** The account the request was previewed against, for masks and market. */
|
|
44
|
+
creditAccount: CreditAccountSlice;
|
|
45
|
+
sdk: OnchainSDK;
|
|
46
|
+
quotaReserve: number | undefined;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
state: OperationState;
|
|
49
|
+
operations: AccountCalculatorOperation[];
|
|
50
|
+
}>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { planTail, projectTail };
|
|
@@ -81,7 +81,11 @@ interface OperationState {
|
|
|
81
81
|
type PreviewErrorReason = "debtOutOfRange" | "leverageOutOfRange" | "insufficientSourceBalance" |
|
|
82
82
|
/** Input token is not accepted by the flow (e.g. deposit of a non-underlying). */
|
|
83
83
|
"unsupportedCollateralToken" |
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* No route for the trade the plan needs: no pool pair between the tokens
|
|
86
|
+
* requested, several and none was picked, or the pathfinder itself found no
|
|
87
|
+
* path for the amounts involved.
|
|
88
|
+
*/
|
|
85
89
|
"unsupportedTokenPair" |
|
|
86
90
|
/**
|
|
87
91
|
* The intent cannot settle with a delay: the source has no redemption config,
|
|
@@ -93,9 +97,8 @@ type PreviewErrorReason = "debtOutOfRange" | "leverageOutOfRange" | "insufficien
|
|
|
93
97
|
/** A redemption of the same asset is already in flight. */
|
|
94
98
|
"withdrawalInProgress" |
|
|
95
99
|
/**
|
|
96
|
-
* The claim names no operation to resume: requested without an intent,
|
|
97
|
-
* through a compressor too old to report one
|
|
98
|
-
* engine no longer previews.
|
|
100
|
+
* The claim names no operation to resume: requested without an intent, or
|
|
101
|
+
* read through a compressor too old to report one.
|
|
99
102
|
*/
|
|
100
103
|
"noRecordedIntent" |
|
|
101
104
|
/** The facade or the pool behind it is paused: nothing can be done at all. */
|
|
@@ -146,10 +149,44 @@ interface DelayedStart {
|
|
|
146
149
|
* instead, which settles all of it in one transaction.
|
|
147
150
|
*/
|
|
148
151
|
settlement: "instant" | "delayed";
|
|
152
|
+
/**
|
|
153
|
+
* What the claim is expected to credit the account with once the redemption
|
|
154
|
+
* matures: the venue's payout token and the amount the request queued.
|
|
155
|
+
* `undefined` when the request settled on the spot and nothing is coming.
|
|
156
|
+
*
|
|
157
|
+
* An estimate, not a quote — the issuer prices the redemption when it pays
|
|
158
|
+
* out, and the state the intent is previewed against was read now.
|
|
159
|
+
*/
|
|
160
|
+
claim: {
|
|
161
|
+
token: Address;
|
|
162
|
+
amount: bigint;
|
|
163
|
+
} | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* The account as the request transaction alone leaves it: the source spent,
|
|
166
|
+
* the phantom of the in-flight redemption in its place, the debt untouched.
|
|
167
|
+
*
|
|
168
|
+
* This is the state the facade judges when the transaction lands, so it is
|
|
169
|
+
* the one the engine's guards are applied to — while the `preview` beside it
|
|
170
|
+
* is where the intent ends up, tail included, which is what a caller asking
|
|
171
|
+
* "what does this do to my position" means.
|
|
172
|
+
*/
|
|
173
|
+
afterRequest: OperationState;
|
|
149
174
|
}
|
|
150
175
|
/**
|
|
151
176
|
* What the leading half of a delayed intent yields: the request transaction,
|
|
152
177
|
* plus what it recorded for the tail.
|
|
178
|
+
*
|
|
179
|
+
* `operations` and `calls` are the request and nothing else — that is the only
|
|
180
|
+
* transaction there is to send now. `preview`, though, is where the intent
|
|
181
|
+
* ends: the state the account reaches once the redemption matures, is claimed
|
|
182
|
+
* and the tail runs, since that is what the caller asked for when they asked
|
|
183
|
+
* to withdraw. The half-way state the request itself lands in is
|
|
184
|
+
* {@link DelayedStart.afterRequest}, and both are validated before either is
|
|
185
|
+
* reported.
|
|
186
|
+
*
|
|
187
|
+
* The tail is projected from oracle prices rather than from a route — the funds
|
|
188
|
+
* it trades do not exist yet — so its half of the numbers is an estimate. What
|
|
189
|
+
* the transaction on offer does is not.
|
|
153
190
|
*/
|
|
154
191
|
type DelayedStartResult = {
|
|
155
192
|
ok: true;
|
|
@@ -406,14 +443,13 @@ type StartIntent = AddCollateralIntent | WithdrawAssetIntent | AdjustLeverageInt
|
|
|
406
443
|
*/
|
|
407
444
|
type DelayableIntent = AdjustLeverageIntent | WithdrawStrategyIntent;
|
|
408
445
|
/**
|
|
409
|
-
* A delayed intent this engine knows how to finish.
|
|
446
|
+
* A delayed intent this engine knows how to finish — every one of them.
|
|
410
447
|
*
|
|
411
|
-
* `CLOSE_ACCOUNT`
|
|
412
|
-
*
|
|
448
|
+
* `CLOSE_ACCOUNT` included: an exit is a plain multicall like any other
|
|
449
|
+
* operation here (sell everything, settle the loan, hand the rest over), not
|
|
450
|
+
* the facade's own close entry point, so the engine can build its tail too.
|
|
413
451
|
*/
|
|
414
|
-
type ResumableIntent =
|
|
415
|
-
type: "CLOSE_ACCOUNT";
|
|
416
|
-
}>;
|
|
452
|
+
type ResumableIntent = DelayedIntent;
|
|
417
453
|
/** Shared inputs plus the matured withdrawal the tail is built around. */
|
|
418
454
|
type FinishIntentProps = StartIntentProps & {
|
|
419
455
|
intent: ResumableIntent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./credit-account-slice.js";
|
|
2
|
+
import { OpenStrategyLeg, RouterPaths, SwapLeg, createOraclePaths, createRouterPaths } from "./router-path.js";
|
|
2
3
|
import { adjustStateToSnapshot } from "./adjust-state-to-snapshot.js";
|
|
3
4
|
import { assembleOperationCalls } from "./assemble-operation-calls.js";
|
|
4
5
|
import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-interest-and-fees.js";
|
|
@@ -7,5 +8,4 @@ import { convertAmount } from "./convert-amount.js";
|
|
|
7
8
|
import { ConvertFn, LedgerSnapshot, OperationLedger } from "./ledger.js";
|
|
8
9
|
import { CandidateToken, isPhantomToken, isRedemptionPhantomToken, pickFattestNonPhantomToken, rankAccountTokens } from "./pick-token.js";
|
|
9
10
|
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./quotas-for-update.js";
|
|
10
|
-
|
|
11
|
-
export { CandidateToken, ConvertFn, LedgerSnapshot, OpenStrategyLeg, OperationLedger, RouterPaths, SwapLeg, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, convertAmount, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals };
|
|
11
|
+
export { CandidateToken, ConvertFn, LedgerSnapshot, OpenStrategyLeg, OperationLedger, RouterPaths, SwapLeg, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, convertAmount, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals };
|
|
@@ -66,5 +66,19 @@ declare function createRouterPaths(args: {
|
|
|
66
66
|
creditAccount: CreditAccountSlice;
|
|
67
67
|
slippage: number;
|
|
68
68
|
}): RouterPaths;
|
|
69
|
+
/**
|
|
70
|
+
* The same door, priced by the oracle and opening onto no calldata.
|
|
71
|
+
*
|
|
72
|
+
* For a leg that cannot be quoted yet: the tail of a redemption trades funds
|
|
73
|
+
* that do not exist, along a route the pathfinder will only be able to build
|
|
74
|
+
* once they do. Asking it now would price a swap of nothing, so the amounts
|
|
75
|
+
* come from the oracle instead — an estimate with no slippage floor, which is
|
|
76
|
+
* all a projection days out can honestly be — and the walk yields a state
|
|
77
|
+
* rather than a transaction.
|
|
78
|
+
*/
|
|
79
|
+
declare function createOraclePaths(args: {
|
|
80
|
+
sdk: OnchainSDK;
|
|
81
|
+
creditAccount: CreditAccountSlice;
|
|
82
|
+
}): RouterPaths;
|
|
69
83
|
//#endregion
|
|
70
|
-
export { OpenStrategyLeg, RouterPaths, SwapLeg, createRouterPaths };
|
|
84
|
+
export { OpenStrategyLeg, RouterPaths, SwapLeg, createOraclePaths, createRouterPaths };
|