@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/gov/actions.ts
DELETED
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fromHex,
|
|
3
|
-
fromText,
|
|
4
|
-
OutRef,
|
|
5
|
-
paymentCredentialOf,
|
|
6
|
-
} from '@lucid-evolution/lucid';
|
|
7
|
-
import {
|
|
8
|
-
addrDetails,
|
|
9
|
-
createProposal,
|
|
10
|
-
createShardsChunks,
|
|
11
|
-
endProposal,
|
|
12
|
-
executeProposal,
|
|
13
|
-
fromSystemParamsAsset,
|
|
14
|
-
InterestOracleParams,
|
|
15
|
-
mergeShards,
|
|
16
|
-
openStakingPosition,
|
|
17
|
-
PriceOracleParams,
|
|
18
|
-
startInterestOracle,
|
|
19
|
-
SystemParams,
|
|
20
|
-
vote,
|
|
21
|
-
} from '../../src';
|
|
22
|
-
import { VoteOption } from '../../src/contracts/poll/types-poll-new';
|
|
23
|
-
import {
|
|
24
|
-
findAllPollShards,
|
|
25
|
-
findPollManager,
|
|
26
|
-
findRandomPollShard,
|
|
27
|
-
} from '../queries/poll-queries';
|
|
28
|
-
import { findStakingPosition } from '../queries/staking-queries';
|
|
29
|
-
import {
|
|
30
|
-
LucidContext,
|
|
31
|
-
runAndAwaitTx,
|
|
32
|
-
runAndAwaitTxBuilder,
|
|
33
|
-
selectWalletByAddress,
|
|
34
|
-
} from '../test-helpers';
|
|
35
|
-
import { findGov } from './governance-queries';
|
|
36
|
-
import { array as A } from 'fp-ts';
|
|
37
|
-
import { expect } from 'vitest';
|
|
38
|
-
import { findExecute } from '../queries/execute-queries';
|
|
39
|
-
import { CollateralAssetInfo } from '../endpoints/initialize';
|
|
40
|
-
import { startPriceOracleTx } from '../../src/contracts/price-oracle/transactions';
|
|
41
|
-
import { AssetClass } from '@3rd-eye-labs/cardano-offchain-common';
|
|
42
|
-
import {
|
|
43
|
-
findAllCollateralAssetsOfIAsset,
|
|
44
|
-
findIAsset,
|
|
45
|
-
} from '../queries/iasset-queries';
|
|
46
|
-
import { Rational, rationalFromInt } from '../../src/types/rational';
|
|
47
|
-
|
|
48
|
-
export async function runVote(
|
|
49
|
-
pollId: bigint,
|
|
50
|
-
option: VoteOption,
|
|
51
|
-
sysParams: SystemParams,
|
|
52
|
-
context: LucidContext,
|
|
53
|
-
): Promise<void> {
|
|
54
|
-
const [pkh, _] = await addrDetails(context.lucid);
|
|
55
|
-
|
|
56
|
-
const stakingPosOref = await findStakingPosition(
|
|
57
|
-
context.lucid,
|
|
58
|
-
sysParams.validatorHashes.stakingHash,
|
|
59
|
-
fromSystemParamsAsset(sysParams.stakingParams.stakingToken),
|
|
60
|
-
pkh.hash,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const pollShard = await findRandomPollShard(
|
|
64
|
-
context.lucid,
|
|
65
|
-
sysParams.validatorHashes.pollShardHash,
|
|
66
|
-
fromSystemParamsAsset(sysParams.pollShardParams.pollToken),
|
|
67
|
-
pollId,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
await runAndAwaitTx(
|
|
71
|
-
context.lucid,
|
|
72
|
-
vote(option, pollShard.utxo, stakingPosOref.utxo, sysParams, context.lucid),
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export async function runCreateAllShards(
|
|
77
|
-
pollId: bigint,
|
|
78
|
-
sysParams: SystemParams,
|
|
79
|
-
context: LucidContext,
|
|
80
|
-
): Promise<void> {
|
|
81
|
-
const govUtxo = await findGov(
|
|
82
|
-
context.lucid,
|
|
83
|
-
sysParams.validatorHashes.govHash,
|
|
84
|
-
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
for (
|
|
88
|
-
let i = 0;
|
|
89
|
-
i < Math.ceil(Number(govUtxo.datum.protocolParams.totalShards) / 2);
|
|
90
|
-
i++
|
|
91
|
-
) {
|
|
92
|
-
const pollUtxo = await findPollManager(
|
|
93
|
-
context.lucid,
|
|
94
|
-
sysParams.validatorHashes.pollManagerHash,
|
|
95
|
-
fromSystemParamsAsset(sysParams.pollManagerParams.pollToken),
|
|
96
|
-
pollId,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
await runAndAwaitTx(
|
|
100
|
-
context.lucid,
|
|
101
|
-
createShardsChunks(2n, pollUtxo.utxo, sysParams, context.lucid),
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export async function runMergeAllShards(
|
|
107
|
-
pollId: bigint,
|
|
108
|
-
sysParams: SystemParams,
|
|
109
|
-
context: LucidContext,
|
|
110
|
-
): Promise<void> {
|
|
111
|
-
const govUtxo = await findGov(
|
|
112
|
-
context.lucid,
|
|
113
|
-
sysParams.validatorHashes.govHash,
|
|
114
|
-
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
for (
|
|
118
|
-
let i = 0;
|
|
119
|
-
i < Math.ceil(Number(govUtxo.datum.protocolParams.totalShards) / 2);
|
|
120
|
-
i++
|
|
121
|
-
) {
|
|
122
|
-
const pollUtxo = await findPollManager(
|
|
123
|
-
context.lucid,
|
|
124
|
-
sysParams.validatorHashes.pollManagerHash,
|
|
125
|
-
fromSystemParamsAsset(sysParams.pollManagerParams.pollToken),
|
|
126
|
-
pollId,
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const allPollShards = await findAllPollShards(
|
|
130
|
-
context.lucid,
|
|
131
|
-
sysParams.validatorHashes.pollShardHash,
|
|
132
|
-
fromSystemParamsAsset(sysParams.pollShardParams.pollToken),
|
|
133
|
-
pollUtxo.datum.pollId,
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
await runAndAwaitTx(
|
|
137
|
-
context.lucid,
|
|
138
|
-
mergeShards(
|
|
139
|
-
pollUtxo.utxo,
|
|
140
|
-
A.takeLeft(2)(allPollShards).map((u) => u.utxo),
|
|
141
|
-
sysParams,
|
|
142
|
-
context.lucid,
|
|
143
|
-
),
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export async function runEndProposal(
|
|
149
|
-
pollId: bigint,
|
|
150
|
-
sysParams: SystemParams,
|
|
151
|
-
context: LucidContext,
|
|
152
|
-
): Promise<void> {
|
|
153
|
-
const pollUtxo = await findPollManager(
|
|
154
|
-
context.lucid,
|
|
155
|
-
sysParams.validatorHashes.pollManagerHash,
|
|
156
|
-
fromSystemParamsAsset(sysParams.pollManagerParams.pollToken),
|
|
157
|
-
pollId,
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
const govUtxo = await findGov(
|
|
161
|
-
context.lucid,
|
|
162
|
-
sysParams.validatorHashes.govHash,
|
|
163
|
-
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
await runAndAwaitTx(
|
|
167
|
-
context.lucid,
|
|
168
|
-
endProposal(pollUtxo.utxo, govUtxo.utxo, sysParams, context.lucid),
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export async function waitForVotingEnd(
|
|
173
|
-
pollId: bigint,
|
|
174
|
-
sysParams: SystemParams,
|
|
175
|
-
context: LucidContext,
|
|
176
|
-
): Promise<void> {
|
|
177
|
-
const pollUtxo = await findPollManager(
|
|
178
|
-
context.lucid,
|
|
179
|
-
sysParams.validatorHashes.pollManagerHash,
|
|
180
|
-
fromSystemParamsAsset(sysParams.pollManagerParams.pollToken),
|
|
181
|
-
pollId,
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
const targetSlot = context.lucid.unixTimeToSlot(
|
|
185
|
-
Number(pollUtxo.datum.votingEndTime),
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
if (targetSlot > context.lucid.currentSlot()) {
|
|
189
|
-
expect(targetSlot).toBeGreaterThan(context.lucid.currentSlot());
|
|
190
|
-
|
|
191
|
-
context.emulator.awaitSlot(targetSlot - context.lucid.currentSlot() + 1);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export async function runExecuteProposal(
|
|
196
|
-
pollId: bigint,
|
|
197
|
-
treasuryWithdrawalOref: OutRef | null,
|
|
198
|
-
allIAssetOrefs: OutRef[] | null,
|
|
199
|
-
iAssetOref: OutRef | null,
|
|
200
|
-
allCollateralAssetsOrefsOfIAsset: OutRef[] | null,
|
|
201
|
-
collateralAssetOref: OutRef | null,
|
|
202
|
-
stableswapPoolOrCdpCreatorOref: OutRef | null,
|
|
203
|
-
sysParams: SystemParams,
|
|
204
|
-
context: LucidContext,
|
|
205
|
-
): Promise<void> {
|
|
206
|
-
const executeUtxo = await findExecute(
|
|
207
|
-
context.lucid,
|
|
208
|
-
sysParams.validatorHashes.executeHash,
|
|
209
|
-
fromSystemParamsAsset(sysParams.executeParams.upgradeToken),
|
|
210
|
-
pollId,
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
await runAndAwaitTx(
|
|
214
|
-
context.lucid,
|
|
215
|
-
executeProposal(
|
|
216
|
-
executeUtxo.utxo,
|
|
217
|
-
(
|
|
218
|
-
await findGov(
|
|
219
|
-
context.lucid,
|
|
220
|
-
sysParams.validatorHashes.govHash,
|
|
221
|
-
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
222
|
-
)
|
|
223
|
-
).utxo,
|
|
224
|
-
treasuryWithdrawalOref,
|
|
225
|
-
allIAssetOrefs,
|
|
226
|
-
iAssetOref,
|
|
227
|
-
allCollateralAssetsOrefsOfIAsset,
|
|
228
|
-
collateralAssetOref,
|
|
229
|
-
stableswapPoolOrCdpCreatorOref,
|
|
230
|
-
sysParams,
|
|
231
|
-
context.lucid,
|
|
232
|
-
),
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export async function processSuccessfulProposal(
|
|
237
|
-
pollId: bigint,
|
|
238
|
-
treasuryWithdrawalOref: OutRef | null,
|
|
239
|
-
allIAssetOrefs: OutRef[] | null,
|
|
240
|
-
iAssetOref: OutRef | null,
|
|
241
|
-
allCollateralAssetsOrefsOfIAsset: OutRef[] | null,
|
|
242
|
-
collateralAssetOref: OutRef | null,
|
|
243
|
-
stableswapPoolOrCdpCreatorOref: OutRef | null,
|
|
244
|
-
sysParams: SystemParams,
|
|
245
|
-
context: LucidContext,
|
|
246
|
-
createStakingPos: boolean = true,
|
|
247
|
-
): Promise<void> {
|
|
248
|
-
await runCreateAllShards(pollId, sysParams, context);
|
|
249
|
-
|
|
250
|
-
if (createStakingPos) {
|
|
251
|
-
await runAndAwaitTx(
|
|
252
|
-
context.lucid,
|
|
253
|
-
openStakingPosition(100_000_000_000n, sysParams, context.lucid),
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
await runVote(pollId, 'Yes', sysParams, context);
|
|
258
|
-
|
|
259
|
-
await waitForVotingEnd(pollId, sysParams, context);
|
|
260
|
-
|
|
261
|
-
await runMergeAllShards(pollId, sysParams, context);
|
|
262
|
-
|
|
263
|
-
await runEndProposal(pollId, sysParams, context);
|
|
264
|
-
|
|
265
|
-
await runExecuteProposal(
|
|
266
|
-
pollId,
|
|
267
|
-
treasuryWithdrawalOref,
|
|
268
|
-
allIAssetOrefs,
|
|
269
|
-
iAssetOref,
|
|
270
|
-
allCollateralAssetsOrefsOfIAsset,
|
|
271
|
-
collateralAssetOref,
|
|
272
|
-
stableswapPoolOrCdpCreatorOref,
|
|
273
|
-
sysParams,
|
|
274
|
-
context,
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export async function whitelistCollateralAsset(
|
|
279
|
-
context: LucidContext,
|
|
280
|
-
sysParams: SystemParams,
|
|
281
|
-
iassetAscii: string,
|
|
282
|
-
newCollateralAsset: AssetClass,
|
|
283
|
-
initialPrice: Rational,
|
|
284
|
-
initialInterest: bigint,
|
|
285
|
-
createStakingPos: boolean,
|
|
286
|
-
): Promise<CollateralAssetInfo> {
|
|
287
|
-
const prevAddr = await context.lucid.wallet().address();
|
|
288
|
-
|
|
289
|
-
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
290
|
-
|
|
291
|
-
const interestOracleParams: InterestOracleParams = {
|
|
292
|
-
biasTime: 120_000n,
|
|
293
|
-
owner: paymentCredentialOf(context.users.admin.address).hash,
|
|
294
|
-
};
|
|
295
|
-
const [startInterestTx, interestOracleNft] = await startInterestOracle(
|
|
296
|
-
0n,
|
|
297
|
-
initialInterest,
|
|
298
|
-
0n,
|
|
299
|
-
interestOracleParams,
|
|
300
|
-
context.lucid,
|
|
301
|
-
);
|
|
302
|
-
await runAndAwaitTxBuilder(context.lucid, startInterestTx);
|
|
303
|
-
|
|
304
|
-
const oracleParams: PriceOracleParams = {
|
|
305
|
-
biasTime: 120_000n,
|
|
306
|
-
expirationPeriod: 1_800_000n,
|
|
307
|
-
owner: paymentCredentialOf(context.users.admin.address).hash,
|
|
308
|
-
};
|
|
309
|
-
const [priceOracleTx, priceOranceNft] = await startPriceOracleTx(
|
|
310
|
-
context.lucid,
|
|
311
|
-
'COLLATERAL_ORACLE',
|
|
312
|
-
initialPrice,
|
|
313
|
-
oracleParams,
|
|
314
|
-
);
|
|
315
|
-
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
316
|
-
|
|
317
|
-
const [tx, pollId] = await createProposal(
|
|
318
|
-
{
|
|
319
|
-
AddCollateralAsset: {
|
|
320
|
-
correspondingIAsset: fromHex(fromText(iassetAscii)),
|
|
321
|
-
collateralAsset: newCollateralAsset,
|
|
322
|
-
assetExtraDecimals: 0n,
|
|
323
|
-
assetPriceInfo: { OracleNft: priceOranceNft },
|
|
324
|
-
interestOracleNft: interestOracleNft,
|
|
325
|
-
redemptionRatio: rationalFromInt(2n),
|
|
326
|
-
maintenanceRatio: { numerator: 15n, denominator: 10n },
|
|
327
|
-
liquidationRatio: { numerator: 12n, denominator: 10n },
|
|
328
|
-
minCollateralAmt: 1_000_000n,
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
null,
|
|
332
|
-
sysParams,
|
|
333
|
-
context.lucid,
|
|
334
|
-
(
|
|
335
|
-
await findGov(
|
|
336
|
-
context.lucid,
|
|
337
|
-
sysParams.validatorHashes.govHash,
|
|
338
|
-
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
339
|
-
)
|
|
340
|
-
).utxo,
|
|
341
|
-
[],
|
|
342
|
-
);
|
|
343
|
-
|
|
344
|
-
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
345
|
-
|
|
346
|
-
const iassetOutput = await findIAsset(
|
|
347
|
-
context.lucid,
|
|
348
|
-
sysParams.validatorHashes.iassetHash,
|
|
349
|
-
fromSystemParamsAsset(sysParams.executeParams.iAssetToken),
|
|
350
|
-
iassetAscii,
|
|
351
|
-
);
|
|
352
|
-
|
|
353
|
-
await processSuccessfulProposal(
|
|
354
|
-
pollId,
|
|
355
|
-
null,
|
|
356
|
-
null,
|
|
357
|
-
iassetOutput.utxo,
|
|
358
|
-
(
|
|
359
|
-
await findAllCollateralAssetsOfIAsset(
|
|
360
|
-
context.lucid,
|
|
361
|
-
sysParams.validatorHashes.iassetHash,
|
|
362
|
-
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
363
|
-
fromHex(fromText(iassetAscii)),
|
|
364
|
-
)
|
|
365
|
-
).map((o) => o.utxo),
|
|
366
|
-
null,
|
|
367
|
-
null,
|
|
368
|
-
sysParams,
|
|
369
|
-
context,
|
|
370
|
-
createStakingPos,
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
selectWalletByAddress(context, prevAddr);
|
|
374
|
-
|
|
375
|
-
return {
|
|
376
|
-
collateralAsset: newCollateralAsset,
|
|
377
|
-
interestOracleNft: interestOracleNft,
|
|
378
|
-
oracleParams: oracleParams,
|
|
379
|
-
interestOracleParams,
|
|
380
|
-
};
|
|
381
|
-
}
|