@indigo-labs/indigo-sdk 0.3.17 → 0.3.18

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 CHANGED
@@ -3459,17 +3459,28 @@ async function treasurySplit(treasuryOutRef, lucid, sysParams) {
3459
3459
  );
3460
3460
  const [adaAsset, ...nonAdaAssets] = Object.keys(treasuryUtxo.assets);
3461
3461
  const tx = lucid.newTx().collectFrom([treasuryUtxo], serialiseTreasuryRedeemer("Split")).readFrom([treasuryScriptRefUtxo]);
3462
+ let paidLovelaces = 0n;
3462
3463
  for (const asset of import_fp_ts11.array.reverse(nonAdaAssets.sort())) {
3464
+ const utxoMinLovelace = (0, import_cardano_offchain_common11.estimateUtxoMinLovelace)(
3465
+ lucid.config().protocolParameters,
3466
+ mkTreasuryAddr(lucid, sysParams),
3467
+ { [asset]: treasuryUtxo.assets[asset] },
3468
+ { InlineDatum: { datum: import_lucid11.Data.void() } }
3469
+ );
3470
+ paidLovelaces += utxoMinLovelace;
3463
3471
  tx.pay.ToContract(
3464
3472
  mkTreasuryAddr(lucid, sysParams),
3465
3473
  { kind: "inline", value: import_lucid11.Data.void() },
3466
- { [asset]: treasuryUtxo.assets[asset] }
3474
+ (0, import_lucid11.addAssets)(
3475
+ { [asset]: treasuryUtxo.assets[asset] },
3476
+ (0, import_cardano_offchain_common11.mkLovelacesOf)(utxoMinLovelace)
3477
+ )
3467
3478
  );
3468
3479
  }
3469
3480
  tx.pay.ToContract(
3470
3481
  mkTreasuryAddr(lucid, sysParams),
3471
3482
  { kind: "inline", value: import_lucid11.Data.void() },
3472
- { [adaAsset]: treasuryUtxo.assets[adaAsset] }
3483
+ { [adaAsset]: treasuryUtxo.assets[adaAsset] - paidLovelaces }
3473
3484
  );
3474
3485
  return tx;
3475
3486
  }
package/dist/index.mjs CHANGED
@@ -2677,6 +2677,7 @@ import {
2677
2677
  } from "@lucid-evolution/lucid";
2678
2678
  import {
2679
2679
  adaAssetClass,
2680
+ estimateUtxoMinLovelace as estimateUtxoMinLovelace2,
2680
2681
  mkAssetsOf as mkAssetsOf4,
2681
2682
  mkLovelacesOf,
2682
2683
  negateAssets
@@ -3174,17 +3175,28 @@ async function treasurySplit(treasuryOutRef, lucid, sysParams) {
3174
3175
  );
3175
3176
  const [adaAsset, ...nonAdaAssets] = Object.keys(treasuryUtxo.assets);
3176
3177
  const tx = lucid.newTx().collectFrom([treasuryUtxo], serialiseTreasuryRedeemer("Split")).readFrom([treasuryScriptRefUtxo]);
3178
+ let paidLovelaces = 0n;
3177
3179
  for (const asset of A6.reverse(nonAdaAssets.sort())) {
3180
+ const utxoMinLovelace = estimateUtxoMinLovelace2(
3181
+ lucid.config().protocolParameters,
3182
+ mkTreasuryAddr(lucid, sysParams),
3183
+ { [asset]: treasuryUtxo.assets[asset] },
3184
+ { InlineDatum: { datum: Data17.void() } }
3185
+ );
3186
+ paidLovelaces += utxoMinLovelace;
3178
3187
  tx.pay.ToContract(
3179
3188
  mkTreasuryAddr(lucid, sysParams),
3180
3189
  { kind: "inline", value: Data17.void() },
3181
- { [asset]: treasuryUtxo.assets[asset] }
3190
+ addAssets5(
3191
+ { [asset]: treasuryUtxo.assets[asset] },
3192
+ mkLovelacesOf(utxoMinLovelace)
3193
+ )
3182
3194
  );
3183
3195
  }
3184
3196
  tx.pay.ToContract(
3185
3197
  mkTreasuryAddr(lucid, sysParams),
3186
3198
  { kind: "inline", value: Data17.void() },
3187
- { [adaAsset]: treasuryUtxo.assets[adaAsset] }
3199
+ { [adaAsset]: treasuryUtxo.assets[adaAsset] - paidLovelaces }
3188
3200
  );
3189
3201
  return tx;
3190
3202
  }
@@ -6957,7 +6969,7 @@ import {
6957
6969
  addressFromBech32 as addressFromBech322,
6958
6970
  addressToBech32 as addressToBech322,
6959
6971
  assetClassValueOf as assetClassValueOf5,
6960
- estimateUtxoMinLovelace as estimateUtxoMinLovelace2,
6972
+ estimateUtxoMinLovelace as estimateUtxoMinLovelace3,
6961
6973
  lovelacesAmt as lovelacesAmt2,
6962
6974
  matchSingle as matchSingle3,
6963
6975
  mkAssetsOf as mkAssetsOf7,
@@ -7320,7 +7332,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7320
7332
  outputIndex: BigInt(accountUtxo.outputIndex)
7321
7333
  }
7322
7334
  });
7323
- const ownerOutputMinUtxoLovelace = estimateUtxoMinLovelace2(
7335
+ const ownerOutputMinUtxoLovelace = estimateUtxoMinLovelace3(
7324
7336
  lucid.config().protocolParameters,
7325
7337
  outputAddress,
7326
7338
  theoreticalOwnerOutputVal,
@@ -7349,7 +7361,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7349
7361
  fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7350
7362
  1n
7351
7363
  );
7352
- const accountOutMinUtxoLovelace = estimateUtxoMinLovelace2(
7364
+ const accountOutMinUtxoLovelace = estimateUtxoMinLovelace3(
7353
7365
  lucid.config().protocolParameters,
7354
7366
  stabilityPoolUtxo.address,
7355
7367
  accountOutputValWithoutAda,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -16,6 +16,7 @@ import { matchSingle } from '../../utils/utils';
16
16
  import {
17
17
  adaAssetClass,
18
18
  AssetClass,
19
+ estimateUtxoMinLovelace,
19
20
  mkAssetsOf,
20
21
  mkLovelacesOf,
21
22
  negateAssets,
@@ -245,18 +246,32 @@ export async function treasurySplit(
245
246
  .collectFrom([treasuryUtxo], serialiseTreasuryRedeemer('Split'))
246
247
  .readFrom([treasuryScriptRefUtxo]);
247
248
 
249
+ let paidLovelaces = 0n;
250
+
248
251
  for (const asset of A.reverse(nonAdaAssets.sort())) {
252
+ const utxoMinLovelace = estimateUtxoMinLovelace(
253
+ lucid.config().protocolParameters!,
254
+ mkTreasuryAddr(lucid, sysParams),
255
+ { [asset]: treasuryUtxo.assets[asset] },
256
+ { InlineDatum: { datum: Data.void() } },
257
+ );
258
+
259
+ paidLovelaces += utxoMinLovelace;
260
+
249
261
  tx.pay.ToContract(
250
262
  mkTreasuryAddr(lucid, sysParams),
251
263
  { kind: 'inline', value: Data.void() },
252
- { [asset]: treasuryUtxo.assets[asset] },
264
+ addAssets(
265
+ { [asset]: treasuryUtxo.assets[asset] },
266
+ mkLovelacesOf(utxoMinLovelace),
267
+ ),
253
268
  );
254
269
  }
255
270
 
256
271
  tx.pay.ToContract(
257
272
  mkTreasuryAddr(lucid, sysParams),
258
273
  { kind: 'inline', value: Data.void() },
259
- { [adaAsset]: treasuryUtxo.assets[adaAsset] },
274
+ { [adaAsset]: treasuryUtxo.assets[adaAsset] - paidLovelaces },
260
275
  );
261
276
 
262
277
  return tx;
@@ -1406,7 +1406,7 @@ describe('Gov', () => {
1406
1406
  );
1407
1407
 
1408
1408
  await benchmarkAndAwaitTx(
1409
- 'Prepare withdrawal',
1409
+ 'Prepare withdrawal with 7 inputs / assets',
1410
1410
  await treasuryPrepareWithdrawal(
1411
1411
  await findAllTreasuryUtxosWithNonAdaAsset(
1412
1412
  context.lucid,
@@ -1924,7 +1924,7 @@ describe('Stability pool', () => {
1924
1924
  });
1925
1925
 
1926
1926
  // These are the most significant tests for benchmarking the maximum number of collateral assets supported.
1927
- describe.skip('Liquidate', () => {
1927
+ describe('Liquidate', () => {
1928
1928
  test<MyContext>('Liquidate with 10 reward assets in the pool - collecting with 2 assets in treasury', async (context: MyContext) => {
1929
1929
  context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
1930
1930