@indigo-labs/indigo-sdk 0.2.41 → 0.3.0

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.
Files changed (201) hide show
  1. package/.github/workflows/ci.yml +4 -2
  2. package/dist/index.d.mts +3008 -2194
  3. package/dist/index.d.ts +3008 -2194
  4. package/dist/index.js +9827 -6194
  5. package/dist/index.mjs +8591 -4809
  6. package/package.json +14 -3
  7. package/src/contracts/cdp/helpers.ts +68 -72
  8. package/src/contracts/cdp/scripts.ts +50 -13
  9. package/src/contracts/cdp/transactions.ts +831 -545
  10. package/src/contracts/cdp/types-new.ts +256 -0
  11. package/src/contracts/cdp/types.ts +26 -144
  12. package/src/contracts/cdp-creator/scripts.ts +15 -9
  13. package/src/contracts/cdp-creator/types-new.ts +50 -0
  14. package/src/contracts/cdp-creator/types.ts +5 -31
  15. package/src/contracts/collector/scripts.ts +1 -1
  16. package/src/contracts/collector/transactions.ts +23 -13
  17. package/src/contracts/collector/types-new.ts +17 -0
  18. package/src/contracts/execute/scripts.ts +19 -10
  19. package/src/contracts/execute/types-new.ts +44 -0
  20. package/src/contracts/execute/types.ts +5 -38
  21. package/src/contracts/gov/helpers.ts +187 -51
  22. package/src/contracts/gov/scripts.ts +17 -10
  23. package/src/contracts/gov/transactions.ts +599 -271
  24. package/src/contracts/gov/types-new.ts +253 -100
  25. package/src/contracts/gov/types.ts +4 -71
  26. package/src/contracts/iasset/helpers.ts +172 -0
  27. package/src/contracts/iasset/scripts.ts +38 -0
  28. package/src/contracts/iasset/types.ts +154 -0
  29. package/src/contracts/initialize/actions.ts +768 -0
  30. package/src/contracts/initialize/helpers.ts +611 -36
  31. package/src/contracts/initialize/types.ts +102 -28
  32. package/src/contracts/interest-collection/helpers.ts +19 -0
  33. package/src/contracts/interest-collection/scripts.ts +44 -0
  34. package/src/contracts/interest-collection/transactions.ts +436 -0
  35. package/src/contracts/interest-collection/types-new.ts +50 -0
  36. package/src/contracts/interest-collection/types.ts +26 -0
  37. package/src/contracts/interest-oracle/helpers.ts +2 -30
  38. package/src/contracts/interest-oracle/scripts.ts +1 -1
  39. package/src/contracts/interest-oracle/transactions.ts +21 -16
  40. package/src/contracts/interest-oracle/types-new.ts +32 -0
  41. package/src/contracts/interest-oracle/types.ts +1 -40
  42. package/src/contracts/one-shot/transactions.ts +1 -2
  43. package/src/contracts/poll/helpers.ts +5 -23
  44. package/src/contracts/poll/scripts.ts +12 -13
  45. package/src/contracts/poll/types-poll-manager.ts +1 -19
  46. package/src/contracts/poll/types-poll-new.ts +170 -0
  47. package/src/contracts/poll/types-poll-shard.ts +2 -24
  48. package/src/contracts/price-oracle/helpers.ts +1 -4
  49. package/src/contracts/price-oracle/scripts.ts +3 -8
  50. package/src/contracts/price-oracle/transactions.ts +32 -25
  51. package/src/contracts/price-oracle/types-new.ts +50 -0
  52. package/src/contracts/price-oracle/types.ts +2 -36
  53. package/src/contracts/pyth-feed/helpers.ts +58 -0
  54. package/src/contracts/pyth-feed/scripts.ts +15 -0
  55. package/src/contracts/pyth-feed/types.ts +181 -0
  56. package/src/contracts/rob/helpers.ts +405 -0
  57. package/src/contracts/rob/scripts.ts +35 -0
  58. package/src/contracts/rob/transactions.ts +410 -0
  59. package/src/contracts/rob/types-new.ts +128 -0
  60. package/src/contracts/rob/types.ts +16 -0
  61. package/src/contracts/rob-leverage/helpers.ts +424 -0
  62. package/src/contracts/{leverage → rob-leverage}/transactions.ts +68 -48
  63. package/src/contracts/stability-pool/helpers.ts +714 -230
  64. package/src/contracts/stability-pool/scripts.ts +20 -15
  65. package/src/contracts/stability-pool/transactions.ts +625 -495
  66. package/src/contracts/stability-pool/types-new.ts +237 -100
  67. package/src/contracts/stability-pool/types.ts +5 -22
  68. package/src/contracts/stableswap/helpers.ts +22 -0
  69. package/src/contracts/stableswap/scripts.ts +37 -0
  70. package/src/contracts/stableswap/transactions.ts +647 -0
  71. package/src/contracts/stableswap/types-new.ts +131 -0
  72. package/src/contracts/stableswap/types.ts +17 -0
  73. package/src/contracts/staking/helpers.ts +49 -34
  74. package/src/contracts/staking/scripts.ts +1 -1
  75. package/src/contracts/staking/transactions.ts +85 -130
  76. package/src/contracts/staking/types-new.ts +60 -28
  77. package/src/contracts/staking/types.ts +1 -28
  78. package/src/contracts/treasury/helpers.ts +21 -0
  79. package/src/contracts/treasury/scripts.ts +16 -26
  80. package/src/contracts/treasury/transactions.ts +256 -27
  81. package/src/contracts/treasury/types-new.ts +69 -0
  82. package/src/contracts/treasury/types.ts +2 -43
  83. package/src/contracts/version-registry/scripts.ts +2 -2
  84. package/src/contracts/version-registry/types-new.ts +6 -7
  85. package/src/index.ts +37 -20
  86. package/src/scripts/auth-token-policy.ts +3 -2
  87. package/src/scripts/iasset-policy.ts +3 -2
  88. package/src/types/evolution-schema-options.ts +3 -3
  89. package/src/types/generic.ts +17 -89
  90. package/src/types/multisig.ts +48 -0
  91. package/src/types/on-chain-decimal.ts +14 -7
  92. package/src/types/rational.ts +61 -0
  93. package/src/types/system-params.ts +237 -41
  94. package/src/utils/array-utils.ts +70 -1
  95. package/src/utils/bigint-utils.ts +12 -0
  96. package/src/utils/indigo-helpers.ts +8 -10
  97. package/src/utils/lucid-utils.ts +47 -40
  98. package/src/utils/oracle-helpers.ts +62 -0
  99. package/src/utils/pyth/decode.ts +223 -0
  100. package/src/utils/pyth/encode.ts +262 -0
  101. package/src/utils/pyth/index.ts +14 -0
  102. package/src/utils/pyth/types.ts +87 -0
  103. package/src/validators/always-succeed-validator.ts +6 -0
  104. package/src/validators/cdp-creator-validator.ts +2 -2
  105. package/src/validators/cdp-redeem-validator.ts +7 -0
  106. package/src/validators/cdp-validator.ts +2 -2
  107. package/src/validators/collector-validator.ts +2 -2
  108. package/src/validators/execute-validator.ts +2 -2
  109. package/src/validators/governance-validator.ts +2 -2
  110. package/src/validators/iasset-validator.ts +7 -0
  111. package/src/validators/interest-collection-validator.ts +7 -0
  112. package/src/validators/interest-oracle-validator.ts +2 -2
  113. package/src/validators/poll-manager-validator.ts +2 -2
  114. package/src/validators/poll-shard-validator.ts +2 -2
  115. package/src/validators/price-oracle-validator.ts +7 -0
  116. package/src/validators/pyth-feed-validator.ts +7 -0
  117. package/src/validators/rob-validator.ts +7 -0
  118. package/src/validators/stability-pool-validator.ts +2 -2
  119. package/src/validators/stableswap-validator.ts +7 -0
  120. package/src/validators/staking-validator.ts +2 -2
  121. package/src/validators/treasury-validator.ts +2 -2
  122. package/src/validators/version-record-policy.ts +2 -2
  123. package/src/validators/version-registry-validator.ts +2 -2
  124. package/tests/always-succeed/script.ts +7 -0
  125. package/tests/bigint-utils.test.ts +41 -0
  126. package/tests/cdp/actions.ts +611 -0
  127. package/tests/cdp/cdp-helpers.ts +55 -0
  128. package/tests/cdp/cdp-queries.ts +440 -0
  129. package/tests/cdp/cdp.test.ts +6087 -0
  130. package/tests/cdp/transactions-mutated.ts +1729 -0
  131. package/tests/data/system-params.json +177 -34
  132. package/tests/datums.test.ts +209 -210
  133. package/tests/endpoints/initialize.ts +68 -0
  134. package/tests/endpoints/interest-collector.ts +37 -0
  135. package/tests/endpoints/treasury.ts +70 -0
  136. package/tests/gov/actions.ts +406 -0
  137. package/tests/gov/gov.test.ts +4450 -0
  138. package/tests/{queries → gov}/governance-queries.ts +6 -3
  139. package/tests/hash-checks.test.ts +38 -11
  140. package/tests/indigo-test-helpers.ts +100 -0
  141. package/tests/initialize.test.ts +61 -9
  142. package/tests/interest-collection/interest-collection.test.ts +892 -0
  143. package/tests/interest-collection/interest-collector-queries.ts +49 -0
  144. package/tests/interest-collection/transactions-mutated.ts +260 -0
  145. package/tests/interest-oracle.test.ts +43 -35
  146. package/tests/mock/assets-mock.ts +234 -23
  147. package/tests/mock/protocol-params-mock.ts +21 -0
  148. package/tests/price-oracle/actions.ts +163 -0
  149. package/tests/price-oracle/price-oracle-queries.ts +12 -0
  150. package/tests/price-oracle/price-oracle.test.ts +240 -0
  151. package/tests/price-oracle/transactions-mutated.ts +62 -0
  152. package/tests/pyth/endpoints.ts +96 -0
  153. package/tests/pyth/helpers.ts +37 -0
  154. package/tests/pyth/pyth-encoding.test.ts +376 -0
  155. package/tests/pyth/pyth-indigo.test.ts +509 -0
  156. package/tests/pyth/pyth.test.ts +300 -0
  157. package/tests/queries/execute-queries.ts +6 -5
  158. package/tests/queries/iasset-queries.ts +175 -5
  159. package/tests/queries/interest-oracle-queries.ts +4 -2
  160. package/tests/queries/poll-queries.ts +8 -9
  161. package/tests/queries/stability-pool-queries.ts +95 -48
  162. package/tests/queries/staking-queries.ts +4 -2
  163. package/tests/queries/treasury-queries.ts +80 -5
  164. package/tests/rob/actions.ts +58 -0
  165. package/tests/{lrp-leverage.test.ts → rob/rob-leverage.test.ts} +393 -296
  166. package/tests/rob/rob-queries.ts +95 -0
  167. package/tests/rob/rob.test.ts +3762 -0
  168. package/tests/rob/transactions-mutated.ts +853 -0
  169. package/tests/script-size.test.ts +240 -0
  170. package/tests/setup.ts +135 -0
  171. package/tests/stability-pool/actions.ts +210 -0
  172. package/tests/stability-pool.test.ts +5469 -666
  173. package/tests/stableswap/stableswap-actions.ts +84 -0
  174. package/tests/stableswap/stableswap-queries.ts +89 -0
  175. package/tests/stableswap/stableswap.test.ts +3891 -0
  176. package/tests/stableswap/transactions-mutated.ts +348 -0
  177. package/tests/staking.test.ts +82 -99
  178. package/tests/test-helpers.ts +58 -11
  179. package/tests/treasury.test.ts +242 -0
  180. package/tests/utils/asserts.ts +74 -0
  181. package/tests/utils/benchmark-utils.ts +81 -0
  182. package/tests/utils/index.ts +122 -4
  183. package/tsconfig.json +9 -1
  184. package/vitest.config.ts +3 -1
  185. package/src/contracts/collector/types.ts +0 -16
  186. package/src/contracts/initialize/transactions.ts +0 -891
  187. package/src/contracts/leverage/helpers.ts +0 -424
  188. package/src/contracts/lrp/helpers.ts +0 -294
  189. package/src/contracts/lrp/scripts.ts +0 -27
  190. package/src/contracts/lrp/transactions.ts +0 -250
  191. package/src/contracts/lrp/types.ts +0 -131
  192. package/src/contracts/poll/types-poll.ts +0 -88
  193. package/src/contracts/vesting/helpers.ts +0 -218
  194. package/src/utils/value-helpers.ts +0 -37
  195. package/src/validators/lrp-validator.ts +0 -7
  196. package/tests/cdp.test.ts +0 -1528
  197. package/tests/gov.test.ts +0 -2011
  198. package/tests/lrp.test.ts +0 -673
  199. package/tests/queries/cdp-queries.ts +0 -220
  200. package/tests/queries/lrp-queries.ts +0 -76
  201. package/tests/queries/price-oracle-queries.ts +0 -10
@@ -1,18 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import {
3
- CDPContent,
4
- IAssetContent,
5
- parseIAssetDatumOrThrow,
6
- parseInterestOracleDatum,
7
- parsePriceOracleDatum,
8
- serialiseFeedInterestOracleRedeemer,
9
- serialiseIAssetDatum,
10
- serialiseInterestOracleDatum,
11
- serialisePriceOracleDatum,
12
- serialiseCdpDatum,
13
- parseCdpDatum,
14
- } from '../src/index';
15
- import { fromHex, fromText } from '@lucid-evolution/lucid';
2
+ import { Data, fromHex } from '@lucid-evolution/lucid';
16
3
  import {
17
4
  parseStakingManagerDatum,
18
5
  parseStakingPositionOrThrow,
@@ -21,30 +8,34 @@ import {
21
8
  StakingPosition,
22
9
  } from '../src/contracts/staking/types-new';
23
10
  import {
24
- AccountContent,
25
- parseAccountDatum,
26
- parseSnapshotEpochToScaleToSumDatum,
27
- parseStabilityPoolDatum,
28
- serialiseStabilityPoolDatum,
29
- SnapshotEpochToScaleToSumContent,
30
- StabilityPoolContent,
31
- } from '../src/contracts/stability-pool/types-new';
32
- import { option as O } from 'fp-ts';
11
+ parsePriceOracleDatum,
12
+ serialisePriceOracleDatum,
13
+ } from '../src/contracts/price-oracle/types-new';
14
+ import {
15
+ parseInterestOracleDatum,
16
+ serialiseFeedInterestOracleRedeemer,
17
+ serialiseInterestOracleDatum,
18
+ } from '../src/contracts/interest-oracle/types-new';
19
+ import * as Core from '@evolution-sdk/evolution';
33
20
 
34
21
  describe('Datum checks', () => {
35
22
  it('Price Oracle', () => {
36
- expect(
37
- parsePriceOracleDatum('d8799fd8799f1a0013c347ff1b00000194d68e13d8ff'),
38
- ).toEqual({
39
- price: { getOnChainInt: 1295175n },
40
- expiration: 1738766423000n,
41
- });
42
23
  expect(
43
24
  serialisePriceOracleDatum({
44
- price: { getOnChainInt: 1295175n },
45
- expiration: 1738766423000n,
25
+ price: { numerator: 1_295_175n, denominator: 1_000_000n },
26
+ expirationTime: 1738766423000n,
27
+ auxiliaryData: Core.Data.fromCBORHex(Data.void()),
46
28
  }),
47
- ).toEqual('d8799fd8799f1a0013c347ff1b00000194d68e13d8ff');
29
+ ).toEqual('d8799fd8799f1a0013c3471a000f4240ff1b00000194d68e13d8d87980ff');
30
+ expect(
31
+ parsePriceOracleDatum(
32
+ 'd8799fd8799f1a0013c3471a000f4240ff1b00000194d68e13d8d87980ff',
33
+ ),
34
+ ).toEqual({
35
+ price: { numerator: 1295175n, denominator: 1000000n },
36
+ expirationTime: 1738766423000n,
37
+ auxiliaryData: Core.Data.fromCBORHex(Data.void()),
38
+ });
48
39
  });
49
40
 
50
41
  it('Interest Oracle', () => {
@@ -75,78 +66,82 @@ describe('Datum checks', () => {
75
66
  ).toEqual('d8799fd8799f1a000f4240ff1a66cf2400ff');
76
67
  });
77
68
 
78
- it('CDP', () => {
79
- // Active CDP
80
- const activeCDPDatum =
81
- 'd8799fd8799fd8799f581c98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1cff44695553441b00000004d9b0a47ed8799f1b00000194d5ebec201b03022de04fddf5f9ffffff';
82
- const activeCDPObject: CDPContent = {
83
- cdpOwner: '98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1c',
84
- iasset: fromText('iUSD'),
85
- mintedAmt: 20832101502n,
86
- cdpFees: {
87
- ActiveCDPInterestTracking: {
88
- lastSettled: 1738755796000n,
89
- unitaryInterestSnapshot: 216786173503075833n,
90
- },
91
- },
92
- };
93
- expect(serialiseCdpDatum(activeCDPObject)).toEqual(activeCDPDatum);
94
- expect(parseCdpDatum(activeCDPDatum)).toEqual(O.some(activeCDPObject));
69
+ // eslint-disable-next-line vitest/no-commented-out-tests
70
+ // it.todo('CDP', () => {
71
+ // // Active CDP
72
+ // const activeCDPDatum =
73
+ // 'd8799fd8799fd8799f581c98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1cff44695553441b00000004d9b0a47ed8799f1b00000194d5ebec201b03022de04fddf5f9ffffff';
74
+ // const activeCDPObject: CDPContent = {
75
+ // cdpOwner: fromHex(
76
+ // '98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1c',
77
+ // ),
78
+ // iasset: fromHex(fromText('iUSD')),
79
+ // mintedAmt: 20832101502n,
80
+ // cdpFees: {
81
+ // ActiveCDPInterestTracking: {
82
+ // lastSettled: 1738755796000n,
83
+ // unitaryInterestSnapshot: 216786173503075833n,
84
+ // },
85
+ // },
86
+ // };
87
+ // expect(serialiseCdpDatum(activeCDPObject)).toEqual(activeCDPDatum);
88
+ // expect(parseCdpDatum(activeCDPDatum)).toEqual(O.some(activeCDPObject));
95
89
 
96
- // Frozen CDP
97
- const frozenCDPDatum =
98
- 'd8799fd8799fd87a8044695553441a0050924ed87a9f1a0002765a1a0003ca56ffffff';
99
- const frozenCDPObject: CDPContent = {
100
- cdpOwner: null,
101
- iasset: fromText('iUSD'),
102
- mintedAmt: 5280334n,
103
- cdpFees: {
104
- FrozenCDPAccumulatedFees: {
105
- lovelacesTreasury: 161370n,
106
- lovelacesIndyStakers: 248406n,
107
- },
108
- },
109
- };
110
- expect(parseCdpDatum(frozenCDPDatum)).toEqual(O.some(frozenCDPObject));
111
- expect(serialiseCdpDatum(frozenCDPObject)).toEqual(frozenCDPDatum);
112
- });
90
+ // // Frozen CDP
91
+ // const frozenCDPDatum =
92
+ // 'd8799fd8799fd87a8044695553441a0050924ed87a9f1a0002765a1a0003ca56ffffff';
93
+ // const frozenCDPObject: CDPContent = {
94
+ // cdpOwner: null,
95
+ // iasset: fromHex(fromText('iUSD')),
96
+ // mintedAmt: 5280334n,
97
+ // cdpFees: {
98
+ // FrozenCDPAccumulatedFees: {
99
+ // iassetInterest: 161370n,
100
+ // lovelacesIndyStakers: 248406n,
101
+ // },
102
+ // },
103
+ // };
104
+ // expect(parseCdpDatum(frozenCDPDatum)).toEqual(O.some(frozenCDPObject));
105
+ // expect(serialiseCdpDatum(frozenCDPObject)).toEqual(frozenCDPDatum);
106
+ // });
113
107
 
114
- it('iAsset', () => {
115
- const assetDatum =
116
- 'd87a9fd8799f4469455448d87a9fd8799fd8799f581c6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e952694554483230323231323139313931333032ffffffd8799f581c7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef302494d694554485f494e544552455354ffd8799f1a08f0d180ffd8799f1a06dac2c0ffd8799f1a068e7780ffd8799f1a000186a0ffd8799f1a001e8480ffd8799f19c350ffd8799f1a000f4240ffd8799f1a000f4240ffd8799f1a01c9c380ffd87980d8799f4469534f4cffffff';
117
- const assetObject: IAssetContent = {
118
- assetName: fromText('iETH'),
119
- price: {
120
- Oracle: {
121
- content: {
122
- oracleNft: {
123
- currencySymbol:
124
- '6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e9',
125
- tokenName: fromText('iETH20221219191302'),
126
- },
127
- },
128
- },
129
- },
130
- interestOracleNft: {
131
- currencySymbol:
132
- '7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef30249',
133
- tokenName: fromText('iETH_INTEREST'),
134
- },
135
- redemptionRatio: { getOnChainInt: 150000000n },
136
- maintenanceRatio: { getOnChainInt: 115000000n },
137
- liquidationRatio: { getOnChainInt: 110000000n },
138
- debtMintingFeePercentage: { getOnChainInt: 100000n },
139
- liquidationProcessingFeePercentage: { getOnChainInt: 2000000n },
140
- stabilityPoolWithdrawalFeePercentage: { getOnChainInt: 50000n },
141
- redemptionReimbursementPercentage: { getOnChainInt: 1000000n },
142
- redemptionProcessingFeePercentage: { getOnChainInt: 1000000n },
143
- interestCollectorPortionPercentage: { getOnChainInt: 30000000n },
144
- firstIAsset: false,
145
- nextIAsset: fromText('iSOL'),
146
- };
147
- expect(serialiseIAssetDatum(assetObject)).toEqual(assetDatum);
148
- expect(parseIAssetDatumOrThrow(assetDatum)).toEqual(assetObject);
149
- });
108
+ // eslint-disable-next-line vitest/no-commented-out-tests
109
+ // it.todo('iAsset', () => {
110
+ // const assetDatum =
111
+ // 'd87a9fd8799f4469455448d87a9fd8799fd8799f581c6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e952694554483230323231323139313931333032ffffffd8799f581c7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef302494d694554485f494e544552455354ffd8799f1a08f0d180ffd8799f1a06dac2c0ffd8799f1a068e7780ffd8799f1a000186a0ffd8799f1a001e8480ffd8799f19c350ffd8799f1a000f4240ffd8799f1a000f4240ffd8799f1a01c9c380ffd87980d8799f4469534f4cffffff';
112
+ // const assetObject: IAssetDatum = {
113
+ // assetName: fromHex(fromText('iETH')),
114
+ // price: {
115
+ // Oracle: {
116
+ // oracleNft: {
117
+ // currencySymbol: fromHex(
118
+ // '6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e9',
119
+ // ),
120
+ // tokenName: fromHex(fromText('iETH20221219191302')),
121
+ // },
122
+ // },
123
+ // },
124
+ // interestOracleNft: {
125
+ // currencySymbol: fromHex(
126
+ // '7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef30249',
127
+ // ),
128
+ // tokenName: fromHex(fromText('iETH_INTEREST')),
129
+ // },
130
+ // redemptionRatio: { getOnChainInt: 150000000n },
131
+ // maintenanceRatio: { getOnChainInt: 115000000n },
132
+ // liquidationRatio: { getOnChainInt: 110000000n },
133
+ // debtMintingFeePercentage: { getOnChainInt: 100000n },
134
+ // liquidationProcessingFeePercentage: { getOnChainInt: 2000000n },
135
+ // stabilityPoolWithdrawalFeePercentage: { getOnChainInt: 50000n },
136
+ // redemptionReimbursementPercentage: { getOnChainInt: 1000000n },
137
+ // redemptionProcessingFeePercentage: { getOnChainInt: 1000000n },
138
+ // interestCollectorPortionPercentage: { getOnChainInt: 30000000n },
139
+ // firstIAsset: false,
140
+ // nextIAsset: fromHex(fromText('iSOL')),
141
+ // };
142
+ // expect(serialiseIAssetDatum(assetObject)).toEqual(assetDatum);
143
+ // expect(parseIAssetDatumOrThrow(assetDatum)).toEqual(assetObject);
144
+ // });
150
145
 
151
146
  it('Staking Manager', () => {
152
147
  const stakingManagerDatum =
@@ -168,14 +163,14 @@ describe('Datum checks', () => {
168
163
 
169
164
  it('Staking Position', () => {
170
165
  const stakingPositionDatum =
171
- 'd87a9fd8799f581cd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f43a11853d8799f1a5c8c1cfb1b0000019616971410ffd8799f1b0000013a7ed5b0fdffffff';
166
+ 'd87a9fd8799f581cd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f439f9f1853d8799f1a5c8c1cfb1b0000019616971410ffffffd8799f1b0000013a7ed5b0fdffffff';
172
167
  const stakingPositionObject: StakingPosition = {
173
168
  owner: fromHex(
174
169
  'd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f43',
175
170
  ),
176
- lockedAmount: new Map([
171
+ lockedAmount: [
177
172
  [83n, { voteAmt: 1552686331n, votingEnd: 1744135722000n }],
178
- ]),
173
+ ],
179
174
  positionSnapshot: {
180
175
  snapshotAda: 1350747664637n,
181
176
  },
@@ -189,115 +184,119 @@ describe('Datum checks', () => {
189
184
  );
190
185
  });
191
186
 
192
- it('Stability Pool', () => {
193
- const stabilityPoolDatum =
194
- 'd8799fd8799f4469555344d8799fd8799f1b0a37ad5c452ffb2affd8799fc24d1f94ac680ce6b48ea21bb122baffd8799f1b0fde3bba456cd5deff0100ffa2d8799f0000ffd8799f1b084494e2d23b2b7effd8799f0100ffd8799f1b0fde3bba456cd5deffffff';
195
- const stabilityPoolObject: StabilityPoolContent = {
196
- asset: fromHex(fromText('iUSD')),
197
- poolSnapshot: {
198
- productVal: { value: 736247675907734314n },
199
- depositVal: { value: 2502085246000826468068228145850n },
200
- sumVal: { value: 1143417026613401054n },
201
- epoch: 1n,
202
- scale: 0n,
203
- },
204
- epochToScaleToSum: new Map([
205
- [{ epoch: 0n, scale: 0n }, { value: 595764752630360958n }],
206
- [{ epoch: 1n, scale: 0n }, { value: 1143417026613401054n }],
207
- ]),
208
- };
209
- expect(parseStabilityPoolDatum(stabilityPoolDatum)).toEqual(
210
- stabilityPoolObject,
211
- );
212
- expect(
213
- serialiseStabilityPoolDatum({ StabilityPool: stabilityPoolObject }),
214
- ).toEqual(stabilityPoolDatum);
215
- });
187
+ // eslint-disable-next-line vitest/no-commented-out-tests
188
+ // it('Stability Pool', () => {
189
+ // const stabilityPoolDatum =
190
+ // 'd8799fd8799f4469555344d8799fd8799f1b0a37ad5c452ffb2affd8799fc24d1f94ac680ce6b48ea21bb122baffd8799f1b0fde3bba456cd5deff0100ff9f9fd8799f0000ffd8799f1b084494e2d23b2b7effff9fd8799f0100ffd8799f1b0fde3bba456cd5deffffffffff';
191
+ // const stabilityPoolObject: StabilityPoolContent = {
192
+ // asset: fromHex(fromText('iUSD')),
193
+ // poolSnapshot: {
194
+ // productVal: { value: 736247675907734314n },
195
+ // depositVal: { value: 2502085246000826468068228145850n },
196
+ // sumVal: { value: 1143417026613401054n },
197
+ // epoch: 1n,
198
+ // scale: 0n,
199
+ // },
200
+ // epochToScaleToSum: [
201
+ // [{ epoch: 0n, scale: 0n }, { value: 595764752630360958n }],
202
+ // [{ epoch: 1n, scale: 0n }, { value: 1143417026613401054n }],
203
+ // ],
204
+ // };
205
+ // expect(parseStabilityPoolDatum(stabilityPoolDatum)).toEqual(
206
+ // stabilityPoolObject,
207
+ // );
208
+ // expect(
209
+ // serialiseStabilityPoolDatum({ StabilityPool: stabilityPoolObject }),
210
+ // ).toEqual(stabilityPoolDatum);
211
+ // });
216
212
 
217
- it('Stability Pool Account', () => {
218
- const stabilityPoolDatum =
219
- 'd87a9fd8799f581c12c646d4c6d7a35c14788d15f0f6142f6148975d8932592fbd625f674469555344d8799fd8799f1b0a37ad5c452ffb2affd8799fc24c39fa2838b1f7dd38267f0a6dffd8799f1b0fde3b75c28ab489ff0100ffd87a80ffff';
220
- const stabilityPoolObject: AccountContent = {
221
- owner: fromHex(
222
- '12c646d4c6d7a35c14788d15f0f6142f6148975d8932592fbd625f67',
223
- ),
224
- asset: fromHex(fromText('iUSD')),
225
- accountSnapshot: {
226
- productVal: { value: 736247675907734314n },
227
- depositVal: { value: 17943066955221270821727046253n },
228
- sumVal: { value: 1143416732359767177n },
229
- epoch: 1n,
230
- scale: 0n,
231
- },
232
- request: null,
233
- };
213
+ // eslint-disable-next-line vitest/no-commented-out-tests
214
+ // it('Stability Pool Account', () => {
215
+ // const stabilityPoolDatum =
216
+ // 'd87a9fd8799f581c12c646d4c6d7a35c14788d15f0f6142f6148975d8932592fbd625f674469555344d8799fd8799f1b0a37ad5c452ffb2affd8799fc24c39fa2838b1f7dd38267f0a6dffd8799f1b0fde3b75c28ab489ff0100ffd87a80ffff';
217
+ // const stabilityPoolObject: AccountContent = {
218
+ // owner: fromHex(
219
+ // '12c646d4c6d7a35c14788d15f0f6142f6148975d8932592fbd625f67',
220
+ // ),
221
+ // asset: fromHex(fromText('iUSD')),
222
+ // accountSnapshot: {
223
+ // productVal: { value: 736247675907734314n },
224
+ // depositVal: { value: 17943066955221270821727046253n },
225
+ // sumVal: { value: 1143416732359767177n },
226
+ // epoch: 1n,
227
+ // scale: 0n,
228
+ // },
229
+ // request: null,
230
+ // };
234
231
 
235
- expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
236
- expect(
237
- serialiseStabilityPoolDatum({ Account: stabilityPoolObject }),
238
- ).toEqual(stabilityPoolDatum);
239
- });
232
+ // expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
233
+ // expect(
234
+ // serialiseStabilityPoolDatum({ Account: stabilityPoolObject }),
235
+ // ).toEqual(stabilityPoolDatum);
236
+ // });
240
237
 
241
- it('Stability Pool Account w/ Adjust Request', () => {
242
- const stabilityPoolDatum =
243
- 'd87a9fd8799f581c90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c4469555344d8799fd8799f1b0a374472be304a62ffd8799fc24b01aef07f96e5ce00f80000ffd8799f1b0f88aa07a1048079ff0100ffd8799fd87a9f3a0007c359d8799fd8799f581c90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15cffd8799fd8799fd8799f581c75a4f9204b9308a92a09b0e22b94125e56f24b73bb85e2795f176c6affffffffffffffff';
244
- const stabilityPoolObject: AccountContent = {
245
- owner: fromHex(
246
- '90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c',
247
- ),
248
- asset: fromHex(fromText('iUSD')),
249
- accountSnapshot: {
250
- productVal: { value: 736132323706161762n },
251
- depositVal: { value: 2035054000000000000000000n },
252
- sumVal: { value: 1119331457144488057n },
253
- epoch: 1n,
254
- scale: 0n,
255
- },
256
- request: {
257
- Adjust: {
258
- amount: -508762n,
259
- outputAddress: {
260
- paymentCredential: {
261
- PublicKeyCredential: fromHex(
262
- '90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c',
263
- ),
264
- },
265
- stakeCredential: {
266
- Inline: {
267
- PublicKeyCredential: fromHex(
268
- '75a4f9204b9308a92a09b0e22b94125e56f24b73bb85e2795f176c6a',
269
- ),
270
- },
271
- },
272
- },
273
- },
274
- },
275
- };
238
+ // eslint-disable-next-line vitest/no-commented-out-tests
239
+ // it('Stability Pool Account w/ Adjust Request', () => {
240
+ // const stabilityPoolDatum =
241
+ // 'd87a9fd8799f581c90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c4469555344d8799fd8799f1b0a374472be304a62ffd8799fc24b01aef07f96e5ce00f80000ffd8799f1b0f88aa07a1048079ff0100ffd8799fd87a9f3a0007c359d8799fd8799f581c90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15cffd8799fd8799fd8799f581c75a4f9204b9308a92a09b0e22b94125e56f24b73bb85e2795f176c6affffffffffffffff';
242
+ // const stabilityPoolObject: AccountContent = {
243
+ // owner: fromHex(
244
+ // '90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c',
245
+ // ),
246
+ // asset: fromHex(fromText('iUSD')),
247
+ // accountSnapshot: {
248
+ // productVal: { value: 736132323706161762n },
249
+ // depositVal: { value: 2035054000000000000000000n },
250
+ // sumVal: { value: 1119331457144488057n },
251
+ // epoch: 1n,
252
+ // scale: 0n,
253
+ // },
254
+ // request: {
255
+ // Adjust: {
256
+ // amount: -508762n,
257
+ // outputAddress: {
258
+ // paymentCredential: {
259
+ // PublicKeyCredential: fromHex(
260
+ // '90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c',
261
+ // ),
262
+ // },
263
+ // stakeCredential: {
264
+ // Inline: {
265
+ // PublicKeyCredential: fromHex(
266
+ // '75a4f9204b9308a92a09b0e22b94125e56f24b73bb85e2795f176c6a',
267
+ // ),
268
+ // },
269
+ // },
270
+ // },
271
+ // },
272
+ // },
273
+ // };
276
274
 
277
- expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
278
- expect(
279
- serialiseStabilityPoolDatum({ Account: stabilityPoolObject }),
280
- ).toEqual(stabilityPoolDatum);
281
- });
275
+ // expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
276
+ // expect(
277
+ // serialiseStabilityPoolDatum({ Account: stabilityPoolObject }),
278
+ // ).toEqual(stabilityPoolDatum);
279
+ // });
282
280
 
283
- it('Stability Pool SnapshotEpochToScaleToSum', () => {
284
- const stabilityPoolDatum =
285
- 'd87b9fd8799fa2d8799f0000ffd8799f1b084494e2d23b2b7effd8799f0100ffd8799f1b0fde3bba456cd5deff4469555344ffff';
286
- const stabilityPoolObject: SnapshotEpochToScaleToSumContent = {
287
- asset: fromHex(fromText('iUSD')),
288
- snapshot: new Map([
289
- [{ epoch: 0n, scale: 0n }, { value: 595764752630360958n }],
290
- [{ epoch: 1n, scale: 0n }, { value: 1143417026613401054n }],
291
- ]),
292
- };
281
+ // eslint-disable-next-line vitest/no-commented-out-tests
282
+ // it('Stability Pool SnapshotEpochToScaleToSum', () => {
283
+ // const stabilityPoolDatum =
284
+ // 'd87b9fd8799f9f9fd8799f0000ffd8799f1b084494e2d23b2b7effff9fd8799f0100ffd8799f1b0fde3bba456cd5deffffff4469555344ffff';
285
+ // const stabilityPoolObject: SnapshotEpochToScaleToSumContent = {
286
+ // asset: fromHex(fromText('iUSD')),
287
+ // snapshot: [
288
+ // [{ epoch: 0n, scale: 0n }, { value: 595764752630360958n }],
289
+ // [{ epoch: 1n, scale: 0n }, { value: 1143417026613401054n }],
290
+ // ],
291
+ // };
293
292
 
294
- expect(parseSnapshotEpochToScaleToSumDatum(stabilityPoolDatum)).toEqual(
295
- stabilityPoolObject,
296
- );
297
- expect(
298
- serialiseStabilityPoolDatum({
299
- SnapshotEpochToScaleToSum: stabilityPoolObject,
300
- }),
301
- ).toEqual(stabilityPoolDatum);
302
- });
293
+ // expect(parseSnapshotEpochToScaleToSumDatum(stabilityPoolDatum)).toEqual(
294
+ // stabilityPoolObject,
295
+ // );
296
+ // expect(
297
+ // serialiseStabilityPoolDatum({
298
+ // SnapshotEpochToScaleToSum: stabilityPoolObject,
299
+ // }),
300
+ // ).toEqual(stabilityPoolDatum);
301
+ // });
303
302
  });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Test endpoint for protocol initialization.
3
+ * Re-exports from the initialize contract and provides a test-friendly init() wrapper
4
+ * that uses protocolParamsMock and optional initPyth when pythConfig is not provided.
5
+ */
6
+
7
+ import type { LucidEvolution } from '@lucid-evolution/lucid';
8
+ import type { ScriptCredential } from '../../src';
9
+ import type { ProtocolParams } from '../../src/contracts/gov/types-new';
10
+ import {
11
+ init as initContract,
12
+ initPythConfig,
13
+ } from '../../src/contracts/initialize/actions';
14
+ import {
15
+ mintOneTimeToken,
16
+ DEFAULT_INIT_OPTIONS,
17
+ } from '../../src/contracts/initialize/helpers';
18
+ import type {
19
+ AssetInfo,
20
+ CollateralAssetInfo,
21
+ InitialAssetParam,
22
+ InitializeOptions,
23
+ } from '../../src/contracts/initialize/types';
24
+ import { protocolParamsMock } from '../mock/protocol-params-mock';
25
+ import { AssetClass } from '@3rd-eye-labs/cardano-offchain-common';
26
+
27
+ export type {
28
+ AssetInfo,
29
+ CollateralAssetInfo,
30
+ InitialAssetParam,
31
+ InitializeOptions,
32
+ };
33
+ export { initPythConfig, mintOneTimeToken, DEFAULT_INIT_OPTIONS };
34
+
35
+ /**
36
+ * Initialize the protocol (test helper).
37
+ * Uses protocolParamsMock merged with overrideProtocolParams.
38
+ * If pythConfig is not provided, initializes Pyth via initPyth + initPythConfig.
39
+ * Uses DEFAULT_INIT_OPTIONS when initOptions is not provided.
40
+ */
41
+ export async function init(
42
+ lucid: LucidEvolution,
43
+ defaultInitialAssets: InitialAssetParam[],
44
+ currentSlot: number,
45
+ mkPythBasedAssets: (
46
+ pythStateNft: AssetClass,
47
+ ) => InitialAssetParam[] = () => [],
48
+ overrideProtocolParams: Partial<ProtocolParams> = {},
49
+ initOptions: InitializeOptions = DEFAULT_INIT_OPTIONS,
50
+ spStakingCred?: ScriptCredential,
51
+ treasuryStakingCred?: ScriptCredential,
52
+ ): Promise<ReturnType<typeof initContract>> {
53
+ const protocolParams: ProtocolParams = {
54
+ ...protocolParamsMock,
55
+ ...overrideProtocolParams,
56
+ };
57
+
58
+ return initContract(
59
+ lucid,
60
+ defaultInitialAssets,
61
+ currentSlot,
62
+ mkPythBasedAssets,
63
+ protocolParams,
64
+ initOptions,
65
+ spStakingCred,
66
+ treasuryStakingCred,
67
+ );
68
+ }
@@ -0,0 +1,37 @@
1
+ import { Assets, Data, UTxO } from '@lucid-evolution/lucid';
2
+ import { createScriptAddress, SystemParams } from '../../src';
3
+ import { IndigoTestContext, runAndAwaitTxBuilder } from '../test-helpers';
4
+ import { getNewUtxosAtAddressAfterAction } from '../utils';
5
+
6
+ export async function createUtxosAtInterestCollector(
7
+ utxosNo: number,
8
+ assets: Assets,
9
+ sysParams: SystemParams,
10
+ context: IndigoTestContext,
11
+ ): Promise<UTxO[]> {
12
+ const interestCollectorAddr = createScriptAddress(
13
+ context.lucid.config().network!,
14
+ sysParams.validatorHashes.interestCollectionHash,
15
+ );
16
+
17
+ const tx = context.lucid.newTx();
18
+
19
+ for (let i = 0; i < utxosNo; i++) {
20
+ tx.pay.ToContract(
21
+ interestCollectorAddr,
22
+ { kind: 'inline', value: Data.void() },
23
+ assets,
24
+ );
25
+ }
26
+
27
+ const [_, utxos] = await getNewUtxosAtAddressAfterAction(
28
+ context.lucid,
29
+ interestCollectorAddr,
30
+ () => runAndAwaitTxBuilder(context.lucid, tx),
31
+ );
32
+
33
+ if (utxos.length !== utxosNo)
34
+ throw Error('Expected a different number of interest collectors');
35
+
36
+ return utxos;
37
+ }
@@ -0,0 +1,70 @@
1
+ import { Assets, Data, UTxO } from '@lucid-evolution/lucid';
2
+ import {
3
+ fromSystemParamsAsset,
4
+ SystemParams,
5
+ } from '../../src/types/system-params';
6
+ import { LucidContext, runAndAwaitTxBuilder } from '../test-helpers';
7
+ import { createScriptAddress } from '../../src/utils/lucid-utils';
8
+ import { getNewUtxosAtAddressAfterAction } from '../utils';
9
+ import { matchSingle, mkAssetsOf } from '@3rd-eye-labs/cardano-offchain-common';
10
+
11
+ export async function createMultipleUtxosAtTreasury(
12
+ assets: Assets,
13
+ numberUtxos: bigint,
14
+ sysParams: SystemParams,
15
+ context: LucidContext,
16
+ ): Promise<UTxO[]> {
17
+ const treasuryAddr = createScriptAddress(
18
+ context.lucid.config().network!,
19
+ sysParams.validatorHashes.treasuryHash,
20
+ );
21
+
22
+ const tx = context.lucid.newTx();
23
+
24
+ for (let i = 0; i < numberUtxos; i++) {
25
+ tx.pay.ToContract(
26
+ treasuryAddr,
27
+ { kind: 'inline', value: Data.void() },
28
+ assets,
29
+ );
30
+ }
31
+
32
+ const [_, utxos] = await getNewUtxosAtAddressAfterAction(
33
+ context.lucid,
34
+ treasuryAddr,
35
+ () => runAndAwaitTxBuilder(context.lucid, tx),
36
+ );
37
+
38
+ if (utxos.length !== Number(numberUtxos)) {
39
+ new Error('Expected a different number of new treasury UTxOs');
40
+ }
41
+
42
+ return utxos;
43
+ }
44
+
45
+ export async function createUtxoAtTreasury(
46
+ assets: Assets,
47
+ sysParams: SystemParams,
48
+ context: LucidContext,
49
+ ): Promise<UTxO> {
50
+ const utxos = await createMultipleUtxosAtTreasury(
51
+ assets,
52
+ 1n,
53
+ sysParams,
54
+ context,
55
+ );
56
+
57
+ return matchSingle(utxos, () => new Error('Expected a single treasury UTXO'));
58
+ }
59
+
60
+ export async function createIndyUtxoAtTreasury(
61
+ indyAmt: bigint,
62
+ sysParams: SystemParams,
63
+ context: LucidContext,
64
+ ): Promise<UTxO> {
65
+ return createUtxoAtTreasury(
66
+ mkAssetsOf(fromSystemParamsAsset(sysParams.govParams.indyAsset), indyAmt),
67
+ sysParams,
68
+ context,
69
+ );
70
+ }