@indigo-labs/indigo-sdk 0.3.15 → 0.3.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.
@@ -16,14 +16,12 @@ jobs:
16
16
  uses: actions/checkout@v4
17
17
 
18
18
  - name: Setup Node.js
19
- uses: actions/setup-node@v4
19
+ uses: actions/setup-node@v6
20
20
  with:
21
21
  node-version-file: '.nvmrc'
22
22
 
23
23
  - name: Setup pnpm
24
- uses: pnpm/action-setup@v4
25
- with:
26
- version: latest
24
+ uses: pnpm/action-setup@v6
27
25
 
28
26
  - name: Get pnpm store directory
29
27
  shell: bash
package/dist/index.js CHANGED
@@ -1079,9 +1079,10 @@ function serialiseStabilityPoolRedeemer(r) {
1079
1079
  function parseStabilityPoolRedeemer(datum) {
1080
1080
  try {
1081
1081
  return import_fp_ts2.option.some(
1082
- import_evolution4.Data.withSchema(StabilityPoolRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
1083
- datum
1084
- )
1082
+ import_evolution4.Data.withSchema(
1083
+ StabilityPoolRedeemerSchema,
1084
+ DEFAULT_SCHEMA_OPTIONS
1085
+ ).fromCBORHex(datum)
1085
1086
  );
1086
1087
  } catch (_) {
1087
1088
  return import_fp_ts2.option.none;
@@ -5595,9 +5596,10 @@ function serialiseStakingRedeemer(r) {
5595
5596
  function parseStakingRedeemer(datum) {
5596
5597
  try {
5597
5598
  return import_fp_ts13.option.some(
5598
- import_evolution16.Data.withSchema(StakingRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5599
- datum
5600
- )
5599
+ import_evolution16.Data.withSchema(
5600
+ StakingRedeemerSchema,
5601
+ DEFAULT_SCHEMA_OPTIONS
5602
+ ).fromCBORHex(datum)
5601
5603
  );
5602
5604
  } catch (_) {
5603
5605
  return import_fp_ts13.option.none;
@@ -5892,9 +5894,10 @@ function serialisePollShardRedeemer(r) {
5892
5894
  function parsePollShardRedeemer(datum) {
5893
5895
  try {
5894
5896
  return import_fp_ts14.option.some(
5895
- import_evolution18.Data.withSchema(PollShardRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5896
- datum
5897
- )
5897
+ import_evolution18.Data.withSchema(
5898
+ PollShardRedeemerSchema,
5899
+ DEFAULT_SCHEMA_OPTIONS
5900
+ ).fromCBORHex(datum)
5898
5901
  );
5899
5902
  } catch (_) {
5900
5903
  return import_fp_ts14.option.none;
@@ -11067,9 +11070,7 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11067
11070
  const roundedExpectedOutputLovelaces = (expectedOutputLovelaces / 1000000n + 1n) * 1000000n;
11068
11071
  return lucid.newTx().pay.ToContract(
11069
11072
  (0, import_lucid67.credentialToAddress)(lucid.config().network, {
11070
- hash: (0, import_lucid67.validatorToScriptHash)(
11071
- mkStableswapValidatorFromSP(params.stableswapParams)
11072
- ),
11073
+ hash: params.validatorHashes.stableswapHash,
11073
11074
  type: "Script"
11074
11075
  }),
11075
11076
  {
package/dist/index.mjs CHANGED
@@ -730,9 +730,10 @@ function serialiseStabilityPoolRedeemer(r) {
730
730
  function parseStabilityPoolRedeemer(datum) {
731
731
  try {
732
732
  return O.some(
733
- Data3.withSchema(StabilityPoolRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
734
- datum
735
- )
733
+ Data3.withSchema(
734
+ StabilityPoolRedeemerSchema,
735
+ DEFAULT_SCHEMA_OPTIONS
736
+ ).fromCBORHex(datum)
736
737
  );
737
738
  } catch (_) {
738
739
  return O.none;
@@ -5343,9 +5344,10 @@ function serialiseStakingRedeemer(r) {
5343
5344
  function parseStakingRedeemer(datum) {
5344
5345
  try {
5345
5346
  return O10.some(
5346
- Data27.withSchema(StakingRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5347
- datum
5348
- )
5347
+ Data27.withSchema(
5348
+ StakingRedeemerSchema,
5349
+ DEFAULT_SCHEMA_OPTIONS
5350
+ ).fromCBORHex(datum)
5349
5351
  );
5350
5352
  } catch (_) {
5351
5353
  return O10.none;
@@ -5650,9 +5652,10 @@ function serialisePollShardRedeemer(r) {
5650
5652
  function parsePollShardRedeemer(datum) {
5651
5653
  try {
5652
5654
  return O11.some(
5653
- Data29.withSchema(PollShardRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
5654
- datum
5655
- )
5655
+ Data29.withSchema(
5656
+ PollShardRedeemerSchema,
5657
+ DEFAULT_SCHEMA_OPTIONS
5658
+ ).fromCBORHex(datum)
5656
5659
  );
5657
5660
  } catch (_) {
5658
5661
  return O11.none;
@@ -10950,8 +10953,7 @@ import {
10950
10953
  fromText as fromText15,
10951
10954
  paymentCredentialOf as paymentCredentialOf3,
10952
10955
  sortUTxOs as sortUTxOs2,
10953
- toHex as toHex17,
10954
- validatorToScriptHash as validatorToScriptHash7
10956
+ toHex as toHex17
10955
10957
  } from "@lucid-evolution/lucid";
10956
10958
  import {
10957
10959
  addressFromBech32 as addressFromBech323,
@@ -11002,9 +11004,7 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11002
11004
  const roundedExpectedOutputLovelaces = (expectedOutputLovelaces / 1000000n + 1n) * 1000000n;
11003
11005
  return lucid.newTx().pay.ToContract(
11004
11006
  credentialToAddress6(lucid.config().network, {
11005
- hash: validatorToScriptHash7(
11006
- mkStableswapValidatorFromSP(params.stableswapParams)
11007
- ),
11007
+ hash: params.validatorHashes.stableswapHash,
11008
11008
  type: "Script"
11009
11009
  }),
11010
11010
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
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",
@@ -39,6 +39,7 @@
39
39
  ],
40
40
  "author": "3rd Eye Labs",
41
41
  "license": "MIT",
42
+ "packageManager": "pnpm@10.33.4",
42
43
  "dependencies": {
43
44
  "@3rd-eye-labs/cardano-offchain-common": "1.2.0",
44
45
  "@evolution-sdk/evolution": "^0.3.22",
@@ -0,0 +1,62 @@
1
+ #!/bin/bash
2
+
3
+ # Runs the testsuite X times and collects the mem spent for each run,
4
+ # at the end, it summarises the results (max, median, avg).
5
+ # It's best to run just a single test using `.only` so it's quick.
6
+ #
7
+ # Usage: ./bench.sh <test-file> <benchmark-name> <runs>
8
+ # Example: ./bench.sh interest-collection.test.ts "Interest Collection - Batch Collect 13 CDPs" 20
9
+
10
+ if [ "$#" -ne 3 ]; then
11
+ echo "Usage: $0 <test-file> <benchmark-name> <runs>"
12
+ echo "Example: $0 interest-collection.test.ts \"Interest Collection - Batch Collect 13 CDPs\" 20"
13
+ exit 1
14
+ fi
15
+
16
+ test_file="$1"
17
+ benchmark_name="$2"
18
+ runs="$3"
19
+
20
+ if ! [[ "$runs" =~ ^[0-9]+$ ]] || [ "$runs" -lt 1 ]; then
21
+ echo "Error: <runs> must be a positive integer"
22
+ exit 1
23
+ fi
24
+
25
+ total=0
26
+ values=()
27
+
28
+ for i in $(seq 1 $runs); do
29
+ echo -n "Run $i/$runs... "
30
+ output=$(pnpm test "$test_file" 2>&1)
31
+ mem=$(echo "$output" | grep "$benchmark_name" | grep -oP "'\d+\.\d+%'" | head -1 | tr -d "'%")
32
+
33
+ if [ -z "$mem" ]; then
34
+ echo "ERROR: benchmark '$benchmark_name' not found in output — aborting"
35
+ exit 1
36
+ fi
37
+
38
+ echo "Memory: ${mem}%"
39
+ values+=("$mem")
40
+ total=$(echo "$total + $mem" | bc)
41
+ done
42
+
43
+ sorted=($(printf '%s\n' "${values[@]}" | sort -n))
44
+
45
+ avg=$(echo "scale=3; $total / $runs" | bc)
46
+ min=${sorted[0]}
47
+ max=${sorted[$runs-1]}
48
+
49
+ mid=$(($runs / 2))
50
+ if (( $runs % 2 == 0 )); then
51
+ median=$(echo "scale=3; (${sorted[$mid-1]} + ${sorted[$mid]}) / 2" | bc)
52
+ else
53
+ median=${sorted[$mid]}
54
+ fi
55
+
56
+ echo ""
57
+ echo "=== Benchmark: $benchmark_name ==="
58
+ echo "=== Test file: $test_file | Runs: $runs ==="
59
+ echo "Average : ${avg}%"
60
+ echo "Minimum : ${min}%"
61
+ echo "Maximum : ${max}%"
62
+ echo "Median : ${median}%"
@@ -119,19 +119,24 @@ export function serialisePollShardRedeemer(r: PollShardRedeemer): string {
119
119
  return Data.withSchema(PollShardRedeemerSchema).toCBORHex(r);
120
120
  }
121
121
 
122
- export function parsePollShardRedeemer(datum: string): O.Option<PollShardRedeemer> {
122
+ export function parsePollShardRedeemer(
123
+ datum: string,
124
+ ): O.Option<PollShardRedeemer> {
123
125
  try {
124
126
  return O.some(
125
- Data.withSchema(PollShardRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
126
- datum,
127
- ),
127
+ Data.withSchema(
128
+ PollShardRedeemerSchema,
129
+ DEFAULT_SCHEMA_OPTIONS,
130
+ ).fromCBORHex(datum),
128
131
  );
129
132
  } catch (_) {
130
133
  return O.none;
131
134
  }
132
135
  }
133
136
 
134
- export function parsePollShardRedeemerOrThrow(datum: string): PollShardRedeemer {
137
+ export function parsePollShardRedeemerOrThrow(
138
+ datum: string,
139
+ ): PollShardRedeemer {
135
140
  return F.pipe(
136
141
  parsePollShardRedeemer(datum),
137
142
  O.match(() => {
@@ -236,18 +236,24 @@ export function serialiseStabilityPoolRedeemer(
236
236
  ).toCBORHex(r);
237
237
  }
238
238
 
239
- export function parseStabilityPoolRedeemer(datum: string): O.Option<StabilityPoolRedeemer> {
239
+ export function parseStabilityPoolRedeemer(
240
+ datum: string,
241
+ ): O.Option<StabilityPoolRedeemer> {
240
242
  try {
241
- return O.some(Data.withSchema(StabilityPoolRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
242
- datum,
243
- )
243
+ return O.some(
244
+ Data.withSchema(
245
+ StabilityPoolRedeemerSchema,
246
+ DEFAULT_SCHEMA_OPTIONS,
247
+ ).fromCBORHex(datum),
244
248
  );
245
249
  } catch (_) {
246
250
  return O.none;
247
251
  }
248
252
  }
249
253
 
250
- export function parseStabilityPoolRedeemerOrThrow(datum: string): StabilityPoolRedeemer {
254
+ export function parseStabilityPoolRedeemerOrThrow(
255
+ datum: string,
256
+ ): StabilityPoolRedeemer {
251
257
  return F.pipe(
252
258
  parseStabilityPoolRedeemer(datum),
253
259
  O.match(() => {
@@ -12,13 +12,11 @@ import {
12
12
  toHex,
13
13
  TxBuilder,
14
14
  UTxO,
15
- validatorToScriptHash,
16
15
  } from '@lucid-evolution/lucid';
17
16
  import {
18
17
  fromSystemParamsScriptRef,
19
18
  SystemParams,
20
19
  } from '../../types/system-params';
21
- import { mkStableswapValidatorFromSP } from './scripts';
22
20
  import { estimateUtxoMinLovelace } from '../../utils/lucid-utils';
23
21
  import {
24
22
  parseStableswapOrderDatumOrThrow,
@@ -135,9 +133,7 @@ export async function createStableswapOrder(
135
133
 
136
134
  return lucid.newTx().pay.ToContract(
137
135
  credentialToAddress(lucid.config().network!, {
138
- hash: validatorToScriptHash(
139
- mkStableswapValidatorFromSP(params.stableswapParams),
140
- ),
136
+ hash: params.validatorHashes.stableswapHash,
141
137
  type: 'Script',
142
138
  }),
143
139
  {
@@ -75,9 +75,11 @@ export function serialiseStakingRedeemer(r: StakingRedeemer): string {
75
75
 
76
76
  export function parseStakingRedeemer(datum: string): O.Option<StakingRedeemer> {
77
77
  try {
78
- return O.some(Data.withSchema(StakingRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
79
- datum,
80
- ),
78
+ return O.some(
79
+ Data.withSchema(
80
+ StakingRedeemerSchema,
81
+ DEFAULT_SCHEMA_OPTIONS,
82
+ ).fromCBORHex(datum),
81
83
  );
82
84
  } catch (_) {
83
85
  return O.none;
@@ -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('Liquidate', () => {
1927
+ describe.skip('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
 
package/vitest.config.ts CHANGED
@@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config';
3
3
  export default defineConfig({
4
4
  test: {
5
5
  hookTimeout: 0,
6
- testTimeout: 400_000,
6
+ testTimeout: 500_000,
7
7
  reporters: 'verbose',
8
8
  include: ['./tests/**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
9
9
  globalSetup: './tests/setup.ts',