@indigo-labs/indigo-sdk 0.2.42 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +4 -2
- package/dist/index.d.mts +3008 -2194
- package/dist/index.d.ts +3008 -2194
- package/dist/index.js +9827 -6194
- package/dist/index.mjs +8591 -4809
- package/package.json +14 -3
- package/src/contracts/cdp/helpers.ts +68 -72
- package/src/contracts/cdp/scripts.ts +50 -13
- package/src/contracts/cdp/transactions.ts +831 -545
- package/src/contracts/cdp/types-new.ts +256 -0
- package/src/contracts/cdp/types.ts +26 -144
- package/src/contracts/cdp-creator/scripts.ts +15 -9
- package/src/contracts/cdp-creator/types-new.ts +50 -0
- package/src/contracts/cdp-creator/types.ts +5 -31
- package/src/contracts/collector/scripts.ts +1 -1
- package/src/contracts/collector/transactions.ts +23 -13
- package/src/contracts/collector/types-new.ts +17 -0
- package/src/contracts/execute/scripts.ts +19 -10
- package/src/contracts/execute/types-new.ts +44 -0
- package/src/contracts/execute/types.ts +5 -38
- package/src/contracts/gov/helpers.ts +187 -51
- package/src/contracts/gov/scripts.ts +17 -10
- package/src/contracts/gov/transactions.ts +599 -271
- package/src/contracts/gov/types-new.ts +253 -100
- package/src/contracts/gov/types.ts +4 -71
- package/src/contracts/iasset/helpers.ts +172 -0
- package/src/contracts/iasset/scripts.ts +38 -0
- package/src/contracts/iasset/types.ts +154 -0
- package/src/contracts/initialize/actions.ts +768 -0
- package/src/contracts/initialize/helpers.ts +611 -36
- package/src/contracts/initialize/types.ts +102 -28
- package/src/contracts/interest-collection/helpers.ts +19 -0
- package/src/contracts/interest-collection/scripts.ts +44 -0
- package/src/contracts/interest-collection/transactions.ts +436 -0
- package/src/contracts/interest-collection/types-new.ts +50 -0
- package/src/contracts/interest-collection/types.ts +26 -0
- package/src/contracts/interest-oracle/helpers.ts +2 -30
- package/src/contracts/interest-oracle/scripts.ts +1 -1
- package/src/contracts/interest-oracle/transactions.ts +21 -16
- package/src/contracts/interest-oracle/types-new.ts +32 -0
- package/src/contracts/interest-oracle/types.ts +1 -40
- package/src/contracts/one-shot/transactions.ts +1 -2
- package/src/contracts/poll/helpers.ts +5 -23
- package/src/contracts/poll/scripts.ts +12 -13
- package/src/contracts/poll/types-poll-manager.ts +1 -19
- package/src/contracts/poll/types-poll-new.ts +170 -0
- package/src/contracts/poll/types-poll-shard.ts +2 -24
- package/src/contracts/price-oracle/helpers.ts +1 -4
- package/src/contracts/price-oracle/scripts.ts +3 -8
- package/src/contracts/price-oracle/transactions.ts +32 -25
- package/src/contracts/price-oracle/types-new.ts +50 -0
- package/src/contracts/price-oracle/types.ts +2 -36
- package/src/contracts/pyth-feed/helpers.ts +58 -0
- package/src/contracts/pyth-feed/scripts.ts +15 -0
- package/src/contracts/pyth-feed/types.ts +181 -0
- package/src/contracts/rob/helpers.ts +405 -0
- package/src/contracts/rob/scripts.ts +35 -0
- package/src/contracts/rob/transactions.ts +410 -0
- package/src/contracts/rob/types-new.ts +128 -0
- package/src/contracts/rob/types.ts +16 -0
- package/src/contracts/rob-leverage/helpers.ts +424 -0
- package/src/contracts/{leverage → rob-leverage}/transactions.ts +68 -48
- package/src/contracts/stability-pool/helpers.ts +714 -230
- package/src/contracts/stability-pool/scripts.ts +20 -15
- package/src/contracts/stability-pool/transactions.ts +625 -493
- package/src/contracts/stability-pool/types-new.ts +237 -100
- package/src/contracts/stability-pool/types.ts +5 -22
- package/src/contracts/stableswap/helpers.ts +22 -0
- package/src/contracts/stableswap/scripts.ts +37 -0
- package/src/contracts/stableswap/transactions.ts +647 -0
- package/src/contracts/stableswap/types-new.ts +131 -0
- package/src/contracts/stableswap/types.ts +17 -0
- package/src/contracts/staking/helpers.ts +49 -34
- package/src/contracts/staking/scripts.ts +1 -1
- package/src/contracts/staking/transactions.ts +85 -130
- package/src/contracts/staking/types-new.ts +60 -28
- package/src/contracts/staking/types.ts +1 -28
- package/src/contracts/treasury/helpers.ts +21 -0
- package/src/contracts/treasury/scripts.ts +16 -26
- package/src/contracts/treasury/transactions.ts +256 -27
- package/src/contracts/treasury/types-new.ts +69 -0
- package/src/contracts/treasury/types.ts +2 -43
- package/src/contracts/version-registry/scripts.ts +2 -2
- package/src/contracts/version-registry/types-new.ts +6 -7
- package/src/index.ts +37 -20
- package/src/scripts/auth-token-policy.ts +3 -2
- package/src/scripts/iasset-policy.ts +3 -2
- package/src/types/evolution-schema-options.ts +3 -3
- package/src/types/generic.ts +17 -89
- package/src/types/multisig.ts +48 -0
- package/src/types/on-chain-decimal.ts +14 -7
- package/src/types/rational.ts +61 -0
- package/src/types/system-params.ts +237 -41
- package/src/utils/array-utils.ts +70 -1
- package/src/utils/bigint-utils.ts +12 -0
- package/src/utils/indigo-helpers.ts +8 -10
- package/src/utils/lucid-utils.ts +47 -40
- package/src/utils/oracle-helpers.ts +62 -0
- package/src/utils/pyth/decode.ts +223 -0
- package/src/utils/pyth/encode.ts +262 -0
- package/src/utils/pyth/index.ts +14 -0
- package/src/utils/pyth/types.ts +87 -0
- package/src/validators/always-succeed-validator.ts +6 -0
- package/src/validators/cdp-creator-validator.ts +2 -2
- package/src/validators/cdp-redeem-validator.ts +7 -0
- package/src/validators/cdp-validator.ts +2 -2
- package/src/validators/collector-validator.ts +2 -2
- package/src/validators/execute-validator.ts +2 -2
- package/src/validators/governance-validator.ts +2 -2
- package/src/validators/iasset-validator.ts +7 -0
- package/src/validators/interest-collection-validator.ts +7 -0
- package/src/validators/interest-oracle-validator.ts +2 -2
- package/src/validators/poll-manager-validator.ts +2 -2
- package/src/validators/poll-shard-validator.ts +2 -2
- package/src/validators/price-oracle-validator.ts +7 -0
- package/src/validators/pyth-feed-validator.ts +7 -0
- package/src/validators/rob-validator.ts +7 -0
- package/src/validators/stability-pool-validator.ts +2 -2
- package/src/validators/stableswap-validator.ts +7 -0
- package/src/validators/staking-validator.ts +2 -2
- package/src/validators/treasury-validator.ts +2 -2
- package/src/validators/version-record-policy.ts +2 -2
- package/src/validators/version-registry-validator.ts +2 -2
- package/tests/always-succeed/script.ts +7 -0
- package/tests/bigint-utils.test.ts +41 -0
- package/tests/cdp/actions.ts +611 -0
- package/tests/cdp/cdp-helpers.ts +55 -0
- package/tests/cdp/cdp-queries.ts +440 -0
- package/tests/cdp/cdp.test.ts +6087 -0
- package/tests/cdp/transactions-mutated.ts +1729 -0
- package/tests/data/system-params.json +177 -34
- package/tests/datums.test.ts +209 -210
- package/tests/endpoints/initialize.ts +68 -0
- package/tests/endpoints/interest-collector.ts +37 -0
- package/tests/endpoints/treasury.ts +70 -0
- package/tests/gov/actions.ts +406 -0
- package/tests/gov/gov.test.ts +4450 -0
- package/tests/{queries → gov}/governance-queries.ts +6 -3
- package/tests/hash-checks.test.ts +38 -11
- package/tests/indigo-test-helpers.ts +100 -0
- package/tests/initialize.test.ts +61 -9
- package/tests/interest-collection/interest-collection.test.ts +892 -0
- package/tests/interest-collection/interest-collector-queries.ts +49 -0
- package/tests/interest-collection/transactions-mutated.ts +260 -0
- package/tests/interest-oracle.test.ts +43 -35
- package/tests/mock/assets-mock.ts +234 -23
- package/tests/mock/protocol-params-mock.ts +21 -0
- package/tests/price-oracle/actions.ts +163 -0
- package/tests/price-oracle/price-oracle-queries.ts +12 -0
- package/tests/price-oracle/price-oracle.test.ts +240 -0
- package/tests/price-oracle/transactions-mutated.ts +62 -0
- package/tests/pyth/endpoints.ts +96 -0
- package/tests/pyth/helpers.ts +37 -0
- package/tests/pyth/pyth-encoding.test.ts +376 -0
- package/tests/pyth/pyth-indigo.test.ts +509 -0
- package/tests/pyth/pyth.test.ts +300 -0
- package/tests/queries/execute-queries.ts +6 -5
- package/tests/queries/iasset-queries.ts +175 -5
- package/tests/queries/interest-oracle-queries.ts +4 -2
- package/tests/queries/poll-queries.ts +8 -9
- package/tests/queries/stability-pool-queries.ts +95 -48
- package/tests/queries/staking-queries.ts +4 -2
- package/tests/queries/treasury-queries.ts +80 -5
- package/tests/rob/actions.ts +58 -0
- package/tests/{lrp-leverage.test.ts → rob/rob-leverage.test.ts} +393 -296
- package/tests/rob/rob-queries.ts +95 -0
- package/tests/rob/rob.test.ts +3762 -0
- package/tests/rob/transactions-mutated.ts +853 -0
- package/tests/script-size.test.ts +240 -0
- package/tests/setup.ts +135 -0
- package/tests/stability-pool/actions.ts +210 -0
- package/tests/stability-pool.test.ts +5469 -666
- package/tests/stableswap/stableswap-actions.ts +84 -0
- package/tests/stableswap/stableswap-queries.ts +89 -0
- package/tests/stableswap/stableswap.test.ts +3891 -0
- package/tests/stableswap/transactions-mutated.ts +348 -0
- package/tests/staking.test.ts +82 -99
- package/tests/test-helpers.ts +58 -11
- package/tests/treasury.test.ts +242 -0
- package/tests/utils/asserts.ts +74 -0
- package/tests/utils/benchmark-utils.ts +81 -0
- package/tests/utils/index.ts +122 -4
- package/tsconfig.json +9 -1
- package/vitest.config.ts +3 -1
- package/src/contracts/collector/types.ts +0 -16
- package/src/contracts/initialize/transactions.ts +0 -891
- package/src/contracts/leverage/helpers.ts +0 -424
- package/src/contracts/lrp/helpers.ts +0 -294
- package/src/contracts/lrp/scripts.ts +0 -27
- package/src/contracts/lrp/transactions.ts +0 -250
- package/src/contracts/lrp/types.ts +0 -131
- package/src/contracts/poll/types-poll.ts +0 -88
- package/src/contracts/vesting/helpers.ts +0 -218
- package/src/utils/value-helpers.ts +0 -37
- package/src/validators/lrp-validator.ts +0 -7
- package/tests/cdp.test.ts +0 -1528
- package/tests/gov.test.ts +0 -2011
- package/tests/lrp.test.ts +0 -673
- package/tests/queries/cdp-queries.ts +0 -220
- package/tests/queries/lrp-queries.ts +0 -76
- package/tests/queries/price-oracle-queries.ts +0 -10
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addAssets,
|
|
3
|
+
credentialToRewardAddress,
|
|
4
|
+
fromHex,
|
|
5
|
+
fromText,
|
|
6
|
+
LucidEvolution,
|
|
7
|
+
mintingPolicyToId,
|
|
8
|
+
scriptHashToCredential,
|
|
9
|
+
toHex,
|
|
10
|
+
validatorToScriptHash,
|
|
11
|
+
} from '@lucid-evolution/lucid';
|
|
12
|
+
import {
|
|
13
|
+
AssetClass,
|
|
14
|
+
mkAssetsOf,
|
|
15
|
+
mkLovelacesOf,
|
|
16
|
+
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
17
|
+
import type { AssetInfo, InitialAssetParam, InitializeOptions } from './types';
|
|
18
|
+
import type {
|
|
19
|
+
CdpParamsSP,
|
|
20
|
+
CdpRedeemParamsSP,
|
|
21
|
+
ExecuteParamsSP,
|
|
22
|
+
PythConfig,
|
|
23
|
+
PythFeedConfig,
|
|
24
|
+
ScriptCredential,
|
|
25
|
+
SystemParams,
|
|
26
|
+
VersionRecordParams,
|
|
27
|
+
} from '../../types/system-params';
|
|
28
|
+
import type { CollectorParamsSP, GovParamsSP } from '../../types/system-params';
|
|
29
|
+
import type {
|
|
30
|
+
CDPCreatorParamsSP,
|
|
31
|
+
IAssetParamsSP,
|
|
32
|
+
InterestCollectionParamsSP,
|
|
33
|
+
PollManagerParamsSP,
|
|
34
|
+
PollShardParamsSP,
|
|
35
|
+
RobParamsSP,
|
|
36
|
+
StabilityPoolParamsSP,
|
|
37
|
+
StakingParamsSP,
|
|
38
|
+
StableswapParamsSP,
|
|
39
|
+
TreasuryParamsSP,
|
|
40
|
+
} from '../../types/system-params';
|
|
41
|
+
import type { ProtocolParams } from '../gov/types-new';
|
|
42
|
+
import {
|
|
43
|
+
fromSysParamsPythFeedParams,
|
|
44
|
+
toSystemParamsAsset,
|
|
45
|
+
} from '../../types/system-params';
|
|
46
|
+
import { mkAuthTokenPolicy } from '../../scripts/auth-token-policy';
|
|
47
|
+
import { mkIAssetTokenPolicy } from '../../scripts/iasset-policy';
|
|
48
|
+
import {
|
|
49
|
+
mkVersionRecordTokenPolicy,
|
|
50
|
+
mkVersionRegistryValidator,
|
|
51
|
+
} from '../version-registry/scripts';
|
|
52
|
+
import {
|
|
53
|
+
mkCdpRedeemValidatorFromSP,
|
|
54
|
+
mkCdpValidatorFromSP,
|
|
55
|
+
} from '../cdp/scripts';
|
|
56
|
+
import { mkExecuteValidatorFromSP } from '../execute/scripts';
|
|
57
|
+
import {
|
|
58
|
+
mkPollManagerValidatorFromSP,
|
|
59
|
+
mkPollShardValidatorFromSP,
|
|
60
|
+
} from '../poll/scripts';
|
|
61
|
+
import { mkRobValidatorFromSP } from '../rob/scripts';
|
|
62
|
+
import { mkStableswapValidatorFromSP } from '../stableswap/scripts';
|
|
63
|
+
import { mkCollectorValidatorFromSP } from '../collector/scripts';
|
|
64
|
+
import { mkInterestCollectionValidatorFromSP } from '../interest-collection/scripts';
|
|
65
|
+
import { mkIAssetValidatorFromSP } from '../iasset/scripts';
|
|
66
|
+
import { mkPythFeedValidator } from '../pyth-feed/scripts';
|
|
67
|
+
import { mkStakingValidatorFromSP } from '../staking/scripts';
|
|
68
|
+
import { mkStabilityPoolValidatorFromSP } from '../stability-pool/scripts';
|
|
69
|
+
import { mkTreasuryValidatorFromSP } from '../treasury/scripts';
|
|
70
|
+
import { mkCDPCreatorValidatorFromSP } from '../cdp-creator/scripts';
|
|
71
|
+
import { mkGovValidatorFromSP } from '../gov/scripts';
|
|
72
|
+
import { submitTx } from '../../utils/lucid-utils';
|
|
73
|
+
import {
|
|
74
|
+
deriveAuthToken,
|
|
75
|
+
initScriptRef,
|
|
76
|
+
initCollector,
|
|
77
|
+
initCDPCreator,
|
|
78
|
+
initGovernance,
|
|
79
|
+
initInterestCollector,
|
|
80
|
+
initStakingManager,
|
|
81
|
+
initTreasury,
|
|
82
|
+
initializeAsset,
|
|
83
|
+
mintAuthTokenDirect,
|
|
84
|
+
mintOneTimeAsset,
|
|
85
|
+
INIT_TOKEN_NAMES,
|
|
86
|
+
} from './helpers';
|
|
87
|
+
import { runAndAwaitTxBuilder } from '../../../tests/test-helpers';
|
|
88
|
+
import { match } from 'ts-pattern';
|
|
89
|
+
import { initPyth } from '../../../tests/pyth/endpoints';
|
|
90
|
+
|
|
91
|
+
const DEFAULT_STAKING_CRED: ScriptCredential = {
|
|
92
|
+
tag: 'StakingHash',
|
|
93
|
+
contents: {
|
|
94
|
+
tag: 'ScriptCredential',
|
|
95
|
+
contents: 'b8358aadd30c60eba168608ad5e875592e9b7cb8c700827cde87f9a3',
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Initialize Pyth config from an existing Pyth state asset (e.g. from test's initPyth).
|
|
101
|
+
* Caller is responsible for creating the Pyth state asset before calling this.
|
|
102
|
+
*/
|
|
103
|
+
export async function initPythConfig(
|
|
104
|
+
lucid: LucidEvolution,
|
|
105
|
+
initialAssets: InitialAssetParam[],
|
|
106
|
+
pythStateAsset: AssetClass,
|
|
107
|
+
): Promise<PythConfig> {
|
|
108
|
+
let allPythFeeds: { [key: string]: PythFeedConfig } = {};
|
|
109
|
+
|
|
110
|
+
for (const asset of initialAssets) {
|
|
111
|
+
for (const collateral of asset.collateralAssets) {
|
|
112
|
+
const result = await match(collateral.priceOracle)
|
|
113
|
+
.returnType<Promise<{ [key: string]: PythFeedConfig }>>()
|
|
114
|
+
.with({ tag: '_pyth_oracle_nft' }, async (val) => {
|
|
115
|
+
const pythFeedValidator = mkPythFeedValidator(
|
|
116
|
+
fromSysParamsPythFeedParams(val.pythFeedParams),
|
|
117
|
+
);
|
|
118
|
+
const pythFeedValHash = validatorToScriptHash(pythFeedValidator);
|
|
119
|
+
const pythFeedValScriptRef = await initScriptRef(
|
|
120
|
+
lucid,
|
|
121
|
+
pythFeedValidator,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// Register the stake key for pyth feed validator.
|
|
125
|
+
await runAndAwaitTxBuilder(
|
|
126
|
+
lucid,
|
|
127
|
+
lucid.newTx().register.Stake(
|
|
128
|
+
credentialToRewardAddress(lucid.config().network!, {
|
|
129
|
+
hash: validatorToScriptHash(pythFeedValidator),
|
|
130
|
+
type: 'Script',
|
|
131
|
+
}),
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const key = `${asset.name}/${toHex(collateral.collateralAsset.currencySymbol)}.${toHex(collateral.collateralAsset.tokenName)}`;
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
[key]: {
|
|
139
|
+
params: val.pythFeedParams,
|
|
140
|
+
pythFeedValHash,
|
|
141
|
+
pythFeedValScriptRef: { input: pythFeedValScriptRef },
|
|
142
|
+
} satisfies PythFeedConfig,
|
|
143
|
+
};
|
|
144
|
+
})
|
|
145
|
+
.otherwise(() => Promise.resolve({}));
|
|
146
|
+
|
|
147
|
+
allPythFeeds = { ...allPythFeeds, ...result };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
pythStateAssetClass: toSystemParamsAsset(pythStateAsset),
|
|
153
|
+
pythFeeds: allPythFeeds,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export async function init(
|
|
158
|
+
lucid: LucidEvolution,
|
|
159
|
+
defaultInitialAssets: InitialAssetParam[],
|
|
160
|
+
currentSlot: number,
|
|
161
|
+
mkPythBasedAssets: (
|
|
162
|
+
pythStateNft: AssetClass,
|
|
163
|
+
) => InitialAssetParam[] = () => [],
|
|
164
|
+
protocolParams: ProtocolParams,
|
|
165
|
+
initOptions: InitializeOptions,
|
|
166
|
+
spStakingCred: ScriptCredential | undefined = DEFAULT_STAKING_CRED,
|
|
167
|
+
treasuryStakingCred: ScriptCredential | undefined = DEFAULT_STAKING_CRED,
|
|
168
|
+
): Promise<[SystemParams, AssetInfo[]]> {
|
|
169
|
+
const startSlot = lucid.currentSlot();
|
|
170
|
+
|
|
171
|
+
const {
|
|
172
|
+
totalIndySupply,
|
|
173
|
+
numCdpCreators,
|
|
174
|
+
treasuryIndyAmount,
|
|
175
|
+
numCollectors,
|
|
176
|
+
numInterestCollectors,
|
|
177
|
+
numTreasuryUtxos,
|
|
178
|
+
accountCreateFeeLovelaces,
|
|
179
|
+
accountProcessingCooldownMs,
|
|
180
|
+
interestSettlementCooldown,
|
|
181
|
+
partialRedemptionExtraFeeLovelace,
|
|
182
|
+
biasTime,
|
|
183
|
+
gBiasTime,
|
|
184
|
+
accountProcessingBiasTime,
|
|
185
|
+
interestCollectorUtxoLovelaces,
|
|
186
|
+
} = initOptions;
|
|
187
|
+
const tn = INIT_TOKEN_NAMES;
|
|
188
|
+
|
|
189
|
+
const indyAsset = await mintOneTimeAsset(lucid, tn.indy, totalIndySupply);
|
|
190
|
+
const daoAsset = await mintOneTimeAsset(lucid, tn.dao, 1n);
|
|
191
|
+
const govNftAsset = await mintOneTimeAsset(lucid, tn.govNft, 1n);
|
|
192
|
+
|
|
193
|
+
const pollToken = deriveAuthToken(govNftAsset, tn.pollManager);
|
|
194
|
+
const upgradeToken = deriveAuthToken(pollToken, tn.upgrade);
|
|
195
|
+
const iassetToken = deriveAuthToken(upgradeToken, tn.iasset);
|
|
196
|
+
const collateralAssetAuthToken = deriveAuthToken(
|
|
197
|
+
iassetToken,
|
|
198
|
+
tn.collateralAsset,
|
|
199
|
+
);
|
|
200
|
+
const stabilityPoolToken = deriveAuthToken(upgradeToken, tn.stabilityPool);
|
|
201
|
+
|
|
202
|
+
const versionRecordParams: VersionRecordParams = {
|
|
203
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
204
|
+
};
|
|
205
|
+
const versionRecordTokenPolicy = mkVersionRecordTokenPolicy({
|
|
206
|
+
upgradeToken: {
|
|
207
|
+
currencySymbol: toHex(upgradeToken.currencySymbol),
|
|
208
|
+
tokenName: toHex(upgradeToken.tokenName),
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
const versionRecordToken: AssetClass = {
|
|
212
|
+
currencySymbol: fromHex(mintingPolicyToId(versionRecordTokenPolicy)),
|
|
213
|
+
tokenName: fromHex(fromText(tn.versionRecord)),
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const versionRegistryValidator = mkVersionRegistryValidator();
|
|
217
|
+
const versionRegistryValHash = validatorToScriptHash(
|
|
218
|
+
versionRegistryValidator,
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const cdpCreatorAsset = await mintOneTimeAsset(
|
|
222
|
+
lucid,
|
|
223
|
+
tn.cdpCreator,
|
|
224
|
+
numCdpCreators,
|
|
225
|
+
);
|
|
226
|
+
const cdpToken = deriveAuthToken(cdpCreatorAsset, tn.cdp);
|
|
227
|
+
|
|
228
|
+
const stakingManagerAsset = await mintOneTimeAsset(
|
|
229
|
+
lucid,
|
|
230
|
+
tn.stakingManager,
|
|
231
|
+
1n,
|
|
232
|
+
);
|
|
233
|
+
const stakingToken = deriveAuthToken(stakingManagerAsset, tn.staking);
|
|
234
|
+
|
|
235
|
+
const collectorParams: CollectorParamsSP = {
|
|
236
|
+
stakingManagerNFT: toSystemParamsAsset(stakingManagerAsset),
|
|
237
|
+
stakingToken: toSystemParamsAsset(stakingToken),
|
|
238
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
239
|
+
};
|
|
240
|
+
const collectorValidator = mkCollectorValidatorFromSP(collectorParams);
|
|
241
|
+
const collectorValHash = validatorToScriptHash(collectorValidator);
|
|
242
|
+
|
|
243
|
+
const stakingParams: StakingParamsSP = {
|
|
244
|
+
stakingManagerNFT: toSystemParamsAsset(stakingManagerAsset),
|
|
245
|
+
stakingToken: toSystemParamsAsset(stakingToken),
|
|
246
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
247
|
+
pollToken: toSystemParamsAsset(pollToken),
|
|
248
|
+
indyToken: toSystemParamsAsset(indyAsset),
|
|
249
|
+
collectorValHash: collectorValHash,
|
|
250
|
+
};
|
|
251
|
+
const stakingValHash = validatorToScriptHash(
|
|
252
|
+
mkStakingValidatorFromSP(stakingParams),
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
await initStakingManager(lucid, stakingParams);
|
|
256
|
+
|
|
257
|
+
const iassetParams: IAssetParamsSP = {
|
|
258
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
259
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
260
|
+
};
|
|
261
|
+
const iassetValidator = mkIAssetValidatorFromSP(iassetParams);
|
|
262
|
+
const iassetValHash = validatorToScriptHash(iassetValidator);
|
|
263
|
+
|
|
264
|
+
const assetSymbolPolicy = mkIAssetTokenPolicy(cdpToken);
|
|
265
|
+
const assetSymbol = mintingPolicyToId(assetSymbolPolicy);
|
|
266
|
+
|
|
267
|
+
const snapshotEpochToScaleToSumToken = deriveAuthToken(
|
|
268
|
+
stabilityPoolToken,
|
|
269
|
+
tn.snapshotEpochToScaleToSum,
|
|
270
|
+
);
|
|
271
|
+
const accountToken = deriveAuthToken(stabilityPoolToken, tn.account);
|
|
272
|
+
|
|
273
|
+
const stabilityPoolParams: StabilityPoolParamsSP = {
|
|
274
|
+
assetSymbol: { unCurrencySymbol: assetSymbol },
|
|
275
|
+
stabilityPoolToken: toSystemParamsAsset(stabilityPoolToken),
|
|
276
|
+
snapshotEpochToScaleToSumToken: toSystemParamsAsset(
|
|
277
|
+
snapshotEpochToScaleToSumToken,
|
|
278
|
+
),
|
|
279
|
+
accountToken: toSystemParamsAsset(accountToken),
|
|
280
|
+
cdpToken: toSystemParamsAsset(cdpToken),
|
|
281
|
+
iAssetAuthToken: toSystemParamsAsset(iassetToken),
|
|
282
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
283
|
+
iassetValHash: iassetValHash,
|
|
284
|
+
accountCreateFeeLovelaces: Number(accountCreateFeeLovelaces),
|
|
285
|
+
accountProcessingCooldownMs: Number(accountProcessingCooldownMs),
|
|
286
|
+
accountProcessingBiasMs: accountProcessingBiasTime
|
|
287
|
+
? Number(accountProcessingBiasTime)
|
|
288
|
+
: Number(biasTime),
|
|
289
|
+
stakeCredential: spStakingCred,
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const stabilityPoolValidator =
|
|
293
|
+
mkStabilityPoolValidatorFromSP(stabilityPoolParams);
|
|
294
|
+
const stabilityPoolValHash = validatorToScriptHash(stabilityPoolValidator);
|
|
295
|
+
|
|
296
|
+
const treasuryParams: TreasuryParamsSP = {
|
|
297
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
298
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
299
|
+
treasuryUtxosStakeCredential: treasuryStakingCred,
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const treasuryValidator = mkTreasuryValidatorFromSP(treasuryParams);
|
|
303
|
+
const treasuryValHash = validatorToScriptHash(treasuryValidator);
|
|
304
|
+
|
|
305
|
+
await initTreasury(
|
|
306
|
+
lucid,
|
|
307
|
+
treasuryParams,
|
|
308
|
+
daoAsset,
|
|
309
|
+
indyAsset,
|
|
310
|
+
treasuryIndyAmount,
|
|
311
|
+
numTreasuryUtxos,
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
const multisigUtxoNft = await mintOneTimeAsset(lucid, tn.multisigUtxo, 1n);
|
|
315
|
+
|
|
316
|
+
const interestCollectionParams: InterestCollectionParamsSP = {
|
|
317
|
+
versionRecordNft: toSystemParamsAsset(versionRecordToken),
|
|
318
|
+
multisigUtxoNft: toSystemParamsAsset(multisigUtxoNft),
|
|
319
|
+
cdpAuthTk: toSystemParamsAsset(cdpToken),
|
|
320
|
+
collateralAssetAuthTk: toSystemParamsAsset(collateralAssetAuthToken),
|
|
321
|
+
govAuthTk: toSystemParamsAsset(govNftAsset),
|
|
322
|
+
cdpAssetSymbol: { unCurrencySymbol: assetSymbol },
|
|
323
|
+
cdpBiasTime: BigInt(biasTime),
|
|
324
|
+
interestSettlementCooldown,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const interestCollectionValidator = mkInterestCollectionValidatorFromSP(
|
|
328
|
+
interestCollectionParams,
|
|
329
|
+
);
|
|
330
|
+
const interestCollectionValHash = validatorToScriptHash(
|
|
331
|
+
interestCollectionValidator,
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
await initInterestCollector(
|
|
335
|
+
lucid,
|
|
336
|
+
interestCollectionValHash,
|
|
337
|
+
multisigUtxoNft,
|
|
338
|
+
numInterestCollectors,
|
|
339
|
+
interestCollectorUtxoLovelaces,
|
|
340
|
+
);
|
|
341
|
+
const pythStateNft = await initPyth(lucid);
|
|
342
|
+
|
|
343
|
+
const initialAssets = [
|
|
344
|
+
...defaultInitialAssets,
|
|
345
|
+
...mkPythBasedAssets(pythStateNft),
|
|
346
|
+
];
|
|
347
|
+
|
|
348
|
+
const pythConfig = await initPythConfig(lucid, initialAssets, pythStateNft);
|
|
349
|
+
|
|
350
|
+
const cdpRedeemParams: CdpRedeemParamsSP = {
|
|
351
|
+
cdpAuthToken: toSystemParamsAsset(cdpToken),
|
|
352
|
+
cdpAssetSymbol: { unCurrencySymbol: assetSymbol },
|
|
353
|
+
iAssetAuthToken: toSystemParamsAsset(iassetToken),
|
|
354
|
+
collateralAssetAuthToken: toSystemParamsAsset(collateralAssetAuthToken),
|
|
355
|
+
interestCollectorValHash: interestCollectionValHash,
|
|
356
|
+
iassetValHash: iassetValHash,
|
|
357
|
+
treasuryValHash: treasuryValHash,
|
|
358
|
+
govNFT: toSystemParamsAsset(govNftAsset),
|
|
359
|
+
partialRedemptionExtraFeeLovelace,
|
|
360
|
+
biasTime,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const cdpRedeemValidator = mkCdpRedeemValidatorFromSP(cdpRedeemParams);
|
|
364
|
+
const cdpRedeemValHash = validatorToScriptHash(cdpRedeemValidator);
|
|
365
|
+
|
|
366
|
+
const cdpRedeemRewardAddr = credentialToRewardAddress(
|
|
367
|
+
lucid.config().network!,
|
|
368
|
+
scriptHashToCredential(cdpRedeemValHash),
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
await submitTx(lucid, lucid.newTx().register.Stake(cdpRedeemRewardAddr));
|
|
372
|
+
|
|
373
|
+
const cdpParams: CdpParamsSP = {
|
|
374
|
+
cdpAuthToken: toSystemParamsAsset(cdpToken),
|
|
375
|
+
cdpAssetSymbol: { unCurrencySymbol: assetSymbol },
|
|
376
|
+
iAssetAuthToken: toSystemParamsAsset(iassetToken),
|
|
377
|
+
collateralAssetAuthToken: toSystemParamsAsset(collateralAssetAuthToken),
|
|
378
|
+
stabilityPoolAuthToken: toSystemParamsAsset(stabilityPoolToken),
|
|
379
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
380
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
381
|
+
interestCollectorValHash: interestCollectionValHash,
|
|
382
|
+
spValHash: stabilityPoolValHash,
|
|
383
|
+
iassetValHash: iassetValHash,
|
|
384
|
+
treasuryValHash: treasuryValHash,
|
|
385
|
+
cdpRedeemValHash: cdpRedeemValHash,
|
|
386
|
+
biasTime,
|
|
387
|
+
};
|
|
388
|
+
const cdpValidator = mkCdpValidatorFromSP(cdpParams);
|
|
389
|
+
const cdpValHash = validatorToScriptHash(cdpValidator);
|
|
390
|
+
|
|
391
|
+
const cdpCreatorParams: CDPCreatorParamsSP = {
|
|
392
|
+
cdpCreatorNft: toSystemParamsAsset(cdpCreatorAsset),
|
|
393
|
+
cdpAssetCs: { unCurrencySymbol: assetSymbol },
|
|
394
|
+
cdpAuthTk: toSystemParamsAsset(cdpToken),
|
|
395
|
+
iAssetAuthTk: toSystemParamsAsset(iassetToken),
|
|
396
|
+
collateralAssetAuthTk: toSystemParamsAsset(collateralAssetAuthToken),
|
|
397
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
398
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
399
|
+
iassetValHash: iassetValHash,
|
|
400
|
+
cdpScriptHash: cdpValHash,
|
|
401
|
+
treasuryValHash: treasuryValHash,
|
|
402
|
+
biasTime: cdpParams.biasTime,
|
|
403
|
+
};
|
|
404
|
+
const cdpCreatorValidator = mkCDPCreatorValidatorFromSP(cdpCreatorParams);
|
|
405
|
+
const cdpCreatorValHash = validatorToScriptHash(cdpCreatorValidator);
|
|
406
|
+
|
|
407
|
+
const stableswapParams: StableswapParamsSP = {
|
|
408
|
+
iassetSymbol: { unCurrencySymbol: assetSymbol },
|
|
409
|
+
cdpToken: toSystemParamsAsset(cdpToken),
|
|
410
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
411
|
+
cdpValHash: cdpValHash,
|
|
412
|
+
treasuryValHash: treasuryValHash,
|
|
413
|
+
};
|
|
414
|
+
const stableswapValidator = mkStableswapValidatorFromSP(stableswapParams);
|
|
415
|
+
const stableswapValHash = validatorToScriptHash(stableswapValidator);
|
|
416
|
+
|
|
417
|
+
await initCollector(lucid, collectorParams, numCollectors);
|
|
418
|
+
|
|
419
|
+
const assetInfos: AssetInfo[] = [];
|
|
420
|
+
if (initialAssets.length > 0) {
|
|
421
|
+
await mintAuthTokenDirect(lucid, govNftAsset, tn.pollManager, 1n);
|
|
422
|
+
await mintAuthTokenDirect(lucid, pollToken, tn.upgrade, 1n);
|
|
423
|
+
if (initialAssets.length > 0) {
|
|
424
|
+
await mintAuthTokenDirect(
|
|
425
|
+
lucid,
|
|
426
|
+
upgradeToken,
|
|
427
|
+
tn.iasset,
|
|
428
|
+
BigInt(initialAssets.length),
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const totalCollateralAssetsCount = initialAssets.reduce(
|
|
433
|
+
(acc, asset) => acc + asset.collateralAssets.length,
|
|
434
|
+
0,
|
|
435
|
+
);
|
|
436
|
+
const totalStablePoolsCount = initialAssets.reduce(
|
|
437
|
+
(acc, asset) => acc + asset.stablepools.length,
|
|
438
|
+
0,
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
if (totalCollateralAssetsCount > 0n) {
|
|
442
|
+
// We must first send a single cdp creator asset to the wallet address to avoid the "Must consume exactly 1 asset" error
|
|
443
|
+
await runAndAwaitTxBuilder(
|
|
444
|
+
lucid,
|
|
445
|
+
lucid
|
|
446
|
+
.newTx()
|
|
447
|
+
.pay.ToAddress(
|
|
448
|
+
await lucid.wallet().address(),
|
|
449
|
+
addAssets(
|
|
450
|
+
mkAssetsOf(iassetToken, 1n),
|
|
451
|
+
mkLovelacesOf(BigInt(totalCollateralAssetsCount) * 5000000n),
|
|
452
|
+
),
|
|
453
|
+
),
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
await mintAuthTokenDirect(
|
|
457
|
+
lucid,
|
|
458
|
+
iassetToken,
|
|
459
|
+
tn.collateralAsset,
|
|
460
|
+
BigInt(totalCollateralAssetsCount),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (totalStablePoolsCount > 0n) {
|
|
465
|
+
// We must first send a single cdp creator asset to the wallet address to avoid the "Must consume exactly 1 asset" error
|
|
466
|
+
await runAndAwaitTxBuilder(
|
|
467
|
+
lucid,
|
|
468
|
+
lucid
|
|
469
|
+
.newTx()
|
|
470
|
+
.pay.ToAddress(
|
|
471
|
+
await lucid.wallet().address(),
|
|
472
|
+
addAssets(
|
|
473
|
+
mkAssetsOf(cdpCreatorAsset, 1n),
|
|
474
|
+
mkLovelacesOf(BigInt(totalStablePoolsCount) * 5000000n),
|
|
475
|
+
),
|
|
476
|
+
),
|
|
477
|
+
);
|
|
478
|
+
await mintAuthTokenDirect(
|
|
479
|
+
lucid,
|
|
480
|
+
cdpCreatorAsset,
|
|
481
|
+
tn.cdp,
|
|
482
|
+
BigInt(totalStablePoolsCount),
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (initialAssets.length > 0) {
|
|
487
|
+
await mintAuthTokenDirect(
|
|
488
|
+
lucid,
|
|
489
|
+
upgradeToken,
|
|
490
|
+
tn.stabilityPool,
|
|
491
|
+
BigInt(initialAssets.length),
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
for (const asset of initialAssets) {
|
|
495
|
+
const assetInfo = await initializeAsset(
|
|
496
|
+
lucid,
|
|
497
|
+
iassetParams,
|
|
498
|
+
iassetToken,
|
|
499
|
+
collateralAssetAuthToken,
|
|
500
|
+
cdpToken,
|
|
501
|
+
cdpParams,
|
|
502
|
+
stableswapValHash,
|
|
503
|
+
stabilityPoolParams,
|
|
504
|
+
stabilityPoolToken,
|
|
505
|
+
asset,
|
|
506
|
+
pythConfig,
|
|
507
|
+
currentSlot,
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
assetInfos.push(assetInfo);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
await mintAuthTokenDirect(lucid, pollToken, tn.upgrade, -1n);
|
|
515
|
+
await mintAuthTokenDirect(lucid, govNftAsset, tn.pollManager, -1n);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Send the CDP creator UTxOs after initializing the assets to allow for the creation of stableswap pools
|
|
519
|
+
await initCDPCreator(lucid, cdpCreatorParams, numCdpCreators);
|
|
520
|
+
|
|
521
|
+
const executeParams: ExecuteParamsSP = {
|
|
522
|
+
govNFT: toSystemParamsAsset(govNftAsset),
|
|
523
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
524
|
+
iAssetToken: toSystemParamsAsset(iassetToken),
|
|
525
|
+
collateralAssetToken: toSystemParamsAsset(collateralAssetAuthToken),
|
|
526
|
+
stabilityPoolToken: toSystemParamsAsset(stabilityPoolToken),
|
|
527
|
+
cdpCreatorToken: toSystemParamsAsset(cdpCreatorAsset),
|
|
528
|
+
cdpToken: toSystemParamsAsset(cdpToken),
|
|
529
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
530
|
+
iassetValHash: iassetValHash,
|
|
531
|
+
cdpValHash: cdpValHash,
|
|
532
|
+
sPoolValHash: stabilityPoolValHash,
|
|
533
|
+
versionRegistryValHash: versionRegistryValHash,
|
|
534
|
+
treasuryValHash: treasuryValHash,
|
|
535
|
+
};
|
|
536
|
+
const executeValidator = mkExecuteValidatorFromSP(executeParams);
|
|
537
|
+
const executeValHash = validatorToScriptHash(executeValidator);
|
|
538
|
+
|
|
539
|
+
const pollShardParams: PollShardParamsSP = {
|
|
540
|
+
pollToken: toSystemParamsAsset(pollToken),
|
|
541
|
+
stakingToken: toSystemParamsAsset(stakingToken),
|
|
542
|
+
indyAsset: toSystemParamsAsset(indyAsset),
|
|
543
|
+
stakingValHash: stakingValHash,
|
|
544
|
+
};
|
|
545
|
+
const pollShardValidator = mkPollShardValidatorFromSP(pollShardParams);
|
|
546
|
+
const pollShardValHash = validatorToScriptHash(pollShardValidator);
|
|
547
|
+
|
|
548
|
+
const pollManagerParams: PollManagerParamsSP = {
|
|
549
|
+
govNFT: toSystemParamsAsset(govNftAsset),
|
|
550
|
+
pollToken: toSystemParamsAsset(pollToken),
|
|
551
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
552
|
+
indyAsset: toSystemParamsAsset(indyAsset),
|
|
553
|
+
govExecuteValHash: executeValHash,
|
|
554
|
+
pBiasTime: BigInt(biasTime),
|
|
555
|
+
shardsValHash: pollShardValHash,
|
|
556
|
+
treasuryValHash: treasuryValHash,
|
|
557
|
+
};
|
|
558
|
+
const pollManagerValidator = mkPollManagerValidatorFromSP(pollManagerParams);
|
|
559
|
+
const pollManagerValHash = validatorToScriptHash(pollManagerValidator);
|
|
560
|
+
|
|
561
|
+
const govParams: GovParamsSP = {
|
|
562
|
+
gBiasTime: gBiasTime ? BigInt(gBiasTime) : BigInt(biasTime),
|
|
563
|
+
govNFT: toSystemParamsAsset(govNftAsset),
|
|
564
|
+
pollToken: toSystemParamsAsset(pollToken),
|
|
565
|
+
upgradeToken: toSystemParamsAsset(upgradeToken),
|
|
566
|
+
indyAsset: toSystemParamsAsset(indyAsset),
|
|
567
|
+
versionRecordToken: toSystemParamsAsset(versionRecordToken),
|
|
568
|
+
pollManagerValHash: pollManagerValHash,
|
|
569
|
+
iassetValHash: iassetValHash,
|
|
570
|
+
daoIdentityToken: toSystemParamsAsset(daoAsset),
|
|
571
|
+
iAssetAuthToken: toSystemParamsAsset(iassetToken),
|
|
572
|
+
iassetSymbol: { unCurrencySymbol: assetSymbol },
|
|
573
|
+
};
|
|
574
|
+
const govValidator = mkGovValidatorFromSP(govParams);
|
|
575
|
+
const govValHash = validatorToScriptHash(govValidator);
|
|
576
|
+
|
|
577
|
+
await initGovernance(
|
|
578
|
+
lucid,
|
|
579
|
+
govParams,
|
|
580
|
+
govNftAsset,
|
|
581
|
+
defaultInitialAssets,
|
|
582
|
+
protocolParams,
|
|
583
|
+
);
|
|
584
|
+
|
|
585
|
+
const robParams: RobParamsSP = {
|
|
586
|
+
iassetAuthToken: cdpParams.iAssetAuthToken,
|
|
587
|
+
collateralAssetAuthToken: cdpParams.collateralAssetAuthToken,
|
|
588
|
+
iassetPolicyId: cdpParams.cdpAssetSymbol,
|
|
589
|
+
iassetValHash: iassetValHash,
|
|
590
|
+
versionRecordToken: cdpParams.versionRecordToken,
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
const robValidator = mkRobValidatorFromSP(robParams);
|
|
594
|
+
const robValHash = validatorToScriptHash(robValidator);
|
|
595
|
+
|
|
596
|
+
// Policy scripts needed for script refs (deriveAuthToken only returns AssetClass)
|
|
597
|
+
const cdpTokenPolicy = mkAuthTokenPolicy(cdpCreatorAsset, fromText(tn.cdp));
|
|
598
|
+
const iassetTokenPolicy = mkAuthTokenPolicy(
|
|
599
|
+
upgradeToken,
|
|
600
|
+
fromText(tn.iasset),
|
|
601
|
+
);
|
|
602
|
+
const accountTokenPolicy = mkAuthTokenPolicy(
|
|
603
|
+
stabilityPoolToken,
|
|
604
|
+
fromText(tn.account),
|
|
605
|
+
);
|
|
606
|
+
const stabilityPoolTokenPolicy = mkAuthTokenPolicy(
|
|
607
|
+
upgradeToken,
|
|
608
|
+
fromText(tn.stabilityPool),
|
|
609
|
+
);
|
|
610
|
+
const pollTokenPolicy = mkAuthTokenPolicy(
|
|
611
|
+
govNftAsset,
|
|
612
|
+
fromText(tn.pollManager),
|
|
613
|
+
);
|
|
614
|
+
const stakingTokenPolicy = mkAuthTokenPolicy(
|
|
615
|
+
stakingManagerAsset,
|
|
616
|
+
fromText(tn.staking),
|
|
617
|
+
);
|
|
618
|
+
const collateralAssetAuthTokenPolicy = mkAuthTokenPolicy(
|
|
619
|
+
iassetToken,
|
|
620
|
+
fromText(tn.collateralAsset),
|
|
621
|
+
);
|
|
622
|
+
const upgradeTokenPolicy = mkAuthTokenPolicy(pollToken, fromText(tn.upgrade));
|
|
623
|
+
const snapshotEpochToScaleToSumTokenPolicy = mkAuthTokenPolicy(
|
|
624
|
+
stabilityPoolToken,
|
|
625
|
+
fromText(tn.snapshotEpochToScaleToSum),
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
const sysParams: SystemParams = {
|
|
629
|
+
cdpParams: cdpParams,
|
|
630
|
+
iassetParams: iassetParams,
|
|
631
|
+
cdpCreatorParams: cdpCreatorParams,
|
|
632
|
+
cdpRedeemParams: cdpRedeemParams,
|
|
633
|
+
collectorParams: collectorParams,
|
|
634
|
+
executeParams: executeParams,
|
|
635
|
+
govParams: govParams,
|
|
636
|
+
stakingParams: stakingParams,
|
|
637
|
+
stabilityPoolParams: stabilityPoolParams,
|
|
638
|
+
stableswapParams: stableswapParams,
|
|
639
|
+
treasuryParams: treasuryParams,
|
|
640
|
+
pollShardParams: pollShardParams,
|
|
641
|
+
pollManagerParams: pollManagerParams,
|
|
642
|
+
interestCollectionParams: interestCollectionParams,
|
|
643
|
+
indyToken: toSystemParamsAsset(indyAsset),
|
|
644
|
+
robParams: robParams,
|
|
645
|
+
versionRecordParams: versionRecordParams,
|
|
646
|
+
startTime: {
|
|
647
|
+
slot: startSlot,
|
|
648
|
+
blockHeader: 'TODO',
|
|
649
|
+
},
|
|
650
|
+
scriptReferences: {
|
|
651
|
+
interestCollectionValidatorRef: {
|
|
652
|
+
input: await initScriptRef(lucid, interestCollectionValidator),
|
|
653
|
+
},
|
|
654
|
+
robValidatorRef: {
|
|
655
|
+
input: await initScriptRef(lucid, robValidator),
|
|
656
|
+
},
|
|
657
|
+
cdpCreatorValidatorRef: {
|
|
658
|
+
input: await initScriptRef(lucid, cdpCreatorValidator),
|
|
659
|
+
},
|
|
660
|
+
cdpValidatorRef: {
|
|
661
|
+
input: await initScriptRef(lucid, cdpValidator),
|
|
662
|
+
},
|
|
663
|
+
cdpRedeemValidatorRef: {
|
|
664
|
+
input: await initScriptRef(lucid, cdpRedeemValidator),
|
|
665
|
+
},
|
|
666
|
+
collectorValidatorRef: {
|
|
667
|
+
input: await initScriptRef(lucid, collectorValidator),
|
|
668
|
+
},
|
|
669
|
+
executeValidatorRef: {
|
|
670
|
+
input: await initScriptRef(lucid, executeValidator),
|
|
671
|
+
},
|
|
672
|
+
pollShardValidatorRef: {
|
|
673
|
+
input: await initScriptRef(lucid, pollShardValidator),
|
|
674
|
+
},
|
|
675
|
+
pollManagerValidatorRef: {
|
|
676
|
+
input: await initScriptRef(lucid, pollManagerValidator),
|
|
677
|
+
},
|
|
678
|
+
iAssetTokenPolicyRef: {
|
|
679
|
+
input: await initScriptRef(lucid, assetSymbolPolicy),
|
|
680
|
+
},
|
|
681
|
+
stakingValidatorRef: {
|
|
682
|
+
input: await initScriptRef(
|
|
683
|
+
lucid,
|
|
684
|
+
mkStakingValidatorFromSP(stakingParams),
|
|
685
|
+
),
|
|
686
|
+
},
|
|
687
|
+
stabilityPoolValidatorRef: {
|
|
688
|
+
input: await initScriptRef(lucid, stabilityPoolValidator),
|
|
689
|
+
},
|
|
690
|
+
stableswapValidatorRef: {
|
|
691
|
+
input: await initScriptRef(lucid, stableswapValidator),
|
|
692
|
+
},
|
|
693
|
+
treasuryValidatorRef: {
|
|
694
|
+
input: await initScriptRef(lucid, treasuryValidator),
|
|
695
|
+
},
|
|
696
|
+
governanceValidatorRef: {
|
|
697
|
+
input: await initScriptRef(lucid, govValidator),
|
|
698
|
+
},
|
|
699
|
+
versionRegistryValidatorRef: {
|
|
700
|
+
input: await initScriptRef(lucid, versionRegistryValidator),
|
|
701
|
+
},
|
|
702
|
+
iassetValidatorRef: {
|
|
703
|
+
input: await initScriptRef(lucid, iassetValidator),
|
|
704
|
+
},
|
|
705
|
+
authTokenPolicies: {
|
|
706
|
+
cdpAuthTokenRef: {
|
|
707
|
+
input: await initScriptRef(lucid, cdpTokenPolicy),
|
|
708
|
+
},
|
|
709
|
+
iAssetAuthTokenRef: {
|
|
710
|
+
input: await initScriptRef(lucid, iassetTokenPolicy),
|
|
711
|
+
},
|
|
712
|
+
accountTokenRef: {
|
|
713
|
+
input: await initScriptRef(lucid, accountTokenPolicy),
|
|
714
|
+
},
|
|
715
|
+
stabilityPoolAuthTokenRef: {
|
|
716
|
+
input: await initScriptRef(lucid, stabilityPoolTokenPolicy),
|
|
717
|
+
},
|
|
718
|
+
pollManagerTokenRef: {
|
|
719
|
+
input: await initScriptRef(lucid, pollTokenPolicy),
|
|
720
|
+
},
|
|
721
|
+
stakingTokenRef: {
|
|
722
|
+
input: await initScriptRef(lucid, stakingTokenPolicy),
|
|
723
|
+
},
|
|
724
|
+
versionRecordTokenPolicyRef: {
|
|
725
|
+
input: await initScriptRef(lucid, versionRecordTokenPolicy),
|
|
726
|
+
},
|
|
727
|
+
iAssetTokenRef: {
|
|
728
|
+
input: await initScriptRef(lucid, assetSymbolPolicy),
|
|
729
|
+
},
|
|
730
|
+
collateralAssetTokenRef: {
|
|
731
|
+
input: await initScriptRef(lucid, collateralAssetAuthTokenPolicy),
|
|
732
|
+
},
|
|
733
|
+
upgradeTokenRef: {
|
|
734
|
+
input: await initScriptRef(lucid, upgradeTokenPolicy),
|
|
735
|
+
},
|
|
736
|
+
stabilityPoolTokenRef: {
|
|
737
|
+
input: await initScriptRef(lucid, stabilityPoolTokenPolicy),
|
|
738
|
+
},
|
|
739
|
+
snapshotEpochToScaleToSumTokenRef: {
|
|
740
|
+
input: await initScriptRef(
|
|
741
|
+
lucid,
|
|
742
|
+
snapshotEpochToScaleToSumTokenPolicy,
|
|
743
|
+
),
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
validatorHashes: {
|
|
748
|
+
cdpCreatorHash: cdpCreatorValHash,
|
|
749
|
+
cdpHash: cdpValHash,
|
|
750
|
+
executeHash: executeValHash,
|
|
751
|
+
govHash: govValHash,
|
|
752
|
+
interestCollectionHash: interestCollectionValHash,
|
|
753
|
+
pollShardHash: pollShardValHash,
|
|
754
|
+
pollManagerHash: pollManagerValHash,
|
|
755
|
+
treasuryHash: treasuryValHash,
|
|
756
|
+
stabilityPoolHash: stabilityPoolValHash,
|
|
757
|
+
stableswapHash: stableswapValHash,
|
|
758
|
+
stakingHash: stakingValHash,
|
|
759
|
+
collectorHash: collectorValHash,
|
|
760
|
+
versionRegistryHash: versionRegistryValHash,
|
|
761
|
+
robHash: robValHash,
|
|
762
|
+
iassetHash: iassetValHash,
|
|
763
|
+
},
|
|
764
|
+
pythConfig,
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
return [sysParams, assetInfos];
|
|
768
|
+
}
|