@indigo-labs/indigo-sdk 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +17 -0
- package/dist/index.mjs +15 -0
- package/package.json +11 -1
- package/.claude/settings.local.json +0 -7
- package/.github/workflows/ci.yml +0 -66
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/.prettierignore +0 -1
- package/.prettierrc +0 -6
- package/eslint.config.mjs +0 -42
- package/scripts/bench.sh +0 -62
- package/scripts/run-repeat.sh +0 -22
- package/src/contracts/cdp/helpers.ts +0 -173
- package/src/contracts/cdp/scripts.ts +0 -70
- package/src/contracts/cdp/transactions.ts +0 -1584
- package/src/contracts/cdp/types-new.ts +0 -277
- package/src/contracts/cdp/types.ts +0 -43
- package/src/contracts/cdp-creator/queries.ts +0 -30
- package/src/contracts/cdp-creator/scripts.ts +0 -45
- package/src/contracts/cdp-creator/types-new.ts +0 -50
- package/src/contracts/cdp-creator/types.ts +0 -24
- package/src/contracts/collector/scripts.ts +0 -32
- package/src/contracts/collector/transactions.ts +0 -50
- package/src/contracts/collector/types-new.ts +0 -17
- package/src/contracts/execute/scripts.ts +0 -57
- package/src/contracts/execute/types-new.ts +0 -44
- package/src/contracts/execute/types.ts +0 -24
- package/src/contracts/gov/helpers.ts +0 -351
- package/src/contracts/gov/scripts.ts +0 -41
- package/src/contracts/gov/transactions.ts +0 -1607
- package/src/contracts/gov/types-new.ts +0 -268
- package/src/contracts/gov/types.ts +0 -22
- package/src/contracts/iasset/helpers.ts +0 -170
- package/src/contracts/iasset/queries.ts +0 -102
- package/src/contracts/iasset/scripts.ts +0 -38
- package/src/contracts/iasset/types.ts +0 -154
- package/src/contracts/initialize/actions.ts +0 -789
- package/src/contracts/initialize/helpers.ts +0 -616
- package/src/contracts/initialize/types.ts +0 -116
- package/src/contracts/interest-collection/helpers.ts +0 -19
- package/src/contracts/interest-collection/queries.ts +0 -66
- package/src/contracts/interest-collection/scripts.ts +0 -44
- package/src/contracts/interest-collection/transactions.ts +0 -433
- package/src/contracts/interest-collection/types-new.ts +0 -50
- package/src/contracts/interest-collection/types.ts +0 -26
- package/src/contracts/interest-oracle/helpers.ts +0 -61
- package/src/contracts/interest-oracle/scripts.ts +0 -18
- package/src/contracts/interest-oracle/transactions.ts +0 -151
- package/src/contracts/interest-oracle/types-new.ts +0 -32
- package/src/contracts/interest-oracle/types.ts +0 -16
- package/src/contracts/one-shot/scripts.ts +0 -12
- package/src/contracts/one-shot/transactions.ts +0 -66
- package/src/contracts/one-shot/types.ts +0 -22
- package/src/contracts/poll/helpers.ts +0 -37
- package/src/contracts/poll/scripts.ts +0 -71
- package/src/contracts/poll/types-poll-manager.ts +0 -20
- package/src/contracts/poll/types-poll-new.ts +0 -196
- package/src/contracts/poll/types-poll-shard.ts +0 -16
- package/src/contracts/price-oracle/helpers.ts +0 -30
- package/src/contracts/price-oracle/scripts.ts +0 -18
- package/src/contracts/price-oracle/transactions.ts +0 -115
- package/src/contracts/price-oracle/types-new.ts +0 -50
- package/src/contracts/price-oracle/types.ts +0 -16
- package/src/contracts/pyth-feed/helpers.ts +0 -82
- package/src/contracts/pyth-feed/scripts.ts +0 -15
- package/src/contracts/pyth-feed/types.ts +0 -181
- package/src/contracts/rob/helpers.ts +0 -666
- package/src/contracts/rob/scripts.ts +0 -35
- package/src/contracts/rob/transactions.ts +0 -423
- package/src/contracts/rob/types-new.ts +0 -128
- package/src/contracts/rob/types.ts +0 -16
- package/src/contracts/rob-leverage/helpers.ts +0 -422
- package/src/contracts/rob-leverage/transactions.ts +0 -368
- package/src/contracts/stability-pool/helpers.ts +0 -798
- package/src/contracts/stability-pool/queries.ts +0 -132
- package/src/contracts/stability-pool/scripts.ts +0 -51
- package/src/contracts/stability-pool/transactions.ts +0 -921
- package/src/contracts/stability-pool/types-new.ts +0 -385
- package/src/contracts/stability-pool/types.ts +0 -25
- package/src/contracts/stableswap/helpers.ts +0 -507
- package/src/contracts/stableswap/scripts.ts +0 -37
- package/src/contracts/stableswap/transactions.ts +0 -475
- package/src/contracts/stableswap/types-new.ts +0 -131
- package/src/contracts/stableswap/types.ts +0 -17
- package/src/contracts/staking/helpers.ts +0 -136
- package/src/contracts/staking/scripts.ts +0 -41
- package/src/contracts/staking/transactions.ts +0 -349
- package/src/contracts/staking/types-new.ts +0 -137
- package/src/contracts/staking/types.ts +0 -17
- package/src/contracts/treasury/helpers.ts +0 -21
- package/src/contracts/treasury/queries.ts +0 -100
- package/src/contracts/treasury/scripts.ts +0 -27
- package/src/contracts/treasury/transactions.ts +0 -334
- package/src/contracts/treasury/types-new.ts +0 -69
- package/src/contracts/treasury/types.ts +0 -14
- package/src/contracts/version-registry/scripts.ts +0 -29
- package/src/contracts/version-registry/types-new.ts +0 -18
- package/src/contracts/version-registry/types.ts +0 -17
- package/src/index.ts +0 -93
- package/src/scripts/always-fail-validator.ts +0 -7
- package/src/scripts/auth-token-policy.ts +0 -24
- package/src/scripts/iasset-policy.ts +0 -23
- package/src/types/evolution-schema-options.ts +0 -16
- package/src/types/generic.ts +0 -52
- package/src/types/multisig.ts +0 -48
- package/src/types/on-chain-decimal.ts +0 -57
- package/src/types/rational.ts +0 -61
- package/src/types/system-params.ts +0 -463
- package/src/utils/array-utils.ts +0 -108
- package/src/utils/bigint-utils.ts +0 -35
- package/src/utils/helper-txs.ts +0 -31
- package/src/utils/indigo-helpers.ts +0 -17
- package/src/utils/lucid-utils.ts +0 -125
- package/src/utils/oracle-helpers.ts +0 -62
- package/src/utils/pyth/decode.ts +0 -223
- package/src/utils/pyth/encode.ts +0 -262
- package/src/utils/pyth/index.ts +0 -14
- package/src/utils/pyth/types.ts +0 -87
- package/src/utils/time-helpers.ts +0 -4
- package/src/utils/utils.ts +0 -25
- package/src/validators/always-succeed-validator.ts +0 -6
- package/src/validators/cdp-creator-validator.ts +0 -7
- package/src/validators/cdp-redeem-validator.ts +0 -7
- package/src/validators/cdp-validator.ts +0 -7
- package/src/validators/collector-validator.ts +0 -7
- package/src/validators/execute-validator.ts +0 -7
- package/src/validators/governance-validator.ts +0 -7
- package/src/validators/iasset-validator.ts +0 -7
- package/src/validators/interest-collection-validator.ts +0 -7
- package/src/validators/interest-oracle-validator.ts +0 -7
- package/src/validators/one-shot-policy.ts +0 -7
- package/src/validators/poll-manager-validator.ts +0 -7
- package/src/validators/poll-shard-validator.ts +0 -7
- package/src/validators/price-oracle-validator.ts +0 -7
- package/src/validators/pyth-feed-validator.ts +0 -7
- package/src/validators/rob-validator.ts +0 -7
- package/src/validators/stability-pool-validator.ts +0 -7
- package/src/validators/stableswap-validator.ts +0 -7
- package/src/validators/staking-validator.ts +0 -7
- package/src/validators/treasury-validator.ts +0 -7
- package/src/validators/version-record-policy.ts +0 -7
- package/src/validators/version-registry-validator.ts +0 -7
- package/tests/always-succeed/script.ts +0 -7
- package/tests/array-utils.test.ts +0 -92
- package/tests/bigint-utils.test.ts +0 -41
- package/tests/cdp/actions.ts +0 -680
- package/tests/cdp/cdp-helpers.ts +0 -55
- package/tests/cdp/cdp-queries.ts +0 -423
- package/tests/cdp/cdp.test.ts +0 -6730
- package/tests/cdp/transactions-mutated.ts +0 -1733
- package/tests/data/system-params.json +0 -1155
- package/tests/datums.test.ts +0 -302
- package/tests/endpoints/initialize.ts +0 -78
- package/tests/endpoints/interest-collector.ts +0 -37
- package/tests/endpoints/treasury.ts +0 -70
- package/tests/gov/actions.ts +0 -381
- package/tests/gov/gov.test.ts +0 -5147
- package/tests/gov/governance-queries.ts +0 -37
- package/tests/hash-checks.test.ts +0 -112
- package/tests/indigo-test-helpers.ts +0 -99
- package/tests/initialize.test.ts +0 -79
- package/tests/interest-calculations.test.ts +0 -120
- package/tests/interest-collection/interest-collection.test.ts +0 -843
- package/tests/interest-collection/transactions-mutated.ts +0 -260
- package/tests/interest-oracle.test.ts +0 -93
- package/tests/mock/assets-mock.ts +0 -243
- package/tests/mock/protocol-params-mock.ts +0 -21
- package/tests/price-oracle/actions.ts +0 -161
- package/tests/price-oracle/price-oracle-queries.ts +0 -12
- package/tests/price-oracle/price-oracle.test.ts +0 -228
- package/tests/price-oracle/transactions-mutated.ts +0 -59
- package/tests/pyth/endpoints.ts +0 -96
- package/tests/pyth/helpers.ts +0 -37
- package/tests/pyth/pyth-encoding.test.ts +0 -376
- package/tests/pyth/pyth-feeds.test.ts +0 -943
- package/tests/pyth/pyth-indigo.test.ts +0 -505
- package/tests/pyth/pyth.test.ts +0 -299
- package/tests/queries/collector-queries.ts +0 -27
- package/tests/queries/execute-queries.ts +0 -47
- package/tests/queries/iasset-queries.ts +0 -149
- package/tests/queries/interest-oracle-queries.ts +0 -12
- package/tests/queries/poll-queries.ts +0 -97
- package/tests/queries/staking-queries.ts +0 -54
- package/tests/rob/actions.ts +0 -56
- package/tests/rob/rob-leverage.test.ts +0 -2555
- package/tests/rob/rob-queries.ts +0 -95
- package/tests/rob/rob.test.ts +0 -3677
- package/tests/rob/transactions-mutated.ts +0 -844
- package/tests/script-size.test.ts +0 -240
- package/tests/setup.ts +0 -135
- package/tests/stability-pool/actions.ts +0 -229
- package/tests/stability-pool.test.ts +0 -6491
- package/tests/stableswap/stableswap-actions.ts +0 -83
- package/tests/stableswap/stableswap-queries.ts +0 -98
- package/tests/stableswap/stableswap.test.ts +0 -4471
- package/tests/stableswap/transactions-mutated.ts +0 -348
- package/tests/staking.test.ts +0 -172
- package/tests/test-helpers.ts +0 -94
- package/tests/treasury/actions.ts +0 -67
- package/tests/treasury/treasury.test.ts +0 -320
- package/tests/utils/asserts.ts +0 -87
- package/tests/utils/benchmark-utils.ts +0 -130
- package/tests/utils/index.ts +0 -168
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -27
- package/vitest.config.ts +0 -11
|
@@ -1,943 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fromHex,
|
|
3
|
-
SpendingValidator,
|
|
4
|
-
validatorToScriptHash,
|
|
5
|
-
} from '@lucid-evolution/lucid';
|
|
6
|
-
import {
|
|
7
|
-
AssetClassSP,
|
|
8
|
-
fromSysParamsPythFeedParams,
|
|
9
|
-
mkPythFeedValidator,
|
|
10
|
-
PythFeedParamsSP,
|
|
11
|
-
toDataDerivedPythPrice,
|
|
12
|
-
} from '../../src';
|
|
13
|
-
import { expect, test } from 'vitest';
|
|
14
|
-
|
|
15
|
-
/******************************
|
|
16
|
-
** Pyth configs for iAssets **
|
|
17
|
-
******************************/
|
|
18
|
-
|
|
19
|
-
const pythStateAssetClass: AssetClassSP = [
|
|
20
|
-
{
|
|
21
|
-
unCurrencySymbol:
|
|
22
|
-
'c935c937d0deda8975142c7b77aeef8f8cd48791e89a8ca7a0edc154',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
unTokenName: 'Pyth State',
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
/** Config: 1 / ADA/USD => USD/ADA */
|
|
30
|
-
test('iusd pyth feed', () => {
|
|
31
|
-
const IUSD_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
32
|
-
config: {
|
|
33
|
-
tag: 'inverse',
|
|
34
|
-
val: {
|
|
35
|
-
tag: 'value',
|
|
36
|
-
val: {
|
|
37
|
-
priceFeedId: 16,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const iusdPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
45
|
-
fromSysParamsPythFeedParams(IUSD_PYTH_FEED_PARAMS),
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const iusdPythFeedValidatorHash = validatorToScriptHash(
|
|
49
|
-
iusdPythFeedValidator,
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(iusdPythFeedValidatorHash).toEqual(
|
|
53
|
-
// Rebuild the params without conversion functions as well.
|
|
54
|
-
validatorToScriptHash(
|
|
55
|
-
mkPythFeedValidator({
|
|
56
|
-
config: {
|
|
57
|
-
Inverse: {
|
|
58
|
-
value: toDataDerivedPythPrice({
|
|
59
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
64
|
-
}),
|
|
65
|
-
),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
expect(iusdPythFeedValidatorHash).toEqual(
|
|
69
|
-
'4cb907af98c1ed5ee9f251691a0ec909f2a26b583ed271f2a88a55cb',
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
/** Config: BTC/USD / ADA/USD => BTC/ADA */
|
|
74
|
-
test('ibtc pyth feed', () => {
|
|
75
|
-
const IBTC_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
76
|
-
config: {
|
|
77
|
-
tag: 'divide',
|
|
78
|
-
val: [
|
|
79
|
-
{
|
|
80
|
-
tag: 'value',
|
|
81
|
-
val: {
|
|
82
|
-
priceFeedId: 1,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
tag: 'value',
|
|
87
|
-
val: {
|
|
88
|
-
priceFeedId: 16,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const ibtcPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
97
|
-
fromSysParamsPythFeedParams(IBTC_PYTH_FEED_PARAMS),
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const ibtcPythFeedValidatorHash = validatorToScriptHash(
|
|
101
|
-
ibtcPythFeedValidator,
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
expect(ibtcPythFeedValidatorHash).toEqual(
|
|
105
|
-
// Rebuild the params without conversion functions as well.
|
|
106
|
-
validatorToScriptHash(
|
|
107
|
-
mkPythFeedValidator({
|
|
108
|
-
config: {
|
|
109
|
-
Divide: {
|
|
110
|
-
x: toDataDerivedPythPrice({
|
|
111
|
-
Value: { configuration: { priceFeedId: 1n } },
|
|
112
|
-
}),
|
|
113
|
-
y: toDataDerivedPythPrice({
|
|
114
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
115
|
-
}),
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
119
|
-
}),
|
|
120
|
-
),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
expect(ibtcPythFeedValidatorHash).toEqual(
|
|
124
|
-
'77f65e4d14ed8106e8a97814bdb0e7688f652fe41c71295a42f11a26',
|
|
125
|
-
);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
/** Config: ETH/USD / ADA/USD => ETH/ADA */
|
|
129
|
-
test('ieth pyth feed', () => {
|
|
130
|
-
const IETH_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
131
|
-
config: {
|
|
132
|
-
tag: 'divide',
|
|
133
|
-
val: [
|
|
134
|
-
{
|
|
135
|
-
tag: 'value',
|
|
136
|
-
val: {
|
|
137
|
-
priceFeedId: 2,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
tag: 'value',
|
|
142
|
-
val: {
|
|
143
|
-
priceFeedId: 16,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const iethPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
152
|
-
fromSysParamsPythFeedParams(IETH_PYTH_FEED_PARAMS),
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
const iethPythFeedValidatorHash = validatorToScriptHash(
|
|
156
|
-
iethPythFeedValidator,
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
expect(iethPythFeedValidatorHash).toEqual(
|
|
160
|
-
// Rebuild the params without conversion functions as well.
|
|
161
|
-
validatorToScriptHash(
|
|
162
|
-
mkPythFeedValidator({
|
|
163
|
-
config: {
|
|
164
|
-
Divide: {
|
|
165
|
-
x: toDataDerivedPythPrice({
|
|
166
|
-
Value: { configuration: { priceFeedId: 2n } },
|
|
167
|
-
}),
|
|
168
|
-
y: toDataDerivedPythPrice({
|
|
169
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
170
|
-
}),
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
174
|
-
}),
|
|
175
|
-
),
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
expect(iethPythFeedValidatorHash).toEqual(
|
|
179
|
-
'893828eeaa8bf4322559da69b69f0f36795d430f5942e2472cef8a88',
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
/** Config: SOL/USD / ADA/USD => SOL/ADA */
|
|
184
|
-
test('isol pyth feed', () => {
|
|
185
|
-
const ISOL_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
186
|
-
config: {
|
|
187
|
-
tag: 'divide',
|
|
188
|
-
val: [
|
|
189
|
-
{
|
|
190
|
-
tag: 'value',
|
|
191
|
-
val: {
|
|
192
|
-
priceFeedId: 6,
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
tag: 'value',
|
|
197
|
-
val: {
|
|
198
|
-
priceFeedId: 16,
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
},
|
|
203
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const isolPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
207
|
-
fromSysParamsPythFeedParams(ISOL_PYTH_FEED_PARAMS),
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
const isolPythFeedValidatorHash = validatorToScriptHash(
|
|
211
|
-
isolPythFeedValidator,
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
expect(isolPythFeedValidatorHash).toEqual(
|
|
215
|
-
// Rebuild the params without conversion functions as well.
|
|
216
|
-
validatorToScriptHash(
|
|
217
|
-
mkPythFeedValidator({
|
|
218
|
-
config: {
|
|
219
|
-
Divide: {
|
|
220
|
-
x: toDataDerivedPythPrice({
|
|
221
|
-
Value: { configuration: { priceFeedId: 6n } },
|
|
222
|
-
}),
|
|
223
|
-
y: toDataDerivedPythPrice({
|
|
224
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
225
|
-
}),
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
229
|
-
}),
|
|
230
|
-
),
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
expect(isolPythFeedValidatorHash).toEqual(
|
|
234
|
-
'9a899983b90e2c2cfbc985cd34812a1ba393e169d7f7d277085ab14a',
|
|
235
|
-
);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
/** Config: EUR/USD / ADA/USD => EUR/ADA */
|
|
239
|
-
test('ieur pyth feed', () => {
|
|
240
|
-
const IEUR_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
241
|
-
config: {
|
|
242
|
-
tag: 'divide',
|
|
243
|
-
val: [
|
|
244
|
-
{
|
|
245
|
-
tag: 'value',
|
|
246
|
-
val: {
|
|
247
|
-
priceFeedId: 327,
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
tag: 'value',
|
|
252
|
-
val: {
|
|
253
|
-
priceFeedId: 16,
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
],
|
|
257
|
-
},
|
|
258
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
const ieurPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
262
|
-
fromSysParamsPythFeedParams(IEUR_PYTH_FEED_PARAMS),
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
const ieurPythFeedValidatorHash = validatorToScriptHash(
|
|
266
|
-
ieurPythFeedValidator,
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
expect(ieurPythFeedValidatorHash).toEqual(
|
|
270
|
-
// Rebuild the params without conversion functions as well.
|
|
271
|
-
validatorToScriptHash(
|
|
272
|
-
mkPythFeedValidator({
|
|
273
|
-
config: {
|
|
274
|
-
Divide: {
|
|
275
|
-
x: toDataDerivedPythPrice({
|
|
276
|
-
Value: { configuration: { priceFeedId: 327n } },
|
|
277
|
-
}),
|
|
278
|
-
y: toDataDerivedPythPrice({
|
|
279
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
280
|
-
}),
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
284
|
-
}),
|
|
285
|
-
),
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
expect(ieurPythFeedValidatorHash).toEqual(
|
|
289
|
-
'9da7071e0abb11aa4e1b669ae60592d3dbcaade6e9724c45b1a654eb',
|
|
290
|
-
);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
/** Config: (1 / USD/JPY) / ADA/USD => JPY/ADA */
|
|
294
|
-
test('ijpy pyth feed', () => {
|
|
295
|
-
const IJPY_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
296
|
-
config: {
|
|
297
|
-
tag: 'divide',
|
|
298
|
-
val: [
|
|
299
|
-
{
|
|
300
|
-
tag: 'inverse',
|
|
301
|
-
val: {
|
|
302
|
-
tag: 'value',
|
|
303
|
-
val: {
|
|
304
|
-
priceFeedId: 340,
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
tag: 'value',
|
|
310
|
-
val: {
|
|
311
|
-
priceFeedId: 16,
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
],
|
|
315
|
-
},
|
|
316
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
const ijpyPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
320
|
-
fromSysParamsPythFeedParams(IJPY_PYTH_FEED_PARAMS),
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
const ijpyPythFeedValidatorHash = validatorToScriptHash(
|
|
324
|
-
ijpyPythFeedValidator,
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
expect(ijpyPythFeedValidatorHash).toEqual(
|
|
328
|
-
// Rebuild the params without conversion functions as well.
|
|
329
|
-
validatorToScriptHash(
|
|
330
|
-
mkPythFeedValidator({
|
|
331
|
-
config: {
|
|
332
|
-
Divide: {
|
|
333
|
-
x: toDataDerivedPythPrice({
|
|
334
|
-
Inverse: {
|
|
335
|
-
value: toDataDerivedPythPrice({
|
|
336
|
-
Value: { configuration: { priceFeedId: 340n } },
|
|
337
|
-
}),
|
|
338
|
-
},
|
|
339
|
-
}),
|
|
340
|
-
y: toDataDerivedPythPrice({
|
|
341
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
342
|
-
}),
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
346
|
-
}),
|
|
347
|
-
),
|
|
348
|
-
);
|
|
349
|
-
|
|
350
|
-
expect(ijpyPythFeedValidatorHash).toEqual(
|
|
351
|
-
'0db1238594da8cb18260454e115dd63bd9789aad487ff1d80f59799a',
|
|
352
|
-
);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
/** Config: 1 / NIGHT/USD => USD/NIGHT */
|
|
356
|
-
test('iusd night pyth feed', () => {
|
|
357
|
-
const IUSD_NIGHT_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
358
|
-
config: {
|
|
359
|
-
tag: 'inverse',
|
|
360
|
-
val: {
|
|
361
|
-
tag: 'value',
|
|
362
|
-
val: {
|
|
363
|
-
priceFeedId: 2970,
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
const iusdNightPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
371
|
-
fromSysParamsPythFeedParams(IUSD_NIGHT_PYTH_FEED_PARAMS),
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
const iusdNightPythFeedValidatorHash = validatorToScriptHash(
|
|
375
|
-
iusdNightPythFeedValidator,
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
expect(iusdNightPythFeedValidatorHash).toEqual(
|
|
379
|
-
// Rebuild the params without conversion functions as well.
|
|
380
|
-
validatorToScriptHash(
|
|
381
|
-
mkPythFeedValidator({
|
|
382
|
-
config: {
|
|
383
|
-
Inverse: {
|
|
384
|
-
value: toDataDerivedPythPrice({
|
|
385
|
-
Value: { configuration: { priceFeedId: 2970n } },
|
|
386
|
-
}),
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
390
|
-
}),
|
|
391
|
-
),
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
expect(iusdNightPythFeedValidatorHash).toEqual(
|
|
395
|
-
'1d4c0f85dcbcc230f1550f30574206c5b9bddff47b7b135edb12de69',
|
|
396
|
-
);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
/** Config: (EUR / USD) / (NIGHT/USD) => EUR/NIGHT */
|
|
400
|
-
test('ieur night pyth feed', () => {
|
|
401
|
-
const IEUR_NIGHT_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
402
|
-
config: {
|
|
403
|
-
tag: 'divide',
|
|
404
|
-
val: [
|
|
405
|
-
{
|
|
406
|
-
tag: 'value',
|
|
407
|
-
val: {
|
|
408
|
-
priceFeedId: 327,
|
|
409
|
-
},
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
tag: 'value',
|
|
413
|
-
val: {
|
|
414
|
-
priceFeedId: 2970,
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
],
|
|
418
|
-
},
|
|
419
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
const ieurNightPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
423
|
-
fromSysParamsPythFeedParams(IEUR_NIGHT_PYTH_FEED_PARAMS),
|
|
424
|
-
);
|
|
425
|
-
|
|
426
|
-
const ieurNightPythFeedValidatorHash = validatorToScriptHash(
|
|
427
|
-
ieurNightPythFeedValidator,
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
expect(ieurNightPythFeedValidatorHash).toEqual(
|
|
431
|
-
// Rebuild the params without conversion functions as well.
|
|
432
|
-
validatorToScriptHash(
|
|
433
|
-
mkPythFeedValidator({
|
|
434
|
-
config: {
|
|
435
|
-
Divide: {
|
|
436
|
-
x: toDataDerivedPythPrice({
|
|
437
|
-
Value: { configuration: { priceFeedId: 327n } },
|
|
438
|
-
}),
|
|
439
|
-
y: toDataDerivedPythPrice({
|
|
440
|
-
Value: { configuration: { priceFeedId: 2970n } },
|
|
441
|
-
}),
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
445
|
-
}),
|
|
446
|
-
),
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
expect(ieurNightPythFeedValidatorHash).toEqual(
|
|
450
|
-
'2104dd1545835d7b13f2dd482bcc3943cf42ec15fa968411d4632149',
|
|
451
|
-
);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
/** Config: (1 / USD/JPY) / (NIGHT/USD) => JPY/NIGHT */
|
|
455
|
-
test('ijpy night pyth feed', () => {
|
|
456
|
-
const IJPY_NIGHT_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
457
|
-
config: {
|
|
458
|
-
tag: 'divide',
|
|
459
|
-
val: [
|
|
460
|
-
{
|
|
461
|
-
tag: 'inverse',
|
|
462
|
-
val: {
|
|
463
|
-
tag: 'value',
|
|
464
|
-
val: {
|
|
465
|
-
priceFeedId: 340,
|
|
466
|
-
},
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
tag: 'value',
|
|
471
|
-
val: {
|
|
472
|
-
priceFeedId: 2970,
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
|
-
],
|
|
476
|
-
},
|
|
477
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
const ijpyNightPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
481
|
-
fromSysParamsPythFeedParams(IJPY_NIGHT_PYTH_FEED_PARAMS),
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
const ijpyNightPythFeedValidatorHash = validatorToScriptHash(
|
|
485
|
-
ijpyNightPythFeedValidator,
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
expect(ijpyNightPythFeedValidatorHash).toEqual(
|
|
489
|
-
// Rebuild the params without conversion functions as well.
|
|
490
|
-
validatorToScriptHash(
|
|
491
|
-
mkPythFeedValidator({
|
|
492
|
-
config: {
|
|
493
|
-
Divide: {
|
|
494
|
-
x: toDataDerivedPythPrice({
|
|
495
|
-
Inverse: {
|
|
496
|
-
value: toDataDerivedPythPrice({
|
|
497
|
-
Value: { configuration: { priceFeedId: 340n } },
|
|
498
|
-
}),
|
|
499
|
-
},
|
|
500
|
-
}),
|
|
501
|
-
y: toDataDerivedPythPrice({
|
|
502
|
-
Value: { configuration: { priceFeedId: 2970n } },
|
|
503
|
-
}),
|
|
504
|
-
},
|
|
505
|
-
},
|
|
506
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
507
|
-
}),
|
|
508
|
-
),
|
|
509
|
-
);
|
|
510
|
-
|
|
511
|
-
expect(ijpyNightPythFeedValidatorHash).toEqual(
|
|
512
|
-
'00bc4b3a8710593c2e25c6e151fbdff3ec79106e828a48e16f9422f8',
|
|
513
|
-
);
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
/** Config: (EUR / USD) / (USDCx/USD) => EUR/USDCx */
|
|
517
|
-
test('ieur usdcx pyth feed', () => {
|
|
518
|
-
const IEUR_USDCX_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
519
|
-
config: {
|
|
520
|
-
tag: 'divide',
|
|
521
|
-
val: [
|
|
522
|
-
{
|
|
523
|
-
tag: 'value',
|
|
524
|
-
val: {
|
|
525
|
-
priceFeedId: 327,
|
|
526
|
-
},
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
tag: 'value',
|
|
530
|
-
val: {
|
|
531
|
-
priceFeedId: 7,
|
|
532
|
-
},
|
|
533
|
-
},
|
|
534
|
-
],
|
|
535
|
-
},
|
|
536
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
const ieurUSDCxPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
540
|
-
fromSysParamsPythFeedParams(IEUR_USDCX_PYTH_FEED_PARAMS),
|
|
541
|
-
);
|
|
542
|
-
|
|
543
|
-
const ieurUSDCxPythFeedValidatorHash = validatorToScriptHash(
|
|
544
|
-
ieurUSDCxPythFeedValidator,
|
|
545
|
-
);
|
|
546
|
-
|
|
547
|
-
expect(ieurUSDCxPythFeedValidatorHash).toEqual(
|
|
548
|
-
// Rebuild the params without conversion functions as well.
|
|
549
|
-
validatorToScriptHash(
|
|
550
|
-
mkPythFeedValidator({
|
|
551
|
-
config: {
|
|
552
|
-
Divide: {
|
|
553
|
-
x: toDataDerivedPythPrice({
|
|
554
|
-
Value: { configuration: { priceFeedId: 327n } },
|
|
555
|
-
}),
|
|
556
|
-
y: toDataDerivedPythPrice({
|
|
557
|
-
Value: { configuration: { priceFeedId: 7n } },
|
|
558
|
-
}),
|
|
559
|
-
},
|
|
560
|
-
},
|
|
561
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
562
|
-
}),
|
|
563
|
-
),
|
|
564
|
-
);
|
|
565
|
-
|
|
566
|
-
expect(ieurUSDCxPythFeedValidatorHash).toEqual(
|
|
567
|
-
'0b1d64e558d1c38e420c2348e8674c99cf9a4552ebc4e18c1f20a20b',
|
|
568
|
-
);
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
/** Config: (1 / USD/JPY) / (USDCx/USD) => JPY/USDCx */
|
|
572
|
-
test('ijpy usdcx pyth feed', () => {
|
|
573
|
-
const IJPY_USDCX_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
574
|
-
config: {
|
|
575
|
-
tag: 'divide',
|
|
576
|
-
val: [
|
|
577
|
-
{
|
|
578
|
-
tag: 'inverse',
|
|
579
|
-
val: {
|
|
580
|
-
tag: 'value',
|
|
581
|
-
val: {
|
|
582
|
-
priceFeedId: 340,
|
|
583
|
-
},
|
|
584
|
-
},
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
tag: 'value',
|
|
588
|
-
val: {
|
|
589
|
-
priceFeedId: 7,
|
|
590
|
-
},
|
|
591
|
-
},
|
|
592
|
-
],
|
|
593
|
-
},
|
|
594
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
595
|
-
};
|
|
596
|
-
|
|
597
|
-
const ijpyUSDCxPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
598
|
-
fromSysParamsPythFeedParams(IJPY_USDCX_PYTH_FEED_PARAMS),
|
|
599
|
-
);
|
|
600
|
-
|
|
601
|
-
const ijpyUSDCxPythFeedValidatorHash = validatorToScriptHash(
|
|
602
|
-
ijpyUSDCxPythFeedValidator,
|
|
603
|
-
);
|
|
604
|
-
|
|
605
|
-
expect(ijpyUSDCxPythFeedValidatorHash).toEqual(
|
|
606
|
-
// Rebuild the params without conversion functions as well.
|
|
607
|
-
validatorToScriptHash(
|
|
608
|
-
mkPythFeedValidator({
|
|
609
|
-
config: {
|
|
610
|
-
Divide: {
|
|
611
|
-
x: toDataDerivedPythPrice({
|
|
612
|
-
Inverse: {
|
|
613
|
-
value: toDataDerivedPythPrice({
|
|
614
|
-
Value: { configuration: { priceFeedId: 340n } },
|
|
615
|
-
}),
|
|
616
|
-
},
|
|
617
|
-
}),
|
|
618
|
-
y: toDataDerivedPythPrice({
|
|
619
|
-
Value: { configuration: { priceFeedId: 7n } },
|
|
620
|
-
}),
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
624
|
-
}),
|
|
625
|
-
),
|
|
626
|
-
);
|
|
627
|
-
|
|
628
|
-
expect(ijpyUSDCxPythFeedValidatorHash).toEqual(
|
|
629
|
-
'f2c4e1f46052f4f1de0088a9c70889b3bef48bd6015fd4c0adb3195c',
|
|
630
|
-
);
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
/** Config: (BTC / USD) / (NIGHT/USD) => BTC/NIGHT */
|
|
634
|
-
test('ibtc night pyth feed', () => {
|
|
635
|
-
const IBTC_NIGHT_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
636
|
-
config: {
|
|
637
|
-
tag: 'divide',
|
|
638
|
-
val: [
|
|
639
|
-
{
|
|
640
|
-
tag: 'value',
|
|
641
|
-
val: {
|
|
642
|
-
priceFeedId: 1,
|
|
643
|
-
},
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
tag: 'value',
|
|
647
|
-
val: {
|
|
648
|
-
priceFeedId: 2970,
|
|
649
|
-
},
|
|
650
|
-
},
|
|
651
|
-
],
|
|
652
|
-
},
|
|
653
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
const ibtcNightPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
657
|
-
fromSysParamsPythFeedParams(IBTC_NIGHT_PYTH_FEED_PARAMS),
|
|
658
|
-
);
|
|
659
|
-
|
|
660
|
-
const ibtcNightPythFeedValidatorHash = validatorToScriptHash(
|
|
661
|
-
ibtcNightPythFeedValidator,
|
|
662
|
-
);
|
|
663
|
-
|
|
664
|
-
expect(ibtcNightPythFeedValidatorHash).toEqual(
|
|
665
|
-
// Rebuild the params without conversion functions as well.
|
|
666
|
-
validatorToScriptHash(
|
|
667
|
-
mkPythFeedValidator({
|
|
668
|
-
config: {
|
|
669
|
-
Divide: {
|
|
670
|
-
x: toDataDerivedPythPrice({
|
|
671
|
-
Value: { configuration: { priceFeedId: 1n } },
|
|
672
|
-
}),
|
|
673
|
-
y: toDataDerivedPythPrice({
|
|
674
|
-
Value: { configuration: { priceFeedId: 2970n } },
|
|
675
|
-
}),
|
|
676
|
-
},
|
|
677
|
-
},
|
|
678
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
679
|
-
}),
|
|
680
|
-
),
|
|
681
|
-
);
|
|
682
|
-
|
|
683
|
-
expect(ibtcNightPythFeedValidatorHash).toEqual(
|
|
684
|
-
'176c55745286f4a139bf69719514fb4769be572f0b009b31ae482a3d',
|
|
685
|
-
);
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
/** Config: (ETH / USD) / (NIGHT/USD) => BTC/NIGHT */
|
|
689
|
-
test('ieth night pyth feed', () => {
|
|
690
|
-
const IETH_NIGHT_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
691
|
-
config: {
|
|
692
|
-
tag: 'divide',
|
|
693
|
-
val: [
|
|
694
|
-
{
|
|
695
|
-
tag: 'value',
|
|
696
|
-
val: {
|
|
697
|
-
priceFeedId: 2,
|
|
698
|
-
},
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
tag: 'value',
|
|
702
|
-
val: {
|
|
703
|
-
priceFeedId: 2970,
|
|
704
|
-
},
|
|
705
|
-
},
|
|
706
|
-
],
|
|
707
|
-
},
|
|
708
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
709
|
-
};
|
|
710
|
-
|
|
711
|
-
const iethNightPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
712
|
-
fromSysParamsPythFeedParams(IETH_NIGHT_PYTH_FEED_PARAMS),
|
|
713
|
-
);
|
|
714
|
-
|
|
715
|
-
const iethNightPythFeedValidatorHash = validatorToScriptHash(
|
|
716
|
-
iethNightPythFeedValidator,
|
|
717
|
-
);
|
|
718
|
-
|
|
719
|
-
expect(iethNightPythFeedValidatorHash).toEqual(
|
|
720
|
-
// Rebuild the params without conversion functions as well.
|
|
721
|
-
validatorToScriptHash(
|
|
722
|
-
mkPythFeedValidator({
|
|
723
|
-
config: {
|
|
724
|
-
Divide: {
|
|
725
|
-
x: toDataDerivedPythPrice({
|
|
726
|
-
Value: { configuration: { priceFeedId: 2n } },
|
|
727
|
-
}),
|
|
728
|
-
y: toDataDerivedPythPrice({
|
|
729
|
-
Value: { configuration: { priceFeedId: 2970n } },
|
|
730
|
-
}),
|
|
731
|
-
},
|
|
732
|
-
},
|
|
733
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
734
|
-
}),
|
|
735
|
-
),
|
|
736
|
-
);
|
|
737
|
-
|
|
738
|
-
expect(iethNightPythFeedValidatorHash).toEqual(
|
|
739
|
-
'9fd83fdd93a6945790498fe47fdeff28a8beda1f611784edcd1fee98',
|
|
740
|
-
);
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
/** Config: (BTC / USD) / (USDCx/USD) => BTC/USDCx */
|
|
744
|
-
test('ibtc usdcx pyth feed', () => {
|
|
745
|
-
const IBTC_USDCX_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
746
|
-
config: {
|
|
747
|
-
tag: 'divide',
|
|
748
|
-
val: [
|
|
749
|
-
{
|
|
750
|
-
tag: 'value',
|
|
751
|
-
val: {
|
|
752
|
-
priceFeedId: 1,
|
|
753
|
-
},
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
tag: 'value',
|
|
757
|
-
val: {
|
|
758
|
-
priceFeedId: 7,
|
|
759
|
-
},
|
|
760
|
-
},
|
|
761
|
-
],
|
|
762
|
-
},
|
|
763
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
const ibtcUSDCxPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
767
|
-
fromSysParamsPythFeedParams(IBTC_USDCX_PYTH_FEED_PARAMS),
|
|
768
|
-
);
|
|
769
|
-
|
|
770
|
-
const ibtcUSDCxPythFeedValidatorHash = validatorToScriptHash(
|
|
771
|
-
ibtcUSDCxPythFeedValidator,
|
|
772
|
-
);
|
|
773
|
-
|
|
774
|
-
expect(ibtcUSDCxPythFeedValidatorHash).toEqual(
|
|
775
|
-
// Rebuild the params without conversion functions as well.
|
|
776
|
-
validatorToScriptHash(
|
|
777
|
-
mkPythFeedValidator({
|
|
778
|
-
config: {
|
|
779
|
-
Divide: {
|
|
780
|
-
x: toDataDerivedPythPrice({
|
|
781
|
-
Value: { configuration: { priceFeedId: 1n } },
|
|
782
|
-
}),
|
|
783
|
-
y: toDataDerivedPythPrice({
|
|
784
|
-
Value: { configuration: { priceFeedId: 7n } },
|
|
785
|
-
}),
|
|
786
|
-
},
|
|
787
|
-
},
|
|
788
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
789
|
-
}),
|
|
790
|
-
),
|
|
791
|
-
);
|
|
792
|
-
|
|
793
|
-
expect(ibtcUSDCxPythFeedValidatorHash).toEqual(
|
|
794
|
-
'df5a33036a62f20fa23f07d50a8da0b56714ae6c69f7389b82318fef',
|
|
795
|
-
);
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
/** Config: (ETH / USD) / (USDCx/USD) => BTC/USDCx */
|
|
799
|
-
test('ieth usdcx pyth feed', () => {
|
|
800
|
-
const IETH_USDCX_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
801
|
-
config: {
|
|
802
|
-
tag: 'divide',
|
|
803
|
-
val: [
|
|
804
|
-
{
|
|
805
|
-
tag: 'value',
|
|
806
|
-
val: {
|
|
807
|
-
priceFeedId: 2,
|
|
808
|
-
},
|
|
809
|
-
},
|
|
810
|
-
{
|
|
811
|
-
tag: 'value',
|
|
812
|
-
val: {
|
|
813
|
-
priceFeedId: 7,
|
|
814
|
-
},
|
|
815
|
-
},
|
|
816
|
-
],
|
|
817
|
-
},
|
|
818
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
const iethUSDCxPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
822
|
-
fromSysParamsPythFeedParams(IETH_USDCX_PYTH_FEED_PARAMS),
|
|
823
|
-
);
|
|
824
|
-
|
|
825
|
-
const iethUSDCxPythFeedValidatorHash = validatorToScriptHash(
|
|
826
|
-
iethUSDCxPythFeedValidator,
|
|
827
|
-
);
|
|
828
|
-
|
|
829
|
-
expect(iethUSDCxPythFeedValidatorHash).toEqual(
|
|
830
|
-
// Rebuild the params without conversion functions as well.
|
|
831
|
-
validatorToScriptHash(
|
|
832
|
-
mkPythFeedValidator({
|
|
833
|
-
config: {
|
|
834
|
-
Divide: {
|
|
835
|
-
x: toDataDerivedPythPrice({
|
|
836
|
-
Value: { configuration: { priceFeedId: 2n } },
|
|
837
|
-
}),
|
|
838
|
-
y: toDataDerivedPythPrice({
|
|
839
|
-
Value: { configuration: { priceFeedId: 7n } },
|
|
840
|
-
}),
|
|
841
|
-
},
|
|
842
|
-
},
|
|
843
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
844
|
-
}),
|
|
845
|
-
),
|
|
846
|
-
);
|
|
847
|
-
|
|
848
|
-
expect(iethUSDCxPythFeedValidatorHash).toEqual(
|
|
849
|
-
'f83f5e86412ad360e1f6f248503b11fa92edf4aaa4a6799f1f067317',
|
|
850
|
-
);
|
|
851
|
-
});
|
|
852
|
-
|
|
853
|
-
/** Config: (ADA / USD) / (USD/NIGHT) => ADA/NIGHT */
|
|
854
|
-
test('iada night pyth feed', () => {
|
|
855
|
-
const IADA_NIGHT_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
856
|
-
config: {
|
|
857
|
-
tag: 'divide',
|
|
858
|
-
val: [
|
|
859
|
-
{
|
|
860
|
-
tag: 'value',
|
|
861
|
-
val: {
|
|
862
|
-
priceFeedId: 16,
|
|
863
|
-
},
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
tag: 'value',
|
|
867
|
-
val: {
|
|
868
|
-
priceFeedId: 2970,
|
|
869
|
-
},
|
|
870
|
-
},
|
|
871
|
-
],
|
|
872
|
-
},
|
|
873
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
const iadaNightPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
877
|
-
fromSysParamsPythFeedParams(IADA_NIGHT_PYTH_FEED_PARAMS),
|
|
878
|
-
);
|
|
879
|
-
|
|
880
|
-
const iadaNightPythFeedValidatorHash = validatorToScriptHash(
|
|
881
|
-
iadaNightPythFeedValidator,
|
|
882
|
-
);
|
|
883
|
-
|
|
884
|
-
expect(iadaNightPythFeedValidatorHash).toEqual(
|
|
885
|
-
// Rebuild the params without conversion functions as well.
|
|
886
|
-
validatorToScriptHash(
|
|
887
|
-
mkPythFeedValidator({
|
|
888
|
-
config: {
|
|
889
|
-
Divide: {
|
|
890
|
-
x: toDataDerivedPythPrice({
|
|
891
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
892
|
-
}),
|
|
893
|
-
y: toDataDerivedPythPrice({
|
|
894
|
-
Value: { configuration: { priceFeedId: 2970n } },
|
|
895
|
-
}),
|
|
896
|
-
},
|
|
897
|
-
},
|
|
898
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
899
|
-
}),
|
|
900
|
-
),
|
|
901
|
-
);
|
|
902
|
-
|
|
903
|
-
expect(iadaNightPythFeedValidatorHash).toEqual(
|
|
904
|
-
'c16544a7009549cf26bde1cead12859b1933186da3c2717cd30074b9',
|
|
905
|
-
);
|
|
906
|
-
});
|
|
907
|
-
|
|
908
|
-
/** Config: ADA / USD */
|
|
909
|
-
test('iada usdcx pyth feed', () => {
|
|
910
|
-
const IADA_USDCX_PYTH_FEED_PARAMS: PythFeedParamsSP = {
|
|
911
|
-
config: {
|
|
912
|
-
tag: 'value',
|
|
913
|
-
val: {
|
|
914
|
-
priceFeedId: 16,
|
|
915
|
-
},
|
|
916
|
-
},
|
|
917
|
-
pythStatePolicyId: pythStateAssetClass[0],
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
const iadaUSDCxPythFeedValidator: SpendingValidator = mkPythFeedValidator(
|
|
921
|
-
fromSysParamsPythFeedParams(IADA_USDCX_PYTH_FEED_PARAMS),
|
|
922
|
-
);
|
|
923
|
-
|
|
924
|
-
const iadaUSDCxPythFeedValidatorHash = validatorToScriptHash(
|
|
925
|
-
iadaUSDCxPythFeedValidator,
|
|
926
|
-
);
|
|
927
|
-
|
|
928
|
-
expect(iadaUSDCxPythFeedValidatorHash).toEqual(
|
|
929
|
-
// Rebuild the params without conversion functions as well.
|
|
930
|
-
validatorToScriptHash(
|
|
931
|
-
mkPythFeedValidator({
|
|
932
|
-
config: {
|
|
933
|
-
Value: { configuration: { priceFeedId: 16n } },
|
|
934
|
-
},
|
|
935
|
-
pythStatePolicyId: fromHex(pythStateAssetClass[0].unCurrencySymbol),
|
|
936
|
-
}),
|
|
937
|
-
),
|
|
938
|
-
);
|
|
939
|
-
|
|
940
|
-
expect(iadaUSDCxPythFeedValidatorHash).toEqual(
|
|
941
|
-
'075b0ce5d592d51262e6d3e1c8a88e94c86470f95dc7b8e7a9139782',
|
|
942
|
-
);
|
|
943
|
-
});
|