@indigo-labs/indigo-sdk 0.5.4 → 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.
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +17 -0
- package/dist/index.mjs +15 -0
- package/package.json +11 -1
- package/.claude/settings.local.json +0 -7
- package/.github/workflows/ci.yml +0 -66
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/.prettierignore +0 -1
- package/.prettierrc +0 -6
- package/eslint.config.mjs +0 -42
- package/scripts/bench.sh +0 -62
- package/scripts/run-repeat.sh +0 -22
- package/src/contracts/cdp/helpers.ts +0 -173
- package/src/contracts/cdp/scripts.ts +0 -70
- package/src/contracts/cdp/transactions.ts +0 -1584
- package/src/contracts/cdp/types-new.ts +0 -277
- package/src/contracts/cdp/types.ts +0 -43
- package/src/contracts/cdp-creator/queries.ts +0 -30
- package/src/contracts/cdp-creator/scripts.ts +0 -45
- package/src/contracts/cdp-creator/types-new.ts +0 -50
- package/src/contracts/cdp-creator/types.ts +0 -24
- package/src/contracts/collector/scripts.ts +0 -32
- package/src/contracts/collector/transactions.ts +0 -50
- package/src/contracts/collector/types-new.ts +0 -17
- package/src/contracts/execute/scripts.ts +0 -57
- package/src/contracts/execute/types-new.ts +0 -44
- package/src/contracts/execute/types.ts +0 -24
- package/src/contracts/gov/helpers.ts +0 -351
- package/src/contracts/gov/scripts.ts +0 -41
- package/src/contracts/gov/transactions.ts +0 -1607
- package/src/contracts/gov/types-new.ts +0 -268
- package/src/contracts/gov/types.ts +0 -22
- package/src/contracts/iasset/helpers.ts +0 -170
- package/src/contracts/iasset/queries.ts +0 -102
- package/src/contracts/iasset/scripts.ts +0 -38
- package/src/contracts/iasset/types.ts +0 -154
- package/src/contracts/initialize/actions.ts +0 -789
- package/src/contracts/initialize/helpers.ts +0 -616
- package/src/contracts/initialize/types.ts +0 -116
- package/src/contracts/interest-collection/helpers.ts +0 -19
- package/src/contracts/interest-collection/queries.ts +0 -66
- package/src/contracts/interest-collection/scripts.ts +0 -44
- package/src/contracts/interest-collection/transactions.ts +0 -433
- package/src/contracts/interest-collection/types-new.ts +0 -50
- package/src/contracts/interest-collection/types.ts +0 -26
- package/src/contracts/interest-oracle/helpers.ts +0 -61
- package/src/contracts/interest-oracle/scripts.ts +0 -18
- package/src/contracts/interest-oracle/transactions.ts +0 -151
- package/src/contracts/interest-oracle/types-new.ts +0 -32
- package/src/contracts/interest-oracle/types.ts +0 -16
- package/src/contracts/one-shot/scripts.ts +0 -12
- package/src/contracts/one-shot/transactions.ts +0 -66
- package/src/contracts/one-shot/types.ts +0 -22
- package/src/contracts/poll/helpers.ts +0 -37
- package/src/contracts/poll/scripts.ts +0 -71
- package/src/contracts/poll/types-poll-manager.ts +0 -20
- package/src/contracts/poll/types-poll-new.ts +0 -196
- package/src/contracts/poll/types-poll-shard.ts +0 -16
- package/src/contracts/price-oracle/helpers.ts +0 -30
- package/src/contracts/price-oracle/scripts.ts +0 -18
- package/src/contracts/price-oracle/transactions.ts +0 -115
- package/src/contracts/price-oracle/types-new.ts +0 -50
- package/src/contracts/price-oracle/types.ts +0 -16
- package/src/contracts/pyth-feed/helpers.ts +0 -82
- package/src/contracts/pyth-feed/scripts.ts +0 -15
- package/src/contracts/pyth-feed/types.ts +0 -181
- package/src/contracts/rob/helpers.ts +0 -666
- package/src/contracts/rob/scripts.ts +0 -35
- package/src/contracts/rob/transactions.ts +0 -423
- package/src/contracts/rob/types-new.ts +0 -128
- package/src/contracts/rob/types.ts +0 -16
- package/src/contracts/rob-leverage/helpers.ts +0 -422
- package/src/contracts/rob-leverage/transactions.ts +0 -368
- package/src/contracts/stability-pool/helpers.ts +0 -798
- package/src/contracts/stability-pool/queries.ts +0 -132
- package/src/contracts/stability-pool/scripts.ts +0 -51
- package/src/contracts/stability-pool/transactions.ts +0 -921
- package/src/contracts/stability-pool/types-new.ts +0 -385
- package/src/contracts/stability-pool/types.ts +0 -25
- package/src/contracts/stableswap/helpers.ts +0 -507
- package/src/contracts/stableswap/scripts.ts +0 -37
- package/src/contracts/stableswap/transactions.ts +0 -475
- package/src/contracts/stableswap/types-new.ts +0 -131
- package/src/contracts/stableswap/types.ts +0 -17
- package/src/contracts/staking/helpers.ts +0 -136
- package/src/contracts/staking/scripts.ts +0 -41
- package/src/contracts/staking/transactions.ts +0 -349
- package/src/contracts/staking/types-new.ts +0 -137
- package/src/contracts/staking/types.ts +0 -17
- package/src/contracts/treasury/helpers.ts +0 -21
- package/src/contracts/treasury/queries.ts +0 -100
- package/src/contracts/treasury/scripts.ts +0 -27
- package/src/contracts/treasury/transactions.ts +0 -334
- package/src/contracts/treasury/types-new.ts +0 -69
- package/src/contracts/treasury/types.ts +0 -14
- package/src/contracts/version-registry/scripts.ts +0 -29
- package/src/contracts/version-registry/types-new.ts +0 -18
- package/src/contracts/version-registry/types.ts +0 -17
- package/src/index.ts +0 -93
- package/src/scripts/always-fail-validator.ts +0 -7
- package/src/scripts/auth-token-policy.ts +0 -24
- package/src/scripts/iasset-policy.ts +0 -23
- package/src/types/evolution-schema-options.ts +0 -16
- package/src/types/generic.ts +0 -52
- package/src/types/multisig.ts +0 -48
- package/src/types/on-chain-decimal.ts +0 -57
- package/src/types/rational.ts +0 -61
- package/src/types/system-params.ts +0 -463
- package/src/utils/array-utils.ts +0 -108
- package/src/utils/bigint-utils.ts +0 -35
- package/src/utils/helper-txs.ts +0 -31
- package/src/utils/indigo-helpers.ts +0 -17
- package/src/utils/lucid-utils.ts +0 -125
- package/src/utils/oracle-helpers.ts +0 -62
- package/src/utils/pyth/decode.ts +0 -223
- package/src/utils/pyth/encode.ts +0 -262
- package/src/utils/pyth/index.ts +0 -14
- package/src/utils/pyth/types.ts +0 -87
- package/src/utils/time-helpers.ts +0 -4
- package/src/utils/utils.ts +0 -25
- package/src/validators/always-succeed-validator.ts +0 -6
- package/src/validators/cdp-creator-validator.ts +0 -7
- package/src/validators/cdp-redeem-validator.ts +0 -7
- package/src/validators/cdp-validator.ts +0 -7
- package/src/validators/collector-validator.ts +0 -7
- package/src/validators/execute-validator.ts +0 -7
- package/src/validators/governance-validator.ts +0 -7
- package/src/validators/iasset-validator.ts +0 -7
- package/src/validators/interest-collection-validator.ts +0 -7
- package/src/validators/interest-oracle-validator.ts +0 -7
- package/src/validators/one-shot-policy.ts +0 -7
- package/src/validators/poll-manager-validator.ts +0 -7
- package/src/validators/poll-shard-validator.ts +0 -7
- package/src/validators/price-oracle-validator.ts +0 -7
- package/src/validators/pyth-feed-validator.ts +0 -7
- package/src/validators/rob-validator.ts +0 -7
- package/src/validators/stability-pool-validator.ts +0 -7
- package/src/validators/stableswap-validator.ts +0 -7
- package/src/validators/staking-validator.ts +0 -7
- package/src/validators/treasury-validator.ts +0 -7
- package/src/validators/version-record-policy.ts +0 -7
- package/src/validators/version-registry-validator.ts +0 -7
- package/tests/always-succeed/script.ts +0 -7
- package/tests/array-utils.test.ts +0 -92
- package/tests/bigint-utils.test.ts +0 -41
- package/tests/cdp/actions.ts +0 -680
- package/tests/cdp/cdp-helpers.ts +0 -55
- package/tests/cdp/cdp-queries.ts +0 -423
- package/tests/cdp/cdp.test.ts +0 -6730
- package/tests/cdp/transactions-mutated.ts +0 -1733
- package/tests/data/system-params.json +0 -1155
- package/tests/datums.test.ts +0 -302
- package/tests/endpoints/initialize.ts +0 -78
- package/tests/endpoints/interest-collector.ts +0 -37
- package/tests/endpoints/treasury.ts +0 -70
- package/tests/gov/actions.ts +0 -381
- package/tests/gov/gov.test.ts +0 -5147
- package/tests/gov/governance-queries.ts +0 -37
- package/tests/hash-checks.test.ts +0 -112
- package/tests/indigo-test-helpers.ts +0 -99
- package/tests/initialize.test.ts +0 -79
- package/tests/interest-calculations.test.ts +0 -120
- package/tests/interest-collection/interest-collection.test.ts +0 -843
- package/tests/interest-collection/transactions-mutated.ts +0 -260
- package/tests/interest-oracle.test.ts +0 -93
- package/tests/mock/assets-mock.ts +0 -243
- package/tests/mock/protocol-params-mock.ts +0 -21
- package/tests/price-oracle/actions.ts +0 -161
- package/tests/price-oracle/price-oracle-queries.ts +0 -12
- package/tests/price-oracle/price-oracle.test.ts +0 -228
- package/tests/price-oracle/transactions-mutated.ts +0 -59
- package/tests/pyth/endpoints.ts +0 -96
- package/tests/pyth/helpers.ts +0 -37
- package/tests/pyth/pyth-encoding.test.ts +0 -376
- package/tests/pyth/pyth-feeds.test.ts +0 -943
- package/tests/pyth/pyth-indigo.test.ts +0 -505
- package/tests/pyth/pyth.test.ts +0 -299
- package/tests/queries/collector-queries.ts +0 -27
- package/tests/queries/execute-queries.ts +0 -47
- package/tests/queries/iasset-queries.ts +0 -149
- package/tests/queries/interest-oracle-queries.ts +0 -12
- package/tests/queries/poll-queries.ts +0 -97
- package/tests/queries/staking-queries.ts +0 -54
- package/tests/rob/actions.ts +0 -56
- package/tests/rob/rob-leverage.test.ts +0 -2555
- package/tests/rob/rob-queries.ts +0 -95
- package/tests/rob/rob.test.ts +0 -3677
- package/tests/rob/transactions-mutated.ts +0 -844
- package/tests/script-size.test.ts +0 -240
- package/tests/setup.ts +0 -135
- package/tests/stability-pool/actions.ts +0 -229
- package/tests/stability-pool.test.ts +0 -6491
- package/tests/stableswap/stableswap-actions.ts +0 -83
- package/tests/stableswap/stableswap-queries.ts +0 -98
- package/tests/stableswap/stableswap.test.ts +0 -4471
- package/tests/stableswap/transactions-mutated.ts +0 -348
- package/tests/staking.test.ts +0 -172
- package/tests/test-helpers.ts +0 -94
- package/tests/treasury/actions.ts +0 -67
- package/tests/treasury/treasury.test.ts +0 -320
- package/tests/utils/asserts.ts +0 -87
- package/tests/utils/benchmark-utils.ts +0 -130
- package/tests/utils/index.ts +0 -168
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -27
- 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
|
-
}
|
package/tests/initialize.test.ts
DELETED
|
@@ -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
|
-
});
|