@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
package/tests/datums.test.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { Data, fromHex } from '@lucid-evolution/lucid';
|
|
3
|
-
import {
|
|
4
|
-
parseStakingManagerDatum,
|
|
5
|
-
parseStakingPositionOrThrow,
|
|
6
|
-
serialiseStakingDatum,
|
|
7
|
-
StakingManager,
|
|
8
|
-
StakingPosition,
|
|
9
|
-
} from '../src/contracts/staking/types-new';
|
|
10
|
-
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';
|
|
20
|
-
|
|
21
|
-
describe('Datum checks', () => {
|
|
22
|
-
it('Price Oracle', () => {
|
|
23
|
-
expect(
|
|
24
|
-
serialisePriceOracleDatum({
|
|
25
|
-
price: { numerator: 1_295_175n, denominator: 1_000_000n },
|
|
26
|
-
expirationTime: 1738766423000n,
|
|
27
|
-
auxiliaryData: Core.Data.fromCBORHex(Data.void()),
|
|
28
|
-
}),
|
|
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
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('Interest Oracle', () => {
|
|
42
|
-
expect(
|
|
43
|
-
parseInterestOracleDatum(
|
|
44
|
-
'd8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff',
|
|
45
|
-
),
|
|
46
|
-
).toEqual({
|
|
47
|
-
unitaryInterest: 108338304224695572n,
|
|
48
|
-
interestRate: { getOnChainInt: 200000n },
|
|
49
|
-
lastUpdated: 1738626287000n,
|
|
50
|
-
});
|
|
51
|
-
expect(
|
|
52
|
-
serialiseInterestOracleDatum({
|
|
53
|
-
unitaryInterest: 108338304224695572n,
|
|
54
|
-
interestRate: { getOnChainInt: 200000n },
|
|
55
|
-
lastUpdated: 1738626287000n,
|
|
56
|
-
}),
|
|
57
|
-
).toEqual('d8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('Interest Oracle Redeemer', () => {
|
|
61
|
-
expect(
|
|
62
|
-
serialiseFeedInterestOracleRedeemer({
|
|
63
|
-
newInterestRate: { getOnChainInt: 1_000_000n },
|
|
64
|
-
currentTime: 1724851200n,
|
|
65
|
-
}),
|
|
66
|
-
).toEqual('d8799fd8799f1a000f4240ff1a66cf2400ff');
|
|
67
|
-
});
|
|
68
|
-
|
|
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));
|
|
89
|
-
|
|
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
|
-
// });
|
|
107
|
-
|
|
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
|
-
// });
|
|
145
|
-
|
|
146
|
-
it('Staking Manager', () => {
|
|
147
|
-
const stakingManagerDatum =
|
|
148
|
-
'd8799fd8799f1b000009c04704429ed8799f1b000001402802fec1ffffff';
|
|
149
|
-
const stakingManagerObject: StakingManager = {
|
|
150
|
-
totalStake: 10721429832350n,
|
|
151
|
-
managerSnapshot: {
|
|
152
|
-
snapshotAda: 1375060819649n,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
expect(parseStakingManagerDatum(stakingManagerDatum)).toEqual(
|
|
157
|
-
stakingManagerObject,
|
|
158
|
-
);
|
|
159
|
-
expect(serialiseStakingDatum(stakingManagerObject)).toEqual(
|
|
160
|
-
stakingManagerDatum,
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('Staking Position', () => {
|
|
165
|
-
const stakingPositionDatum =
|
|
166
|
-
'd87a9fd8799f581cd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f439f9f1853d8799f1a5c8c1cfb1b0000019616971410ffffffd8799f1b0000013a7ed5b0fdffffff';
|
|
167
|
-
const stakingPositionObject: StakingPosition = {
|
|
168
|
-
owner: fromHex(
|
|
169
|
-
'd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f43',
|
|
170
|
-
),
|
|
171
|
-
lockedAmount: [
|
|
172
|
-
[83n, { voteAmt: 1552686331n, votingEnd: 1744135722000n }],
|
|
173
|
-
],
|
|
174
|
-
positionSnapshot: {
|
|
175
|
-
snapshotAda: 1350747664637n,
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
expect(parseStakingPositionOrThrow(stakingPositionDatum)).toEqual(
|
|
180
|
-
stakingPositionObject,
|
|
181
|
-
);
|
|
182
|
-
expect(serialiseStakingDatum(stakingPositionObject)).toEqual(
|
|
183
|
-
stakingPositionDatum,
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
|
|
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
|
-
// });
|
|
212
|
-
|
|
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
|
-
// };
|
|
231
|
-
|
|
232
|
-
// expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
|
|
233
|
-
// expect(
|
|
234
|
-
// serialiseStabilityPoolDatum({ Account: stabilityPoolObject }),
|
|
235
|
-
// ).toEqual(stabilityPoolDatum);
|
|
236
|
-
// });
|
|
237
|
-
|
|
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
|
-
// };
|
|
274
|
-
|
|
275
|
-
// expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
|
|
276
|
-
// expect(
|
|
277
|
-
// serialiseStabilityPoolDatum({ Account: stabilityPoolObject }),
|
|
278
|
-
// ).toEqual(stabilityPoolDatum);
|
|
279
|
-
// });
|
|
280
|
-
|
|
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
|
-
// };
|
|
292
|
-
|
|
293
|
-
// expect(parseSnapshotEpochToScaleToSumDatum(stabilityPoolDatum)).toEqual(
|
|
294
|
-
// stabilityPoolObject,
|
|
295
|
-
// );
|
|
296
|
-
// expect(
|
|
297
|
-
// serialiseStabilityPoolDatum({
|
|
298
|
-
// SnapshotEpochToScaleToSum: stabilityPoolObject,
|
|
299
|
-
// }),
|
|
300
|
-
// ).toEqual(stabilityPoolDatum);
|
|
301
|
-
// });
|
|
302
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
mkPythBasedAssets: (
|
|
45
|
-
pythStateNft: AssetClass,
|
|
46
|
-
) => InitialAssetParam[] = () => [],
|
|
47
|
-
overrideProtocolParams: Partial<ProtocolParams> = {},
|
|
48
|
-
initOptions: InitializeOptions = DEFAULT_INIT_OPTIONS,
|
|
49
|
-
spStakingCred: ScriptCredential = {
|
|
50
|
-
tag: 'StakingHash',
|
|
51
|
-
contents: {
|
|
52
|
-
tag: 'ScriptCredential',
|
|
53
|
-
contents: 'b8358aadd30c60eba168608ad5e875592e9b7cb8c700827cde87f9a3',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
treasuryStakingCred: ScriptCredential = {
|
|
57
|
-
tag: 'StakingHash',
|
|
58
|
-
contents: {
|
|
59
|
-
tag: 'ScriptCredential',
|
|
60
|
-
contents: 'b8358aadd30c60eba168608ad5e875592e9b7cb8c700827cde87f9a3',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
): Promise<ReturnType<typeof initContract>> {
|
|
64
|
-
const protocolParams: ProtocolParams = {
|
|
65
|
-
...protocolParamsMock,
|
|
66
|
-
...overrideProtocolParams,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return initContract(
|
|
70
|
-
lucid,
|
|
71
|
-
defaultInitialAssets,
|
|
72
|
-
mkPythBasedAssets,
|
|
73
|
-
protocolParams,
|
|
74
|
-
initOptions,
|
|
75
|
-
spStakingCred,
|
|
76
|
-
treasuryStakingCred,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
}
|