@indigo-labs/indigo-sdk 0.3.24 → 0.3.26

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 CHANGED
@@ -3244,7 +3244,7 @@ declare function spMul(a: SPInteger, b: SPInteger): SPInteger;
3244
3244
  declare function spDiv(a: SPInteger, b: SPInteger): SPInteger;
3245
3245
  declare function spZeroNegatives(a: SPInteger): SPInteger;
3246
3246
 
3247
- declare const BASE_MAX_TX_FEE = 1000000n;
3247
+ declare const BASE_MAX_TX_FEE = 1250000n;
3248
3248
  declare const MAX_E2S2S_ENTRIES_COUNT = 5;
3249
3249
  declare const initSumVal: SPInteger;
3250
3250
  declare const initSpState: StateSnapshot;
@@ -4514,7 +4514,7 @@ declare function attachOracle(iasset: Uint8Array<ArrayBufferLike>, collateralAss
4514
4514
  referenceInputs: UTxO[];
4515
4515
  }>;
4516
4516
 
4517
- declare const BASE_MAX_EXECUTION_FEE = 1000000n;
4517
+ declare const BASE_MAX_EXECUTION_FEE = 1620000n;
4518
4518
  declare function createDestinationDatum(datum: Data$1.Data | null, outRef: OutRef): string;
4519
4519
 
4520
4520
  declare function createStableswapOrder(iasset: string, collateralAsset: AssetClass, amount: bigint, minting: boolean, poolDatum: StableswapPoolContent, params: SystemParams, lucid: LucidEvolution, destinationAddress?: Address, destinationInlineDatum?: Core.Data.Data, maxExecutionFee?: bigint, additionalLovelaces?: bigint, maxFeeRatio?: Rational): Promise<TxBuilder>;
package/dist/index.d.ts CHANGED
@@ -3244,7 +3244,7 @@ declare function spMul(a: SPInteger, b: SPInteger): SPInteger;
3244
3244
  declare function spDiv(a: SPInteger, b: SPInteger): SPInteger;
3245
3245
  declare function spZeroNegatives(a: SPInteger): SPInteger;
3246
3246
 
3247
- declare const BASE_MAX_TX_FEE = 1000000n;
3247
+ declare const BASE_MAX_TX_FEE = 1250000n;
3248
3248
  declare const MAX_E2S2S_ENTRIES_COUNT = 5;
3249
3249
  declare const initSumVal: SPInteger;
3250
3250
  declare const initSpState: StateSnapshot;
@@ -4514,7 +4514,7 @@ declare function attachOracle(iasset: Uint8Array<ArrayBufferLike>, collateralAss
4514
4514
  referenceInputs: UTxO[];
4515
4515
  }>;
4516
4516
 
4517
- declare const BASE_MAX_EXECUTION_FEE = 1000000n;
4517
+ declare const BASE_MAX_EXECUTION_FEE = 1620000n;
4518
4518
  declare function createDestinationDatum(datum: Data$1.Data | null, outRef: OutRef): string;
4519
4519
 
4520
4520
  declare function createStableswapOrder(iasset: string, collateralAsset: AssetClass, amount: bigint, minting: boolean, poolDatum: StableswapPoolContent, params: SystemParams, lucid: LucidEvolution, destinationAddress?: Address, destinationInlineDatum?: Core.Data.Data, maxExecutionFee?: bigint, additionalLovelaces?: bigint, maxFeeRatio?: Rational): Promise<TxBuilder>;
package/dist/index.js CHANGED
@@ -1389,7 +1389,7 @@ var mkStabilityPoolValidatorFromSP = (params) => {
1389
1389
  };
1390
1390
 
1391
1391
  // src/contracts/stability-pool/helpers.ts
1392
- var BASE_MAX_TX_FEE = 1000000n;
1392
+ var BASE_MAX_TX_FEE = 1250000n;
1393
1393
  var MAX_E2S2S_ENTRIES_COUNT = 5;
1394
1394
  var newScaleMultiplier = 1000000000n;
1395
1395
  var initSumVal = { value: 0n };
@@ -7218,16 +7218,22 @@ async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
7218
7218
  const datum = {
7219
7219
  owner: (0, import_lucid29.fromHex)(pkh.hash),
7220
7220
  iasset,
7221
- state: initSpState,
7221
+ state: { ...initSpState, depositVal: mkSPInteger(amount) },
7222
7222
  assetSums: [],
7223
7223
  request: "Create",
7224
7224
  lastRequestProcessingTime: 0n
7225
7225
  };
7226
7226
  return lucid.newTx().pay.ToContract(
7227
- (0, import_lucid29.credentialToAddress)(lucid.config().network, {
7228
- hash: sysParams.validatorHashes.stabilityPoolHash,
7229
- type: "Script"
7230
- }),
7227
+ (0, import_lucid29.credentialToAddress)(
7228
+ lucid.config().network,
7229
+ {
7230
+ hash: sysParams.validatorHashes.stabilityPoolHash,
7231
+ type: "Script"
7232
+ },
7233
+ sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
7234
+ sysParams.stabilityPoolParams.stakeCredential
7235
+ ) : void 0
7236
+ ),
7231
7237
  {
7232
7238
  kind: "inline",
7233
7239
  value: serialiseStabilityPoolDatum({ Account: datum })
@@ -7236,7 +7242,9 @@ async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
7236
7242
  (0, import_cardano_offchain_common18.mkAssetsOf)(iassetAssetClass, amount),
7237
7243
  (0, import_cardano_offchain_common18.mkLovelacesOf)(
7238
7244
  // TODO: Calculate a more accurate amount to just cover costs.
7239
- 5000000n
7245
+ // This should cover the account creation fee,
7246
+ // the minimum ADA for the account UTxO and the transaction fee.
7247
+ BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) + 3000000n
7240
7248
  )
7241
7249
  )
7242
7250
  ).addSignerKey(pkh.hash);
@@ -7284,7 +7292,9 @@ async function requestSpAccountAdjustment(amount, accountUtxo, sysParams, lucid)
7284
7292
  (0, import_lucid29.addAssets)(
7285
7293
  (0, import_cardano_offchain_common18.mkLovelacesOf)(
7286
7294
  // TODO: Calculate a more accurate amount to just cover costs.
7287
- 7000000n
7295
+ // This should cover the minimum ADA for 2 UTxOs (account and
7296
+ // rewards withdrawal) and the transaction fee.
7297
+ 5000000n
7288
7298
  ),
7289
7299
  (0, import_cardano_offchain_common18.mkAssetsOf)(
7290
7300
  fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
@@ -7337,7 +7347,8 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
7337
7347
  (0, import_lucid29.addAssets)(
7338
7348
  (0, import_cardano_offchain_common18.mkLovelacesOf)(
7339
7349
  // TODO: Calculate a more accurate amount to just cover costs.
7340
- 5000000n
7350
+ // This should cover the minimum ADA for the rewards UTxO and the transaction fee.
7351
+ 3000000n
7341
7352
  ),
7342
7353
  (0, import_cardano_offchain_common18.mkAssetsOf)(
7343
7354
  fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
@@ -7346,7 +7357,7 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
7346
7357
  )
7347
7358
  ).addSignerKey((0, import_lucid29.toHex)(oldAccountDatum.owner));
7348
7359
  }
7349
- async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
7360
+ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot, txFee) {
7350
7361
  const network = lucid.config().network;
7351
7362
  const currentTime = BigInt((0, import_lucid29.slotToUnixTime)(network, currentSlot));
7352
7363
  const stabilityPoolScriptRef = (0, import_cardano_offchain_common18.matchSingle)(
@@ -7395,7 +7406,46 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7395
7406
  accountUtxo.assets,
7396
7407
  iassetAssetClass
7397
7408
  );
7398
- const poolAddr = mkStabilityPoolAddr(lucid, sysParams);
7409
+ const poolAddr = (0, import_lucid29.credentialToAddress)(
7410
+ lucid.config().network,
7411
+ {
7412
+ hash: sysParams.validatorHashes.stabilityPoolHash,
7413
+ type: "Script"
7414
+ },
7415
+ sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
7416
+ sysParams.stabilityPoolParams.stakeCredential
7417
+ ) : void 0
7418
+ );
7419
+ const accountOutputAdaAmt = (0, import_cardano_offchain_common18.lovelacesAmt)(accountUtxo.assets) - BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) - txFee;
7420
+ const accountTokenVal = (0, import_cardano_offchain_common18.mkAssetsOf)(
7421
+ fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7422
+ 1n
7423
+ );
7424
+ const accountOutputDatum = serialiseStabilityPoolDatum({
7425
+ Account: {
7426
+ owner: accountDatum.owner,
7427
+ iasset: stabilityPoolDatum.iasset,
7428
+ state: {
7429
+ ...stabilityPoolDatum.state,
7430
+ depositVal: mkSPInteger(requestDepositAmt)
7431
+ },
7432
+ assetSums: stabilityPoolDatum.assetStates.map(([key, val]) => [
7433
+ key,
7434
+ val.currentSumVal
7435
+ ]),
7436
+ request: null,
7437
+ lastRequestProcessingTime: currentTime
7438
+ }
7439
+ });
7440
+ const accountOutMinUtxoLovelace = (0, import_cardano_offchain_common18.estimateUtxoMinLovelace)(
7441
+ lucid.config().protocolParameters,
7442
+ poolAddr,
7443
+ accountTokenVal,
7444
+ { InlineDatum: { datum: accountOutputDatum } }
7445
+ );
7446
+ if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
7447
+ throw new Error("Request doesn't have enough ADA to be processed.");
7448
+ }
7399
7449
  tx.readFrom([accountTokenScriptRef]).collectFrom([accountUtxo], {
7400
7450
  kind: "selected",
7401
7451
  inputs: [stabilityPoolUtxo, accountUtxo],
@@ -7407,13 +7457,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7407
7457
  currentTime
7408
7458
  }
7409
7459
  })
7410
- }).mintAssets(
7411
- (0, import_cardano_offchain_common18.mkAssetsOf)(
7412
- fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7413
- 1n
7414
- ),
7415
- import_lucid29.Data.void()
7416
- ).pay.ToContract(
7460
+ }).mintAssets(accountTokenVal, import_lucid29.Data.void()).pay.ToContract(
7417
7461
  poolAddr,
7418
7462
  {
7419
7463
  kind: "inline",
@@ -7446,31 +7490,10 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7446
7490
  poolAddr,
7447
7491
  {
7448
7492
  kind: "inline",
7449
- value: serialiseStabilityPoolDatum({
7450
- Account: {
7451
- owner: accountDatum.owner,
7452
- iasset: stabilityPoolDatum.iasset,
7453
- state: {
7454
- ...stabilityPoolDatum.state,
7455
- depositVal: mkSPInteger(requestDepositAmt)
7456
- },
7457
- assetSums: stabilityPoolDatum.assetStates.map(([key, val]) => [
7458
- key,
7459
- val.currentSumVal
7460
- ]),
7461
- request: null,
7462
- lastRequestProcessingTime: currentTime
7463
- }
7464
- })
7493
+ value: accountOutputDatum
7465
7494
  },
7466
- (0, import_lucid29.addAssets)(
7467
- (0, import_cardano_offchain_common18.mkAssetsOf)(
7468
- fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7469
- 1n
7470
- ),
7471
- (0, import_cardano_offchain_common18.mkLovelacesOf)((0, import_cardano_offchain_common18.lovelacesAmt)(accountUtxo.assets))
7472
- )
7473
- );
7495
+ (0, import_lucid29.addAssets)(accountTokenVal, (0, import_cardano_offchain_common18.mkLovelacesOf)(accountOutputAdaAmt))
7496
+ ).setMinFee(txFee);
7474
7497
  }).with({ Adjust: import_ts_pattern18.P.select() }, async (adjustContent) => {
7475
7498
  const iassetDatum = parseIAssetDatumOrThrow(
7476
7499
  getInlineDatumOrThrow(iAssetUtxo)
@@ -7594,7 +7617,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7594
7617
  accountOutputValWithoutAda,
7595
7618
  { InlineDatum: { datum: accountOutputDat } }
7596
7619
  );
7597
- const accountOutputAdaAmt = (0, import_cardano_offchain_common18.lovelacesAmt)(accountUtxo.assets) - extraOwnerOutputLovelacesAmt;
7620
+ const accountOutputAdaAmt = (0, import_cardano_offchain_common18.lovelacesAmt)(accountUtxo.assets) - extraOwnerOutputLovelacesAmt - txFee;
7598
7621
  if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
7599
7622
  throw new Error("Account doesn't have enough ADA to be processed.");
7600
7623
  }
@@ -7615,8 +7638,11 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7615
7638
  value: ownerOutputDat
7616
7639
  },
7617
7640
  actualOwnerOutputVal
7618
- );
7641
+ ).setMinFee(txFee);
7619
7642
  }).with({ Close: import_ts_pattern18.P.select() }, async (closeContent) => {
7643
+ if (txFee > closeContent.maxTxFee) {
7644
+ throw new Error("Account doesn't allow current transaction fee.");
7645
+ }
7620
7646
  const accountTokenScriptRef = (0, import_cardano_offchain_common18.matchSingle)(
7621
7647
  await lucid.utxosByOutRef([
7622
7648
  fromSystemParamsScriptRef(
@@ -7713,14 +7739,38 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7713
7739
  })
7714
7740
  },
7715
7741
  (0, import_lucid29.addAssets)(
7716
- (0, import_cardano_offchain_common18.mkLovelacesOf)((0, import_cardano_offchain_common18.lovelacesAmt)(accountUtxo.assets)),
7742
+ (0, import_cardano_offchain_common18.mkLovelacesOf)((0, import_cardano_offchain_common18.lovelacesAmt)(accountUtxo.assets) - txFee),
7717
7743
  reward,
7718
7744
  (0, import_cardano_offchain_common18.mkAssetsOf)(iassetAssetClass, withdrawnAmt - withdrawalFeeAmt)
7719
7745
  )
7720
- );
7746
+ ).setMinFee(txFee);
7721
7747
  }).exhaustive();
7722
7748
  return tx;
7723
7749
  }
7750
+ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
7751
+ const draftTx = processSpRequestAuxiliary(
7752
+ stabilityPoolUtxo,
7753
+ accountUtxo,
7754
+ iAssetUtxo,
7755
+ allE2s2sSnapshotOrefs,
7756
+ sysParams,
7757
+ lucid,
7758
+ currentSlot,
7759
+ // Placeholder transation fee
7760
+ 1n
7761
+ );
7762
+ const fee = (await (await draftTx).complete()).toTransaction().body().fee();
7763
+ return processSpRequestAuxiliary(
7764
+ stabilityPoolUtxo,
7765
+ accountUtxo,
7766
+ iAssetUtxo,
7767
+ allE2s2sSnapshotOrefs,
7768
+ sysParams,
7769
+ lucid,
7770
+ currentSlot,
7771
+ fee
7772
+ );
7773
+ }
7724
7774
  async function createE2s2sSnapshots(stabilityPoolOref, sysParams, lucid) {
7725
7775
  const stabilityPoolRefScriptUtxo = (0, import_cardano_offchain_common18.matchSingle)(
7726
7776
  await lucid.utxosByOutRef([
@@ -11119,7 +11169,7 @@ function parseStableswapOrderRedeemerOrThrow(redeemerCborHex) {
11119
11169
 
11120
11170
  // src/contracts/stableswap/helpers.ts
11121
11171
  var import_evolution21 = require("@evolution-sdk/evolution");
11122
- var BASE_MAX_EXECUTION_FEE = 1000000n;
11172
+ var BASE_MAX_EXECUTION_FEE = 1620000n;
11123
11173
  function createDestinationDatum(datum, outRef) {
11124
11174
  if (!datum) {
11125
11175
  return serialiseStableswapOutputDatum([
@@ -11443,7 +11493,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11443
11493
  stableswapPoolUtxo.assets,
11444
11494
  (0, import_cardano_offchain_common30.mkAssetsOf)(collateralAc, collateralAmtChangePool)
11445
11495
  ) : stableswapPoolUtxo.assets
11446
- ).setMinFee(2055720n);
11496
+ ).setMinFee(stableswapOrderOrefs.length > 1 ? 1498875n : 1030000n);
11447
11497
  if (amountToMint !== 0n) {
11448
11498
  tx.mintAssets((0, import_cardano_offchain_common30.mkAssetsOf)(iassetAc, amountToMint), import_lucid67.Data.void());
11449
11499
  }
package/dist/index.mjs CHANGED
@@ -1050,7 +1050,7 @@ var mkStabilityPoolValidatorFromSP = (params) => {
1050
1050
  };
1051
1051
 
1052
1052
  // src/contracts/stability-pool/helpers.ts
1053
- var BASE_MAX_TX_FEE = 1000000n;
1053
+ var BASE_MAX_TX_FEE = 1250000n;
1054
1054
  var MAX_E2S2S_ENTRIES_COUNT = 5;
1055
1055
  var newScaleMultiplier = 1000000000n;
1056
1056
  var initSumVal = { value: 0n };
@@ -6957,11 +6957,11 @@ var mkGovValidatorFromSP = (params) => {
6957
6957
  import {
6958
6958
  fromText as fromText5,
6959
6959
  Data as Data32,
6960
- credentialToAddress as credentialToAddress3,
6961
6960
  fromHex as fromHex9,
6962
6961
  toHex as toHex9,
6963
6962
  addAssets as addAssets9,
6964
- slotToUnixTime as slotToUnixTime7
6963
+ slotToUnixTime as slotToUnixTime7,
6964
+ credentialToAddress as credentialToAddress3
6965
6965
  } from "@lucid-evolution/lucid";
6966
6966
  import {
6967
6967
  adaAssetClass as adaAssetClass4,
@@ -6988,16 +6988,22 @@ async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
6988
6988
  const datum = {
6989
6989
  owner: fromHex9(pkh.hash),
6990
6990
  iasset,
6991
- state: initSpState,
6991
+ state: { ...initSpState, depositVal: mkSPInteger(amount) },
6992
6992
  assetSums: [],
6993
6993
  request: "Create",
6994
6994
  lastRequestProcessingTime: 0n
6995
6995
  };
6996
6996
  return lucid.newTx().pay.ToContract(
6997
- credentialToAddress3(lucid.config().network, {
6998
- hash: sysParams.validatorHashes.stabilityPoolHash,
6999
- type: "Script"
7000
- }),
6997
+ credentialToAddress3(
6998
+ lucid.config().network,
6999
+ {
7000
+ hash: sysParams.validatorHashes.stabilityPoolHash,
7001
+ type: "Script"
7002
+ },
7003
+ sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
7004
+ sysParams.stabilityPoolParams.stakeCredential
7005
+ ) : void 0
7006
+ ),
7001
7007
  {
7002
7008
  kind: "inline",
7003
7009
  value: serialiseStabilityPoolDatum({ Account: datum })
@@ -7006,7 +7012,9 @@ async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
7006
7012
  mkAssetsOf7(iassetAssetClass, amount),
7007
7013
  mkLovelacesOf4(
7008
7014
  // TODO: Calculate a more accurate amount to just cover costs.
7009
- 5000000n
7015
+ // This should cover the account creation fee,
7016
+ // the minimum ADA for the account UTxO and the transaction fee.
7017
+ BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) + 3000000n
7010
7018
  )
7011
7019
  )
7012
7020
  ).addSignerKey(pkh.hash);
@@ -7054,7 +7062,9 @@ async function requestSpAccountAdjustment(amount, accountUtxo, sysParams, lucid)
7054
7062
  addAssets9(
7055
7063
  mkLovelacesOf4(
7056
7064
  // TODO: Calculate a more accurate amount to just cover costs.
7057
- 7000000n
7065
+ // This should cover the minimum ADA for 2 UTxOs (account and
7066
+ // rewards withdrawal) and the transaction fee.
7067
+ 5000000n
7058
7068
  ),
7059
7069
  mkAssetsOf7(
7060
7070
  fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
@@ -7107,7 +7117,8 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
7107
7117
  addAssets9(
7108
7118
  mkLovelacesOf4(
7109
7119
  // TODO: Calculate a more accurate amount to just cover costs.
7110
- 5000000n
7120
+ // This should cover the minimum ADA for the rewards UTxO and the transaction fee.
7121
+ 3000000n
7111
7122
  ),
7112
7123
  mkAssetsOf7(
7113
7124
  fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
@@ -7116,7 +7127,7 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
7116
7127
  )
7117
7128
  ).addSignerKey(toHex9(oldAccountDatum.owner));
7118
7129
  }
7119
- async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
7130
+ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot, txFee) {
7120
7131
  const network = lucid.config().network;
7121
7132
  const currentTime = BigInt(slotToUnixTime7(network, currentSlot));
7122
7133
  const stabilityPoolScriptRef = matchSingle3(
@@ -7165,7 +7176,46 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7165
7176
  accountUtxo.assets,
7166
7177
  iassetAssetClass
7167
7178
  );
7168
- const poolAddr = mkStabilityPoolAddr(lucid, sysParams);
7179
+ const poolAddr = credentialToAddress3(
7180
+ lucid.config().network,
7181
+ {
7182
+ hash: sysParams.validatorHashes.stabilityPoolHash,
7183
+ type: "Script"
7184
+ },
7185
+ sysParams.stabilityPoolParams.stakeCredential != null ? fromSysParamsCredential(
7186
+ sysParams.stabilityPoolParams.stakeCredential
7187
+ ) : void 0
7188
+ );
7189
+ const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - BigInt(sysParams.stabilityPoolParams.accountCreateFeeLovelaces) - txFee;
7190
+ const accountTokenVal = mkAssetsOf7(
7191
+ fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7192
+ 1n
7193
+ );
7194
+ const accountOutputDatum = serialiseStabilityPoolDatum({
7195
+ Account: {
7196
+ owner: accountDatum.owner,
7197
+ iasset: stabilityPoolDatum.iasset,
7198
+ state: {
7199
+ ...stabilityPoolDatum.state,
7200
+ depositVal: mkSPInteger(requestDepositAmt)
7201
+ },
7202
+ assetSums: stabilityPoolDatum.assetStates.map(([key, val]) => [
7203
+ key,
7204
+ val.currentSumVal
7205
+ ]),
7206
+ request: null,
7207
+ lastRequestProcessingTime: currentTime
7208
+ }
7209
+ });
7210
+ const accountOutMinUtxoLovelace = estimateUtxoMinLovelace3(
7211
+ lucid.config().protocolParameters,
7212
+ poolAddr,
7213
+ accountTokenVal,
7214
+ { InlineDatum: { datum: accountOutputDatum } }
7215
+ );
7216
+ if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
7217
+ throw new Error("Request doesn't have enough ADA to be processed.");
7218
+ }
7169
7219
  tx.readFrom([accountTokenScriptRef]).collectFrom([accountUtxo], {
7170
7220
  kind: "selected",
7171
7221
  inputs: [stabilityPoolUtxo, accountUtxo],
@@ -7177,13 +7227,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7177
7227
  currentTime
7178
7228
  }
7179
7229
  })
7180
- }).mintAssets(
7181
- mkAssetsOf7(
7182
- fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7183
- 1n
7184
- ),
7185
- Data32.void()
7186
- ).pay.ToContract(
7230
+ }).mintAssets(accountTokenVal, Data32.void()).pay.ToContract(
7187
7231
  poolAddr,
7188
7232
  {
7189
7233
  kind: "inline",
@@ -7216,31 +7260,10 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7216
7260
  poolAddr,
7217
7261
  {
7218
7262
  kind: "inline",
7219
- value: serialiseStabilityPoolDatum({
7220
- Account: {
7221
- owner: accountDatum.owner,
7222
- iasset: stabilityPoolDatum.iasset,
7223
- state: {
7224
- ...stabilityPoolDatum.state,
7225
- depositVal: mkSPInteger(requestDepositAmt)
7226
- },
7227
- assetSums: stabilityPoolDatum.assetStates.map(([key, val]) => [
7228
- key,
7229
- val.currentSumVal
7230
- ]),
7231
- request: null,
7232
- lastRequestProcessingTime: currentTime
7233
- }
7234
- })
7263
+ value: accountOutputDatum
7235
7264
  },
7236
- addAssets9(
7237
- mkAssetsOf7(
7238
- fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
7239
- 1n
7240
- ),
7241
- mkLovelacesOf4(lovelacesAmt2(accountUtxo.assets))
7242
- )
7243
- );
7265
+ addAssets9(accountTokenVal, mkLovelacesOf4(accountOutputAdaAmt))
7266
+ ).setMinFee(txFee);
7244
7267
  }).with({ Adjust: P17.select() }, async (adjustContent) => {
7245
7268
  const iassetDatum = parseIAssetDatumOrThrow(
7246
7269
  getInlineDatumOrThrow(iAssetUtxo)
@@ -7364,7 +7387,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7364
7387
  accountOutputValWithoutAda,
7365
7388
  { InlineDatum: { datum: accountOutputDat } }
7366
7389
  );
7367
- const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - extraOwnerOutputLovelacesAmt;
7390
+ const accountOutputAdaAmt = lovelacesAmt2(accountUtxo.assets) - extraOwnerOutputLovelacesAmt - txFee;
7368
7391
  if (accountOutputAdaAmt < accountOutMinUtxoLovelace) {
7369
7392
  throw new Error("Account doesn't have enough ADA to be processed.");
7370
7393
  }
@@ -7385,8 +7408,11 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7385
7408
  value: ownerOutputDat
7386
7409
  },
7387
7410
  actualOwnerOutputVal
7388
- );
7411
+ ).setMinFee(txFee);
7389
7412
  }).with({ Close: P17.select() }, async (closeContent) => {
7413
+ if (txFee > closeContent.maxTxFee) {
7414
+ throw new Error("Account doesn't allow current transaction fee.");
7415
+ }
7390
7416
  const accountTokenScriptRef = matchSingle3(
7391
7417
  await lucid.utxosByOutRef([
7392
7418
  fromSystemParamsScriptRef(
@@ -7483,14 +7509,38 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
7483
7509
  })
7484
7510
  },
7485
7511
  addAssets9(
7486
- mkLovelacesOf4(lovelacesAmt2(accountUtxo.assets)),
7512
+ mkLovelacesOf4(lovelacesAmt2(accountUtxo.assets) - txFee),
7487
7513
  reward,
7488
7514
  mkAssetsOf7(iassetAssetClass, withdrawnAmt - withdrawalFeeAmt)
7489
7515
  )
7490
- );
7516
+ ).setMinFee(txFee);
7491
7517
  }).exhaustive();
7492
7518
  return tx;
7493
7519
  }
7520
+ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
7521
+ const draftTx = processSpRequestAuxiliary(
7522
+ stabilityPoolUtxo,
7523
+ accountUtxo,
7524
+ iAssetUtxo,
7525
+ allE2s2sSnapshotOrefs,
7526
+ sysParams,
7527
+ lucid,
7528
+ currentSlot,
7529
+ // Placeholder transation fee
7530
+ 1n
7531
+ );
7532
+ const fee = (await (await draftTx).complete()).toTransaction().body().fee();
7533
+ return processSpRequestAuxiliary(
7534
+ stabilityPoolUtxo,
7535
+ accountUtxo,
7536
+ iAssetUtxo,
7537
+ allE2s2sSnapshotOrefs,
7538
+ sysParams,
7539
+ lucid,
7540
+ currentSlot,
7541
+ fee
7542
+ );
7543
+ }
7494
7544
  async function createE2s2sSnapshots(stabilityPoolOref, sysParams, lucid) {
7495
7545
  const stabilityPoolRefScriptUtxo = matchSingle3(
7496
7546
  await lucid.utxosByOutRef([
@@ -11021,7 +11071,7 @@ function parseStableswapOrderRedeemerOrThrow(redeemerCborHex) {
11021
11071
 
11022
11072
  // src/contracts/stableswap/helpers.ts
11023
11073
  import { Data as Data52 } from "@evolution-sdk/evolution";
11024
- var BASE_MAX_EXECUTION_FEE = 1000000n;
11074
+ var BASE_MAX_EXECUTION_FEE = 1620000n;
11025
11075
  function createDestinationDatum(datum, outRef) {
11026
11076
  if (!datum) {
11027
11077
  return serialiseStableswapOutputDatum([
@@ -11364,7 +11414,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11364
11414
  stableswapPoolUtxo.assets,
11365
11415
  mkAssetsOf16(collateralAc, collateralAmtChangePool)
11366
11416
  ) : stableswapPoolUtxo.assets
11367
- ).setMinFee(2055720n);
11417
+ ).setMinFee(stableswapOrderOrefs.length > 1 ? 1498875n : 1030000n);
11368
11418
  if (amountToMint !== 0n) {
11369
11419
  tx.mintAssets(mkAssetsOf16(iassetAc, amountToMint), Data53.void());
11370
11420
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
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",
@@ -53,7 +53,7 @@ import {
53
53
  } from '../../types/system-params';
54
54
  import { mkStabilityPoolValidatorFromSP } from './scripts';
55
55
 
56
- export const BASE_MAX_TX_FEE = 1_000_000n;
56
+ export const BASE_MAX_TX_FEE = 1_250_000n;
57
57
 
58
58
  export const MAX_E2S2S_ENTRIES_COUNT = 5;
59
59
  const newScaleMultiplier = 1_000_000_000n;