@indigo-labs/indigo-sdk 0.2.7 → 0.2.8

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
@@ -4786,7 +4786,9 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
4786
4786
  ).addSignerKey(pkh.hash);
4787
4787
  }
4788
4788
  async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, stakingManagerRef) {
4789
- const now = Date.now();
4789
+ const network = lucid.config().network;
4790
+ const currentSlot = lucid.currentSlot();
4791
+ const currentTime = (0, import_lucid35.slotToUnixTime)(network, currentSlot);
4790
4792
  const stakingPositionOut = await findStakingPositionByOutRef(
4791
4793
  stakingPositionRef,
4792
4794
  lucid
@@ -4807,9 +4809,9 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
4807
4809
  const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / rewardSnapshotPrecision;
4808
4810
  const newLockedAmount = updateStakingLockedAmount(
4809
4811
  stakingPositionOut.datum.lockedAmount,
4810
- BigInt(now)
4812
+ BigInt(currentTime)
4811
4813
  );
4812
- return lucid.newTx().validFrom(Date.now()).readFrom([stakingRefScriptUtxo]).collectFrom(
4814
+ return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo]).collectFrom(
4813
4815
  [stakingPositionOut.utxo],
4814
4816
  serialiseStakingRedeemer({
4815
4817
  AdjustStakedAmount: { adjustAmount: amount }
@@ -4846,6 +4848,9 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
4846
4848
  ).addSignerKey((0, import_lucid35.toHex)(stakingPositionOut.datum.owner));
4847
4849
  }
4848
4850
  async function closeStakingPosition(stakingPositionRef, params, lucid, stakingManagerRef) {
4851
+ const network = lucid.config().network;
4852
+ const currentSlot = lucid.currentSlot();
4853
+ const currentTime = (0, import_lucid35.slotToUnixTime)(network, currentSlot);
4849
4854
  const stakingPositionOut = await findStakingPositionByOutRef(
4850
4855
  stakingPositionRef,
4851
4856
  lucid
@@ -4872,7 +4877,7 @@ async function closeStakingPosition(stakingPositionRef, params, lucid, stakingMa
4872
4877
  const currentSnapshotAda = stakingManagerOut.datum.managerSnapshot.snapshotAda;
4873
4878
  const oldSnapshotAda = stakingPositionOut.datum.positionSnapshot.snapshotAda;
4874
4879
  const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / (1000000n * 1000000n);
4875
- return lucid.newTx().validFrom(Date.now()).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], import_lucid35.Data.to(new import_lucid35.Constr(4, []))).collectFrom([stakingManagerOut.utxo], import_lucid35.Data.to(new import_lucid35.Constr(1, []))).pay.ToContract(
4880
+ return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], import_lucid35.Data.to(new import_lucid35.Constr(4, []))).collectFrom([stakingManagerOut.utxo], import_lucid35.Data.to(new import_lucid35.Constr(1, []))).pay.ToContract(
4876
4881
  stakingManagerOut.utxo.address,
4877
4882
  {
4878
4883
  kind: "inline",
package/dist/index.mjs CHANGED
@@ -4544,6 +4544,7 @@ import {
4544
4544
  Data as Data22,
4545
4545
  fromHex as fromHex3,
4546
4546
  fromText as fromText6,
4547
+ slotToUnixTime as slotToUnixTime5,
4547
4548
  toHex as toHex2
4548
4549
  } from "@lucid-evolution/lucid";
4549
4550
  async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
@@ -4603,7 +4604,9 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
4603
4604
  ).addSignerKey(pkh.hash);
4604
4605
  }
4605
4606
  async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, stakingManagerRef) {
4606
- const now = Date.now();
4607
+ const network = lucid.config().network;
4608
+ const currentSlot = lucid.currentSlot();
4609
+ const currentTime = slotToUnixTime5(network, currentSlot);
4607
4610
  const stakingPositionOut = await findStakingPositionByOutRef(
4608
4611
  stakingPositionRef,
4609
4612
  lucid
@@ -4624,9 +4627,9 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
4624
4627
  const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / rewardSnapshotPrecision;
4625
4628
  const newLockedAmount = updateStakingLockedAmount(
4626
4629
  stakingPositionOut.datum.lockedAmount,
4627
- BigInt(now)
4630
+ BigInt(currentTime)
4628
4631
  );
4629
- return lucid.newTx().validFrom(Date.now()).readFrom([stakingRefScriptUtxo]).collectFrom(
4632
+ return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo]).collectFrom(
4630
4633
  [stakingPositionOut.utxo],
4631
4634
  serialiseStakingRedeemer({
4632
4635
  AdjustStakedAmount: { adjustAmount: amount }
@@ -4663,6 +4666,9 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
4663
4666
  ).addSignerKey(toHex2(stakingPositionOut.datum.owner));
4664
4667
  }
4665
4668
  async function closeStakingPosition(stakingPositionRef, params, lucid, stakingManagerRef) {
4669
+ const network = lucid.config().network;
4670
+ const currentSlot = lucid.currentSlot();
4671
+ const currentTime = slotToUnixTime5(network, currentSlot);
4666
4672
  const stakingPositionOut = await findStakingPositionByOutRef(
4667
4673
  stakingPositionRef,
4668
4674
  lucid
@@ -4689,7 +4695,7 @@ async function closeStakingPosition(stakingPositionRef, params, lucid, stakingMa
4689
4695
  const currentSnapshotAda = stakingManagerOut.datum.managerSnapshot.snapshotAda;
4690
4696
  const oldSnapshotAda = stakingPositionOut.datum.positionSnapshot.snapshotAda;
4691
4697
  const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / (1000000n * 1000000n);
4692
- return lucid.newTx().validFrom(Date.now()).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], Data22.to(new Constr3(4, []))).collectFrom([stakingManagerOut.utxo], Data22.to(new Constr3(1, []))).pay.ToContract(
4698
+ return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], Data22.to(new Constr3(4, []))).collectFrom([stakingManagerOut.utxo], Data22.to(new Constr3(1, []))).pay.ToContract(
4693
4699
  stakingManagerOut.utxo.address,
4694
4700
  {
4695
4701
  kind: "inline",
@@ -5413,7 +5419,7 @@ function randomLrpsSubsetSatisfyingTargetLovelaces(iasset, targetLovelacesToSpen
5413
5419
  import {
5414
5420
  addAssets as addAssets9,
5415
5421
  unixTimeToSlot as unixTimeToSlot2,
5416
- slotToUnixTime as slotToUnixTime5
5422
+ slotToUnixTime as slotToUnixTime6
5417
5423
  } from "@lucid-evolution/lucid";
5418
5424
  import { unzip, zip } from "fp-ts/lib/Array";
5419
5425
  async function openLrp(assetTokenName, lovelacesAmt2, maxPrice, lucid, sysParams, lrpStakeCredential) {
@@ -5485,7 +5491,7 @@ async function redeemLrp(redemptionLrpsData, priceOracleOutRef, iassetOutRef, lu
5485
5491
  0n
5486
5492
  );
5487
5493
  return lucid.newTx().validTo(
5488
- slotToUnixTime5(
5494
+ slotToUnixTime6(
5489
5495
  network,
5490
5496
  unixTimeToSlot2(network, Number(priceOracleDatum.expiration)) - 1
5491
5497
  )
@@ -5591,7 +5597,7 @@ async function runCreateScriptRefTx(lucid, scriptRefValidator, network) {
5591
5597
  // src/contracts/leverage/transactions.ts
5592
5598
  import {
5593
5599
  addAssets as addAssets10,
5594
- slotToUnixTime as slotToUnixTime6,
5600
+ slotToUnixTime as slotToUnixTime7,
5595
5601
  Data as Data27
5596
5602
  } from "@lucid-evolution/lucid";
5597
5603
 
@@ -5770,7 +5776,7 @@ function calculateLeverageFromCollateralRatio(iasset, collateralRatioPercentage,
5770
5776
  // src/contracts/leverage/transactions.ts
5771
5777
  async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, iassetOutRef, cdpCreatorOref, interestOracleOref, collectorOref, sysParams, lucid, allLrps, currentSlot) {
5772
5778
  const network = lucid.config().network;
5773
- const currentTime = BigInt(slotToUnixTime6(network, currentSlot));
5779
+ const currentTime = BigInt(slotToUnixTime7(network, currentSlot));
5774
5780
  const [pkh, skh] = await addrDetails(lucid);
5775
5781
  const lrpScriptRefUtxo = matchSingle(
5776
5782
  await lucid.utxosByOutRef([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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",
@@ -6,6 +6,7 @@ import {
6
6
  fromText,
7
7
  LucidEvolution,
8
8
  OutRef,
9
+ slotToUnixTime,
9
10
  toHex,
10
11
  TxBuilder,
11
12
  } from '@lucid-evolution/lucid';
@@ -121,7 +122,10 @@ export async function adjustStakingPosition(
121
122
  lucid: LucidEvolution,
122
123
  stakingManagerRef?: OutRef,
123
124
  ): Promise<TxBuilder> {
124
- const now = Date.now();
125
+
126
+ const network = lucid.config().network!;
127
+ const currentSlot = lucid.currentSlot();
128
+ const currentTime = slotToUnixTime(network, currentSlot);
125
129
 
126
130
  const stakingPositionOut = await findStakingPositionByOutRef(
127
131
  stakingPositionRef,
@@ -158,12 +162,12 @@ export async function adjustStakingPosition(
158
162
 
159
163
  const newLockedAmount = updateStakingLockedAmount(
160
164
  stakingPositionOut.datum.lockedAmount,
161
- BigInt(now),
165
+ BigInt(currentTime),
162
166
  );
163
167
 
164
168
  return lucid
165
169
  .newTx()
166
- .validFrom(Date.now())
170
+ .validFrom(currentTime)
167
171
  .readFrom([stakingRefScriptUtxo])
168
172
  .collectFrom(
169
173
  [stakingPositionOut.utxo],
@@ -212,6 +216,10 @@ export async function closeStakingPosition(
212
216
  lucid: LucidEvolution,
213
217
  stakingManagerRef?: OutRef,
214
218
  ): Promise<TxBuilder> {
219
+ const network = lucid.config().network!;
220
+ const currentSlot = lucid.currentSlot();
221
+ const currentTime = slotToUnixTime(network, currentSlot);
222
+
215
223
  const stakingPositionOut = await findStakingPositionByOutRef(
216
224
  stakingPositionRef,
217
225
  lucid,
@@ -255,7 +263,7 @@ export async function closeStakingPosition(
255
263
 
256
264
  return lucid
257
265
  .newTx()
258
- .validFrom(Date.now())
266
+ .validFrom(currentTime)
259
267
  .readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo])
260
268
  .collectFrom([stakingPositionOut.utxo], Data.to(new Constr(4, [])))
261
269
  .collectFrom([stakingManagerOut.utxo], Data.to(new Constr(1, [])))