@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.
- package/.github/workflows/ci.yml +4 -2
- package/dist/index.d.mts +3008 -2194
- package/dist/index.d.ts +3008 -2194
- package/dist/index.js +9827 -6194
- package/dist/index.mjs +8591 -4809
- package/package.json +14 -3
- package/src/contracts/cdp/helpers.ts +68 -72
- package/src/contracts/cdp/scripts.ts +50 -13
- package/src/contracts/cdp/transactions.ts +831 -545
- package/src/contracts/cdp/types-new.ts +256 -0
- package/src/contracts/cdp/types.ts +26 -144
- package/src/contracts/cdp-creator/scripts.ts +15 -9
- package/src/contracts/cdp-creator/types-new.ts +50 -0
- package/src/contracts/cdp-creator/types.ts +5 -31
- package/src/contracts/collector/scripts.ts +1 -1
- package/src/contracts/collector/transactions.ts +23 -13
- package/src/contracts/collector/types-new.ts +17 -0
- package/src/contracts/execute/scripts.ts +19 -10
- package/src/contracts/execute/types-new.ts +44 -0
- package/src/contracts/execute/types.ts +5 -38
- package/src/contracts/gov/helpers.ts +187 -51
- package/src/contracts/gov/scripts.ts +17 -10
- package/src/contracts/gov/transactions.ts +599 -271
- package/src/contracts/gov/types-new.ts +253 -100
- package/src/contracts/gov/types.ts +4 -71
- package/src/contracts/iasset/helpers.ts +172 -0
- package/src/contracts/iasset/scripts.ts +38 -0
- package/src/contracts/iasset/types.ts +154 -0
- package/src/contracts/initialize/actions.ts +768 -0
- package/src/contracts/initialize/helpers.ts +611 -36
- package/src/contracts/initialize/types.ts +102 -28
- package/src/contracts/interest-collection/helpers.ts +19 -0
- package/src/contracts/interest-collection/scripts.ts +44 -0
- package/src/contracts/interest-collection/transactions.ts +436 -0
- package/src/contracts/interest-collection/types-new.ts +50 -0
- package/src/contracts/interest-collection/types.ts +26 -0
- package/src/contracts/interest-oracle/helpers.ts +2 -30
- package/src/contracts/interest-oracle/scripts.ts +1 -1
- package/src/contracts/interest-oracle/transactions.ts +21 -16
- package/src/contracts/interest-oracle/types-new.ts +32 -0
- package/src/contracts/interest-oracle/types.ts +1 -40
- package/src/contracts/one-shot/transactions.ts +1 -2
- package/src/contracts/poll/helpers.ts +5 -23
- package/src/contracts/poll/scripts.ts +12 -13
- package/src/contracts/poll/types-poll-manager.ts +1 -19
- package/src/contracts/poll/types-poll-new.ts +170 -0
- package/src/contracts/poll/types-poll-shard.ts +2 -24
- package/src/contracts/price-oracle/helpers.ts +1 -4
- package/src/contracts/price-oracle/scripts.ts +3 -8
- package/src/contracts/price-oracle/transactions.ts +32 -25
- package/src/contracts/price-oracle/types-new.ts +50 -0
- package/src/contracts/price-oracle/types.ts +2 -36
- package/src/contracts/pyth-feed/helpers.ts +58 -0
- package/src/contracts/pyth-feed/scripts.ts +15 -0
- package/src/contracts/pyth-feed/types.ts +181 -0
- package/src/contracts/rob/helpers.ts +405 -0
- package/src/contracts/rob/scripts.ts +35 -0
- package/src/contracts/rob/transactions.ts +410 -0
- package/src/contracts/rob/types-new.ts +128 -0
- package/src/contracts/rob/types.ts +16 -0
- package/src/contracts/rob-leverage/helpers.ts +424 -0
- package/src/contracts/{leverage → rob-leverage}/transactions.ts +68 -48
- package/src/contracts/stability-pool/helpers.ts +714 -230
- package/src/contracts/stability-pool/scripts.ts +20 -15
- package/src/contracts/stability-pool/transactions.ts +625 -495
- package/src/contracts/stability-pool/types-new.ts +237 -100
- package/src/contracts/stability-pool/types.ts +5 -22
- package/src/contracts/stableswap/helpers.ts +22 -0
- package/src/contracts/stableswap/scripts.ts +37 -0
- package/src/contracts/stableswap/transactions.ts +647 -0
- package/src/contracts/stableswap/types-new.ts +131 -0
- package/src/contracts/stableswap/types.ts +17 -0
- package/src/contracts/staking/helpers.ts +49 -34
- package/src/contracts/staking/scripts.ts +1 -1
- package/src/contracts/staking/transactions.ts +85 -130
- package/src/contracts/staking/types-new.ts +60 -28
- package/src/contracts/staking/types.ts +1 -28
- package/src/contracts/treasury/helpers.ts +21 -0
- package/src/contracts/treasury/scripts.ts +16 -26
- package/src/contracts/treasury/transactions.ts +256 -27
- package/src/contracts/treasury/types-new.ts +69 -0
- package/src/contracts/treasury/types.ts +2 -43
- package/src/contracts/version-registry/scripts.ts +2 -2
- package/src/contracts/version-registry/types-new.ts +6 -7
- package/src/index.ts +37 -20
- package/src/scripts/auth-token-policy.ts +3 -2
- package/src/scripts/iasset-policy.ts +3 -2
- package/src/types/evolution-schema-options.ts +3 -3
- package/src/types/generic.ts +17 -89
- package/src/types/multisig.ts +48 -0
- package/src/types/on-chain-decimal.ts +14 -7
- package/src/types/rational.ts +61 -0
- package/src/types/system-params.ts +237 -41
- package/src/utils/array-utils.ts +70 -1
- package/src/utils/bigint-utils.ts +12 -0
- package/src/utils/indigo-helpers.ts +8 -10
- package/src/utils/lucid-utils.ts +47 -40
- package/src/utils/oracle-helpers.ts +62 -0
- package/src/utils/pyth/decode.ts +223 -0
- package/src/utils/pyth/encode.ts +262 -0
- package/src/utils/pyth/index.ts +14 -0
- package/src/utils/pyth/types.ts +87 -0
- package/src/validators/always-succeed-validator.ts +6 -0
- package/src/validators/cdp-creator-validator.ts +2 -2
- package/src/validators/cdp-redeem-validator.ts +7 -0
- package/src/validators/cdp-validator.ts +2 -2
- package/src/validators/collector-validator.ts +2 -2
- package/src/validators/execute-validator.ts +2 -2
- package/src/validators/governance-validator.ts +2 -2
- package/src/validators/iasset-validator.ts +7 -0
- package/src/validators/interest-collection-validator.ts +7 -0
- package/src/validators/interest-oracle-validator.ts +2 -2
- package/src/validators/poll-manager-validator.ts +2 -2
- package/src/validators/poll-shard-validator.ts +2 -2
- package/src/validators/price-oracle-validator.ts +7 -0
- package/src/validators/pyth-feed-validator.ts +7 -0
- package/src/validators/rob-validator.ts +7 -0
- package/src/validators/stability-pool-validator.ts +2 -2
- package/src/validators/stableswap-validator.ts +7 -0
- package/src/validators/staking-validator.ts +2 -2
- package/src/validators/treasury-validator.ts +2 -2
- package/src/validators/version-record-policy.ts +2 -2
- package/src/validators/version-registry-validator.ts +2 -2
- package/tests/always-succeed/script.ts +7 -0
- package/tests/bigint-utils.test.ts +41 -0
- package/tests/cdp/actions.ts +611 -0
- package/tests/cdp/cdp-helpers.ts +55 -0
- package/tests/cdp/cdp-queries.ts +440 -0
- package/tests/cdp/cdp.test.ts +6087 -0
- package/tests/cdp/transactions-mutated.ts +1729 -0
- package/tests/data/system-params.json +177 -34
- package/tests/datums.test.ts +209 -210
- package/tests/endpoints/initialize.ts +68 -0
- package/tests/endpoints/interest-collector.ts +37 -0
- package/tests/endpoints/treasury.ts +70 -0
- package/tests/gov/actions.ts +406 -0
- package/tests/gov/gov.test.ts +4450 -0
- package/tests/{queries → gov}/governance-queries.ts +6 -3
- package/tests/hash-checks.test.ts +38 -11
- package/tests/indigo-test-helpers.ts +100 -0
- package/tests/initialize.test.ts +61 -9
- package/tests/interest-collection/interest-collection.test.ts +892 -0
- package/tests/interest-collection/interest-collector-queries.ts +49 -0
- package/tests/interest-collection/transactions-mutated.ts +260 -0
- package/tests/interest-oracle.test.ts +43 -35
- package/tests/mock/assets-mock.ts +234 -23
- package/tests/mock/protocol-params-mock.ts +21 -0
- package/tests/price-oracle/actions.ts +163 -0
- package/tests/price-oracle/price-oracle-queries.ts +12 -0
- package/tests/price-oracle/price-oracle.test.ts +240 -0
- package/tests/price-oracle/transactions-mutated.ts +62 -0
- package/tests/pyth/endpoints.ts +96 -0
- package/tests/pyth/helpers.ts +37 -0
- package/tests/pyth/pyth-encoding.test.ts +376 -0
- package/tests/pyth/pyth-indigo.test.ts +509 -0
- package/tests/pyth/pyth.test.ts +300 -0
- package/tests/queries/execute-queries.ts +6 -5
- package/tests/queries/iasset-queries.ts +175 -5
- package/tests/queries/interest-oracle-queries.ts +4 -2
- package/tests/queries/poll-queries.ts +8 -9
- package/tests/queries/stability-pool-queries.ts +95 -48
- package/tests/queries/staking-queries.ts +4 -2
- package/tests/queries/treasury-queries.ts +80 -5
- package/tests/rob/actions.ts +58 -0
- package/tests/{lrp-leverage.test.ts → rob/rob-leverage.test.ts} +393 -296
- package/tests/rob/rob-queries.ts +95 -0
- package/tests/rob/rob.test.ts +3762 -0
- package/tests/rob/transactions-mutated.ts +853 -0
- package/tests/script-size.test.ts +240 -0
- package/tests/setup.ts +135 -0
- package/tests/stability-pool/actions.ts +210 -0
- package/tests/stability-pool.test.ts +5469 -666
- package/tests/stableswap/stableswap-actions.ts +84 -0
- package/tests/stableswap/stableswap-queries.ts +89 -0
- package/tests/stableswap/stableswap.test.ts +3891 -0
- package/tests/stableswap/transactions-mutated.ts +348 -0
- package/tests/staking.test.ts +82 -99
- package/tests/test-helpers.ts +58 -11
- package/tests/treasury.test.ts +242 -0
- package/tests/utils/asserts.ts +74 -0
- package/tests/utils/benchmark-utils.ts +81 -0
- package/tests/utils/index.ts +122 -4
- package/tsconfig.json +9 -1
- package/vitest.config.ts +3 -1
- package/src/contracts/collector/types.ts +0 -16
- package/src/contracts/initialize/transactions.ts +0 -891
- package/src/contracts/leverage/helpers.ts +0 -424
- package/src/contracts/lrp/helpers.ts +0 -294
- package/src/contracts/lrp/scripts.ts +0 -27
- package/src/contracts/lrp/transactions.ts +0 -250
- package/src/contracts/lrp/types.ts +0 -131
- package/src/contracts/poll/types-poll.ts +0 -88
- package/src/contracts/vesting/helpers.ts +0 -218
- package/src/utils/value-helpers.ts +0 -37
- package/src/validators/lrp-validator.ts +0 -7
- package/tests/cdp.test.ts +0 -1528
- package/tests/gov.test.ts +0 -2011
- package/tests/lrp.test.ts +0 -673
- package/tests/queries/cdp-queries.ts +0 -220
- package/tests/queries/lrp-queries.ts +0 -76
- package/tests/queries/price-oracle-queries.ts +0 -10
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { LucidEvolution, ScriptHash, UTxO } from '@lucid-evolution/lucid';
|
|
2
2
|
import { createScriptAddress } from '../../src/utils/lucid-utils';
|
|
3
|
-
import {
|
|
4
|
-
import { assetClassToUnit } from '../../src/utils/value-helpers';
|
|
5
|
-
import { GovDatum, matchSingle, parseGovDatum } from '../../src';
|
|
3
|
+
import { matchSingle } from '../../src';
|
|
6
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';
|
|
7
10
|
|
|
8
11
|
export async function findGov(
|
|
9
12
|
lucid: LucidEvolution,
|
|
@@ -3,40 +3,52 @@ import {
|
|
|
3
3
|
loadSystemParamsFromFile,
|
|
4
4
|
mkCDPCreatorValidatorFromSP,
|
|
5
5
|
mkInterestOracleValidator,
|
|
6
|
-
|
|
6
|
+
mkRobValidatorFromSP,
|
|
7
7
|
mkCdpValidatorFromSP,
|
|
8
8
|
mkExecuteValidatorFromSP,
|
|
9
9
|
mkCollectorValidatorFromSP,
|
|
10
|
+
mkInterestCollectionValidatorFromSP,
|
|
11
|
+
mkTreasuryValidatorFromSP,
|
|
10
12
|
} from '../src';
|
|
11
13
|
import { validatorToScriptHash } from '@lucid-evolution/lucid';
|
|
12
14
|
import { mkStabilityPoolValidatorFromSP } from '../src/contracts/stability-pool/scripts';
|
|
13
15
|
import { mkGovValidatorFromSP } from '../src/contracts/gov/scripts';
|
|
14
16
|
import { mkStakingValidatorFromSP } from '../src/contracts/staking/scripts';
|
|
17
|
+
import { mkStableswapValidatorFromSP } from '../src/contracts/stableswap/scripts';
|
|
15
18
|
|
|
16
19
|
const systemParams = loadSystemParamsFromFile(
|
|
17
20
|
'./tests/data/system-params.json',
|
|
18
21
|
);
|
|
19
22
|
|
|
20
23
|
describe('Validator Hash checks', () => {
|
|
21
|
-
it('CDP Creator validator hash', () => {
|
|
24
|
+
it.todo('CDP Creator validator hash', () => {
|
|
22
25
|
expect(
|
|
23
26
|
validatorToScriptHash(
|
|
24
27
|
mkCDPCreatorValidatorFromSP(systemParams.cdpCreatorParams),
|
|
25
28
|
),
|
|
26
29
|
).toBe(systemParams.validatorHashes.cdpCreatorHash);
|
|
27
30
|
});
|
|
28
|
-
it('CDP validator hash', () => {
|
|
31
|
+
it.todo('CDP validator hash', () => {
|
|
29
32
|
expect(
|
|
30
33
|
validatorToScriptHash(mkCdpValidatorFromSP(systemParams.cdpParams)),
|
|
31
34
|
).toBe(systemParams.validatorHashes.cdpHash);
|
|
32
35
|
});
|
|
33
|
-
it('Collector validator hash', () => {
|
|
36
|
+
it.todo('Collector validator hash', () => {
|
|
34
37
|
expect(
|
|
35
38
|
validatorToScriptHash(
|
|
36
39
|
mkCollectorValidatorFromSP(systemParams.collectorParams),
|
|
37
40
|
),
|
|
38
41
|
).toBe(systemParams.validatorHashes.collectorHash);
|
|
39
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
|
+
});
|
|
40
52
|
// TODO: Revisit this test, issues with cbor encoding on Lucid?
|
|
41
53
|
// Applying parameters to the validator using `aiken build` does not result in the same hash as the one generate by Lucid.
|
|
42
54
|
it.todo('Execute validator hash', () => {
|
|
@@ -46,27 +58,34 @@ describe('Validator Hash checks', () => {
|
|
|
46
58
|
),
|
|
47
59
|
).toBe(systemParams.validatorHashes.executeHash);
|
|
48
60
|
});
|
|
49
|
-
it('Gov validator hash', () => {
|
|
61
|
+
it.todo('Gov validator hash', () => {
|
|
50
62
|
expect(
|
|
51
63
|
validatorToScriptHash(mkGovValidatorFromSP(systemParams.govParams)),
|
|
52
64
|
).toBe(systemParams.validatorHashes.govHash);
|
|
53
65
|
});
|
|
54
|
-
it('Staking validator hash', () => {
|
|
66
|
+
it.todo('Staking validator hash', () => {
|
|
55
67
|
expect(
|
|
56
68
|
validatorToScriptHash(
|
|
57
69
|
mkStakingValidatorFromSP(systemParams.stakingParams),
|
|
58
70
|
),
|
|
59
71
|
).toBe(systemParams.validatorHashes.stakingHash);
|
|
60
72
|
});
|
|
61
|
-
it('Stability Pool validator hash', () => {
|
|
73
|
+
it.todo('Stability Pool validator hash', () => {
|
|
62
74
|
expect(
|
|
63
75
|
validatorToScriptHash(
|
|
64
76
|
mkStabilityPoolValidatorFromSP(systemParams.stabilityPoolParams),
|
|
65
77
|
),
|
|
66
78
|
).toBe(systemParams.validatorHashes.stabilityPoolHash);
|
|
67
79
|
});
|
|
80
|
+
it.todo('Stableswap validator hash', () => {
|
|
81
|
+
expect(
|
|
82
|
+
validatorToScriptHash(
|
|
83
|
+
mkStableswapValidatorFromSP(systemParams.stableswapParams),
|
|
84
|
+
),
|
|
85
|
+
).toBe(systemParams.validatorHashes.stabilityPoolHash);
|
|
86
|
+
});
|
|
68
87
|
|
|
69
|
-
it('Interest Oracle validator hash', () => {
|
|
88
|
+
it.todo('Interest Oracle validator hash', () => {
|
|
70
89
|
expect(
|
|
71
90
|
validatorToScriptHash(
|
|
72
91
|
mkInterestOracleValidator({
|
|
@@ -77,9 +96,17 @@ describe('Validator Hash checks', () => {
|
|
|
77
96
|
).toBe('b970b3e0e1b591840627e6919898c12ee57e2f0225ab03e056d10d52');
|
|
78
97
|
});
|
|
79
98
|
|
|
80
|
-
it('
|
|
99
|
+
it.todo('ROB validator hash', () => {
|
|
81
100
|
expect(
|
|
82
|
-
validatorToScriptHash(
|
|
83
|
-
).toBe(systemParams.validatorHashes.
|
|
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);
|
|
84
111
|
});
|
|
85
112
|
});
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { 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()],
|
|
85
|
+
context.emulator.slot,
|
|
86
|
+
() => [],
|
|
87
|
+
{
|
|
88
|
+
foundationMultisig: {
|
|
89
|
+
Signature: {
|
|
90
|
+
keyHash: fromHex(
|
|
91
|
+
paymentCredentialOf(context.users.admin.address).hash,
|
|
92
|
+
),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
context.systemParams = systemParams;
|
|
99
|
+
context.assetConfigs = assetConfigs;
|
|
100
|
+
}
|
package/tests/initialize.test.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { beforeEach, test } from 'vitest';
|
|
1
|
+
import { assert, beforeEach, test } from 'vitest';
|
|
2
2
|
import { LucidContext } from './test-helpers';
|
|
3
|
-
import { EmulatorAccount, Lucid } from '@lucid-evolution/lucid';
|
|
3
|
+
import { addAssets, EmulatorAccount, Lucid } from '@lucid-evolution/lucid';
|
|
4
4
|
import { Emulator } from '@lucid-evolution/lucid';
|
|
5
5
|
import { generateEmulatorAccount } from '@lucid-evolution/lucid';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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';
|
|
8
17
|
|
|
9
18
|
type MyContext = LucidContext<{
|
|
10
19
|
admin: EmulatorAccount;
|
|
@@ -12,12 +21,18 @@ type MyContext = LucidContext<{
|
|
|
12
21
|
|
|
13
22
|
beforeEach<MyContext>(async (context: MyContext) => {
|
|
14
23
|
context.users = {
|
|
15
|
-
admin: generateEmulatorAccount(
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
),
|
|
18
30
|
};
|
|
19
31
|
|
|
20
|
-
context.emulator = new Emulator(
|
|
32
|
+
context.emulator = new Emulator(
|
|
33
|
+
[context.users.admin],
|
|
34
|
+
MAINNET_PROTOCOL_PARAMETERS,
|
|
35
|
+
);
|
|
21
36
|
|
|
22
37
|
context.lucid = await Lucid(context.emulator, 'Custom');
|
|
23
38
|
});
|
|
@@ -25,8 +40,45 @@ beforeEach<MyContext>(async (context: MyContext) => {
|
|
|
25
40
|
test<MyContext>('Initialize Protocol - can initialize', async ({
|
|
26
41
|
lucid,
|
|
27
42
|
users,
|
|
43
|
+
emulator,
|
|
28
44
|
}: MyContext) => {
|
|
29
45
|
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
30
46
|
|
|
31
|
-
await init(
|
|
47
|
+
await init(
|
|
48
|
+
lucid,
|
|
49
|
+
[
|
|
50
|
+
iusdInitialAssetCfg(DEFAULT_INTEREST, [
|
|
51
|
+
{
|
|
52
|
+
collateralAsset: EXAMPLE_TOKEN_1,
|
|
53
|
+
collateralToIassetRatio: rationalFromInt(1n),
|
|
54
|
+
feeManager: undefined,
|
|
55
|
+
minMintOrderAmount: 0n,
|
|
56
|
+
minRedemptionOrderAmount: 0n,
|
|
57
|
+
mintingEnabled: true,
|
|
58
|
+
redemptionEnabled: true,
|
|
59
|
+
mintingFeeRatio: { numerator: 1n, denominator: 100n },
|
|
60
|
+
redemptionFeeRatio: { numerator: 1n, denominator: 100n },
|
|
61
|
+
},
|
|
62
|
+
]),
|
|
63
|
+
],
|
|
64
|
+
emulator.slot,
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test<MyContext>('Validate Lucid protocol parameters match Mainnet', ({
|
|
69
|
+
lucid,
|
|
70
|
+
}: MyContext) => {
|
|
71
|
+
const protocolParameters = lucid.config().protocolParameters!;
|
|
72
|
+
assert(
|
|
73
|
+
protocolParameters.maxTxSize === 16384,
|
|
74
|
+
'Lucid maxTxSize does not match Cardano Mainnet',
|
|
75
|
+
);
|
|
76
|
+
assert(
|
|
77
|
+
protocolParameters.maxTxExMem === 16500000n,
|
|
78
|
+
'Lucid maxTxExMem does not match Cardano Mainnet',
|
|
79
|
+
);
|
|
80
|
+
assert(
|
|
81
|
+
protocolParameters.maxTxExSteps === 10000000000n,
|
|
82
|
+
'Lucid maxTxExSteps does not match Cardano Mainnet',
|
|
83
|
+
);
|
|
32
84
|
});
|