@indigo-labs/indigo-sdk 0.5.5 → 0.5.6

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 (204) hide show
  1. package/package.json +11 -1
  2. package/.claude/settings.local.json +0 -7
  3. package/.github/workflows/ci.yml +0 -66
  4. package/.husky/pre-commit +0 -1
  5. package/.nvmrc +0 -1
  6. package/.prettierignore +0 -1
  7. package/.prettierrc +0 -6
  8. package/eslint.config.mjs +0 -42
  9. package/scripts/bench.sh +0 -62
  10. package/scripts/run-repeat.sh +0 -22
  11. package/src/contracts/cdp/helpers.ts +0 -173
  12. package/src/contracts/cdp/scripts.ts +0 -70
  13. package/src/contracts/cdp/transactions.ts +0 -1584
  14. package/src/contracts/cdp/types-new.ts +0 -277
  15. package/src/contracts/cdp/types.ts +0 -43
  16. package/src/contracts/cdp-creator/queries.ts +0 -30
  17. package/src/contracts/cdp-creator/scripts.ts +0 -45
  18. package/src/contracts/cdp-creator/types-new.ts +0 -50
  19. package/src/contracts/cdp-creator/types.ts +0 -24
  20. package/src/contracts/collector/scripts.ts +0 -32
  21. package/src/contracts/collector/transactions.ts +0 -50
  22. package/src/contracts/collector/types-new.ts +0 -17
  23. package/src/contracts/execute/scripts.ts +0 -57
  24. package/src/contracts/execute/types-new.ts +0 -44
  25. package/src/contracts/execute/types.ts +0 -24
  26. package/src/contracts/gov/helpers.ts +0 -351
  27. package/src/contracts/gov/scripts.ts +0 -41
  28. package/src/contracts/gov/transactions.ts +0 -1607
  29. package/src/contracts/gov/types-new.ts +0 -268
  30. package/src/contracts/gov/types.ts +0 -22
  31. package/src/contracts/iasset/helpers.ts +0 -170
  32. package/src/contracts/iasset/queries.ts +0 -102
  33. package/src/contracts/iasset/scripts.ts +0 -38
  34. package/src/contracts/iasset/types.ts +0 -154
  35. package/src/contracts/initialize/actions.ts +0 -789
  36. package/src/contracts/initialize/helpers.ts +0 -616
  37. package/src/contracts/initialize/types.ts +0 -116
  38. package/src/contracts/interest-collection/helpers.ts +0 -19
  39. package/src/contracts/interest-collection/queries.ts +0 -66
  40. package/src/contracts/interest-collection/scripts.ts +0 -44
  41. package/src/contracts/interest-collection/transactions.ts +0 -433
  42. package/src/contracts/interest-collection/types-new.ts +0 -50
  43. package/src/contracts/interest-collection/types.ts +0 -26
  44. package/src/contracts/interest-oracle/helpers.ts +0 -61
  45. package/src/contracts/interest-oracle/scripts.ts +0 -18
  46. package/src/contracts/interest-oracle/transactions.ts +0 -151
  47. package/src/contracts/interest-oracle/types-new.ts +0 -32
  48. package/src/contracts/interest-oracle/types.ts +0 -16
  49. package/src/contracts/one-shot/scripts.ts +0 -12
  50. package/src/contracts/one-shot/transactions.ts +0 -66
  51. package/src/contracts/one-shot/types.ts +0 -22
  52. package/src/contracts/poll/helpers.ts +0 -37
  53. package/src/contracts/poll/scripts.ts +0 -71
  54. package/src/contracts/poll/types-poll-manager.ts +0 -20
  55. package/src/contracts/poll/types-poll-new.ts +0 -196
  56. package/src/contracts/poll/types-poll-shard.ts +0 -16
  57. package/src/contracts/price-oracle/helpers.ts +0 -30
  58. package/src/contracts/price-oracle/scripts.ts +0 -18
  59. package/src/contracts/price-oracle/transactions.ts +0 -115
  60. package/src/contracts/price-oracle/types-new.ts +0 -50
  61. package/src/contracts/price-oracle/types.ts +0 -16
  62. package/src/contracts/pyth-feed/helpers.ts +0 -82
  63. package/src/contracts/pyth-feed/scripts.ts +0 -15
  64. package/src/contracts/pyth-feed/types.ts +0 -181
  65. package/src/contracts/rob/helpers.ts +0 -666
  66. package/src/contracts/rob/scripts.ts +0 -35
  67. package/src/contracts/rob/transactions.ts +0 -423
  68. package/src/contracts/rob/types-new.ts +0 -128
  69. package/src/contracts/rob/types.ts +0 -16
  70. package/src/contracts/rob-leverage/helpers.ts +0 -422
  71. package/src/contracts/rob-leverage/transactions.ts +0 -368
  72. package/src/contracts/stability-pool/helpers.ts +0 -798
  73. package/src/contracts/stability-pool/queries.ts +0 -132
  74. package/src/contracts/stability-pool/scripts.ts +0 -51
  75. package/src/contracts/stability-pool/transactions.ts +0 -921
  76. package/src/contracts/stability-pool/types-new.ts +0 -385
  77. package/src/contracts/stability-pool/types.ts +0 -25
  78. package/src/contracts/stableswap/helpers.ts +0 -507
  79. package/src/contracts/stableswap/scripts.ts +0 -37
  80. package/src/contracts/stableswap/transactions.ts +0 -475
  81. package/src/contracts/stableswap/types-new.ts +0 -131
  82. package/src/contracts/stableswap/types.ts +0 -17
  83. package/src/contracts/staking/helpers.ts +0 -136
  84. package/src/contracts/staking/scripts.ts +0 -41
  85. package/src/contracts/staking/transactions.ts +0 -349
  86. package/src/contracts/staking/types-new.ts +0 -137
  87. package/src/contracts/staking/types.ts +0 -17
  88. package/src/contracts/treasury/helpers.ts +0 -21
  89. package/src/contracts/treasury/queries.ts +0 -100
  90. package/src/contracts/treasury/scripts.ts +0 -27
  91. package/src/contracts/treasury/transactions.ts +0 -334
  92. package/src/contracts/treasury/types-new.ts +0 -69
  93. package/src/contracts/treasury/types.ts +0 -14
  94. package/src/contracts/version-registry/scripts.ts +0 -29
  95. package/src/contracts/version-registry/types-new.ts +0 -18
  96. package/src/contracts/version-registry/types.ts +0 -17
  97. package/src/index.ts +0 -99
  98. package/src/scripts/always-fail-validator.ts +0 -7
  99. package/src/scripts/auth-token-policy.ts +0 -24
  100. package/src/scripts/iasset-policy.ts +0 -23
  101. package/src/types/evolution-schema-options.ts +0 -16
  102. package/src/types/generic.ts +0 -52
  103. package/src/types/multisig.ts +0 -48
  104. package/src/types/on-chain-decimal.ts +0 -57
  105. package/src/types/rational.ts +0 -76
  106. package/src/types/system-params.ts +0 -463
  107. package/src/utils/array-utils.ts +0 -108
  108. package/src/utils/bigint-utils.ts +0 -35
  109. package/src/utils/helper-txs.ts +0 -31
  110. package/src/utils/indigo-helpers.ts +0 -17
  111. package/src/utils/lucid-utils.ts +0 -125
  112. package/src/utils/oracle-helpers.ts +0 -62
  113. package/src/utils/pyth/decode.ts +0 -223
  114. package/src/utils/pyth/encode.ts +0 -262
  115. package/src/utils/pyth/index.ts +0 -14
  116. package/src/utils/pyth/types.ts +0 -87
  117. package/src/utils/time-helpers.ts +0 -4
  118. package/src/utils/utils.ts +0 -25
  119. package/src/validators/always-succeed-validator.ts +0 -6
  120. package/src/validators/cdp-creator-validator.ts +0 -7
  121. package/src/validators/cdp-redeem-validator.ts +0 -7
  122. package/src/validators/cdp-validator.ts +0 -7
  123. package/src/validators/collector-validator.ts +0 -7
  124. package/src/validators/execute-validator.ts +0 -7
  125. package/src/validators/governance-validator.ts +0 -7
  126. package/src/validators/iasset-validator.ts +0 -7
  127. package/src/validators/interest-collection-validator.ts +0 -7
  128. package/src/validators/interest-oracle-validator.ts +0 -7
  129. package/src/validators/one-shot-policy.ts +0 -7
  130. package/src/validators/poll-manager-validator.ts +0 -7
  131. package/src/validators/poll-shard-validator.ts +0 -7
  132. package/src/validators/price-oracle-validator.ts +0 -7
  133. package/src/validators/pyth-feed-validator.ts +0 -7
  134. package/src/validators/rob-validator.ts +0 -7
  135. package/src/validators/stability-pool-validator.ts +0 -7
  136. package/src/validators/stableswap-validator.ts +0 -7
  137. package/src/validators/staking-validator.ts +0 -7
  138. package/src/validators/treasury-validator.ts +0 -7
  139. package/src/validators/version-record-policy.ts +0 -7
  140. package/src/validators/version-registry-validator.ts +0 -7
  141. package/tests/always-succeed/script.ts +0 -7
  142. package/tests/array-utils.test.ts +0 -92
  143. package/tests/bigint-utils.test.ts +0 -41
  144. package/tests/cdp/actions.ts +0 -680
  145. package/tests/cdp/cdp-helpers.ts +0 -55
  146. package/tests/cdp/cdp-queries.ts +0 -423
  147. package/tests/cdp/cdp.test.ts +0 -6730
  148. package/tests/cdp/transactions-mutated.ts +0 -1733
  149. package/tests/data/system-params.json +0 -1155
  150. package/tests/datums.test.ts +0 -302
  151. package/tests/endpoints/initialize.ts +0 -78
  152. package/tests/endpoints/interest-collector.ts +0 -37
  153. package/tests/endpoints/treasury.ts +0 -70
  154. package/tests/gov/actions.ts +0 -381
  155. package/tests/gov/gov.test.ts +0 -5147
  156. package/tests/gov/governance-queries.ts +0 -37
  157. package/tests/hash-checks.test.ts +0 -112
  158. package/tests/indigo-test-helpers.ts +0 -99
  159. package/tests/initialize.test.ts +0 -79
  160. package/tests/interest-calculations.test.ts +0 -120
  161. package/tests/interest-collection/interest-collection.test.ts +0 -843
  162. package/tests/interest-collection/transactions-mutated.ts +0 -260
  163. package/tests/interest-oracle.test.ts +0 -93
  164. package/tests/mock/assets-mock.ts +0 -243
  165. package/tests/mock/protocol-params-mock.ts +0 -21
  166. package/tests/price-oracle/actions.ts +0 -161
  167. package/tests/price-oracle/price-oracle-queries.ts +0 -12
  168. package/tests/price-oracle/price-oracle.test.ts +0 -228
  169. package/tests/price-oracle/transactions-mutated.ts +0 -59
  170. package/tests/pyth/endpoints.ts +0 -96
  171. package/tests/pyth/helpers.ts +0 -37
  172. package/tests/pyth/pyth-encoding.test.ts +0 -376
  173. package/tests/pyth/pyth-feeds.test.ts +0 -943
  174. package/tests/pyth/pyth-indigo.test.ts +0 -505
  175. package/tests/pyth/pyth.test.ts +0 -299
  176. package/tests/queries/collector-queries.ts +0 -27
  177. package/tests/queries/execute-queries.ts +0 -47
  178. package/tests/queries/iasset-queries.ts +0 -149
  179. package/tests/queries/interest-oracle-queries.ts +0 -12
  180. package/tests/queries/poll-queries.ts +0 -97
  181. package/tests/queries/staking-queries.ts +0 -54
  182. package/tests/rob/actions.ts +0 -56
  183. package/tests/rob/rob-leverage.test.ts +0 -2555
  184. package/tests/rob/rob-queries.ts +0 -95
  185. package/tests/rob/rob.test.ts +0 -3677
  186. package/tests/rob/transactions-mutated.ts +0 -844
  187. package/tests/script-size.test.ts +0 -240
  188. package/tests/setup.ts +0 -135
  189. package/tests/stability-pool/actions.ts +0 -229
  190. package/tests/stability-pool.test.ts +0 -6491
  191. package/tests/stableswap/stableswap-actions.ts +0 -83
  192. package/tests/stableswap/stableswap-queries.ts +0 -98
  193. package/tests/stableswap/stableswap.test.ts +0 -4471
  194. package/tests/stableswap/transactions-mutated.ts +0 -348
  195. package/tests/staking.test.ts +0 -172
  196. package/tests/test-helpers.ts +0 -94
  197. package/tests/treasury/actions.ts +0 -67
  198. package/tests/treasury/treasury.test.ts +0 -320
  199. package/tests/utils/asserts.ts +0 -87
  200. package/tests/utils/benchmark-utils.ts +0 -130
  201. package/tests/utils/index.ts +0 -168
  202. package/tsconfig.build.json +0 -4
  203. package/tsconfig.json +0 -27
  204. package/vitest.config.ts +0 -11
@@ -1,37 +0,0 @@
1
- import { LucidEvolution, ScriptHash, UTxO } from '@lucid-evolution/lucid';
2
- import { createScriptAddress } from '../../src/utils/lucid-utils';
3
- import { matchSingle } from '../../src';
4
- import { option as O, array as A, function as F } from 'fp-ts';
5
- import { GovDatum, parseGovDatum } from '../../src/contracts/gov/types-new';
6
- import {
7
- AssetClass,
8
- assetClassToUnit,
9
- } from '@3rd-eye-labs/cardano-offchain-common';
10
-
11
- export async function findGov(
12
- lucid: LucidEvolution,
13
- govScriptHash: ScriptHash,
14
- govNft: AssetClass,
15
- ): Promise<{
16
- utxo: UTxO;
17
- datum: GovDatum;
18
- }> {
19
- const govUtxos = await lucid.utxosAtWithUnit(
20
- createScriptAddress(lucid.config().network!, govScriptHash),
21
- assetClassToUnit(govNft),
22
- );
23
-
24
- return matchSingle(
25
- F.pipe(
26
- govUtxos.map((utxo) =>
27
- F.pipe(
28
- O.fromNullable(utxo.datum),
29
- O.flatMap(parseGovDatum),
30
- O.map((datum) => ({ utxo, datum: datum })),
31
- ),
32
- ),
33
- A.compact,
34
- ),
35
- (res) => new Error('Expected a single Gov UTXO.: ' + JSON.stringify(res)),
36
- );
37
- }
@@ -1,112 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- loadSystemParamsFromFile,
4
- mkCDPCreatorValidatorFromSP,
5
- mkInterestOracleValidator,
6
- mkRobValidatorFromSP,
7
- mkCdpValidatorFromSP,
8
- mkExecuteValidatorFromSP,
9
- mkCollectorValidatorFromSP,
10
- mkInterestCollectionValidatorFromSP,
11
- mkTreasuryValidatorFromSP,
12
- } from '../src';
13
- import { validatorToScriptHash } from '@lucid-evolution/lucid';
14
- import { mkStabilityPoolValidatorFromSP } from '../src/contracts/stability-pool/scripts';
15
- import { mkGovValidatorFromSP } from '../src/contracts/gov/scripts';
16
- import { mkStakingValidatorFromSP } from '../src/contracts/staking/scripts';
17
- import { mkStableswapValidatorFromSP } from '../src/contracts/stableswap/scripts';
18
-
19
- const systemParams = loadSystemParamsFromFile(
20
- './tests/data/system-params.json',
21
- );
22
-
23
- describe('Validator Hash checks', () => {
24
- it.todo('CDP Creator validator hash', () => {
25
- expect(
26
- validatorToScriptHash(
27
- mkCDPCreatorValidatorFromSP(systemParams.cdpCreatorParams),
28
- ),
29
- ).toBe(systemParams.validatorHashes.cdpCreatorHash);
30
- });
31
- it.todo('CDP validator hash', () => {
32
- expect(
33
- validatorToScriptHash(mkCdpValidatorFromSP(systemParams.cdpParams)),
34
- ).toBe(systemParams.validatorHashes.cdpHash);
35
- });
36
- it.todo('Collector validator hash', () => {
37
- expect(
38
- validatorToScriptHash(
39
- mkCollectorValidatorFromSP(systemParams.collectorParams),
40
- ),
41
- ).toBe(systemParams.validatorHashes.collectorHash);
42
- });
43
- it.todo('Interest collector validator hash', () => {
44
- expect(
45
- validatorToScriptHash(
46
- mkInterestCollectionValidatorFromSP(
47
- systemParams.interestCollectionParams,
48
- ),
49
- ),
50
- ).toBe(systemParams.validatorHashes.interestCollectionHash);
51
- });
52
- // TODO: Revisit this test, issues with cbor encoding on Lucid?
53
- // Applying parameters to the validator using `aiken build` does not result in the same hash as the one generate by Lucid.
54
- it.todo('Execute validator hash', () => {
55
- expect(
56
- validatorToScriptHash(
57
- mkExecuteValidatorFromSP(systemParams.executeParams),
58
- ),
59
- ).toBe(systemParams.validatorHashes.executeHash);
60
- });
61
- it.todo('Gov validator hash', () => {
62
- expect(
63
- validatorToScriptHash(mkGovValidatorFromSP(systemParams.govParams)),
64
- ).toBe(systemParams.validatorHashes.govHash);
65
- });
66
- it.todo('Staking validator hash', () => {
67
- expect(
68
- validatorToScriptHash(
69
- mkStakingValidatorFromSP(systemParams.stakingParams),
70
- ),
71
- ).toBe(systemParams.validatorHashes.stakingHash);
72
- });
73
- it.todo('Stability Pool validator hash', () => {
74
- expect(
75
- validatorToScriptHash(
76
- mkStabilityPoolValidatorFromSP(systemParams.stabilityPoolParams),
77
- ),
78
- ).toBe(systemParams.validatorHashes.stabilityPoolHash);
79
- });
80
- it.todo('Stableswap validator hash', () => {
81
- expect(
82
- validatorToScriptHash(
83
- mkStableswapValidatorFromSP(systemParams.stableswapParams),
84
- ),
85
- ).toBe(systemParams.validatorHashes.stabilityPoolHash);
86
- });
87
-
88
- it.todo('Interest Oracle validator hash', () => {
89
- expect(
90
- validatorToScriptHash(
91
- mkInterestOracleValidator({
92
- biasTime: 1_200_000n,
93
- owner: 'a962c79bd58fc9fcecd78f8a963e0ce80e907264cd86cd5814d87333',
94
- }),
95
- ),
96
- ).toBe('b970b3e0e1b591840627e6919898c12ee57e2f0225ab03e056d10d52');
97
- });
98
-
99
- it.todo('ROB validator hash', () => {
100
- expect(
101
- validatorToScriptHash(mkRobValidatorFromSP(systemParams.robParams)),
102
- ).toBe(systemParams.validatorHashes.robHash);
103
- });
104
-
105
- it.todo('Treasury validator hash', () => {
106
- expect(
107
- validatorToScriptHash(
108
- mkTreasuryValidatorFromSP(systemParams.treasuryParams),
109
- ),
110
- ).toBe(systemParams.validatorHashes.treasuryHash);
111
- });
112
- });
@@ -1,99 +0,0 @@
1
- import {
2
- addAssets,
3
- Emulator,
4
- fromHex,
5
- fromText,
6
- generateEmulatorAccount,
7
- generateEmulatorAccountFromPrivateKey,
8
- Lucid,
9
- paymentCredentialOf,
10
- PROTOCOL_PARAMETERS_DEFAULT,
11
- ProtocolParameters,
12
- } from '@lucid-evolution/lucid';
13
- import {
14
- AssetClass,
15
- mkAssetsOf,
16
- mkLovelacesOf,
17
- } from '@3rd-eye-labs/cardano-offchain-common';
18
- import { IndigoTestContext } from './test-helpers';
19
- import { init } from './endpoints/initialize';
20
- import { ieurInitialAssetCfg, iusdInitialAssetCfg } from './mock/assets-mock';
21
-
22
- export const MAINNET_PROTOCOL_PARAMETERS: ProtocolParameters = {
23
- ...PROTOCOL_PARAMETERS_DEFAULT,
24
- maxTxExMem: 16500000n,
25
- };
26
-
27
- export const EXAMPLE_TOKEN_1: AssetClass = {
28
- currencySymbol: fromHex(
29
- '00000000000000000000000000000000000000000000000000000000',
30
- ),
31
- tokenName: fromHex(fromText('example-token-1')),
32
- };
33
- export const EXAMPLE_TOKEN_2: AssetClass = {
34
- currencySymbol: fromHex(
35
- '00000000000000000000000000000000000000000000000000000001',
36
- ),
37
- tokenName: fromHex(fromText('example-token-2')),
38
- };
39
- export const EXAMPLE_TOKEN_3: AssetClass = {
40
- currencySymbol: fromHex(
41
- '00000000000000000000000000000000000000000000000000000002',
42
- ),
43
- tokenName: fromHex(fromText('example-token-3')),
44
- };
45
-
46
- export async function createIndigoTestContext(
47
- context: IndigoTestContext,
48
- ): Promise<void> {
49
- context.users = {
50
- admin: generateEmulatorAccount(
51
- addAssets(
52
- mkLovelacesOf(100_000_000_000_000n),
53
- mkAssetsOf(EXAMPLE_TOKEN_1, 1_000_000_000_000_000n),
54
- ),
55
- ),
56
- user: generateEmulatorAccount(
57
- addAssets(
58
- mkLovelacesOf(100_000_000_000_000n),
59
- mkAssetsOf(EXAMPLE_TOKEN_1, 1_000_000_000_000_000n),
60
- mkAssetsOf(EXAMPLE_TOKEN_2, 1_000_000_000_000_000n),
61
- mkAssetsOf(EXAMPLE_TOKEN_3, 1_000_000_000_000_000n),
62
- ),
63
- ),
64
- user2: generateEmulatorAccount({
65
- lovelace: BigInt(100_000_000_000_000),
66
- }),
67
- withdrawalAccount: generateEmulatorAccountFromPrivateKey({}),
68
- };
69
-
70
- context.emulator = new Emulator(
71
- [
72
- context.users.admin,
73
- context.users.user,
74
- context.users.user2,
75
- context.users.withdrawalAccount,
76
- ],
77
- MAINNET_PROTOCOL_PARAMETERS,
78
- );
79
- context.lucid = await Lucid(context.emulator, 'Custom');
80
- context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
81
-
82
- const [systemParams, assetConfigs] = await init(
83
- context.lucid,
84
- [iusdInitialAssetCfg(), ieurInitialAssetCfg()],
85
- () => [],
86
- {
87
- foundationMultisig: {
88
- Signature: {
89
- keyHash: fromHex(
90
- paymentCredentialOf(context.users.admin.address).hash,
91
- ),
92
- },
93
- },
94
- },
95
- );
96
-
97
- context.systemParams = systemParams;
98
- context.assetConfigs = assetConfigs;
99
- }
@@ -1,79 +0,0 @@
1
- import { assert, beforeEach, test } from 'vitest';
2
- import { LucidContext } from './test-helpers';
3
- import { addAssets, EmulatorAccount, Lucid } from '@lucid-evolution/lucid';
4
- import { Emulator } from '@lucid-evolution/lucid';
5
- import { generateEmulatorAccount } from '@lucid-evolution/lucid';
6
- import { DEFAULT_INTEREST, iusdInitialAssetCfg } from './mock/assets-mock';
7
- import {
8
- EXAMPLE_TOKEN_1,
9
- MAINNET_PROTOCOL_PARAMETERS,
10
- } from './indigo-test-helpers';
11
- import {
12
- mkAssetsOf,
13
- mkLovelacesOf,
14
- } from '@3rd-eye-labs/cardano-offchain-common';
15
- import { rationalFromInt } from '../src/types/rational';
16
- import { init } from './endpoints/initialize';
17
-
18
- type MyContext = LucidContext<{
19
- admin: EmulatorAccount;
20
- }>;
21
-
22
- beforeEach<MyContext>(async (context: MyContext) => {
23
- context.users = {
24
- admin: generateEmulatorAccount(
25
- addAssets(
26
- mkLovelacesOf(100_000_000_000_000n),
27
- mkAssetsOf(EXAMPLE_TOKEN_1, 1_000_000_000_000_000n),
28
- ),
29
- ),
30
- };
31
-
32
- context.emulator = new Emulator(
33
- [context.users.admin],
34
- MAINNET_PROTOCOL_PARAMETERS,
35
- );
36
-
37
- context.lucid = await Lucid(context.emulator, 'Custom');
38
- });
39
-
40
- test<MyContext>('Initialize Protocol - can initialize', async ({
41
- lucid,
42
- users,
43
- }: MyContext) => {
44
- lucid.selectWallet.fromSeed(users.admin.seedPhrase);
45
-
46
- await init(lucid, [
47
- iusdInitialAssetCfg(DEFAULT_INTEREST, [
48
- {
49
- collateralAsset: EXAMPLE_TOKEN_1,
50
- collateralToIassetRatio: rationalFromInt(1n),
51
- feeManager: undefined,
52
- minMintOrderAmount: 0n,
53
- minRedemptionOrderAmount: 0n,
54
- mintingEnabled: true,
55
- redemptionEnabled: true,
56
- mintingFeeRatio: { numerator: 1n, denominator: 100n },
57
- redemptionFeeRatio: { numerator: 1n, denominator: 100n },
58
- },
59
- ]),
60
- ]);
61
- });
62
-
63
- test<MyContext>('Validate Lucid protocol parameters match Mainnet', ({
64
- lucid,
65
- }: MyContext) => {
66
- const protocolParameters = lucid.config().protocolParameters!;
67
- assert(
68
- protocolParameters.maxTxSize === 16384,
69
- 'Lucid maxTxSize does not match Cardano Mainnet',
70
- );
71
- assert(
72
- protocolParameters.maxTxExMem === 16500000n,
73
- 'Lucid maxTxExMem does not match Cardano Mainnet',
74
- );
75
- assert(
76
- protocolParameters.maxTxExSteps === 10000000000n,
77
- 'Lucid maxTxExSteps does not match Cardano Mainnet',
78
- );
79
- });
@@ -1,120 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { ONE_DAY } from '../src/utils/time-helpers';
3
- import {
4
- calculateAccruedInterest,
5
- calculateUnitaryInterestSinceOracleLastUpdated,
6
- } from '../src/contracts/interest-oracle/helpers';
7
-
8
- describe('Interest Calculations', () => {
9
- describe('Calculate Unitary Interest', () => {
10
- it('Should calculate the unitary interest correctly, 0', () => {
11
- expect(
12
- calculateUnitaryInterestSinceOracleLastUpdated(ONE_DAY * 6n, {
13
- unitaryInterest: 684_931_506_849_315n,
14
- interestRate: { getOnChainInt: 100_000n },
15
- lastUpdated: ONE_DAY * 5n,
16
- }),
17
- ).toBe(273_972_602_739_726n);
18
- });
19
-
20
- it('Should calculate the unitary interest correctly, 1', () => {
21
- expect(
22
- calculateUnitaryInterestSinceOracleLastUpdated(ONE_DAY * 6n, {
23
- unitaryInterest: 0n,
24
- interestRate: { getOnChainInt: 50_000n },
25
- lastUpdated: 0n,
26
- }),
27
- ).toBe(821_917_808_219_178n);
28
- });
29
-
30
- it('Should calculate the unitary interest correctly, 2', () => {
31
- expect(
32
- calculateUnitaryInterestSinceOracleLastUpdated(1n, {
33
- unitaryInterest: 0n,
34
- interestRate: { getOnChainInt: 1n },
35
- lastUpdated: 0n,
36
- }),
37
- ).toBe(31n);
38
- });
39
- });
40
-
41
- describe('Calculate Accumulated Interest', () => {
42
- it('Should calculate the accumulated interest correctly, 0', () => {
43
- expect(
44
- calculateAccruedInterest(ONE_DAY, 0n, 1_000_000n, 0n, {
45
- unitaryInterest: 0n,
46
- interestRate: { getOnChainInt: 50_000n },
47
- lastUpdated: 0n,
48
- }),
49
- ).toBe(136n);
50
- });
51
-
52
- it('Should calculate the accumulated interest correctly, 1', () => {
53
- expect(
54
- calculateAccruedInterest(ONE_DAY * 6n, 0n, 1_000_000n, 0n, {
55
- unitaryInterest: 684_931_506_849_315n,
56
- interestRate: { getOnChainInt: 100_000n },
57
- lastUpdated: ONE_DAY * 5n,
58
- }),
59
- ).toBe(684n + 273n);
60
- });
61
-
62
- it('Should calculate the accumulated interest correctly, 2', () => {
63
- expect(
64
- calculateAccruedInterest(ONE_DAY * 17n, 0n, 1_000_000n, 0n, {
65
- unitaryInterest: 1_506_849_315_068_493n,
66
- interestRate: { getOnChainInt: 100_000n },
67
- lastUpdated: ONE_DAY * 15n,
68
- }),
69
- ).toBe(1506n + 547n);
70
- });
71
-
72
- it('Should calculate the accumulated interest correctly, 3', () => {
73
- expect(
74
- calculateAccruedInterest(
75
- ONE_DAY * 17n,
76
- 410_958_904_109_589n,
77
- 1_000_000n,
78
- ONE_DAY * 3n,
79
- {
80
- unitaryInterest: 1_506_849_315_068_493n,
81
- interestRate: { getOnChainInt: 100_000n },
82
- lastUpdated: ONE_DAY * 15n,
83
- },
84
- ),
85
- ).toBe(1095n + 547n);
86
- });
87
-
88
- it('Should calculate the accumulated interest correctly, 4', () => {
89
- expect(
90
- calculateAccruedInterest(
91
- ONE_DAY * 17n,
92
- 767_123_287_671_232n,
93
- 1_000_000n,
94
- ONE_DAY * 6n,
95
- {
96
- unitaryInterest: 1_506_849_315_068_493n,
97
- interestRate: { getOnChainInt: 100_000n },
98
- lastUpdated: ONE_DAY * 15n,
99
- },
100
- ),
101
- ).toBe(739n + 547n);
102
- });
103
-
104
- it('Should calculate the accumulated interest correctly, 5', () => {
105
- expect(
106
- calculateAccruedInterest(
107
- ONE_DAY * 10n,
108
- 821_917_808_219_178n,
109
- 1_000_000n,
110
- ONE_DAY * 6n,
111
- {
112
- unitaryInterest: 0n,
113
- interestRate: { getOnChainInt: 50_000n },
114
- lastUpdated: 0n,
115
- },
116
- ),
117
- ).toBe(547n);
118
- });
119
- });
120
- });