@indigo-labs/indigo-sdk 0.2.12 → 0.2.13
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/index.mjs +7 -3
- package/package.json +1 -1
- package/src/contracts/lrp/transactions.ts +7 -1
- package/tests/lrp.test.ts +3 -3
- package/tests/staking.test.ts +16 -2
package/dist/index.d.mts
CHANGED
|
@@ -2065,7 +2065,7 @@ declare function adjustLrp(lucid: LucidEvolution, lrpOutRef: OutRef,
|
|
|
2065
2065
|
* A positive amount increases the lovelaces in the LRP,
|
|
2066
2066
|
* and a negative amount takes lovelaces from the LRP.
|
|
2067
2067
|
*/
|
|
2068
|
-
lovelacesAdjustAmt: bigint, sysParams: SystemParams): Promise<TxBuilder>;
|
|
2068
|
+
lovelacesAdjustAmt: bigint, newMaxPrice: OnChainDecimal | undefined, sysParams: SystemParams): Promise<TxBuilder>;
|
|
2069
2069
|
/**
|
|
2070
2070
|
* Create Tx claiming the received iAssets.
|
|
2071
2071
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -2065,7 +2065,7 @@ declare function adjustLrp(lucid: LucidEvolution, lrpOutRef: OutRef,
|
|
|
2065
2065
|
* A positive amount increases the lovelaces in the LRP,
|
|
2066
2066
|
* and a negative amount takes lovelaces from the LRP.
|
|
2067
2067
|
*/
|
|
2068
|
-
lovelacesAdjustAmt: bigint, sysParams: SystemParams): Promise<TxBuilder>;
|
|
2068
|
+
lovelacesAdjustAmt: bigint, newMaxPrice: OnChainDecimal | undefined, sysParams: SystemParams): Promise<TxBuilder>;
|
|
2069
2069
|
/**
|
|
2070
2070
|
* Create Tx claiming the received iAssets.
|
|
2071
2071
|
*/
|
package/dist/index.js
CHANGED
|
@@ -5687,7 +5687,7 @@ async function redeemLrp(redemptionLrpsData, priceOracleOutRef, iassetOutRef, lu
|
|
|
5687
5687
|
)
|
|
5688
5688
|
).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
|
|
5689
5689
|
}
|
|
5690
|
-
async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, sysParams) {
|
|
5690
|
+
async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, newMaxPrice, sysParams) {
|
|
5691
5691
|
const lrpScriptRefUtxo = matchSingle(
|
|
5692
5692
|
await lucid.utxosByOutRef([
|
|
5693
5693
|
fromSystemParamsScriptRef(sysParams.scriptReferences.lrpValidatorRef)
|
|
@@ -5714,13 +5714,17 @@ async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, sysParams) {
|
|
|
5714
5714
|
"Can't adjust negatively by more than available. Also, for adjusting by exactly the amount deposited, a close action should be used instead."
|
|
5715
5715
|
);
|
|
5716
5716
|
}
|
|
5717
|
+
if (newMaxPrice && newMaxPrice.getOnChainInt < 0n) {
|
|
5718
|
+
throw new Error("Max price cannot be negative");
|
|
5719
|
+
}
|
|
5717
5720
|
return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).pay.ToContract(
|
|
5718
5721
|
lrpUtxo.address,
|
|
5719
5722
|
{
|
|
5720
5723
|
kind: "inline",
|
|
5721
5724
|
value: serialiseLrpDatum({
|
|
5722
5725
|
...lrpDatum,
|
|
5723
|
-
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt
|
|
5726
|
+
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt,
|
|
5727
|
+
maxPrice: newMaxPrice ? newMaxPrice : lrpDatum.maxPrice
|
|
5724
5728
|
})
|
|
5725
5729
|
},
|
|
5726
5730
|
(0, import_lucid48.addAssets)(
|
|
@@ -5731,7 +5735,7 @@ async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, sysParams) {
|
|
|
5731
5735
|
).addSignerKey(lrpDatum.owner);
|
|
5732
5736
|
}
|
|
5733
5737
|
async function claimLrp(lucid, lrpOutRef, sysParams) {
|
|
5734
|
-
return adjustLrp(lucid, lrpOutRef, 0n, sysParams);
|
|
5738
|
+
return adjustLrp(lucid, lrpOutRef, 0n, void 0, sysParams);
|
|
5735
5739
|
}
|
|
5736
5740
|
|
|
5737
5741
|
// src/contracts/lrp/scripts.ts
|
package/dist/index.mjs
CHANGED
|
@@ -5529,7 +5529,7 @@ async function redeemLrp(redemptionLrpsData, priceOracleOutRef, iassetOutRef, lu
|
|
|
5529
5529
|
)
|
|
5530
5530
|
).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
|
|
5531
5531
|
}
|
|
5532
|
-
async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, sysParams) {
|
|
5532
|
+
async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, newMaxPrice, sysParams) {
|
|
5533
5533
|
const lrpScriptRefUtxo = matchSingle(
|
|
5534
5534
|
await lucid.utxosByOutRef([
|
|
5535
5535
|
fromSystemParamsScriptRef(sysParams.scriptReferences.lrpValidatorRef)
|
|
@@ -5556,13 +5556,17 @@ async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, sysParams) {
|
|
|
5556
5556
|
"Can't adjust negatively by more than available. Also, for adjusting by exactly the amount deposited, a close action should be used instead."
|
|
5557
5557
|
);
|
|
5558
5558
|
}
|
|
5559
|
+
if (newMaxPrice && newMaxPrice.getOnChainInt < 0n) {
|
|
5560
|
+
throw new Error("Max price cannot be negative");
|
|
5561
|
+
}
|
|
5559
5562
|
return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).pay.ToContract(
|
|
5560
5563
|
lrpUtxo.address,
|
|
5561
5564
|
{
|
|
5562
5565
|
kind: "inline",
|
|
5563
5566
|
value: serialiseLrpDatum({
|
|
5564
5567
|
...lrpDatum,
|
|
5565
|
-
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt
|
|
5568
|
+
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt,
|
|
5569
|
+
maxPrice: newMaxPrice ? newMaxPrice : lrpDatum.maxPrice
|
|
5566
5570
|
})
|
|
5567
5571
|
},
|
|
5568
5572
|
addAssets9(
|
|
@@ -5573,7 +5577,7 @@ async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, sysParams) {
|
|
|
5573
5577
|
).addSignerKey(lrpDatum.owner);
|
|
5574
5578
|
}
|
|
5575
5579
|
async function claimLrp(lucid, lrpOutRef, sysParams) {
|
|
5576
|
-
return adjustLrp(lucid, lrpOutRef, 0n, sysParams);
|
|
5580
|
+
return adjustLrp(lucid, lrpOutRef, 0n, void 0, sysParams);
|
|
5577
5581
|
}
|
|
5578
5582
|
|
|
5579
5583
|
// src/contracts/lrp/scripts.ts
|
package/package.json
CHANGED
|
@@ -173,6 +173,7 @@ export async function adjustLrp(
|
|
|
173
173
|
* and a negative amount takes lovelaces from the LRP.
|
|
174
174
|
*/
|
|
175
175
|
lovelacesAdjustAmt: bigint,
|
|
176
|
+
newMaxPrice: OnChainDecimal | undefined,
|
|
176
177
|
sysParams: SystemParams,
|
|
177
178
|
): Promise<TxBuilder> {
|
|
178
179
|
const lrpScriptRefUtxo = matchSingle(
|
|
@@ -212,6 +213,10 @@ export async function adjustLrp(
|
|
|
212
213
|
);
|
|
213
214
|
}
|
|
214
215
|
|
|
216
|
+
if (newMaxPrice && newMaxPrice.getOnChainInt < 0n) {
|
|
217
|
+
throw new Error('Max price cannot be negative');
|
|
218
|
+
}
|
|
219
|
+
|
|
215
220
|
return lucid
|
|
216
221
|
.newTx()
|
|
217
222
|
.readFrom([lrpScriptRefUtxo])
|
|
@@ -223,6 +228,7 @@ export async function adjustLrp(
|
|
|
223
228
|
value: serialiseLrpDatum({
|
|
224
229
|
...lrpDatum,
|
|
225
230
|
lovelacesToSpend: lrpDatum.lovelacesToSpend + lovelacesAdjustAmt,
|
|
231
|
+
maxPrice: newMaxPrice ? newMaxPrice : lrpDatum.maxPrice,
|
|
226
232
|
}),
|
|
227
233
|
},
|
|
228
234
|
addAssets(
|
|
@@ -242,5 +248,5 @@ export async function claimLrp(
|
|
|
242
248
|
lrpOutRef: OutRef,
|
|
243
249
|
sysParams: SystemParams,
|
|
244
250
|
): Promise<TxBuilder> {
|
|
245
|
-
return adjustLrp(lucid, lrpOutRef, 0n, sysParams);
|
|
251
|
+
return adjustLrp(lucid, lrpOutRef, 0n, undefined, sysParams);
|
|
246
252
|
}
|
package/tests/lrp.test.ts
CHANGED
|
@@ -92,7 +92,7 @@ describe('LRP', () => {
|
|
|
92
92
|
await runAndAwaitTx(
|
|
93
93
|
context.lucid,
|
|
94
94
|
findSingleLrp(context, sysParams, iasset, ownPkh).then((lrp) =>
|
|
95
|
-
adjustLrp(context.lucid, lrp, -1_000_000n, sysParams),
|
|
95
|
+
adjustLrp(context.lucid, lrp, -1_000_000n, undefined, sysParams),
|
|
96
96
|
),
|
|
97
97
|
);
|
|
98
98
|
|
|
@@ -118,7 +118,7 @@ describe('LRP', () => {
|
|
|
118
118
|
|
|
119
119
|
await runAndAwaitTx(
|
|
120
120
|
context.lucid,
|
|
121
|
-
adjustLrp(context.lucid, adjustedUtxo1, 5_000_000n, sysParams),
|
|
121
|
+
adjustLrp(context.lucid, adjustedUtxo1, 5_000_000n, undefined, sysParams),
|
|
122
122
|
);
|
|
123
123
|
|
|
124
124
|
const adjustedUtxo2 = await findSingleLrp(
|
|
@@ -327,7 +327,7 @@ describe('LRP', () => {
|
|
|
327
327
|
|
|
328
328
|
await runAndAwaitTx(
|
|
329
329
|
context.lucid,
|
|
330
|
-
adjustLrp(context.lucid, redeemedLrp, -1_000_000n, sysParams),
|
|
330
|
+
adjustLrp(context.lucid, redeemedLrp, -1_000_000n, undefined, sysParams),
|
|
331
331
|
);
|
|
332
332
|
|
|
333
333
|
const adjustedLrp = await findSingleLrp(context, sysParams, iasset, ownPkh);
|
package/tests/staking.test.ts
CHANGED
|
@@ -54,6 +54,7 @@ test<MyContext>('Staking - Create Position', async ({
|
|
|
54
54
|
test<MyContext>('Staking - Adjust Position', async ({
|
|
55
55
|
lucid,
|
|
56
56
|
users,
|
|
57
|
+
emulator,
|
|
57
58
|
}: MyContext) => {
|
|
58
59
|
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
59
60
|
const [systemParams, _] = await init(lucid, [iusdInitialAssetCfg]);
|
|
@@ -78,6 +79,7 @@ test<MyContext>('Staking - Adjust Position', async ({
|
|
|
78
79
|
1_000_000n,
|
|
79
80
|
systemParams,
|
|
80
81
|
lucid,
|
|
82
|
+
emulator.slot,
|
|
81
83
|
),
|
|
82
84
|
);
|
|
83
85
|
});
|
|
@@ -85,6 +87,7 @@ test<MyContext>('Staking - Adjust Position', async ({
|
|
|
85
87
|
test<MyContext>('Staking - Close Position', async ({
|
|
86
88
|
lucid,
|
|
87
89
|
users,
|
|
90
|
+
emulator,
|
|
88
91
|
}: MyContext) => {
|
|
89
92
|
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
90
93
|
const [systemParams, _] = await init(lucid, [iusdInitialAssetCfg]);
|
|
@@ -104,13 +107,19 @@ test<MyContext>('Staking - Close Position', async ({
|
|
|
104
107
|
|
|
105
108
|
await runAndAwaitTx(
|
|
106
109
|
lucid,
|
|
107
|
-
closeStakingPosition(
|
|
110
|
+
closeStakingPosition(
|
|
111
|
+
myStakingPosition.utxo,
|
|
112
|
+
systemParams,
|
|
113
|
+
lucid,
|
|
114
|
+
emulator.slot,
|
|
115
|
+
),
|
|
108
116
|
);
|
|
109
117
|
});
|
|
110
118
|
|
|
111
119
|
test<MyContext>('Staking - Distribute ADA to Stakers', async ({
|
|
112
120
|
lucid,
|
|
113
121
|
users,
|
|
122
|
+
emulator,
|
|
114
123
|
}: MyContext) => {
|
|
115
124
|
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
116
125
|
const [systemParams, _] = await init(lucid, [iusdInitialAssetCfg]);
|
|
@@ -159,7 +168,12 @@ test<MyContext>('Staking - Distribute ADA to Stakers', async ({
|
|
|
159
168
|
() =>
|
|
160
169
|
runAndAwaitTx(
|
|
161
170
|
lucid,
|
|
162
|
-
closeStakingPosition(
|
|
171
|
+
closeStakingPosition(
|
|
172
|
+
myStakingPosition.utxo,
|
|
173
|
+
systemParams,
|
|
174
|
+
lucid,
|
|
175
|
+
emulator.slot,
|
|
176
|
+
),
|
|
163
177
|
),
|
|
164
178
|
);
|
|
165
179
|
|