@indigo-labs/indigo-sdk 0.2.29 → 0.2.30
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/index.js +30 -19
- package/dist/index.mjs +30 -19
- package/package.json +1 -1
- package/src/contracts/cdp/transactions.ts +23 -21
- package/src/contracts/cdp-creator/types.ts +3 -1
- package/src/contracts/lrp/types.ts +1 -1
- package/src/contracts/stability-pool/types-new.ts +6 -2
- package/src/contracts/staking/types-new.ts +3 -1
- package/src/contracts/staking/types.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -908,7 +908,9 @@ var CDPCreatorRedeemerSchema = import_lucid11.Data.Enum([
|
|
|
908
908
|
]);
|
|
909
909
|
var CDPCreatorRedeemer = CDPCreatorRedeemerSchema;
|
|
910
910
|
function serialiseCDPCreatorRedeemer(params) {
|
|
911
|
-
return import_lucid11.Data.to(params, CDPCreatorRedeemer, {
|
|
911
|
+
return import_lucid11.Data.to(params, CDPCreatorRedeemer, {
|
|
912
|
+
canonical: true
|
|
913
|
+
});
|
|
912
914
|
}
|
|
913
915
|
function serialiseCDPCreatorDatum() {
|
|
914
916
|
return import_lucid11.Data.void();
|
|
@@ -1161,14 +1163,18 @@ function serialiseStabilityPoolRedeemer(r) {
|
|
|
1161
1163
|
StabilityPoolRedeemerSchema,
|
|
1162
1164
|
DEFAULT_SCHEMA_OPTIONS
|
|
1163
1165
|
).toCBORHex(r);
|
|
1164
|
-
return import_lucid14.Data.to(import_lucid14.Data.from(rdmr, typeof import_lucid14.Data), typeof import_lucid14.Data, {
|
|
1166
|
+
return import_lucid14.Data.to(import_lucid14.Data.from(rdmr, typeof import_lucid14.Data), typeof import_lucid14.Data, {
|
|
1167
|
+
canonical: false
|
|
1168
|
+
});
|
|
1165
1169
|
}
|
|
1166
1170
|
function serialiseStabilityPoolDatum(d, useIndefiniteMaps = false) {
|
|
1167
1171
|
const datum = import_evolution2.Core.Data.withSchema(StabilityPoolDatumSchema, {
|
|
1168
1172
|
...DEFAULT_SCHEMA_OPTIONS,
|
|
1169
1173
|
useIndefiniteMaps
|
|
1170
1174
|
}).toCBORHex(d);
|
|
1171
|
-
return import_lucid14.Data.to(import_lucid14.Data.from(datum, typeof import_lucid14.Data), typeof import_lucid14.Data, {
|
|
1175
|
+
return import_lucid14.Data.to(import_lucid14.Data.from(datum, typeof import_lucid14.Data), typeof import_lucid14.Data, {
|
|
1176
|
+
canonical: false
|
|
1177
|
+
});
|
|
1172
1178
|
}
|
|
1173
1179
|
function parseStabilityPoolDatum(datum) {
|
|
1174
1180
|
return (0, import_ts_pattern5.match)(
|
|
@@ -1692,6 +1698,19 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
|
|
|
1692
1698
|
Number(priceOracleDatum.expiration),
|
|
1693
1699
|
network
|
|
1694
1700
|
);
|
|
1701
|
+
const interestAdaAmt = (0, import_ts_pattern7.match)(cdpDatum.cdpFees).with({ FrozenCDPAccumulatedFees: import_ts_pattern7.P.any }, () => {
|
|
1702
|
+
throw new Error("CDP fees wrong");
|
|
1703
|
+
}).with({ ActiveCDPInterestTracking: import_ts_pattern7.P.select() }, (interest) => {
|
|
1704
|
+
const interestPaymentIAssetAmt = calculateAccruedInterest(
|
|
1705
|
+
currentTime,
|
|
1706
|
+
interest.unitaryInterestSnapshot,
|
|
1707
|
+
cdpDatum.mintedAmt,
|
|
1708
|
+
interest.lastSettled,
|
|
1709
|
+
interestOracleDatum
|
|
1710
|
+
);
|
|
1711
|
+
return interestPaymentIAssetAmt * priceOracleDatum.price.getOnChainInt / 1000000n;
|
|
1712
|
+
}).exhaustive();
|
|
1713
|
+
const newCollateralAmount = collateralAmount - interestAdaAmt;
|
|
1695
1714
|
const tx = lucid.newTx().validFrom(txValidity.validFrom).validTo(txValidity.validTo).collectFrom(
|
|
1696
1715
|
[cdpUtxo],
|
|
1697
1716
|
serialiseCdpRedeemer({
|
|
@@ -1719,7 +1738,7 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
|
|
|
1719
1738
|
}
|
|
1720
1739
|
})
|
|
1721
1740
|
},
|
|
1722
|
-
(0, import_lucid19.addAssets)(cdpUtxo.assets, mkLovelacesOf(
|
|
1741
|
+
(0, import_lucid19.addAssets)(cdpUtxo.assets, mkLovelacesOf(newCollateralAmount))
|
|
1723
1742
|
);
|
|
1724
1743
|
if (!cdpDatum.cdpOwner) {
|
|
1725
1744
|
throw new Error("Expected active CDP");
|
|
@@ -1746,18 +1765,6 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
|
|
|
1746
1765
|
import_lucid19.Data.void()
|
|
1747
1766
|
);
|
|
1748
1767
|
}
|
|
1749
|
-
const interestAdaAmt = (0, import_ts_pattern7.match)(cdpDatum.cdpFees).with({ FrozenCDPAccumulatedFees: import_ts_pattern7.P.any }, () => {
|
|
1750
|
-
throw new Error("CDP fees wrong");
|
|
1751
|
-
}).with({ ActiveCDPInterestTracking: import_ts_pattern7.P.select() }, (interest) => {
|
|
1752
|
-
const interestPaymentIAssetAmt = calculateAccruedInterest(
|
|
1753
|
-
currentTime,
|
|
1754
|
-
interest.unitaryInterestSnapshot,
|
|
1755
|
-
cdpDatum.mintedAmt,
|
|
1756
|
-
interest.lastSettled,
|
|
1757
|
-
interestOracleDatum
|
|
1758
|
-
);
|
|
1759
|
-
return interestPaymentIAssetAmt * priceOracleDatum.price.getOnChainInt / 1000000n;
|
|
1760
|
-
}).exhaustive();
|
|
1761
1768
|
const interestCollectorAdaAmt = calculateFeeFromPercentage(
|
|
1762
1769
|
iassetDatum.interestCollectorPortionPercentage,
|
|
1763
1770
|
interestAdaAmt
|
|
@@ -2730,7 +2737,9 @@ var StakingRedeemerSchema = import_lucid26.Data.Enum([
|
|
|
2730
2737
|
]);
|
|
2731
2738
|
var StakingRedeemer = StakingRedeemerSchema;
|
|
2732
2739
|
function serialiseStakingRedeemer(redeemer) {
|
|
2733
|
-
const rdmr = import_lucid26.Data.to(redeemer, StakingRedeemer, {
|
|
2740
|
+
const rdmr = import_lucid26.Data.to(redeemer, StakingRedeemer, {
|
|
2741
|
+
canonical: false
|
|
2742
|
+
});
|
|
2734
2743
|
return rdmr;
|
|
2735
2744
|
}
|
|
2736
2745
|
function castStakingParams(params) {
|
|
@@ -2800,7 +2809,9 @@ function serialiseStakingDatum(d) {
|
|
|
2800
2809
|
StakingDatumSchema,
|
|
2801
2810
|
DEFAULT_SCHEMA_OPTIONS
|
|
2802
2811
|
).toCBORHex(d);
|
|
2803
|
-
return import_lucid27.Data.to(import_lucid27.Data.from(datum, typeof import_lucid27.Data), typeof import_lucid27.Data, {
|
|
2812
|
+
return import_lucid27.Data.to(import_lucid27.Data.from(datum, typeof import_lucid27.Data), typeof import_lucid27.Data, {
|
|
2813
|
+
canonical: false
|
|
2814
|
+
});
|
|
2804
2815
|
}
|
|
2805
2816
|
|
|
2806
2817
|
// src/contracts/staking/helpers.ts
|
|
@@ -5423,7 +5434,7 @@ function serialiseLrpDatum(datum) {
|
|
|
5423
5434
|
return import_lucid48.Data.to(datum, LRPDatum);
|
|
5424
5435
|
}
|
|
5425
5436
|
function serialiseLrpRedeemer(redeemer) {
|
|
5426
|
-
return import_lucid48.Data.to(redeemer, LRPRedeemer);
|
|
5437
|
+
return import_lucid48.Data.to(redeemer, LRPRedeemer, { canonical: true });
|
|
5427
5438
|
}
|
|
5428
5439
|
function castLrpParams(params) {
|
|
5429
5440
|
return import_lucid48.Data.castTo(params, LRPParams);
|
package/dist/index.mjs
CHANGED
|
@@ -674,7 +674,9 @@ var CDPCreatorRedeemerSchema = Data8.Enum([
|
|
|
674
674
|
]);
|
|
675
675
|
var CDPCreatorRedeemer = CDPCreatorRedeemerSchema;
|
|
676
676
|
function serialiseCDPCreatorRedeemer(params) {
|
|
677
|
-
return Data8.to(params, CDPCreatorRedeemer, {
|
|
677
|
+
return Data8.to(params, CDPCreatorRedeemer, {
|
|
678
|
+
canonical: true
|
|
679
|
+
});
|
|
678
680
|
}
|
|
679
681
|
function serialiseCDPCreatorDatum() {
|
|
680
682
|
return Data8.void();
|
|
@@ -927,14 +929,18 @@ function serialiseStabilityPoolRedeemer(r) {
|
|
|
927
929
|
StabilityPoolRedeemerSchema,
|
|
928
930
|
DEFAULT_SCHEMA_OPTIONS
|
|
929
931
|
).toCBORHex(r);
|
|
930
|
-
return Data9.to(Data9.from(rdmr, typeof Data9), typeof Data9, {
|
|
932
|
+
return Data9.to(Data9.from(rdmr, typeof Data9), typeof Data9, {
|
|
933
|
+
canonical: false
|
|
934
|
+
});
|
|
931
935
|
}
|
|
932
936
|
function serialiseStabilityPoolDatum(d, useIndefiniteMaps = false) {
|
|
933
937
|
const datum = EvoCore2.Data.withSchema(StabilityPoolDatumSchema, {
|
|
934
938
|
...DEFAULT_SCHEMA_OPTIONS,
|
|
935
939
|
useIndefiniteMaps
|
|
936
940
|
}).toCBORHex(d);
|
|
937
|
-
return Data9.to(Data9.from(datum, typeof Data9), typeof Data9, {
|
|
941
|
+
return Data9.to(Data9.from(datum, typeof Data9), typeof Data9, {
|
|
942
|
+
canonical: false
|
|
943
|
+
});
|
|
938
944
|
}
|
|
939
945
|
function parseStabilityPoolDatum(datum) {
|
|
940
946
|
return match5(
|
|
@@ -1463,6 +1469,19 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
|
|
|
1463
1469
|
Number(priceOracleDatum.expiration),
|
|
1464
1470
|
network
|
|
1465
1471
|
);
|
|
1472
|
+
const interestAdaAmt = match7(cdpDatum.cdpFees).with({ FrozenCDPAccumulatedFees: P6.any }, () => {
|
|
1473
|
+
throw new Error("CDP fees wrong");
|
|
1474
|
+
}).with({ ActiveCDPInterestTracking: P6.select() }, (interest) => {
|
|
1475
|
+
const interestPaymentIAssetAmt = calculateAccruedInterest(
|
|
1476
|
+
currentTime,
|
|
1477
|
+
interest.unitaryInterestSnapshot,
|
|
1478
|
+
cdpDatum.mintedAmt,
|
|
1479
|
+
interest.lastSettled,
|
|
1480
|
+
interestOracleDatum
|
|
1481
|
+
);
|
|
1482
|
+
return interestPaymentIAssetAmt * priceOracleDatum.price.getOnChainInt / 1000000n;
|
|
1483
|
+
}).exhaustive();
|
|
1484
|
+
const newCollateralAmount = collateralAmount - interestAdaAmt;
|
|
1466
1485
|
const tx = lucid.newTx().validFrom(txValidity.validFrom).validTo(txValidity.validTo).collectFrom(
|
|
1467
1486
|
[cdpUtxo],
|
|
1468
1487
|
serialiseCdpRedeemer({
|
|
@@ -1490,7 +1509,7 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
|
|
|
1490
1509
|
}
|
|
1491
1510
|
})
|
|
1492
1511
|
},
|
|
1493
|
-
addAssets3(cdpUtxo.assets, mkLovelacesOf(
|
|
1512
|
+
addAssets3(cdpUtxo.assets, mkLovelacesOf(newCollateralAmount))
|
|
1494
1513
|
);
|
|
1495
1514
|
if (!cdpDatum.cdpOwner) {
|
|
1496
1515
|
throw new Error("Expected active CDP");
|
|
@@ -1517,18 +1536,6 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
|
|
|
1517
1536
|
Data14.void()
|
|
1518
1537
|
);
|
|
1519
1538
|
}
|
|
1520
|
-
const interestAdaAmt = match7(cdpDatum.cdpFees).with({ FrozenCDPAccumulatedFees: P6.any }, () => {
|
|
1521
|
-
throw new Error("CDP fees wrong");
|
|
1522
|
-
}).with({ ActiveCDPInterestTracking: P6.select() }, (interest) => {
|
|
1523
|
-
const interestPaymentIAssetAmt = calculateAccruedInterest(
|
|
1524
|
-
currentTime,
|
|
1525
|
-
interest.unitaryInterestSnapshot,
|
|
1526
|
-
cdpDatum.mintedAmt,
|
|
1527
|
-
interest.lastSettled,
|
|
1528
|
-
interestOracleDatum
|
|
1529
|
-
);
|
|
1530
|
-
return interestPaymentIAssetAmt * priceOracleDatum.price.getOnChainInt / 1000000n;
|
|
1531
|
-
}).exhaustive();
|
|
1532
1539
|
const interestCollectorAdaAmt = calculateFeeFromPercentage(
|
|
1533
1540
|
iassetDatum.interestCollectorPortionPercentage,
|
|
1534
1541
|
interestAdaAmt
|
|
@@ -2508,7 +2515,9 @@ var StakingRedeemerSchema = Data18.Enum([
|
|
|
2508
2515
|
]);
|
|
2509
2516
|
var StakingRedeemer = StakingRedeemerSchema;
|
|
2510
2517
|
function serialiseStakingRedeemer(redeemer) {
|
|
2511
|
-
const rdmr = Data18.to(redeemer, StakingRedeemer, {
|
|
2518
|
+
const rdmr = Data18.to(redeemer, StakingRedeemer, {
|
|
2519
|
+
canonical: false
|
|
2520
|
+
});
|
|
2512
2521
|
return rdmr;
|
|
2513
2522
|
}
|
|
2514
2523
|
function castStakingParams(params) {
|
|
@@ -2578,7 +2587,9 @@ function serialiseStakingDatum(d) {
|
|
|
2578
2587
|
StakingDatumSchema,
|
|
2579
2588
|
DEFAULT_SCHEMA_OPTIONS
|
|
2580
2589
|
).toCBORHex(d);
|
|
2581
|
-
return Data19.to(Data19.from(datum, typeof Data19), typeof Data19, {
|
|
2590
|
+
return Data19.to(Data19.from(datum, typeof Data19), typeof Data19, {
|
|
2591
|
+
canonical: false
|
|
2592
|
+
});
|
|
2582
2593
|
}
|
|
2583
2594
|
|
|
2584
2595
|
// src/contracts/staking/helpers.ts
|
|
@@ -5260,7 +5271,7 @@ function serialiseLrpDatum(datum) {
|
|
|
5260
5271
|
return Data28.to(datum, LRPDatum);
|
|
5261
5272
|
}
|
|
5262
5273
|
function serialiseLrpRedeemer(redeemer) {
|
|
5263
|
-
return Data28.to(redeemer, LRPRedeemer);
|
|
5274
|
+
return Data28.to(redeemer, LRPRedeemer, { canonical: true });
|
|
5264
5275
|
}
|
|
5265
5276
|
function castLrpParams(params) {
|
|
5266
5277
|
return Data28.castTo(params, LRPParams);
|
package/package.json
CHANGED
|
@@ -291,6 +291,28 @@ async function adjustCdp(
|
|
|
291
291
|
network,
|
|
292
292
|
);
|
|
293
293
|
|
|
294
|
+
const interestAdaAmt = match(cdpDatum.cdpFees)
|
|
295
|
+
.with({ FrozenCDPAccumulatedFees: P.any }, () => {
|
|
296
|
+
throw new Error('CDP fees wrong');
|
|
297
|
+
})
|
|
298
|
+
.with({ ActiveCDPInterestTracking: P.select() }, (interest) => {
|
|
299
|
+
const interestPaymentIAssetAmt = calculateAccruedInterest(
|
|
300
|
+
currentTime,
|
|
301
|
+
interest.unitaryInterestSnapshot,
|
|
302
|
+
cdpDatum.mintedAmt,
|
|
303
|
+
interest.lastSettled,
|
|
304
|
+
interestOracleDatum,
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
(interestPaymentIAssetAmt * priceOracleDatum.price.getOnChainInt) /
|
|
309
|
+
1_000_000n
|
|
310
|
+
);
|
|
311
|
+
})
|
|
312
|
+
.exhaustive();
|
|
313
|
+
|
|
314
|
+
const newCollateralAmount = collateralAmount - interestAdaAmt;
|
|
315
|
+
|
|
294
316
|
const tx = lucid
|
|
295
317
|
.newTx()
|
|
296
318
|
.validFrom(txValidity.validFrom)
|
|
@@ -326,7 +348,7 @@ async function adjustCdp(
|
|
|
326
348
|
},
|
|
327
349
|
}),
|
|
328
350
|
},
|
|
329
|
-
addAssets(cdpUtxo.assets, mkLovelacesOf(
|
|
351
|
+
addAssets(cdpUtxo.assets, mkLovelacesOf(newCollateralAmount)),
|
|
330
352
|
);
|
|
331
353
|
|
|
332
354
|
if (!cdpDatum.cdpOwner) {
|
|
@@ -359,26 +381,6 @@ async function adjustCdp(
|
|
|
359
381
|
);
|
|
360
382
|
}
|
|
361
383
|
|
|
362
|
-
const interestAdaAmt = match(cdpDatum.cdpFees)
|
|
363
|
-
.with({ FrozenCDPAccumulatedFees: P.any }, () => {
|
|
364
|
-
throw new Error('CDP fees wrong');
|
|
365
|
-
})
|
|
366
|
-
.with({ ActiveCDPInterestTracking: P.select() }, (interest) => {
|
|
367
|
-
const interestPaymentIAssetAmt = calculateAccruedInterest(
|
|
368
|
-
currentTime,
|
|
369
|
-
interest.unitaryInterestSnapshot,
|
|
370
|
-
cdpDatum.mintedAmt,
|
|
371
|
-
interest.lastSettled,
|
|
372
|
-
interestOracleDatum,
|
|
373
|
-
);
|
|
374
|
-
|
|
375
|
-
return (
|
|
376
|
-
(interestPaymentIAssetAmt * priceOracleDatum.price.getOnChainInt) /
|
|
377
|
-
1_000_000n
|
|
378
|
-
);
|
|
379
|
-
})
|
|
380
|
-
.exhaustive();
|
|
381
|
-
|
|
382
384
|
const interestCollectorAdaAmt = calculateFeeFromPercentage(
|
|
383
385
|
iassetDatum.interestCollectorPortionPercentage,
|
|
384
386
|
interestAdaAmt,
|
|
@@ -40,7 +40,9 @@ export const CDPCreatorRedeemer =
|
|
|
40
40
|
export function serialiseCDPCreatorRedeemer(
|
|
41
41
|
params: CDPCreatorRedeemer,
|
|
42
42
|
): Redeemer {
|
|
43
|
-
return Data.to<CDPCreatorRedeemer>(params, CDPCreatorRedeemer, {
|
|
43
|
+
return Data.to<CDPCreatorRedeemer>(params, CDPCreatorRedeemer, {
|
|
44
|
+
canonical: true,
|
|
45
|
+
});
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export function serialiseCDPCreatorDatum(): Datum {
|
|
@@ -65,7 +65,7 @@ export function serialiseLrpDatum(datum: LRPDatum): Datum {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export function serialiseLrpRedeemer(redeemer: LRPRedeemer): Redeemer {
|
|
68
|
-
return Data.to<LRPRedeemer>(redeemer, LRPRedeemer);
|
|
68
|
+
return Data.to<LRPRedeemer>(redeemer, LRPRedeemer, {canonical: true});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function castLrpParams(params: LRPParams): Data {
|
|
@@ -127,7 +127,9 @@ export function serialiseStabilityPoolRedeemer(
|
|
|
127
127
|
DEFAULT_SCHEMA_OPTIONS,
|
|
128
128
|
).toCBORHex(r);
|
|
129
129
|
|
|
130
|
-
return Data.to(Data.from(rdmr, typeof Data), typeof Data, {
|
|
130
|
+
return Data.to(Data.from(rdmr, typeof Data), typeof Data, {
|
|
131
|
+
canonical: false,
|
|
132
|
+
});
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
export function serialiseStabilityPoolDatum(
|
|
@@ -142,7 +144,9 @@ export function serialiseStabilityPoolDatum(
|
|
|
142
144
|
useIndefiniteMaps: useIndefiniteMaps,
|
|
143
145
|
}).toCBORHex(d);
|
|
144
146
|
|
|
145
|
-
return Data.to(Data.from(datum, typeof Data), typeof Data, {
|
|
147
|
+
return Data.to(Data.from(datum, typeof Data), typeof Data, {
|
|
148
|
+
canonical: false,
|
|
149
|
+
});
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
export function parseStabilityPoolDatum(datum: string): StabilityPoolContent {
|
|
@@ -80,5 +80,7 @@ export function serialiseStakingDatum(d: StakingDatum): string {
|
|
|
80
80
|
DEFAULT_SCHEMA_OPTIONS,
|
|
81
81
|
).toCBORHex(d);
|
|
82
82
|
|
|
83
|
-
return Data.to(Data.from(datum, typeof Data), typeof Data, {
|
|
83
|
+
return Data.to(Data.from(datum, typeof Data), typeof Data, {
|
|
84
|
+
canonical: false,
|
|
85
|
+
});
|
|
84
86
|
}
|
|
@@ -33,7 +33,9 @@ export type StakingRedeemer = Data.Static<typeof StakingRedeemerSchema>;
|
|
|
33
33
|
const StakingRedeemer = StakingRedeemerSchema as unknown as StakingRedeemer;
|
|
34
34
|
|
|
35
35
|
export function serialiseStakingRedeemer(redeemer: StakingRedeemer): Redeemer {
|
|
36
|
-
const rdmr = Data.to<StakingRedeemer>(redeemer, StakingRedeemer, {
|
|
36
|
+
const rdmr = Data.to<StakingRedeemer>(redeemer, StakingRedeemer, {
|
|
37
|
+
canonical: false,
|
|
38
|
+
});
|
|
37
39
|
return rdmr;
|
|
38
40
|
}
|
|
39
41
|
|