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