@indigo-labs/indigo-sdk 0.1.14 → 0.1.16
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 +9 -14
- package/dist/index.mjs +11 -15
- package/package.json +1 -1
- package/src/contracts/lrp.ts +7 -11
- package/src/contracts/stability-pool.ts +48 -44
- package/src/types/indigo/lrp.ts +1 -1
- package/tests/lrp.test.ts +26 -2
package/dist/index.js
CHANGED
|
@@ -1625,7 +1625,7 @@ var StabilityPoolContract = class {
|
|
|
1625
1625
|
action: request
|
|
1626
1626
|
}
|
|
1627
1627
|
};
|
|
1628
|
-
|
|
1628
|
+
const value = {
|
|
1629
1629
|
lovelace: BigInt(
|
|
1630
1630
|
params.stabilityPoolParams.requestCollateralLovelaces + params.stabilityPoolParams.accountAdjustmentFeeLovelaces
|
|
1631
1631
|
),
|
|
@@ -1833,7 +1833,7 @@ var StabilityPoolContract = class {
|
|
|
1833
1833
|
);
|
|
1834
1834
|
const isDepositOrRewardWithdrawal = amount > 0n;
|
|
1835
1835
|
const bigIntMax = (...args) => args.reduce((m, e) => e > m ? e : m);
|
|
1836
|
-
const balanceChange = isDepositOrRewardWithdrawal ? amount : bigIntMax(amount, fromSPInteger(updatedAccountSnapshot.depositVal));
|
|
1836
|
+
const balanceChange = isDepositOrRewardWithdrawal ? amount : bigIntMax(amount, -fromSPInteger(updatedAccountSnapshot.depositVal));
|
|
1837
1837
|
const newAccountSnapshot = {
|
|
1838
1838
|
...updatedAccountSnapshot,
|
|
1839
1839
|
depositVal: spAdd(
|
|
@@ -2817,7 +2817,7 @@ function serialiseLrpDatum(datum) {
|
|
|
2817
2817
|
return import_lucid33.Data.to(datum, LRPDatum);
|
|
2818
2818
|
}
|
|
2819
2819
|
function serialiseLrpRedeemer(redeemer) {
|
|
2820
|
-
return import_lucid33.Data.to(redeemer, LRPRedeemer);
|
|
2820
|
+
return import_lucid33.Data.to(redeemer, LRPRedeemer, { canonical: true });
|
|
2821
2821
|
}
|
|
2822
2822
|
function castLrpParams(params) {
|
|
2823
2823
|
return import_lucid33.Data.castTo(params, LRPParams);
|
|
@@ -2901,6 +2901,8 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2901
2901
|
lovelacesForRedemption
|
|
2902
2902
|
);
|
|
2903
2903
|
const lrpDatum = parseLrpDatum(getInlineDatumOrThrow(lrpUtxo));
|
|
2904
|
+
const outputLovelacesAmt = lrpUtxo.assets.lovelace - lovelacesForRedemption + reimburstmentLovelaces;
|
|
2905
|
+
const assetUnit = (0, import_lucid34.toUnit)(lrpParams.iassetPolicyId, mainLrpDatum.iasset);
|
|
2904
2906
|
return acc.collectFrom(
|
|
2905
2907
|
[lrpUtxo],
|
|
2906
2908
|
serialiseLrpRedeemer(
|
|
@@ -2926,17 +2928,10 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2926
2928
|
lovelacesToSpend: lrpDatum.lovelacesToSpend - lovelacesForRedemption
|
|
2927
2929
|
})
|
|
2928
2930
|
},
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
{
|
|
2934
|
-
currencySymbol: lrpParams.iassetPolicyId,
|
|
2935
|
-
tokenName: mainLrpDatum.iasset
|
|
2936
|
-
},
|
|
2937
|
-
redeemIAssetAmt
|
|
2938
|
-
)
|
|
2939
|
-
)
|
|
2931
|
+
{
|
|
2932
|
+
lovelace: outputLovelacesAmt,
|
|
2933
|
+
[assetUnit]: redeemIAssetAmt + (lrpUtxo.assets[assetUnit] ?? 0n)
|
|
2934
|
+
}
|
|
2940
2935
|
);
|
|
2941
2936
|
}
|
|
2942
2937
|
)(redemptionLrps);
|
package/dist/index.mjs
CHANGED
|
@@ -1504,7 +1504,7 @@ var StabilityPoolContract = class {
|
|
|
1504
1504
|
action: request
|
|
1505
1505
|
}
|
|
1506
1506
|
};
|
|
1507
|
-
|
|
1507
|
+
const value = {
|
|
1508
1508
|
lovelace: BigInt(
|
|
1509
1509
|
params.stabilityPoolParams.requestCollateralLovelaces + params.stabilityPoolParams.accountAdjustmentFeeLovelaces
|
|
1510
1510
|
),
|
|
@@ -1712,7 +1712,7 @@ var StabilityPoolContract = class {
|
|
|
1712
1712
|
);
|
|
1713
1713
|
const isDepositOrRewardWithdrawal = amount > 0n;
|
|
1714
1714
|
const bigIntMax = (...args) => args.reduce((m, e) => e > m ? e : m);
|
|
1715
|
-
const balanceChange = isDepositOrRewardWithdrawal ? amount : bigIntMax(amount, fromSPInteger(updatedAccountSnapshot.depositVal));
|
|
1715
|
+
const balanceChange = isDepositOrRewardWithdrawal ? amount : bigIntMax(amount, -fromSPInteger(updatedAccountSnapshot.depositVal));
|
|
1716
1716
|
const newAccountSnapshot = {
|
|
1717
1717
|
...updatedAccountSnapshot,
|
|
1718
1718
|
depositVal: spAdd(
|
|
@@ -2721,7 +2721,7 @@ function serialiseLrpDatum(datum) {
|
|
|
2721
2721
|
return Data20.to(datum, LRPDatum);
|
|
2722
2722
|
}
|
|
2723
2723
|
function serialiseLrpRedeemer(redeemer) {
|
|
2724
|
-
return Data20.to(redeemer, LRPRedeemer);
|
|
2724
|
+
return Data20.to(redeemer, LRPRedeemer, { canonical: true });
|
|
2725
2725
|
}
|
|
2726
2726
|
function castLrpParams(params) {
|
|
2727
2727
|
return Data20.castTo(params, LRPParams);
|
|
@@ -2731,7 +2731,8 @@ function castLrpParams(params) {
|
|
|
2731
2731
|
import {
|
|
2732
2732
|
addAssets as addAssets3,
|
|
2733
2733
|
unixTimeToSlot as unixTimeToSlot2,
|
|
2734
|
-
slotToUnixTime as slotToUnixTime3
|
|
2734
|
+
slotToUnixTime as slotToUnixTime3,
|
|
2735
|
+
toUnit as toUnit4
|
|
2735
2736
|
} from "@lucid-evolution/lucid";
|
|
2736
2737
|
import { match as match5, P as P5 } from "ts-pattern";
|
|
2737
2738
|
import { unzip, zip } from "fp-ts/lib/Array";
|
|
@@ -2809,6 +2810,8 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2809
2810
|
lovelacesForRedemption
|
|
2810
2811
|
);
|
|
2811
2812
|
const lrpDatum = parseLrpDatum(getInlineDatumOrThrow(lrpUtxo));
|
|
2813
|
+
const outputLovelacesAmt = lrpUtxo.assets.lovelace - lovelacesForRedemption + reimburstmentLovelaces;
|
|
2814
|
+
const assetUnit = toUnit4(lrpParams.iassetPolicyId, mainLrpDatum.iasset);
|
|
2812
2815
|
return acc.collectFrom(
|
|
2813
2816
|
[lrpUtxo],
|
|
2814
2817
|
serialiseLrpRedeemer(
|
|
@@ -2834,17 +2837,10 @@ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutR
|
|
|
2834
2837
|
lovelacesToSpend: lrpDatum.lovelacesToSpend - lovelacesForRedemption
|
|
2835
2838
|
})
|
|
2836
2839
|
},
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
{
|
|
2842
|
-
currencySymbol: lrpParams.iassetPolicyId,
|
|
2843
|
-
tokenName: mainLrpDatum.iasset
|
|
2844
|
-
},
|
|
2845
|
-
redeemIAssetAmt
|
|
2846
|
-
)
|
|
2847
|
-
)
|
|
2840
|
+
{
|
|
2841
|
+
lovelace: outputLovelacesAmt,
|
|
2842
|
+
[assetUnit]: redeemIAssetAmt + (lrpUtxo.assets[assetUnit] ?? 0n)
|
|
2843
|
+
}
|
|
2848
2844
|
);
|
|
2849
2845
|
}
|
|
2850
2846
|
)(redemptionLrps);
|
package/package.json
CHANGED
package/src/contracts/lrp.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
addAssets,
|
|
10
10
|
unixTimeToSlot,
|
|
11
11
|
slotToUnixTime,
|
|
12
|
+
toUnit,
|
|
12
13
|
} from '@lucid-evolution/lucid';
|
|
13
14
|
import {
|
|
14
15
|
addrDetails,
|
|
@@ -158,6 +159,8 @@ export async function redeemLrp(
|
|
|
158
159
|
);
|
|
159
160
|
|
|
160
161
|
const lrpDatum = parseLrpDatum(getInlineDatumOrThrow(lrpUtxo));
|
|
162
|
+
const outputLovelacesAmt = lrpUtxo.assets.lovelace - lovelacesForRedemption + reimburstmentLovelaces;
|
|
163
|
+
const assetUnit = toUnit(lrpParams.iassetPolicyId, mainLrpDatum.iasset);
|
|
161
164
|
|
|
162
165
|
return acc
|
|
163
166
|
.collectFrom(
|
|
@@ -190,17 +193,10 @@ export async function redeemLrp(
|
|
|
190
193
|
lrpDatum.lovelacesToSpend - lovelacesForRedemption,
|
|
191
194
|
}),
|
|
192
195
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
{
|
|
198
|
-
currencySymbol: lrpParams.iassetPolicyId,
|
|
199
|
-
tokenName: mainLrpDatum.iasset,
|
|
200
|
-
},
|
|
201
|
-
redeemIAssetAmt,
|
|
202
|
-
),
|
|
203
|
-
),
|
|
196
|
+
{
|
|
197
|
+
lovelace: outputLovelacesAmt,
|
|
198
|
+
[assetUnit]: redeemIAssetAmt + (lrpUtxo.assets[assetUnit] ?? 0n),
|
|
199
|
+
}
|
|
204
200
|
);
|
|
205
201
|
},
|
|
206
202
|
)(redemptionLrps);
|
|
@@ -51,7 +51,7 @@ export class StabilityPoolContract {
|
|
|
51
51
|
const [pkh, _skh] = await addrDetails(lucid);
|
|
52
52
|
const minLovelaces = BigInt(
|
|
53
53
|
params.stabilityPoolParams.accountCreateFeeLovelaces +
|
|
54
|
-
|
|
54
|
+
params.stabilityPoolParams.requestCollateralLovelaces,
|
|
55
55
|
);
|
|
56
56
|
const datum: StabilityPoolDatum = {
|
|
57
57
|
Account: {
|
|
@@ -83,7 +83,7 @@ export class StabilityPoolContract {
|
|
|
83
83
|
{
|
|
84
84
|
lovelace: minLovelaces,
|
|
85
85
|
[params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
86
|
-
|
|
86
|
+
fromText(asset)]: amount,
|
|
87
87
|
},
|
|
88
88
|
)
|
|
89
89
|
.addSignerKey(pkh.hash);
|
|
@@ -113,6 +113,7 @@ export class StabilityPoolContract {
|
|
|
113
113
|
const oldAccountDatum: AccountContent = parseAccountDatum(
|
|
114
114
|
accountUtxo.datum,
|
|
115
115
|
);
|
|
116
|
+
|
|
116
117
|
const newAccountDatum: AccountContent = {
|
|
117
118
|
...oldAccountDatum,
|
|
118
119
|
request,
|
|
@@ -124,17 +125,20 @@ export class StabilityPoolContract {
|
|
|
124
125
|
},
|
|
125
126
|
};
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
const value = {
|
|
128
129
|
lovelace: BigInt(
|
|
129
130
|
params.stabilityPoolParams.requestCollateralLovelaces +
|
|
130
|
-
|
|
131
|
+
params.stabilityPoolParams.accountAdjustmentFeeLovelaces,
|
|
131
132
|
),
|
|
132
133
|
[params.stabilityPoolParams.accountToken[0].unCurrencySymbol +
|
|
133
|
-
|
|
134
|
+
fromText(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n,
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
if (amount > 0n) {
|
|
137
|
-
value[
|
|
138
|
+
value[
|
|
139
|
+
params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
140
|
+
fromText(asset)
|
|
141
|
+
] = amount;
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
return lucid
|
|
@@ -156,7 +160,7 @@ export class StabilityPoolContract {
|
|
|
156
160
|
},
|
|
157
161
|
}),
|
|
158
162
|
},
|
|
159
|
-
value
|
|
163
|
+
value,
|
|
160
164
|
)
|
|
161
165
|
.addSignerKey(pkh.hash);
|
|
162
166
|
}
|
|
@@ -215,10 +219,10 @@ export class StabilityPoolContract {
|
|
|
215
219
|
{
|
|
216
220
|
lovelace: BigInt(
|
|
217
221
|
params.stabilityPoolParams.requestCollateralLovelaces +
|
|
218
|
-
|
|
222
|
+
params.stabilityPoolParams.accountAdjustmentFeeLovelaces,
|
|
219
223
|
),
|
|
220
224
|
[params.stabilityPoolParams.accountToken[0].unCurrencySymbol +
|
|
221
|
-
|
|
225
|
+
fromText(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n,
|
|
222
226
|
},
|
|
223
227
|
)
|
|
224
228
|
.addSignerKey(pkh.hash);
|
|
@@ -320,16 +324,16 @@ export class StabilityPoolContract {
|
|
|
320
324
|
stabilityPoolUtxo.assets.lovelace +
|
|
321
325
|
BigInt(params.stabilityPoolParams.accountCreateFeeLovelaces),
|
|
322
326
|
[params.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol +
|
|
323
|
-
|
|
327
|
+
fromText(params.stabilityPoolParams.stabilityPoolToken[1].unTokenName)]:
|
|
324
328
|
1n,
|
|
325
329
|
[params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
326
|
-
|
|
330
|
+
fromText(asset)]: stabilityPoolAssetToken + reqAmount,
|
|
327
331
|
};
|
|
328
332
|
|
|
329
333
|
tx.mintAssets(
|
|
330
334
|
{
|
|
331
335
|
[params.stabilityPoolParams.accountToken[0].unCurrencySymbol +
|
|
332
|
-
|
|
336
|
+
fromText(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n,
|
|
333
337
|
},
|
|
334
338
|
Data.to(new Constr(0, [])),
|
|
335
339
|
);
|
|
@@ -370,7 +374,7 @@ export class StabilityPoolContract {
|
|
|
370
374
|
accountUtxo.assets.lovelace -
|
|
371
375
|
BigInt(params.stabilityPoolParams.accountCreateFeeLovelaces),
|
|
372
376
|
[params.stabilityPoolParams.accountToken[0].unCurrencySymbol +
|
|
373
|
-
|
|
377
|
+
fromText(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n,
|
|
374
378
|
},
|
|
375
379
|
);
|
|
376
380
|
} else if ('Adjust' in accountDatum.request) {
|
|
@@ -401,7 +405,7 @@ export class StabilityPoolContract {
|
|
|
401
405
|
|
|
402
406
|
const balanceChange: bigint = isDepositOrRewardWithdrawal
|
|
403
407
|
? amount
|
|
404
|
-
: bigIntMax(amount, fromSPInteger(updatedAccountSnapshot.depositVal));
|
|
408
|
+
: bigIntMax(amount, -fromSPInteger(updatedAccountSnapshot.depositVal));
|
|
405
409
|
const newAccountSnapshot: StabilityPoolSnapshot = {
|
|
406
410
|
...updatedAccountSnapshot,
|
|
407
411
|
depositVal: spAdd(
|
|
@@ -423,9 +427,9 @@ export class StabilityPoolContract {
|
|
|
423
427
|
isDepositOrRewardWithdrawal || newPoolDepositExcludingFee.value === 0n
|
|
424
428
|
? 0n
|
|
425
429
|
: calculateFeeFromPercentage(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
430
|
+
iassetDatum.stabilityPoolWithdrawalFeePercentage,
|
|
431
|
+
-balanceChange,
|
|
432
|
+
);
|
|
429
433
|
const newPoolDeposit = spAdd(
|
|
430
434
|
newPoolDepositExcludingFee,
|
|
431
435
|
mkSPInteger(withdrawalFee),
|
|
@@ -434,12 +438,12 @@ export class StabilityPoolContract {
|
|
|
434
438
|
withdrawalFee === 0n
|
|
435
439
|
? stabilityPoolDatum.snapshot.productVal
|
|
436
440
|
: spMul(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
stabilityPoolDatum.snapshot.productVal,
|
|
442
|
+
spAdd(
|
|
443
|
+
mkSPInteger(1n),
|
|
444
|
+
spDiv(mkSPInteger(withdrawalFee), newPoolDepositExcludingFee),
|
|
445
|
+
),
|
|
446
|
+
);
|
|
443
447
|
const newPoolSum = spAdd(
|
|
444
448
|
stabilityPoolDatum.snapshot.sumVal,
|
|
445
449
|
spDiv(
|
|
@@ -488,14 +492,14 @@ export class StabilityPoolContract {
|
|
|
488
492
|
BigInt(params.stabilityPoolParams.accountAdjustmentFeeLovelaces) -
|
|
489
493
|
reward,
|
|
490
494
|
[params.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol +
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
495
|
+
fromText(
|
|
496
|
+
params.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
|
|
497
|
+
)]: 1n,
|
|
494
498
|
[params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
495
|
-
|
|
499
|
+
fromText(asset)]:
|
|
496
500
|
stabilityPoolUtxo.assets[
|
|
497
|
-
|
|
498
|
-
|
|
501
|
+
params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
502
|
+
fromText(asset)
|
|
499
503
|
] +
|
|
500
504
|
balanceChange +
|
|
501
505
|
withdrawalFee,
|
|
@@ -522,7 +526,7 @@ export class StabilityPoolContract {
|
|
|
522
526
|
BigInt(params.stabilityPoolParams.accountAdjustmentFeeLovelaces) -
|
|
523
527
|
2_000_000n,
|
|
524
528
|
[params.stabilityPoolParams.accountToken[0].unCurrencySymbol +
|
|
525
|
-
|
|
529
|
+
fromText(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n,
|
|
526
530
|
},
|
|
527
531
|
);
|
|
528
532
|
|
|
@@ -547,9 +551,9 @@ export class StabilityPoolContract {
|
|
|
547
551
|
lovelace: reward - rewardLovelacesFee + 2_000_000n,
|
|
548
552
|
...(amount < 0n
|
|
549
553
|
? {
|
|
550
|
-
|
|
554
|
+
[params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
551
555
|
fromText(asset)]: -(amount - withdrawalFee),
|
|
552
|
-
|
|
556
|
+
}
|
|
553
557
|
: {}),
|
|
554
558
|
},
|
|
555
559
|
);
|
|
@@ -588,9 +592,9 @@ export class StabilityPoolContract {
|
|
|
588
592
|
newPoolDepositExcludingFee.value === 0n
|
|
589
593
|
? 0n
|
|
590
594
|
: calculateFeeFromPercentage(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
595
|
+
iassetDatum.stabilityPoolWithdrawalFeePercentage,
|
|
596
|
+
withdrawnAmt.value,
|
|
597
|
+
);
|
|
594
598
|
|
|
595
599
|
const [newPoolDeposit, newPoolProduct] = updatePoolSnapshotWithdrawalFee(
|
|
596
600
|
mkSPInteger(withdrawalFeeAmount),
|
|
@@ -615,7 +619,7 @@ export class StabilityPoolContract {
|
|
|
615
619
|
tx.mintAssets(
|
|
616
620
|
{
|
|
617
621
|
[params.stabilityPoolParams.accountToken[0].unCurrencySymbol +
|
|
618
|
-
|
|
622
|
+
fromText(params.stabilityPoolParams.accountToken[1].unTokenName)]:
|
|
619
623
|
-1n,
|
|
620
624
|
},
|
|
621
625
|
Data.to(new Constr(0, [])),
|
|
@@ -623,8 +627,8 @@ export class StabilityPoolContract {
|
|
|
623
627
|
|
|
624
628
|
const assetOutputAmountForSP =
|
|
625
629
|
stabilityPoolUtxo.assets[
|
|
626
|
-
|
|
627
|
-
|
|
630
|
+
params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
631
|
+
fromText(asset)
|
|
628
632
|
] -
|
|
629
633
|
fromSPInteger(withdrawnAmt) -
|
|
630
634
|
withdrawalFeeAmount;
|
|
@@ -645,14 +649,14 @@ export class StabilityPoolContract {
|
|
|
645
649
|
{
|
|
646
650
|
lovelace: stabilityPoolUtxo.assets.lovelace - reward,
|
|
647
651
|
[params.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol +
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
652
|
+
fromText(
|
|
653
|
+
params.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
|
|
654
|
+
)]: 1n,
|
|
651
655
|
...(assetOutputAmountForSP > 0n
|
|
652
656
|
? {
|
|
653
|
-
|
|
657
|
+
[params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
654
658
|
fromText(asset)]: assetOutputAmountForSP,
|
|
655
|
-
|
|
659
|
+
}
|
|
656
660
|
: {}),
|
|
657
661
|
},
|
|
658
662
|
);
|
|
@@ -677,7 +681,7 @@ export class StabilityPoolContract {
|
|
|
677
681
|
{
|
|
678
682
|
lovelace: accountUtxo.assets.lovelace + reward - rewardLovelacesFee,
|
|
679
683
|
[params.stabilityPoolParams.assetSymbol.unCurrencySymbol +
|
|
680
|
-
|
|
684
|
+
fromText(asset)]: fromSPInteger(withdrawnAmt) - withdrawalFeeAmount,
|
|
681
685
|
},
|
|
682
686
|
);
|
|
683
687
|
}
|
package/src/types/indigo/lrp.ts
CHANGED
|
@@ -51,7 +51,7 @@ export function serialiseLrpDatum(datum: LRPDatum): Datum {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export function serialiseLrpRedeemer(redeemer: LRPRedeemer): Redeemer {
|
|
54
|
-
return Data.to<LRPRedeemer>(redeemer, LRPRedeemer);
|
|
54
|
+
return Data.to<LRPRedeemer>(redeemer, LRPRedeemer, {canonical: true});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export function castLrpParams(params: LRPParams): Data {
|
package/tests/lrp.test.ts
CHANGED
|
@@ -495,7 +495,7 @@ describe('LRP', () => {
|
|
|
495
495
|
);
|
|
496
496
|
});
|
|
497
497
|
|
|
498
|
-
it('
|
|
498
|
+
it('redeem, redeem again and cancel', async () => {
|
|
499
499
|
const network: Network = 'Custom';
|
|
500
500
|
const account1 = generateEmulatorAccount({
|
|
501
501
|
lovelace: 80_000_000_000n, // 80,000 ADA
|
|
@@ -601,15 +601,39 @@ describe('LRP', () => {
|
|
|
601
601
|
|
|
602
602
|
const redeemedLrp = await findSingleOwnLrp();
|
|
603
603
|
|
|
604
|
+
await runAndAwaitTx(
|
|
605
|
+
lucid,
|
|
606
|
+
redeemLrp(
|
|
607
|
+
[[redeemedLrp, redemptionIAssetAmt]],
|
|
608
|
+
lrpRefScriptOutRef,
|
|
609
|
+
await findPriceOracle(
|
|
610
|
+
lucid,
|
|
611
|
+
network,
|
|
612
|
+
testCtx.oracleValHash,
|
|
613
|
+
testCtx.oracleNft,
|
|
614
|
+
),
|
|
615
|
+
await findIAsset(
|
|
616
|
+
lucid,
|
|
617
|
+
testCtx.iassetValHash,
|
|
618
|
+
testCtx.iassetNft,
|
|
619
|
+
toText(iassetTokenName),
|
|
620
|
+
),
|
|
621
|
+
lucid,
|
|
622
|
+
lrpParams,
|
|
623
|
+
network,
|
|
624
|
+
),
|
|
625
|
+
);
|
|
626
|
+
|
|
604
627
|
strictEqual(
|
|
605
628
|
assetClassValueOf(redeemedLrp.assets, redemptionAsset),
|
|
606
629
|
redemptionIAssetAmt,
|
|
607
630
|
'LRP has wrong number of iassets after redemption',
|
|
608
631
|
);
|
|
632
|
+
const closableLrp = await findSingleOwnLrp();
|
|
609
633
|
|
|
610
634
|
await runAndAwaitTx(
|
|
611
635
|
lucid,
|
|
612
|
-
cancelLrp(
|
|
636
|
+
cancelLrp(closableLrp, lrpRefScriptOutRef, lucid),
|
|
613
637
|
);
|
|
614
638
|
});
|
|
615
639
|
|