@indigo-labs/indigo-sdk 0.1.19 → 0.1.21
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 +8 -3
- package/dist/index.d.mts +1298 -677
- package/dist/index.d.ts +1298 -677
- package/dist/index.js +4650 -2217
- package/dist/index.mjs +4592 -2192
- package/eslint.config.mjs +7 -1
- package/package.json +9 -4
- package/src/contracts/cdp/helpers.ts +167 -0
- package/src/contracts/cdp/scripts.ts +33 -0
- package/src/contracts/cdp/transactions.ts +1310 -0
- package/src/contracts/cdp/types.ts +161 -0
- package/src/contracts/cdp-creator/scripts.ts +39 -0
- package/src/{types/indigo/cdp-creator.ts → contracts/cdp-creator/types.ts} +6 -4
- package/src/contracts/collector/scripts.ts +32 -0
- package/src/contracts/collector/transactions.ts +44 -0
- package/src/contracts/execute/scripts.ts +48 -0
- package/src/contracts/execute/types.ts +57 -0
- package/src/contracts/gov/helpers.ts +157 -0
- package/src/contracts/gov/scripts.ts +34 -0
- package/src/contracts/gov/transactions.ts +1224 -0
- package/src/contracts/gov/types-new.ts +115 -0
- package/src/contracts/gov/types.ts +89 -0
- package/src/{helpers/interest-oracle.ts → contracts/interest-oracle/helpers.ts} +37 -9
- package/src/contracts/interest-oracle/scripts.ts +18 -0
- package/src/contracts/interest-oracle/transactions.ts +149 -0
- package/src/{types/indigo/interest-oracle.ts → contracts/interest-oracle/types.ts} +1 -1
- package/src/contracts/lrp/scripts.ts +27 -0
- package/src/contracts/{lrp.ts → lrp/transactions.ts} +23 -23
- package/src/{types/indigo/lrp.ts → contracts/lrp/types.ts} +3 -3
- package/src/{scripts/one-shot-policy.ts → contracts/one-shot/scripts.ts} +1 -1
- package/src/contracts/{one-shot.ts → one-shot/transactions.ts} +3 -3
- package/src/contracts/poll/helpers.ts +55 -0
- package/src/contracts/poll/scripts.ts +72 -0
- package/src/contracts/poll/types-poll-manager.ts +38 -0
- package/src/contracts/poll/types-poll-shard.ts +38 -0
- package/src/contracts/poll/types-poll.ts +88 -0
- package/src/{scripts/price-oracle-validator.ts → contracts/price-oracle/scripts.ts} +1 -4
- package/src/contracts/price-oracle/transactions.ts +112 -0
- package/src/{types/indigo/price-oracle.ts → contracts/price-oracle/types.ts} +16 -4
- package/src/{helpers/stability-pool-helpers.ts → contracts/stability-pool/helpers.ts} +110 -6
- package/src/contracts/stability-pool/scripts.ts +46 -0
- package/src/contracts/stability-pool/transactions.ts +660 -0
- package/src/contracts/stability-pool/types-new.ts +208 -0
- package/src/contracts/stability-pool/types.ts +42 -0
- package/src/contracts/staking/helpers.ts +116 -0
- package/src/contracts/staking/scripts.ts +41 -0
- package/src/contracts/staking/transactions.ts +268 -0
- package/src/contracts/staking/types-new.ts +81 -0
- package/src/contracts/staking/types.ts +41 -0
- package/src/contracts/treasury/scripts.ts +37 -0
- package/src/contracts/treasury/transactions.ts +44 -0
- package/src/contracts/treasury/types.ts +55 -0
- package/src/contracts/version-registry/scripts.ts +29 -0
- package/src/contracts/version-registry/types-new.ts +19 -0
- package/src/{types/indigo/version-record.ts → contracts/version-registry/types.ts} +1 -1
- package/src/contracts/vesting/helpers.ts +267 -0
- package/src/index.ts +38 -33
- package/src/types/evolution-schema-options.ts +16 -0
- package/src/types/generic.ts +78 -60
- package/src/types/on-chain-decimal.ts +22 -0
- package/src/types/system-params.ts +22 -11
- package/src/utils/bigint-utils.ts +7 -0
- package/src/{helpers → utils}/helper-txs.ts +1 -0
- package/src/utils/time-helpers.ts +4 -0
- package/src/{helpers/helpers.ts → utils/utils.ts} +0 -10
- package/src/{helpers → utils}/value-helpers.ts +10 -0
- package/src/{scripts → validators}/cdp-creator-validator.ts +4 -50
- package/src/{scripts → validators}/cdp-validator.ts +3 -5
- package/src/{scripts → validators}/collector-validator.ts +2 -3
- package/src/{scripts/version-registry.ts → validators/execute-validator.ts} +3 -11
- package/src/{scripts/gov-validator.ts → validators/governance-validator.ts} +3 -40
- package/src/{scripts → validators}/interest-oracle-validator.ts +4 -20
- package/src/validators/lrp-validator.ts +7 -0
- package/src/validators/poll-manager-validator.ts +7 -0
- package/src/{scripts → validators}/poll-shard-validator.ts +3 -43
- package/src/{scripts → validators}/stability-pool-validator.ts +4 -57
- package/src/{scripts → validators}/staking-validator.ts +2 -3
- package/src/{scripts → validators}/treasury-validator.ts +2 -3
- package/src/{scripts → validators}/version-record-policy.ts +4 -23
- package/src/validators/version-registry-validator.ts +7 -0
- package/tests/cdp.test.ts +1565 -0
- package/tests/datums.test.ts +125 -108
- package/tests/endpoints/initialize.ts +240 -338
- package/tests/gov.test.ts +1874 -0
- package/tests/hash-checks.test.ts +26 -21
- package/tests/indigo-test-helpers.ts +1 -55
- package/tests/initialize.test.ts +10 -5
- package/tests/interest-calculations.test.ts +18 -18
- package/tests/interest-oracle.test.ts +20 -18
- package/tests/lrp.test.ts +180 -78
- package/tests/mock/assets-mock.ts +59 -0
- package/tests/queries/cdp-queries.ts +144 -0
- package/tests/queries/collector-queries.ts +26 -0
- package/tests/queries/execute-queries.ts +46 -0
- package/tests/queries/governance-queries.ts +19 -16
- package/tests/queries/iasset-queries.ts +46 -23
- package/tests/queries/interest-oracle-queries.ts +3 -6
- package/tests/queries/lrp-queries.ts +2 -2
- package/tests/queries/poll-queries.ts +97 -0
- package/tests/queries/price-oracle-queries.ts +5 -22
- package/tests/queries/stability-pool-queries.ts +10 -8
- package/tests/queries/staking-queries.ts +28 -19
- package/tests/queries/treasury-queries.ts +19 -0
- package/tests/stability-pool.test.ts +186 -71
- package/tests/staking.test.ts +30 -23
- package/tests/test-helpers.ts +11 -2
- package/tests/utils/asserts.ts +13 -0
- package/tests/utils/index.ts +50 -0
- package/tsconfig.json +3 -1
- package/vitest.config.ts +1 -1
- package/.github/workflows/test.yml +0 -44
- package/src/contracts/cdp.ts +0 -748
- package/src/contracts/collector.ts +0 -98
- package/src/contracts/gov.ts +0 -1
- package/src/contracts/interest-oracle.ts +0 -149
- package/src/contracts/stability-pool.ts +0 -692
- package/src/contracts/staking.ts +0 -348
- package/src/contracts/treasury.ts +0 -112
- package/src/helpers/asset-helpers.ts +0 -57
- package/src/helpers/staking-helpers.ts +0 -94
- package/src/helpers/time-helpers.ts +0 -4
- package/src/scripts/execute-validator.ts +0 -52
- package/src/scripts/lrp-validator.ts +0 -40
- package/src/scripts/poll-manager-validator.ts +0 -52
- package/src/types/indigo/cdp.ts +0 -88
- package/src/types/indigo/execute.ts +0 -21
- package/src/types/indigo/gov.ts +0 -51
- package/src/types/indigo/poll-manager.ts +0 -21
- package/src/types/indigo/poll-shard.ts +0 -16
- package/src/types/indigo/stability-pool.ts +0 -233
- package/src/types/indigo/staking.ts +0 -99
- /package/src/{types/one-shot.ts → contracts/one-shot/types.ts} +0 -0
- /package/src/{helpers/price-oracle-helpers.ts → contracts/price-oracle/helpers.ts} +0 -0
- /package/src/{helpers → utils}/indigo-helpers.ts +0 -0
- /package/src/{helpers → utils}/lucid-utils.ts +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import {
|
|
3
3
|
loadSystemParamsFromFile,
|
|
4
|
-
StakingContract,
|
|
5
|
-
CollectorContract,
|
|
6
|
-
CDPContract,
|
|
7
4
|
mkCDPCreatorValidatorFromSP,
|
|
8
5
|
mkInterestOracleValidator,
|
|
9
6
|
mkLrpValidatorFromSP,
|
|
7
|
+
mkCdpValidatorFromSP,
|
|
8
|
+
mkExecuteValidatorFromSP,
|
|
9
|
+
mkCollectorValidatorFromSP,
|
|
10
10
|
} from '../src';
|
|
11
11
|
import { validatorToScriptHash } from '@lucid-evolution/lucid';
|
|
12
|
-
import { mkStabilityPoolValidatorFromSP } from '../src/
|
|
13
|
-
import { mkGovValidatorFromSP } from '../src/
|
|
12
|
+
import { mkStabilityPoolValidatorFromSP } from '../src/contracts/stability-pool/scripts';
|
|
13
|
+
import { mkGovValidatorFromSP } from '../src/contracts/gov/scripts';
|
|
14
|
+
import { mkStakingValidatorFromSP } from '../src/contracts/staking/scripts';
|
|
14
15
|
|
|
15
16
|
const systemParams = loadSystemParamsFromFile(
|
|
16
17
|
'./tests/data/system-params.json',
|
|
@@ -25,33 +26,37 @@ describe('Validator Hash checks', () => {
|
|
|
25
26
|
).toBe(systemParams.validatorHashes.cdpCreatorHash);
|
|
26
27
|
});
|
|
27
28
|
it('CDP validator hash', () => {
|
|
28
|
-
expect(
|
|
29
|
-
systemParams.
|
|
30
|
-
);
|
|
29
|
+
expect(
|
|
30
|
+
validatorToScriptHash(mkCdpValidatorFromSP(systemParams.cdpParams)),
|
|
31
|
+
).toBe(systemParams.validatorHashes.cdpHash);
|
|
31
32
|
});
|
|
32
33
|
it('Collector validator hash', () => {
|
|
33
|
-
expect(
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
expect(
|
|
35
|
+
validatorToScriptHash(
|
|
36
|
+
mkCollectorValidatorFromSP(systemParams.collectorParams),
|
|
37
|
+
),
|
|
38
|
+
).toBe(systemParams.validatorHashes.collectorHash);
|
|
36
39
|
});
|
|
37
40
|
// TODO: Revisit this test, issues with cbor encoding on Lucid?
|
|
38
41
|
// Applying parameters to the validator using `aiken build` does not result in the same hash as the one generate by Lucid.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
it.todo('Execute validator hash', () => {
|
|
43
|
+
expect(
|
|
44
|
+
validatorToScriptHash(
|
|
45
|
+
mkExecuteValidatorFromSP(systemParams.executeParams),
|
|
46
|
+
),
|
|
47
|
+
).toBe(systemParams.validatorHashes.executeHash);
|
|
48
|
+
});
|
|
46
49
|
it('Gov validator hash', () => {
|
|
47
50
|
expect(
|
|
48
51
|
validatorToScriptHash(mkGovValidatorFromSP(systemParams.govParams)),
|
|
49
52
|
).toBe(systemParams.validatorHashes.govHash);
|
|
50
53
|
});
|
|
51
54
|
it('Staking validator hash', () => {
|
|
52
|
-
expect(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
expect(
|
|
56
|
+
validatorToScriptHash(
|
|
57
|
+
mkStakingValidatorFromSP(systemParams.stakingParams),
|
|
58
|
+
),
|
|
59
|
+
).toBe(systemParams.validatorHashes.stakingHash);
|
|
55
60
|
});
|
|
56
61
|
it('Stability Pool validator hash', () => {
|
|
57
62
|
expect(
|
|
@@ -6,67 +6,13 @@ import {
|
|
|
6
6
|
ScriptHash,
|
|
7
7
|
toUnit,
|
|
8
8
|
} from '@lucid-evolution/lucid';
|
|
9
|
-
import { createScriptAddress } from '../src/
|
|
9
|
+
import { createScriptAddress } from '../src/utils/lucid-utils';
|
|
10
10
|
import {
|
|
11
11
|
AssetClass,
|
|
12
12
|
IAssetContent,
|
|
13
|
-
OracleAssetNft,
|
|
14
|
-
PriceOracleParams,
|
|
15
13
|
runOneShotMintTx,
|
|
16
14
|
serialiseIAssetDatum,
|
|
17
|
-
serialisePriceOracleDatum,
|
|
18
15
|
} from '../src';
|
|
19
|
-
import { OnChainDecimal } from '../src/types/on-chain-decimal';
|
|
20
|
-
|
|
21
|
-
export async function runStartPriceOracle(
|
|
22
|
-
lucid: LucidEvolution,
|
|
23
|
-
oracleScriptHash: ScriptHash,
|
|
24
|
-
oracleParams: PriceOracleParams,
|
|
25
|
-
network: Network,
|
|
26
|
-
// Hex encoded
|
|
27
|
-
oracleNftTokenName: string,
|
|
28
|
-
price: OnChainDecimal,
|
|
29
|
-
): Promise<OracleAssetNft> {
|
|
30
|
-
const utxos = await lucid.wallet().getUtxos();
|
|
31
|
-
|
|
32
|
-
const nftPolicyId = await runOneShotMintTx(lucid, {
|
|
33
|
-
referenceOutRef: {
|
|
34
|
-
txHash: utxos[0].txHash,
|
|
35
|
-
outputIdx: BigInt(utxos[0].outputIndex),
|
|
36
|
-
},
|
|
37
|
-
mintAmounts: [{ tokenName: oracleNftTokenName, amount: 1n }],
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const nftValue: Assets = { [toUnit(nftPolicyId, oracleNftTokenName)]: 1n };
|
|
41
|
-
|
|
42
|
-
const txHash = await lucid
|
|
43
|
-
.newTx()
|
|
44
|
-
.pay.ToContract(
|
|
45
|
-
createScriptAddress(network, oracleScriptHash),
|
|
46
|
-
{
|
|
47
|
-
kind: 'inline',
|
|
48
|
-
value: serialisePriceOracleDatum({
|
|
49
|
-
price: price,
|
|
50
|
-
expiration: BigInt(Date.now()) + oracleParams.expiration,
|
|
51
|
-
}),
|
|
52
|
-
},
|
|
53
|
-
nftValue,
|
|
54
|
-
)
|
|
55
|
-
.complete()
|
|
56
|
-
.then((tx) => tx.sign.withWallet().complete())
|
|
57
|
-
.then((tx) => tx.submit());
|
|
58
|
-
|
|
59
|
-
await lucid.awaitTx(txHash);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
oracleNft: {
|
|
63
|
-
asset: {
|
|
64
|
-
currencySymbol: nftPolicyId,
|
|
65
|
-
tokenName: oracleNftTokenName,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
16
|
|
|
71
17
|
/**
|
|
72
18
|
* TODO: the NFT has to be minted using the auth policy based on execute NFT.
|
package/tests/initialize.test.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { beforeEach, test } from 'vitest';
|
|
2
2
|
import { LucidContext } from './test-helpers';
|
|
3
|
-
import { Lucid } from '@lucid-evolution/lucid';
|
|
3
|
+
import { EmulatorAccount, Lucid } from '@lucid-evolution/lucid';
|
|
4
4
|
import { Emulator } from '@lucid-evolution/lucid';
|
|
5
5
|
import { generateEmulatorAccount } from '@lucid-evolution/lucid';
|
|
6
6
|
import { init } from './endpoints/initialize';
|
|
7
|
+
import { iusdInitialAssetCfg } from './mock/assets-mock';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
type MyContext = LucidContext<{
|
|
10
|
+
admin: EmulatorAccount;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
beforeEach<MyContext>(async (context: MyContext) => {
|
|
9
14
|
context.users = {
|
|
10
15
|
admin: generateEmulatorAccount({
|
|
11
16
|
lovelace: BigInt(100_000_000_000_000),
|
|
@@ -17,11 +22,11 @@ beforeEach<LucidContext>(async (context: LucidContext) => {
|
|
|
17
22
|
context.lucid = await Lucid(context.emulator, 'Custom');
|
|
18
23
|
});
|
|
19
24
|
|
|
20
|
-
test<
|
|
25
|
+
test<MyContext>('Initialize Protocol - can initialize', async ({
|
|
21
26
|
lucid,
|
|
22
27
|
users,
|
|
23
|
-
}:
|
|
28
|
+
}: MyContext) => {
|
|
24
29
|
lucid.selectWallet.fromSeed(users.admin.seedPhrase);
|
|
25
30
|
|
|
26
|
-
await init(lucid);
|
|
31
|
+
await init(lucid, [iusdInitialAssetCfg]);
|
|
27
32
|
});
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { ONE_DAY } from '../src/utils/time-helpers';
|
|
3
3
|
import {
|
|
4
4
|
calculateAccruedInterest,
|
|
5
5
|
calculateUnitaryInterestSinceOracleLastUpdated,
|
|
6
|
-
} from '../src/
|
|
6
|
+
} from '../src/contracts/interest-oracle/helpers';
|
|
7
7
|
|
|
8
8
|
describe('Interest Calculations', () => {
|
|
9
9
|
describe('Calculate Unitary Interest', () => {
|
|
10
10
|
it('Should calculate the unitary interest correctly, 0', () => {
|
|
11
11
|
expect(
|
|
12
|
-
calculateUnitaryInterestSinceOracleLastUpdated(
|
|
12
|
+
calculateUnitaryInterestSinceOracleLastUpdated(ONE_DAY * 6n, {
|
|
13
13
|
unitaryInterest: 684_931_506_849_315n,
|
|
14
14
|
interestRate: { getOnChainInt: 100_000n },
|
|
15
|
-
lastUpdated:
|
|
15
|
+
lastUpdated: ONE_DAY * 5n,
|
|
16
16
|
}),
|
|
17
17
|
).toBe(273_972_602_739_726n);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('Should calculate the unitary interest correctly, 1', () => {
|
|
21
21
|
expect(
|
|
22
|
-
calculateUnitaryInterestSinceOracleLastUpdated(
|
|
22
|
+
calculateUnitaryInterestSinceOracleLastUpdated(ONE_DAY * 6n, {
|
|
23
23
|
unitaryInterest: 0n,
|
|
24
24
|
interestRate: { getOnChainInt: 50_000n },
|
|
25
25
|
lastUpdated: 0n,
|
|
@@ -41,7 +41,7 @@ describe('Interest Calculations', () => {
|
|
|
41
41
|
describe('Calculate Accumulated Interest', () => {
|
|
42
42
|
it('Should calculate the accumulated interest correctly, 0', () => {
|
|
43
43
|
expect(
|
|
44
|
-
calculateAccruedInterest(
|
|
44
|
+
calculateAccruedInterest(ONE_DAY, 0n, 1_000_000n, 0n, {
|
|
45
45
|
unitaryInterest: 0n,
|
|
46
46
|
interestRate: { getOnChainInt: 50_000n },
|
|
47
47
|
lastUpdated: 0n,
|
|
@@ -51,20 +51,20 @@ describe('Interest Calculations', () => {
|
|
|
51
51
|
|
|
52
52
|
it('Should calculate the accumulated interest correctly, 1', () => {
|
|
53
53
|
expect(
|
|
54
|
-
calculateAccruedInterest(
|
|
54
|
+
calculateAccruedInterest(ONE_DAY * 6n, 0n, 1_000_000n, 0n, {
|
|
55
55
|
unitaryInterest: 684_931_506_849_315n,
|
|
56
56
|
interestRate: { getOnChainInt: 100_000n },
|
|
57
|
-
lastUpdated:
|
|
57
|
+
lastUpdated: ONE_DAY * 5n,
|
|
58
58
|
}),
|
|
59
59
|
).toBe(684n + 273n);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('Should calculate the accumulated interest correctly, 2', () => {
|
|
63
63
|
expect(
|
|
64
|
-
calculateAccruedInterest(
|
|
64
|
+
calculateAccruedInterest(ONE_DAY * 17n, 0n, 1_000_000n, 0n, {
|
|
65
65
|
unitaryInterest: 1_506_849_315_068_493n,
|
|
66
66
|
interestRate: { getOnChainInt: 100_000n },
|
|
67
|
-
lastUpdated:
|
|
67
|
+
lastUpdated: ONE_DAY * 15n,
|
|
68
68
|
}),
|
|
69
69
|
).toBe(1506n + 547n);
|
|
70
70
|
});
|
|
@@ -72,14 +72,14 @@ describe('Interest Calculations', () => {
|
|
|
72
72
|
it('Should calculate the accumulated interest correctly, 3', () => {
|
|
73
73
|
expect(
|
|
74
74
|
calculateAccruedInterest(
|
|
75
|
-
|
|
75
|
+
ONE_DAY * 17n,
|
|
76
76
|
410_958_904_109_589n,
|
|
77
77
|
1_000_000n,
|
|
78
|
-
|
|
78
|
+
ONE_DAY * 3n,
|
|
79
79
|
{
|
|
80
80
|
unitaryInterest: 1_506_849_315_068_493n,
|
|
81
81
|
interestRate: { getOnChainInt: 100_000n },
|
|
82
|
-
lastUpdated:
|
|
82
|
+
lastUpdated: ONE_DAY * 15n,
|
|
83
83
|
},
|
|
84
84
|
),
|
|
85
85
|
).toBe(1095n + 547n);
|
|
@@ -88,14 +88,14 @@ describe('Interest Calculations', () => {
|
|
|
88
88
|
it('Should calculate the accumulated interest correctly, 4', () => {
|
|
89
89
|
expect(
|
|
90
90
|
calculateAccruedInterest(
|
|
91
|
-
|
|
91
|
+
ONE_DAY * 17n,
|
|
92
92
|
767_123_287_671_232n,
|
|
93
93
|
1_000_000n,
|
|
94
|
-
|
|
94
|
+
ONE_DAY * 6n,
|
|
95
95
|
{
|
|
96
96
|
unitaryInterest: 1_506_849_315_068_493n,
|
|
97
97
|
interestRate: { getOnChainInt: 100_000n },
|
|
98
|
-
lastUpdated:
|
|
98
|
+
lastUpdated: ONE_DAY * 15n,
|
|
99
99
|
},
|
|
100
100
|
),
|
|
101
101
|
).toBe(739n + 547n);
|
|
@@ -104,10 +104,10 @@ describe('Interest Calculations', () => {
|
|
|
104
104
|
it('Should calculate the accumulated interest correctly, 5', () => {
|
|
105
105
|
expect(
|
|
106
106
|
calculateAccruedInterest(
|
|
107
|
-
|
|
107
|
+
ONE_DAY * 10n,
|
|
108
108
|
821_917_808_219_178n,
|
|
109
109
|
1_000_000n,
|
|
110
|
-
|
|
110
|
+
ONE_DAY * 6n,
|
|
111
111
|
{
|
|
112
112
|
unitaryInterest: 0n,
|
|
113
113
|
interestRate: { getOnChainInt: 50_000n },
|
|
@@ -4,16 +4,24 @@ import {
|
|
|
4
4
|
runAndAwaitTx,
|
|
5
5
|
runAndAwaitTxBuilder,
|
|
6
6
|
} from './test-helpers';
|
|
7
|
-
import { Lucid } from '@lucid-evolution/lucid';
|
|
7
|
+
import { EmulatorAccount, Lucid } from '@lucid-evolution/lucid';
|
|
8
8
|
import { Emulator } from '@lucid-evolution/lucid';
|
|
9
9
|
import { generateEmulatorAccount } from '@lucid-evolution/lucid';
|
|
10
|
-
import { addrDetails } from '../src/
|
|
11
|
-
import {
|
|
10
|
+
import { addrDetails } from '../src/utils/lucid-utils';
|
|
11
|
+
import {
|
|
12
|
+
feedInterestOracle,
|
|
13
|
+
InterestOracleParams,
|
|
14
|
+
startInterestOracle,
|
|
15
|
+
} from '../src';
|
|
12
16
|
import { findInterestOracle } from './queries/interest-oracle-queries';
|
|
13
17
|
|
|
18
|
+
type MyContext = LucidContext<{
|
|
19
|
+
user: EmulatorAccount;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
14
22
|
let originalDateNow: () => number;
|
|
15
23
|
|
|
16
|
-
beforeEach<
|
|
24
|
+
beforeEach<MyContext>(async (context: MyContext) => {
|
|
17
25
|
context.users = {
|
|
18
26
|
user: generateEmulatorAccount({
|
|
19
27
|
lovelace: BigInt(100_000_000_000_000),
|
|
@@ -32,15 +40,15 @@ afterEach(() => {
|
|
|
32
40
|
Date.now = originalDateNow;
|
|
33
41
|
});
|
|
34
42
|
|
|
35
|
-
test<
|
|
43
|
+
test<MyContext>('Interest Oracle - Start', async ({
|
|
36
44
|
lucid,
|
|
37
45
|
users,
|
|
38
|
-
}:
|
|
46
|
+
}: MyContext) => {
|
|
39
47
|
lucid.selectWallet.fromSeed(users.user.seedPhrase);
|
|
40
48
|
|
|
41
49
|
const [pkh, _] = await addrDetails(lucid);
|
|
42
50
|
|
|
43
|
-
const [tx, _ac] = await
|
|
51
|
+
const [tx, _ac] = await startInterestOracle(
|
|
44
52
|
0n,
|
|
45
53
|
0n,
|
|
46
54
|
0n,
|
|
@@ -54,10 +62,10 @@ test<LucidContext>('Interest Oracle - Start', async ({
|
|
|
54
62
|
await runAndAwaitTxBuilder(lucid, tx);
|
|
55
63
|
});
|
|
56
64
|
|
|
57
|
-
test<
|
|
65
|
+
test<MyContext>('Interest Oracle - Update', async ({
|
|
58
66
|
lucid,
|
|
59
67
|
users,
|
|
60
|
-
}:
|
|
68
|
+
}: MyContext) => {
|
|
61
69
|
lucid.selectWallet.fromSeed(users.user.seedPhrase);
|
|
62
70
|
|
|
63
71
|
const [pkh, _] = await addrDetails(lucid);
|
|
@@ -66,7 +74,7 @@ test<LucidContext>('Interest Oracle - Update', async ({
|
|
|
66
74
|
owner: pkh.hash,
|
|
67
75
|
};
|
|
68
76
|
|
|
69
|
-
const [tx, assetClass] = await
|
|
77
|
+
const [tx, assetClass] = await startInterestOracle(
|
|
70
78
|
0n,
|
|
71
79
|
0n,
|
|
72
80
|
0n,
|
|
@@ -76,15 +84,9 @@ test<LucidContext>('Interest Oracle - Update', async ({
|
|
|
76
84
|
|
|
77
85
|
await runAndAwaitTxBuilder(lucid, tx);
|
|
78
86
|
|
|
79
|
-
const
|
|
87
|
+
const utxo = await findInterestOracle(lucid, assetClass);
|
|
80
88
|
await runAndAwaitTx(
|
|
81
89
|
lucid,
|
|
82
|
-
|
|
83
|
-
interestParams,
|
|
84
|
-
500_000n,
|
|
85
|
-
lucid,
|
|
86
|
-
undefined,
|
|
87
|
-
utxo,
|
|
88
|
-
),
|
|
90
|
+
feedInterestOracle(interestParams, 500_000n, lucid, undefined, utxo),
|
|
89
91
|
);
|
|
90
92
|
});
|