@indigo-labs/indigo-sdk 0.1.3 → 0.1.4
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/package.json +4 -1
- package/.github/workflows/ci.yml +0 -62
- package/.github/workflows/test.yml +0 -44
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/.prettierrc +0 -6
- package/eslint.config.mjs +0 -35
- package/src/contracts/cdp.ts +0 -741
- 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/lrp.ts +0 -223
- package/src/contracts/one-shot.ts +0 -67
- package/src/contracts/stability-pool.ts +0 -684
- 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/helper-txs.ts +0 -30
- package/src/helpers/helpers.ts +0 -38
- package/src/helpers/indigo-helpers.ts +0 -19
- package/src/helpers/interest-oracle.ts +0 -57
- package/src/helpers/lucid-utils.ts +0 -70
- package/src/helpers/price-oracle-helpers.ts +0 -36
- package/src/helpers/stability-pool-helpers.ts +0 -207
- package/src/helpers/staking-helpers.ts +0 -94
- package/src/helpers/time-helpers.ts +0 -4
- package/src/helpers/value-helpers.ts +0 -16
- package/src/index.ts +0 -34
- package/src/scripts/always-fail-validator.ts +0 -7
- package/src/scripts/auth-token-policy.ts +0 -23
- package/src/scripts/cdp-creator-validator.ts +0 -53
- package/src/scripts/cdp-validator.ts +0 -9
- package/src/scripts/collector-validator.ts +0 -8
- package/src/scripts/execute-validator.ts +0 -52
- package/src/scripts/gov-validator.ts +0 -44
- package/src/scripts/iasset-policy.ts +0 -22
- package/src/scripts/interest-oracle-validator.ts +0 -23
- package/src/scripts/lrp-validator.ts +0 -23
- package/src/scripts/one-shot-policy.ts +0 -62
- package/src/scripts/poll-manager-validator.ts +0 -52
- package/src/scripts/poll-shard-validator.ts +0 -47
- package/src/scripts/price-oracle-validator.ts +0 -26
- package/src/scripts/stability-pool-validator.ts +0 -60
- package/src/scripts/staking-validator.ts +0 -8
- package/src/scripts/treasury-validator.ts +0 -8
- package/src/scripts/version-record-policy.ts +0 -26
- package/src/scripts/version-registry.ts +0 -15
- package/src/types/generic.ts +0 -106
- package/src/types/indigo/cdp-creator.ts +0 -46
- 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/interest-oracle.ts +0 -55
- package/src/types/indigo/lrp.ts +0 -54
- package/src/types/indigo/poll-manager.ts +0 -21
- package/src/types/indigo/poll-shard.ts +0 -16
- package/src/types/indigo/price-oracle.ts +0 -38
- package/src/types/indigo/stability-pool.ts +0 -233
- package/src/types/indigo/staking.ts +0 -99
- package/src/types/indigo/version-record.ts +0 -17
- package/src/types/on-chain-decimal.ts +0 -23
- package/src/types/one-shot.ts +0 -22
- package/src/types/system-params.ts +0 -246
- package/tests/data/system-params.json +0 -989
- package/tests/datums.test.ts +0 -286
- package/tests/endpoints/initialize.ts +0 -1013
- package/tests/hash-checks.test.ts +0 -73
- package/tests/indigo-test-helpers.ts +0 -115
- package/tests/initialize.test.ts +0 -27
- package/tests/interest-calculations.test.ts +0 -120
- package/tests/interest-oracle.test.ts +0 -90
- package/tests/lrp.test.ts +0 -149
- package/tests/queries/governance-queries.ts +0 -31
- package/tests/queries/iasset-queries.ts +0 -39
- package/tests/queries/interest-oracle-queries.ts +0 -13
- package/tests/queries/lrp-queries.ts +0 -39
- package/tests/queries/price-oracle-queries.ts +0 -27
- package/tests/queries/stability-pool-queries.ts +0 -75
- package/tests/queries/staking-queries.ts +0 -43
- package/tests/stability-pool.test.ts +0 -364
- package/tests/staking.test.ts +0 -105
- package/tests/test-helpers.ts +0 -38
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -16
- package/vitest.config.ts +0 -9
package/tests/datums.test.ts
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
CDPContent,
|
|
4
|
-
IAssetContent,
|
|
5
|
-
parseCDPDatum,
|
|
6
|
-
parseIAssetDatum,
|
|
7
|
-
parseInterestOracleDatum,
|
|
8
|
-
parsePriceOracleDatum,
|
|
9
|
-
parseStabilityPoolDatum,
|
|
10
|
-
serialiseCDPDatum,
|
|
11
|
-
serialiseFeedInterestOracleRedeemer,
|
|
12
|
-
serialiseIAssetDatum,
|
|
13
|
-
serialiseInterestOracleDatum,
|
|
14
|
-
serialisePriceOracleDatum,
|
|
15
|
-
serialiseStabilityPoolDatum,
|
|
16
|
-
StabilityPoolContent,
|
|
17
|
-
} from '../src/index';
|
|
18
|
-
import {
|
|
19
|
-
parseStakingManagerDatum,
|
|
20
|
-
parseStakingPositionDatum,
|
|
21
|
-
serialiseStakingDatum,
|
|
22
|
-
StakingManagerContent,
|
|
23
|
-
StakingPositionContent,
|
|
24
|
-
} from '../src/types/indigo/staking';
|
|
25
|
-
import { fromText } from '@lucid-evolution/lucid';
|
|
26
|
-
|
|
27
|
-
describe('Datum checks', () => {
|
|
28
|
-
it('Price Oracle', () => {
|
|
29
|
-
expect(
|
|
30
|
-
parsePriceOracleDatum('d8799fd8799f1a0013c347ff1b00000194d68e13d8ff'),
|
|
31
|
-
).toEqual({
|
|
32
|
-
price: { getOnChainInt: 1295175n },
|
|
33
|
-
expiration: 1738766423000n,
|
|
34
|
-
});
|
|
35
|
-
expect(
|
|
36
|
-
serialisePriceOracleDatum({
|
|
37
|
-
price: { getOnChainInt: 1295175n },
|
|
38
|
-
expiration: 1738766423000n,
|
|
39
|
-
}),
|
|
40
|
-
).toEqual('d8799fd8799f1a0013c347ff1b00000194d68e13d8ff');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('Interest Oracle', () => {
|
|
44
|
-
expect(
|
|
45
|
-
parseInterestOracleDatum(
|
|
46
|
-
'd8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff',
|
|
47
|
-
),
|
|
48
|
-
).toEqual({
|
|
49
|
-
unitaryInterest: 108338304224695572n,
|
|
50
|
-
interestRate: { getOnChainInt: 200000n },
|
|
51
|
-
lastUpdated: 1738626287000n,
|
|
52
|
-
});
|
|
53
|
-
expect(
|
|
54
|
-
serialiseInterestOracleDatum({
|
|
55
|
-
unitaryInterest: 108338304224695572n,
|
|
56
|
-
interestRate: { getOnChainInt: 200000n },
|
|
57
|
-
lastUpdated: 1738626287000n,
|
|
58
|
-
}),
|
|
59
|
-
).toEqual('d8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('Interest Oracle Redeemer', () => {
|
|
63
|
-
expect(
|
|
64
|
-
serialiseFeedInterestOracleRedeemer({
|
|
65
|
-
newInterestRate: { getOnChainInt: 1_000_000n },
|
|
66
|
-
currentTime: 1724851200n,
|
|
67
|
-
}),
|
|
68
|
-
).toEqual('d8799fd8799f1a000f4240ff1a66cf2400ff');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('CDP', () => {
|
|
72
|
-
// Active CDP
|
|
73
|
-
const activeCDPDatum =
|
|
74
|
-
'd8799fd8799fd8799f581c98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1cff44695553441b00000004d9b0a47ed8799f1b00000194d5ebec201b03022de04fddf5f9ffffff';
|
|
75
|
-
const activeCDPObject: CDPContent = {
|
|
76
|
-
cdpOwner: '98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1c',
|
|
77
|
-
iasset: fromText('iUSD'),
|
|
78
|
-
mintedAmt: 20832101502n,
|
|
79
|
-
cdpFees: {
|
|
80
|
-
ActiveCDPInterestTracking: {
|
|
81
|
-
lastSettled: 1738755796000n,
|
|
82
|
-
unitaryInterestSnapshot: 216786173503075833n,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
expect(serialiseCDPDatum(activeCDPObject)).toEqual(activeCDPDatum);
|
|
87
|
-
expect(parseCDPDatum(activeCDPDatum)).toEqual(activeCDPObject);
|
|
88
|
-
|
|
89
|
-
// Frozen CDP
|
|
90
|
-
const frozenCDPDatum =
|
|
91
|
-
'd8799fd8799fd87a8044695553441a0050924ed87a9f1a0002765a1a0003ca56ffffff';
|
|
92
|
-
const frozenCDPObject: CDPContent = {
|
|
93
|
-
cdpOwner: null,
|
|
94
|
-
iasset: fromText('iUSD'),
|
|
95
|
-
mintedAmt: 5280334n,
|
|
96
|
-
cdpFees: {
|
|
97
|
-
FrozenCDPAccumulatedFees: {
|
|
98
|
-
lovelacesTreasury: 161370n,
|
|
99
|
-
lovelacesIndyStakers: 248406n,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
expect(parseCDPDatum(frozenCDPDatum)).toEqual(frozenCDPObject);
|
|
104
|
-
expect(serialiseCDPDatum(frozenCDPObject)).toEqual(frozenCDPDatum);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('iAsset', () => {
|
|
108
|
-
const assetDatum =
|
|
109
|
-
'd87a9fd8799f4469455448d87a9fd8799fd8799f581c6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e952694554483230323231323139313931333032ffffffd8799f581c7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef302494d694554485f494e544552455354ffd8799f1a08f0d180ffd8799f1a06dac2c0ffd8799f1a068e7780ffd8799f1a000186a0ffd8799f1a001e8480ffd8799f19c350ffd8799f1a000f4240ffd8799f1a000f4240ffd8799f1a01c9c380ffd87980d8799f4469534f4cffffff';
|
|
110
|
-
const assetObject: IAssetContent = {
|
|
111
|
-
assetName: fromText('iETH'),
|
|
112
|
-
price: {
|
|
113
|
-
Oracle: {
|
|
114
|
-
oracleNft: {
|
|
115
|
-
asset: {
|
|
116
|
-
currencySymbol:
|
|
117
|
-
'6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e9',
|
|
118
|
-
tokenName: fromText('iETH20221219191302'),
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
interestOracleNft: {
|
|
124
|
-
currencySymbol:
|
|
125
|
-
'7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef30249',
|
|
126
|
-
tokenName: fromText('iETH_INTEREST'),
|
|
127
|
-
},
|
|
128
|
-
redemptionRatio: { getOnChainInt: 150000000n },
|
|
129
|
-
maintenanceRatio: { getOnChainInt: 115000000n },
|
|
130
|
-
liquidationRatio: { getOnChainInt: 110000000n },
|
|
131
|
-
debtMintingFeePercentage: { getOnChainInt: 100000n },
|
|
132
|
-
liquidationProcessingFeePercentage: { getOnChainInt: 2000000n },
|
|
133
|
-
stabilityPoolWithdrawalFeePercentage: { getOnChainInt: 50000n },
|
|
134
|
-
redemptionReimbursementPercentage: { getOnChainInt: 1000000n },
|
|
135
|
-
redemptionProcessingFeePercentage: { getOnChainInt: 1000000n },
|
|
136
|
-
interestCollectorPortionPercentage: { getOnChainInt: 30000000n },
|
|
137
|
-
firstIAsset: false,
|
|
138
|
-
nextIAsset: fromText('iSOL'),
|
|
139
|
-
};
|
|
140
|
-
expect(serialiseIAssetDatum(assetObject)).toEqual(assetDatum);
|
|
141
|
-
expect(parseIAssetDatum(assetDatum)).toEqual(assetObject);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('Staking Manager', () => {
|
|
145
|
-
const stakingManagerDatum =
|
|
146
|
-
'd8799fd8799f1b000009c04704429ed8799f1b000001402802fec1ffffff';
|
|
147
|
-
const stakingManagerObject: StakingManagerContent = {
|
|
148
|
-
totalStake: 10721429832350n,
|
|
149
|
-
managerSnapshot: {
|
|
150
|
-
snapshotAda: 1375060819649n,
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
expect(parseStakingManagerDatum(stakingManagerDatum)).toEqual(
|
|
155
|
-
stakingManagerObject,
|
|
156
|
-
);
|
|
157
|
-
expect(
|
|
158
|
-
serialiseStakingDatum({
|
|
159
|
-
StakingManager: { content: stakingManagerObject },
|
|
160
|
-
}),
|
|
161
|
-
).toEqual(stakingManagerDatum);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('Staking Position', () => {
|
|
165
|
-
const stakingPositionDatum =
|
|
166
|
-
'd87a9fd8799f581cd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f43bf1853d8799f1a5c8c1cfb1b0000019616971410ffffd8799f1b0000013a7ed5b0fdffffff';
|
|
167
|
-
const stakingPositionObject: StakingPositionContent = {
|
|
168
|
-
owner: 'd45527a088a92fd31f42b5777fe39c40f810e0f79d13c6d77eeb7f43',
|
|
169
|
-
lockedAmount: new Map([[83n, [1552686331n, 1744135722000n]]]),
|
|
170
|
-
positionSnapshot: {
|
|
171
|
-
snapshotAda: 1350747664637n,
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
expect(parseStakingPositionDatum(stakingPositionDatum)).toEqual(
|
|
176
|
-
stakingPositionObject,
|
|
177
|
-
);
|
|
178
|
-
expect(
|
|
179
|
-
serialiseStakingDatum({
|
|
180
|
-
StakingPosition: { content: stakingPositionObject },
|
|
181
|
-
}),
|
|
182
|
-
).toEqual(stakingPositionDatum);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('Stability Pool', () => {
|
|
186
|
-
const stabilityPoolDatum =
|
|
187
|
-
'd8799fd8799f4469555344d8799fd8799f1b0a37ad5c452ffb2affd8799fc24d1f94ac680ce6b48ea21bb122baffd8799f1b0fde3bba456cd5deff0100ffa2d8799f0000ffd8799f1b084494e2d23b2b7effd8799f0100ffd8799f1b0fde3bba456cd5deffffff';
|
|
188
|
-
const stabilityPoolObject: StabilityPoolContent = {
|
|
189
|
-
asset: fromText('iUSD'),
|
|
190
|
-
snapshot: {
|
|
191
|
-
productVal: { value: 736247675907734314n },
|
|
192
|
-
depositVal: { value: 2502085246000826468068228145850n },
|
|
193
|
-
sumVal: { value: 1143417026613401054n },
|
|
194
|
-
epoch: 1n,
|
|
195
|
-
scale: 0n,
|
|
196
|
-
},
|
|
197
|
-
epochToScaleToSum: new Map([
|
|
198
|
-
[{ epoch: 0n, scale: 0n }, { value: 595764752630360958n }],
|
|
199
|
-
[{ epoch: 1n, scale: 0n }, { value: 1143417026613401054n }],
|
|
200
|
-
]),
|
|
201
|
-
};
|
|
202
|
-
expect(parseStabilityPoolDatum(stabilityPoolDatum)).toEqual(
|
|
203
|
-
stabilityPoolObject,
|
|
204
|
-
);
|
|
205
|
-
expect(
|
|
206
|
-
serialiseStabilityPoolDatum({
|
|
207
|
-
StabilityPool: { content: stabilityPoolObject },
|
|
208
|
-
}),
|
|
209
|
-
).toEqual(stabilityPoolDatum);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// it('Stability Pool Account', () => {
|
|
213
|
-
// const stabilityPoolDatum =
|
|
214
|
-
// 'd87a9fd8799f581c12c646d4c6d7a35c14788d15f0f6142f6148975d8932592fbd625f674469555344d8799fd8799f1b0a37ad5c452ffb2affd8799fc24c39fa2838b1f7dd38267f0a6dffd8799f1b0fde3b75c28ab489ff0100ffd87a80ffff';
|
|
215
|
-
// const stabilityPoolObject: AccountContent = {
|
|
216
|
-
// owner: '12c646d4c6d7a35c14788d15f0f6142f6148975d8932592fbd625f67',
|
|
217
|
-
// asset: fromText('iUSD'),
|
|
218
|
-
// snapshot: {
|
|
219
|
-
// productVal: { value: 736247675907734314n },
|
|
220
|
-
// depositVal: { value: 17943066955221270821727046253n },
|
|
221
|
-
// sumVal: { value: 1143416732359767177n },
|
|
222
|
-
// epoch: 1n,
|
|
223
|
-
// scale: 0n,
|
|
224
|
-
// },
|
|
225
|
-
// request: null,
|
|
226
|
-
// };
|
|
227
|
-
|
|
228
|
-
// expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
|
|
229
|
-
// expect(
|
|
230
|
-
// serialiseStabilityPoolDatum({ Account: { content: stabilityPoolObject } }),
|
|
231
|
-
// ).toEqual(stabilityPoolDatum);
|
|
232
|
-
// });
|
|
233
|
-
|
|
234
|
-
// it('Stability Pool Account w/ Adjust Request', () => {
|
|
235
|
-
// const stabilityPoolDatum =
|
|
236
|
-
// 'd87a9fd8799f581c90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c4469555344d8799fd8799f1b0a374472be304a62ffd8799fc24b01aef07f96e5ce00f80000ffd8799f1b0f88aa07a1048079ff0100ffd8799fd87a9f3a0007c359d8799fd8799f581c90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15cffd8799fd8799fd8799f581c75a4f9204b9308a92a09b0e22b94125e56f24b73bb85e2795f176c6affffffffffffffff';
|
|
237
|
-
// const stabilityPoolObject: AccountContent = {
|
|
238
|
-
// owner: '90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c',
|
|
239
|
-
// asset: fromText('iUSD'),
|
|
240
|
-
// snapshot: {
|
|
241
|
-
// productVal: { value: 736132323706161762n },
|
|
242
|
-
// depositVal: { value: 2035054000000000000000000n },
|
|
243
|
-
// sumVal: { value: 1119331457144488057n },
|
|
244
|
-
// epoch: 1n,
|
|
245
|
-
// scale: 0n,
|
|
246
|
-
// },
|
|
247
|
-
// request: {
|
|
248
|
-
// Adjust: {
|
|
249
|
-
// amount: -508762n,
|
|
250
|
-
// outputAddress: {
|
|
251
|
-
// paymentCredential: {
|
|
252
|
-
// PublicKeyCredential: ['90e40129516ee738fa6aa9183cf57b45c46946496e1590d34ca1b15c'],
|
|
253
|
-
// },
|
|
254
|
-
// stakeCredential: {
|
|
255
|
-
// Inline: [{PublicKeyCredential: ['75a4f9204b9308a92a09b0e22b94125e56f24b73bb85e2795f176c6a']}],
|
|
256
|
-
// },
|
|
257
|
-
// },
|
|
258
|
-
// },
|
|
259
|
-
// },
|
|
260
|
-
// };
|
|
261
|
-
|
|
262
|
-
// expect(parseAccountDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
|
|
263
|
-
// expect(
|
|
264
|
-
// serialiseStabilityPoolDatum({ Account: { content: stabilityPoolObject } }),
|
|
265
|
-
// ).toEqual(stabilityPoolDatum);
|
|
266
|
-
// });
|
|
267
|
-
|
|
268
|
-
// it('Stability Pool SnapshotEpochToScaleToSum', () => {
|
|
269
|
-
// const stabilityPoolDatum =
|
|
270
|
-
// 'd87b9fd8799f4469555344bfd8799f0000ffd8799f1b084494e2d23b2b7effd8799f0100ffd8799f1b0fde3bba456cd5deffffffff';
|
|
271
|
-
// const stabilityPoolObject: SnapshotEpochToScaleToSumContent = {
|
|
272
|
-
// asset: fromText('iUSD'),
|
|
273
|
-
// snapshot: new Map([
|
|
274
|
-
// [{ epoch: 0n, scale: 0n }, { sum: 595764752630360958n }],
|
|
275
|
-
// [{ epoch: 1n, scale: 0n }, { sum: 1143417026613401054n }],
|
|
276
|
-
// ]),
|
|
277
|
-
// };
|
|
278
|
-
|
|
279
|
-
// expect(parseSnapshotEpochToScaleToSumDatum(stabilityPoolDatum)).toEqual(stabilityPoolObject);
|
|
280
|
-
// expect(
|
|
281
|
-
// serialiseStabilityPoolDatum({
|
|
282
|
-
// SnapshotEpochToScaleToSum: { content: stabilityPoolObject },
|
|
283
|
-
// }),
|
|
284
|
-
// ).toEqual(stabilityPoolDatum);
|
|
285
|
-
// });
|
|
286
|
-
});
|