@indigo-labs/indigo-sdk 0.3.10 → 0.3.11
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 +47 -10
- package/dist/index.d.ts +47 -10
- package/dist/index.js +139 -59
- package/dist/index.mjs +145 -65
- package/package.json +1 -1
- package/src/contracts/cdp/transactions.ts +32 -8
- package/src/contracts/gov/helpers.ts +58 -0
- package/src/contracts/gov/transactions.ts +31 -0
- package/src/contracts/iasset/helpers.ts +2 -0
- package/src/contracts/staking/transactions.ts +3 -0
- package/src/contracts/treasury/transactions.ts +58 -36
- package/src/contracts/treasury/types-new.ts +1 -1
- package/src/validators/cdp-creator-validator.ts +1 -1
- package/src/validators/cdp-redeem-validator.ts +1 -1
- package/src/validators/cdp-validator.ts +1 -1
- package/src/validators/collector-validator.ts +1 -1
- package/src/validators/execute-validator.ts +1 -1
- package/src/validators/governance-validator.ts +1 -1
- package/src/validators/interest-collection-validator.ts +1 -1
- package/src/validators/interest-oracle-validator.ts +1 -1
- package/src/validators/poll-manager-validator.ts +1 -1
- package/src/validators/poll-shard-validator.ts +1 -1
- package/src/validators/stability-pool-validator.ts +1 -1
- package/src/validators/stableswap-validator.ts +1 -1
- package/src/validators/staking-validator.ts +1 -1
- package/src/validators/treasury-validator.ts +1 -1
- package/tests/cdp/actions.ts +87 -6
- package/tests/cdp/cdp.test.ts +949 -94
- package/tests/gov/gov.test.ts +864 -1
- package/tests/queries/treasury-queries.ts +6 -1
- package/tests/stability-pool.test.ts +251 -25
package/tests/gov/gov.test.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '@lucid-evolution/lucid';
|
|
14
14
|
import { describe, beforeEach, test, expect, assert } from 'vitest';
|
|
15
15
|
import {
|
|
16
|
+
adaAssetClass,
|
|
16
17
|
AssetClass,
|
|
17
18
|
assetClassToUnit,
|
|
18
19
|
assetClassValueOf,
|
|
@@ -59,7 +60,11 @@ import {
|
|
|
59
60
|
getNewUtxosAtAddressAfterAction,
|
|
60
61
|
getValueChangeAtAddressAfterAction,
|
|
61
62
|
} from '../utils';
|
|
62
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
iusdInitialAssetCfg,
|
|
65
|
+
mkBaseCollateralAsset,
|
|
66
|
+
mkCollateralAssetsChain,
|
|
67
|
+
} from '../mock/assets-mock';
|
|
63
68
|
import { addressFromBech32 } from '@3rd-eye-labs/cardano-offchain-common';
|
|
64
69
|
import {
|
|
65
70
|
EXAMPLE_TOKEN_1,
|
|
@@ -97,6 +102,8 @@ import {
|
|
|
97
102
|
} from '../queries/iasset-queries';
|
|
98
103
|
import { startPriceOracleTx } from '../../src/contracts/price-oracle/transactions';
|
|
99
104
|
import { rationalFromInt, rationalZero } from '../../src/types/rational';
|
|
105
|
+
import { expectScriptFailure } from '../utils/asserts';
|
|
106
|
+
import { MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET } from '../../src/contracts/iasset/helpers';
|
|
100
107
|
|
|
101
108
|
type MyContext = LucidContext<{
|
|
102
109
|
admin: EmulatorAccount;
|
|
@@ -3045,6 +3052,862 @@ describe('Gov', () => {
|
|
|
3045
3052
|
});
|
|
3046
3053
|
});
|
|
3047
3054
|
|
|
3055
|
+
test<MyContext>('Execute add (nth - 1) collateral asset proposal (no ADA whitelisted) succeeds', async (context: MyContext) => {
|
|
3056
|
+
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
3057
|
+
|
|
3058
|
+
const initialCollateralAssets = [];
|
|
3059
|
+
|
|
3060
|
+
for (let i = 0; i < MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 2; i++) {
|
|
3061
|
+
const collateralAssetI: AssetClass = {
|
|
3062
|
+
currencySymbol: fromHex(
|
|
3063
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3064
|
+
),
|
|
3065
|
+
tokenName: fromHex(fromText(i.toString())),
|
|
3066
|
+
};
|
|
3067
|
+
initialCollateralAssets.push(collateralAssetI);
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
const [sysParams, [iusdAssetInfo]] = await init(
|
|
3071
|
+
context.lucid,
|
|
3072
|
+
[
|
|
3073
|
+
{
|
|
3074
|
+
...iusdInitialAssetCfg(),
|
|
3075
|
+
collateralAssets: mkCollateralAssetsChain(
|
|
3076
|
+
initialCollateralAssets.map((a) => mkBaseCollateralAsset(a, 0n)),
|
|
3077
|
+
),
|
|
3078
|
+
},
|
|
3079
|
+
],
|
|
3080
|
+
context.emulator.slot,
|
|
3081
|
+
);
|
|
3082
|
+
|
|
3083
|
+
const [pkh, _] = await addrDetails(context.lucid);
|
|
3084
|
+
|
|
3085
|
+
const [startInterestTx, interestOracleNft] = await startInterestOracle(
|
|
3086
|
+
0n,
|
|
3087
|
+
0n,
|
|
3088
|
+
0n,
|
|
3089
|
+
{
|
|
3090
|
+
biasTime: 120_000n,
|
|
3091
|
+
owner: pkh.hash,
|
|
3092
|
+
},
|
|
3093
|
+
context.lucid,
|
|
3094
|
+
);
|
|
3095
|
+
await runAndAwaitTxBuilder(context.lucid, startInterestTx);
|
|
3096
|
+
|
|
3097
|
+
const [priceOracleTx, priceOranceNft] = await startPriceOracleTx(
|
|
3098
|
+
context.lucid,
|
|
3099
|
+
'IUSD_INDY_ORACLE',
|
|
3100
|
+
rationalFromInt(1n),
|
|
3101
|
+
{ biasTime: 120_000n, expirationPeriod: 1_800_000n, owner: pkh.hash },
|
|
3102
|
+
context.emulator.slot,
|
|
3103
|
+
);
|
|
3104
|
+
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
3105
|
+
|
|
3106
|
+
const allIassetOrefs = (
|
|
3107
|
+
await findAllIAssets(
|
|
3108
|
+
context.lucid,
|
|
3109
|
+
sysParams.validatorHashes.iassetHash,
|
|
3110
|
+
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
3111
|
+
)
|
|
3112
|
+
).map((iasset) => iasset.utxo);
|
|
3113
|
+
|
|
3114
|
+
await runAndAwaitTx(
|
|
3115
|
+
context.lucid,
|
|
3116
|
+
openStakingPosition(100_000_000_000n, sysParams, context.lucid),
|
|
3117
|
+
);
|
|
3118
|
+
|
|
3119
|
+
const govUtxo = await findGov(
|
|
3120
|
+
context.lucid,
|
|
3121
|
+
sysParams.validatorHashes.govHash,
|
|
3122
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3123
|
+
);
|
|
3124
|
+
|
|
3125
|
+
const collateralAssetN: AssetClass = {
|
|
3126
|
+
currencySymbol: fromHex(
|
|
3127
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3128
|
+
),
|
|
3129
|
+
tokenName: fromHex(
|
|
3130
|
+
fromText(MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET.toString()),
|
|
3131
|
+
),
|
|
3132
|
+
};
|
|
3133
|
+
|
|
3134
|
+
const [tx, pollId] = await createProposal(
|
|
3135
|
+
{
|
|
3136
|
+
AddCollateralAsset: {
|
|
3137
|
+
correspondingIAsset: fromHex(
|
|
3138
|
+
fromText(iusdAssetInfo.iassetTokenNameAscii),
|
|
3139
|
+
),
|
|
3140
|
+
collateralAsset: collateralAssetN,
|
|
3141
|
+
assetExtraDecimals: 0n,
|
|
3142
|
+
assetPriceInfo: { OracleNft: priceOranceNft },
|
|
3143
|
+
interestOracleNft: interestOracleNft,
|
|
3144
|
+
redemptionRatio: rationalFromInt(2n),
|
|
3145
|
+
maintenanceRatio: { numerator: 150n, denominator: 100n },
|
|
3146
|
+
liquidationRatio: { numerator: 120n, denominator: 100n },
|
|
3147
|
+
minCollateralAmt: 1_000_000n,
|
|
3148
|
+
},
|
|
3149
|
+
},
|
|
3150
|
+
null,
|
|
3151
|
+
sysParams,
|
|
3152
|
+
context.lucid,
|
|
3153
|
+
context.emulator.slot,
|
|
3154
|
+
govUtxo.utxo,
|
|
3155
|
+
allIassetOrefs,
|
|
3156
|
+
);
|
|
3157
|
+
|
|
3158
|
+
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
3159
|
+
|
|
3160
|
+
await runCreateAllShards(pollId, sysParams, context);
|
|
3161
|
+
|
|
3162
|
+
await runVote(pollId, 'Yes', sysParams, context);
|
|
3163
|
+
|
|
3164
|
+
await waitForVotingEnd(pollId, sysParams, context);
|
|
3165
|
+
|
|
3166
|
+
await runMergeAllShards(pollId, sysParams, context);
|
|
3167
|
+
|
|
3168
|
+
await runEndProposal(pollId, sysParams, context);
|
|
3169
|
+
|
|
3170
|
+
const executeUtxo = await findExecute(
|
|
3171
|
+
context.lucid,
|
|
3172
|
+
sysParams.validatorHashes.executeHash,
|
|
3173
|
+
fromSystemParamsAsset(sysParams.executeParams.upgradeToken),
|
|
3174
|
+
pollId,
|
|
3175
|
+
);
|
|
3176
|
+
|
|
3177
|
+
const iassetOutput = await findIAsset(
|
|
3178
|
+
context.lucid,
|
|
3179
|
+
sysParams.validatorHashes.iassetHash,
|
|
3180
|
+
fromSystemParamsAsset(sysParams.executeParams.iAssetToken),
|
|
3181
|
+
iusdAssetInfo.iassetTokenNameAscii,
|
|
3182
|
+
);
|
|
3183
|
+
|
|
3184
|
+
await runAndAwaitTx(
|
|
3185
|
+
context.lucid,
|
|
3186
|
+
executeProposal(
|
|
3187
|
+
executeUtxo.utxo,
|
|
3188
|
+
(
|
|
3189
|
+
await findGov(
|
|
3190
|
+
context.lucid,
|
|
3191
|
+
sysParams.validatorHashes.govHash,
|
|
3192
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3193
|
+
)
|
|
3194
|
+
).utxo,
|
|
3195
|
+
null,
|
|
3196
|
+
null,
|
|
3197
|
+
iassetOutput.utxo,
|
|
3198
|
+
(
|
|
3199
|
+
await findAllCollateralAssetsOfIAsset(
|
|
3200
|
+
context.lucid,
|
|
3201
|
+
sysParams.validatorHashes.iassetHash,
|
|
3202
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3203
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3204
|
+
)
|
|
3205
|
+
).map((o) => o.utxo),
|
|
3206
|
+
null,
|
|
3207
|
+
null,
|
|
3208
|
+
sysParams,
|
|
3209
|
+
context.lucid,
|
|
3210
|
+
context.emulator.slot,
|
|
3211
|
+
),
|
|
3212
|
+
);
|
|
3213
|
+
|
|
3214
|
+
const whitelistedCollateralAssets = await findAllCollateralAssetsOfIAsset(
|
|
3215
|
+
context.lucid,
|
|
3216
|
+
sysParams.validatorHashes.iassetHash,
|
|
3217
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3218
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3219
|
+
);
|
|
3220
|
+
|
|
3221
|
+
expect(
|
|
3222
|
+
whitelistedCollateralAssets.length ==
|
|
3223
|
+
MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 1,
|
|
3224
|
+
'Expected different number of whitelisted collateral assets',
|
|
3225
|
+
).toBeTruthy();
|
|
3226
|
+
});
|
|
3227
|
+
|
|
3228
|
+
test<MyContext>('Execute add nth collateral asset proposal (no ADA whitelisted) fails', async (context: MyContext) => {
|
|
3229
|
+
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
3230
|
+
|
|
3231
|
+
const initialCollateralAssets = [];
|
|
3232
|
+
|
|
3233
|
+
for (let i = 0; i < MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 1; i++) {
|
|
3234
|
+
const collateralAssetI: AssetClass = {
|
|
3235
|
+
currencySymbol: fromHex(
|
|
3236
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3237
|
+
),
|
|
3238
|
+
tokenName: fromHex(fromText(i.toString())),
|
|
3239
|
+
};
|
|
3240
|
+
initialCollateralAssets.push(collateralAssetI);
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
const [sysParams, [iusdAssetInfo]] = await init(
|
|
3244
|
+
context.lucid,
|
|
3245
|
+
[
|
|
3246
|
+
{
|
|
3247
|
+
...iusdInitialAssetCfg(),
|
|
3248
|
+
collateralAssets: mkCollateralAssetsChain(
|
|
3249
|
+
initialCollateralAssets.map((a) => mkBaseCollateralAsset(a, 0n)),
|
|
3250
|
+
),
|
|
3251
|
+
},
|
|
3252
|
+
],
|
|
3253
|
+
context.emulator.slot,
|
|
3254
|
+
);
|
|
3255
|
+
|
|
3256
|
+
const [pkh, _] = await addrDetails(context.lucid);
|
|
3257
|
+
|
|
3258
|
+
const [startInterestTx, interestOracleNft] = await startInterestOracle(
|
|
3259
|
+
0n,
|
|
3260
|
+
0n,
|
|
3261
|
+
0n,
|
|
3262
|
+
{
|
|
3263
|
+
biasTime: 120_000n,
|
|
3264
|
+
owner: pkh.hash,
|
|
3265
|
+
},
|
|
3266
|
+
context.lucid,
|
|
3267
|
+
);
|
|
3268
|
+
await runAndAwaitTxBuilder(context.lucid, startInterestTx);
|
|
3269
|
+
|
|
3270
|
+
const [priceOracleTx, priceOranceNft] = await startPriceOracleTx(
|
|
3271
|
+
context.lucid,
|
|
3272
|
+
'IUSD_INDY_ORACLE',
|
|
3273
|
+
rationalFromInt(1n),
|
|
3274
|
+
{ biasTime: 120_000n, expirationPeriod: 1_800_000n, owner: pkh.hash },
|
|
3275
|
+
context.emulator.slot,
|
|
3276
|
+
);
|
|
3277
|
+
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
3278
|
+
|
|
3279
|
+
const allIassetOrefs = (
|
|
3280
|
+
await findAllIAssets(
|
|
3281
|
+
context.lucid,
|
|
3282
|
+
sysParams.validatorHashes.iassetHash,
|
|
3283
|
+
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
3284
|
+
)
|
|
3285
|
+
).map((iasset) => iasset.utxo);
|
|
3286
|
+
|
|
3287
|
+
await runAndAwaitTx(
|
|
3288
|
+
context.lucid,
|
|
3289
|
+
openStakingPosition(100_000_000_000n, sysParams, context.lucid),
|
|
3290
|
+
);
|
|
3291
|
+
|
|
3292
|
+
const whitelistedCollateralAssets = await findAllCollateralAssetsOfIAsset(
|
|
3293
|
+
context.lucid,
|
|
3294
|
+
sysParams.validatorHashes.iassetHash,
|
|
3295
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3296
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3297
|
+
);
|
|
3298
|
+
|
|
3299
|
+
expect(
|
|
3300
|
+
whitelistedCollateralAssets.length ==
|
|
3301
|
+
MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 1,
|
|
3302
|
+
'Expected different number of whitelisted collateral assets',
|
|
3303
|
+
).toBeTruthy();
|
|
3304
|
+
|
|
3305
|
+
const govUtxo = await findGov(
|
|
3306
|
+
context.lucid,
|
|
3307
|
+
sysParams.validatorHashes.govHash,
|
|
3308
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3309
|
+
);
|
|
3310
|
+
|
|
3311
|
+
const collateralAssetN: AssetClass = {
|
|
3312
|
+
currencySymbol: fromHex(
|
|
3313
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3314
|
+
),
|
|
3315
|
+
tokenName: fromHex(
|
|
3316
|
+
fromText(MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET.toString()),
|
|
3317
|
+
),
|
|
3318
|
+
};
|
|
3319
|
+
|
|
3320
|
+
const [tx, pollId] = await createProposal(
|
|
3321
|
+
{
|
|
3322
|
+
AddCollateralAsset: {
|
|
3323
|
+
correspondingIAsset: fromHex(
|
|
3324
|
+
fromText(iusdAssetInfo.iassetTokenNameAscii),
|
|
3325
|
+
),
|
|
3326
|
+
collateralAsset: collateralAssetN,
|
|
3327
|
+
assetExtraDecimals: 0n,
|
|
3328
|
+
assetPriceInfo: { OracleNft: priceOranceNft },
|
|
3329
|
+
interestOracleNft: interestOracleNft,
|
|
3330
|
+
redemptionRatio: rationalFromInt(2n),
|
|
3331
|
+
maintenanceRatio: { numerator: 150n, denominator: 100n },
|
|
3332
|
+
liquidationRatio: { numerator: 120n, denominator: 100n },
|
|
3333
|
+
minCollateralAmt: 1_000_000n,
|
|
3334
|
+
},
|
|
3335
|
+
},
|
|
3336
|
+
null,
|
|
3337
|
+
sysParams,
|
|
3338
|
+
context.lucid,
|
|
3339
|
+
context.emulator.slot,
|
|
3340
|
+
govUtxo.utxo,
|
|
3341
|
+
allIassetOrefs,
|
|
3342
|
+
);
|
|
3343
|
+
|
|
3344
|
+
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
3345
|
+
|
|
3346
|
+
await runCreateAllShards(pollId, sysParams, context);
|
|
3347
|
+
|
|
3348
|
+
await runVote(pollId, 'Yes', sysParams, context);
|
|
3349
|
+
|
|
3350
|
+
await waitForVotingEnd(pollId, sysParams, context);
|
|
3351
|
+
|
|
3352
|
+
await runMergeAllShards(pollId, sysParams, context);
|
|
3353
|
+
|
|
3354
|
+
await runEndProposal(pollId, sysParams, context);
|
|
3355
|
+
|
|
3356
|
+
const executeUtxo = await findExecute(
|
|
3357
|
+
context.lucid,
|
|
3358
|
+
sysParams.validatorHashes.executeHash,
|
|
3359
|
+
fromSystemParamsAsset(sysParams.executeParams.upgradeToken),
|
|
3360
|
+
pollId,
|
|
3361
|
+
);
|
|
3362
|
+
|
|
3363
|
+
const iassetOutput = await findIAsset(
|
|
3364
|
+
context.lucid,
|
|
3365
|
+
sysParams.validatorHashes.iassetHash,
|
|
3366
|
+
fromSystemParamsAsset(sysParams.executeParams.iAssetToken),
|
|
3367
|
+
iusdAssetInfo.iassetTokenNameAscii,
|
|
3368
|
+
);
|
|
3369
|
+
|
|
3370
|
+
await expectScriptFailure(
|
|
3371
|
+
'Max collateral assets reached',
|
|
3372
|
+
executeProposal(
|
|
3373
|
+
executeUtxo.utxo,
|
|
3374
|
+
(
|
|
3375
|
+
await findGov(
|
|
3376
|
+
context.lucid,
|
|
3377
|
+
sysParams.validatorHashes.govHash,
|
|
3378
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3379
|
+
)
|
|
3380
|
+
).utxo,
|
|
3381
|
+
null,
|
|
3382
|
+
null,
|
|
3383
|
+
iassetOutput.utxo,
|
|
3384
|
+
(
|
|
3385
|
+
await findAllCollateralAssetsOfIAsset(
|
|
3386
|
+
context.lucid,
|
|
3387
|
+
sysParams.validatorHashes.iassetHash,
|
|
3388
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3389
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3390
|
+
)
|
|
3391
|
+
).map((o) => o.utxo),
|
|
3392
|
+
null,
|
|
3393
|
+
null,
|
|
3394
|
+
sysParams,
|
|
3395
|
+
context.lucid,
|
|
3396
|
+
context.emulator.slot,
|
|
3397
|
+
),
|
|
3398
|
+
);
|
|
3399
|
+
});
|
|
3400
|
+
|
|
3401
|
+
test<MyContext>('Execute add nth collateral asset proposal (ADA whitelisted) succeeds', async (context: MyContext) => {
|
|
3402
|
+
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
3403
|
+
|
|
3404
|
+
const initialCollateralAssets = [adaAssetClass];
|
|
3405
|
+
|
|
3406
|
+
for (let i = 0; i < MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 2; i++) {
|
|
3407
|
+
const collateralAssetI: AssetClass = {
|
|
3408
|
+
currencySymbol: fromHex(
|
|
3409
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3410
|
+
),
|
|
3411
|
+
tokenName: fromHex(fromText(i.toString())),
|
|
3412
|
+
};
|
|
3413
|
+
initialCollateralAssets.push(collateralAssetI);
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
const [sysParams, [iusdAssetInfo]] = await init(
|
|
3417
|
+
context.lucid,
|
|
3418
|
+
[
|
|
3419
|
+
{
|
|
3420
|
+
...iusdInitialAssetCfg(),
|
|
3421
|
+
collateralAssets: mkCollateralAssetsChain(
|
|
3422
|
+
initialCollateralAssets.map((a) => mkBaseCollateralAsset(a, 0n)),
|
|
3423
|
+
),
|
|
3424
|
+
},
|
|
3425
|
+
],
|
|
3426
|
+
context.emulator.slot,
|
|
3427
|
+
);
|
|
3428
|
+
|
|
3429
|
+
const [pkh, _] = await addrDetails(context.lucid);
|
|
3430
|
+
|
|
3431
|
+
const [startInterestTx, interestOracleNft] = await startInterestOracle(
|
|
3432
|
+
0n,
|
|
3433
|
+
0n,
|
|
3434
|
+
0n,
|
|
3435
|
+
{
|
|
3436
|
+
biasTime: 120_000n,
|
|
3437
|
+
owner: pkh.hash,
|
|
3438
|
+
},
|
|
3439
|
+
context.lucid,
|
|
3440
|
+
);
|
|
3441
|
+
await runAndAwaitTxBuilder(context.lucid, startInterestTx);
|
|
3442
|
+
|
|
3443
|
+
const [priceOracleTx, priceOranceNft] = await startPriceOracleTx(
|
|
3444
|
+
context.lucid,
|
|
3445
|
+
'IUSD_INDY_ORACLE',
|
|
3446
|
+
rationalFromInt(1n),
|
|
3447
|
+
{ biasTime: 120_000n, expirationPeriod: 1_800_000n, owner: pkh.hash },
|
|
3448
|
+
context.emulator.slot,
|
|
3449
|
+
);
|
|
3450
|
+
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
3451
|
+
|
|
3452
|
+
const allIassetOrefs = (
|
|
3453
|
+
await findAllIAssets(
|
|
3454
|
+
context.lucid,
|
|
3455
|
+
sysParams.validatorHashes.iassetHash,
|
|
3456
|
+
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
3457
|
+
)
|
|
3458
|
+
).map((iasset) => iasset.utxo);
|
|
3459
|
+
|
|
3460
|
+
await runAndAwaitTx(
|
|
3461
|
+
context.lucid,
|
|
3462
|
+
openStakingPosition(100_000_000_000n, sysParams, context.lucid),
|
|
3463
|
+
);
|
|
3464
|
+
|
|
3465
|
+
const govUtxo = await findGov(
|
|
3466
|
+
context.lucid,
|
|
3467
|
+
sysParams.validatorHashes.govHash,
|
|
3468
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3469
|
+
);
|
|
3470
|
+
|
|
3471
|
+
const collateralAssetN: AssetClass = {
|
|
3472
|
+
currencySymbol: fromHex(
|
|
3473
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3474
|
+
),
|
|
3475
|
+
tokenName: fromHex(
|
|
3476
|
+
fromText(MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET.toString()),
|
|
3477
|
+
),
|
|
3478
|
+
};
|
|
3479
|
+
|
|
3480
|
+
const [tx, pollId] = await createProposal(
|
|
3481
|
+
{
|
|
3482
|
+
AddCollateralAsset: {
|
|
3483
|
+
correspondingIAsset: fromHex(
|
|
3484
|
+
fromText(iusdAssetInfo.iassetTokenNameAscii),
|
|
3485
|
+
),
|
|
3486
|
+
collateralAsset: collateralAssetN,
|
|
3487
|
+
assetExtraDecimals: 0n,
|
|
3488
|
+
assetPriceInfo: { OracleNft: priceOranceNft },
|
|
3489
|
+
interestOracleNft: interestOracleNft,
|
|
3490
|
+
redemptionRatio: rationalFromInt(2n),
|
|
3491
|
+
maintenanceRatio: { numerator: 150n, denominator: 100n },
|
|
3492
|
+
liquidationRatio: { numerator: 120n, denominator: 100n },
|
|
3493
|
+
minCollateralAmt: 1_000_000n,
|
|
3494
|
+
},
|
|
3495
|
+
},
|
|
3496
|
+
null,
|
|
3497
|
+
sysParams,
|
|
3498
|
+
context.lucid,
|
|
3499
|
+
context.emulator.slot,
|
|
3500
|
+
govUtxo.utxo,
|
|
3501
|
+
allIassetOrefs,
|
|
3502
|
+
);
|
|
3503
|
+
|
|
3504
|
+
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
3505
|
+
|
|
3506
|
+
await runCreateAllShards(pollId, sysParams, context);
|
|
3507
|
+
|
|
3508
|
+
await runVote(pollId, 'Yes', sysParams, context);
|
|
3509
|
+
|
|
3510
|
+
await waitForVotingEnd(pollId, sysParams, context);
|
|
3511
|
+
|
|
3512
|
+
await runMergeAllShards(pollId, sysParams, context);
|
|
3513
|
+
|
|
3514
|
+
await runEndProposal(pollId, sysParams, context);
|
|
3515
|
+
|
|
3516
|
+
const executeUtxo = await findExecute(
|
|
3517
|
+
context.lucid,
|
|
3518
|
+
sysParams.validatorHashes.executeHash,
|
|
3519
|
+
fromSystemParamsAsset(sysParams.executeParams.upgradeToken),
|
|
3520
|
+
pollId,
|
|
3521
|
+
);
|
|
3522
|
+
|
|
3523
|
+
const iassetOutput = await findIAsset(
|
|
3524
|
+
context.lucid,
|
|
3525
|
+
sysParams.validatorHashes.iassetHash,
|
|
3526
|
+
fromSystemParamsAsset(sysParams.executeParams.iAssetToken),
|
|
3527
|
+
iusdAssetInfo.iassetTokenNameAscii,
|
|
3528
|
+
);
|
|
3529
|
+
|
|
3530
|
+
await runAndAwaitTx(
|
|
3531
|
+
context.lucid,
|
|
3532
|
+
executeProposal(
|
|
3533
|
+
executeUtxo.utxo,
|
|
3534
|
+
(
|
|
3535
|
+
await findGov(
|
|
3536
|
+
context.lucid,
|
|
3537
|
+
sysParams.validatorHashes.govHash,
|
|
3538
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3539
|
+
)
|
|
3540
|
+
).utxo,
|
|
3541
|
+
null,
|
|
3542
|
+
null,
|
|
3543
|
+
iassetOutput.utxo,
|
|
3544
|
+
(
|
|
3545
|
+
await findAllCollateralAssetsOfIAsset(
|
|
3546
|
+
context.lucid,
|
|
3547
|
+
sysParams.validatorHashes.iassetHash,
|
|
3548
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3549
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3550
|
+
)
|
|
3551
|
+
).map((o) => o.utxo),
|
|
3552
|
+
null,
|
|
3553
|
+
null,
|
|
3554
|
+
sysParams,
|
|
3555
|
+
context.lucid,
|
|
3556
|
+
context.emulator.slot,
|
|
3557
|
+
),
|
|
3558
|
+
);
|
|
3559
|
+
|
|
3560
|
+
const whitelistedCollateralAssets = await findAllCollateralAssetsOfIAsset(
|
|
3561
|
+
context.lucid,
|
|
3562
|
+
sysParams.validatorHashes.iassetHash,
|
|
3563
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3564
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3565
|
+
);
|
|
3566
|
+
|
|
3567
|
+
expect(
|
|
3568
|
+
whitelistedCollateralAssets.length ==
|
|
3569
|
+
MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET,
|
|
3570
|
+
'Expected different number of whitelisted collateral assets',
|
|
3571
|
+
).toBeTruthy();
|
|
3572
|
+
});
|
|
3573
|
+
|
|
3574
|
+
test<MyContext>('Execute add ADA collateral asset proposal with (nth - 1) whitelisted assets succeeds', async (context: MyContext) => {
|
|
3575
|
+
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
3576
|
+
|
|
3577
|
+
const initialCollateralAssets = [];
|
|
3578
|
+
|
|
3579
|
+
for (let i = 0; i < MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 1; i++) {
|
|
3580
|
+
const collateralAssetI: AssetClass = {
|
|
3581
|
+
currencySymbol: fromHex(
|
|
3582
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3583
|
+
),
|
|
3584
|
+
tokenName: fromHex(fromText(i.toString())),
|
|
3585
|
+
};
|
|
3586
|
+
initialCollateralAssets.push(collateralAssetI);
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
const [sysParams, [iusdAssetInfo]] = await init(
|
|
3590
|
+
context.lucid,
|
|
3591
|
+
[
|
|
3592
|
+
{
|
|
3593
|
+
...iusdInitialAssetCfg(),
|
|
3594
|
+
collateralAssets: mkCollateralAssetsChain(
|
|
3595
|
+
initialCollateralAssets.map((a) => mkBaseCollateralAsset(a, 0n)),
|
|
3596
|
+
),
|
|
3597
|
+
},
|
|
3598
|
+
],
|
|
3599
|
+
context.emulator.slot,
|
|
3600
|
+
);
|
|
3601
|
+
|
|
3602
|
+
const [pkh, _] = await addrDetails(context.lucid);
|
|
3603
|
+
|
|
3604
|
+
const [startInterestTx, interestOracleNft] = await startInterestOracle(
|
|
3605
|
+
0n,
|
|
3606
|
+
0n,
|
|
3607
|
+
0n,
|
|
3608
|
+
{
|
|
3609
|
+
biasTime: 120_000n,
|
|
3610
|
+
owner: pkh.hash,
|
|
3611
|
+
},
|
|
3612
|
+
context.lucid,
|
|
3613
|
+
);
|
|
3614
|
+
await runAndAwaitTxBuilder(context.lucid, startInterestTx);
|
|
3615
|
+
|
|
3616
|
+
const [priceOracleTx, priceOranceNft] = await startPriceOracleTx(
|
|
3617
|
+
context.lucid,
|
|
3618
|
+
'IUSD_INDY_ORACLE',
|
|
3619
|
+
rationalFromInt(1n),
|
|
3620
|
+
{ biasTime: 120_000n, expirationPeriod: 1_800_000n, owner: pkh.hash },
|
|
3621
|
+
context.emulator.slot,
|
|
3622
|
+
);
|
|
3623
|
+
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
3624
|
+
|
|
3625
|
+
const allIassetOrefs = (
|
|
3626
|
+
await findAllIAssets(
|
|
3627
|
+
context.lucid,
|
|
3628
|
+
sysParams.validatorHashes.iassetHash,
|
|
3629
|
+
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
3630
|
+
)
|
|
3631
|
+
).map((iasset) => iasset.utxo);
|
|
3632
|
+
|
|
3633
|
+
await runAndAwaitTx(
|
|
3634
|
+
context.lucid,
|
|
3635
|
+
openStakingPosition(100_000_000_000n, sysParams, context.lucid),
|
|
3636
|
+
);
|
|
3637
|
+
|
|
3638
|
+
const govUtxo = await findGov(
|
|
3639
|
+
context.lucid,
|
|
3640
|
+
sysParams.validatorHashes.govHash,
|
|
3641
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3642
|
+
);
|
|
3643
|
+
|
|
3644
|
+
const [tx, pollId] = await createProposal(
|
|
3645
|
+
{
|
|
3646
|
+
AddCollateralAsset: {
|
|
3647
|
+
correspondingIAsset: fromHex(
|
|
3648
|
+
fromText(iusdAssetInfo.iassetTokenNameAscii),
|
|
3649
|
+
),
|
|
3650
|
+
collateralAsset: adaAssetClass,
|
|
3651
|
+
assetExtraDecimals: 0n,
|
|
3652
|
+
assetPriceInfo: { OracleNft: priceOranceNft },
|
|
3653
|
+
interestOracleNft: interestOracleNft,
|
|
3654
|
+
redemptionRatio: rationalFromInt(2n),
|
|
3655
|
+
maintenanceRatio: { numerator: 150n, denominator: 100n },
|
|
3656
|
+
liquidationRatio: { numerator: 120n, denominator: 100n },
|
|
3657
|
+
minCollateralAmt: 1_000_000n,
|
|
3658
|
+
},
|
|
3659
|
+
},
|
|
3660
|
+
null,
|
|
3661
|
+
sysParams,
|
|
3662
|
+
context.lucid,
|
|
3663
|
+
context.emulator.slot,
|
|
3664
|
+
govUtxo.utxo,
|
|
3665
|
+
allIassetOrefs,
|
|
3666
|
+
);
|
|
3667
|
+
|
|
3668
|
+
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
3669
|
+
|
|
3670
|
+
await runCreateAllShards(pollId, sysParams, context);
|
|
3671
|
+
|
|
3672
|
+
await runVote(pollId, 'Yes', sysParams, context);
|
|
3673
|
+
|
|
3674
|
+
await waitForVotingEnd(pollId, sysParams, context);
|
|
3675
|
+
|
|
3676
|
+
await runMergeAllShards(pollId, sysParams, context);
|
|
3677
|
+
|
|
3678
|
+
await runEndProposal(pollId, sysParams, context);
|
|
3679
|
+
|
|
3680
|
+
const executeUtxo = await findExecute(
|
|
3681
|
+
context.lucid,
|
|
3682
|
+
sysParams.validatorHashes.executeHash,
|
|
3683
|
+
fromSystemParamsAsset(sysParams.executeParams.upgradeToken),
|
|
3684
|
+
pollId,
|
|
3685
|
+
);
|
|
3686
|
+
|
|
3687
|
+
const iassetOutput = await findIAsset(
|
|
3688
|
+
context.lucid,
|
|
3689
|
+
sysParams.validatorHashes.iassetHash,
|
|
3690
|
+
fromSystemParamsAsset(sysParams.executeParams.iAssetToken),
|
|
3691
|
+
iusdAssetInfo.iassetTokenNameAscii,
|
|
3692
|
+
);
|
|
3693
|
+
|
|
3694
|
+
await runAndAwaitTx(
|
|
3695
|
+
context.lucid,
|
|
3696
|
+
executeProposal(
|
|
3697
|
+
executeUtxo.utxo,
|
|
3698
|
+
(
|
|
3699
|
+
await findGov(
|
|
3700
|
+
context.lucid,
|
|
3701
|
+
sysParams.validatorHashes.govHash,
|
|
3702
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3703
|
+
)
|
|
3704
|
+
).utxo,
|
|
3705
|
+
null,
|
|
3706
|
+
null,
|
|
3707
|
+
iassetOutput.utxo,
|
|
3708
|
+
(
|
|
3709
|
+
await findAllCollateralAssetsOfIAsset(
|
|
3710
|
+
context.lucid,
|
|
3711
|
+
sysParams.validatorHashes.iassetHash,
|
|
3712
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3713
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3714
|
+
)
|
|
3715
|
+
).map((o) => o.utxo),
|
|
3716
|
+
null,
|
|
3717
|
+
null,
|
|
3718
|
+
sysParams,
|
|
3719
|
+
context.lucid,
|
|
3720
|
+
context.emulator.slot,
|
|
3721
|
+
),
|
|
3722
|
+
);
|
|
3723
|
+
|
|
3724
|
+
const whitelistedCollateralAssets = await findAllCollateralAssetsOfIAsset(
|
|
3725
|
+
context.lucid,
|
|
3726
|
+
sysParams.validatorHashes.iassetHash,
|
|
3727
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3728
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3729
|
+
);
|
|
3730
|
+
|
|
3731
|
+
expect(
|
|
3732
|
+
whitelistedCollateralAssets.length ==
|
|
3733
|
+
MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET,
|
|
3734
|
+
'Expected different number of whitelisted collateral assets',
|
|
3735
|
+
).toBeTruthy();
|
|
3736
|
+
});
|
|
3737
|
+
|
|
3738
|
+
test<MyContext>('Execute add (nth + 1) collateral asset proposal (ADA whitelisted) fails', async (context: MyContext) => {
|
|
3739
|
+
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
3740
|
+
|
|
3741
|
+
const initialCollateralAssets = [adaAssetClass];
|
|
3742
|
+
|
|
3743
|
+
for (let i = 0; i < MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET - 1; i++) {
|
|
3744
|
+
const collateralAssetI: AssetClass = {
|
|
3745
|
+
currencySymbol: fromHex(
|
|
3746
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3747
|
+
),
|
|
3748
|
+
tokenName: fromHex(fromText(i.toString())),
|
|
3749
|
+
};
|
|
3750
|
+
initialCollateralAssets.push(collateralAssetI);
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
const [sysParams, [iusdAssetInfo]] = await init(
|
|
3754
|
+
context.lucid,
|
|
3755
|
+
[
|
|
3756
|
+
{
|
|
3757
|
+
...iusdInitialAssetCfg(),
|
|
3758
|
+
collateralAssets: mkCollateralAssetsChain(
|
|
3759
|
+
initialCollateralAssets.map((a) => mkBaseCollateralAsset(a, 0n)),
|
|
3760
|
+
),
|
|
3761
|
+
},
|
|
3762
|
+
],
|
|
3763
|
+
context.emulator.slot,
|
|
3764
|
+
);
|
|
3765
|
+
|
|
3766
|
+
const [pkh, _] = await addrDetails(context.lucid);
|
|
3767
|
+
|
|
3768
|
+
const [startInterestTx, interestOracleNft] = await startInterestOracle(
|
|
3769
|
+
0n,
|
|
3770
|
+
0n,
|
|
3771
|
+
0n,
|
|
3772
|
+
{
|
|
3773
|
+
biasTime: 120_000n,
|
|
3774
|
+
owner: pkh.hash,
|
|
3775
|
+
},
|
|
3776
|
+
context.lucid,
|
|
3777
|
+
);
|
|
3778
|
+
await runAndAwaitTxBuilder(context.lucid, startInterestTx);
|
|
3779
|
+
|
|
3780
|
+
const [priceOracleTx, priceOranceNft] = await startPriceOracleTx(
|
|
3781
|
+
context.lucid,
|
|
3782
|
+
'IUSD_INDY_ORACLE',
|
|
3783
|
+
rationalFromInt(1n),
|
|
3784
|
+
{ biasTime: 120_000n, expirationPeriod: 1_800_000n, owner: pkh.hash },
|
|
3785
|
+
context.emulator.slot,
|
|
3786
|
+
);
|
|
3787
|
+
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
3788
|
+
|
|
3789
|
+
const allIassetOrefs = (
|
|
3790
|
+
await findAllIAssets(
|
|
3791
|
+
context.lucid,
|
|
3792
|
+
sysParams.validatorHashes.iassetHash,
|
|
3793
|
+
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
3794
|
+
)
|
|
3795
|
+
).map((iasset) => iasset.utxo);
|
|
3796
|
+
|
|
3797
|
+
await runAndAwaitTx(
|
|
3798
|
+
context.lucid,
|
|
3799
|
+
openStakingPosition(100_000_000_000n, sysParams, context.lucid),
|
|
3800
|
+
);
|
|
3801
|
+
|
|
3802
|
+
const whitelistedCollateralAssets = await findAllCollateralAssetsOfIAsset(
|
|
3803
|
+
context.lucid,
|
|
3804
|
+
sysParams.validatorHashes.iassetHash,
|
|
3805
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3806
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3807
|
+
);
|
|
3808
|
+
|
|
3809
|
+
expect(
|
|
3810
|
+
whitelistedCollateralAssets.length ==
|
|
3811
|
+
MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET,
|
|
3812
|
+
'Expected different number of whitelisted collateral assets',
|
|
3813
|
+
).toBeTruthy();
|
|
3814
|
+
|
|
3815
|
+
const govUtxo = await findGov(
|
|
3816
|
+
context.lucid,
|
|
3817
|
+
sysParams.validatorHashes.govHash,
|
|
3818
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3819
|
+
);
|
|
3820
|
+
|
|
3821
|
+
const collateralAssetN: AssetClass = {
|
|
3822
|
+
currencySymbol: fromHex(
|
|
3823
|
+
'00000000000000000000000000000000000000000000000000000000',
|
|
3824
|
+
),
|
|
3825
|
+
tokenName: fromHex(
|
|
3826
|
+
fromText(MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET.toString()),
|
|
3827
|
+
),
|
|
3828
|
+
};
|
|
3829
|
+
|
|
3830
|
+
const [tx, pollId] = await createProposal(
|
|
3831
|
+
{
|
|
3832
|
+
AddCollateralAsset: {
|
|
3833
|
+
correspondingIAsset: fromHex(
|
|
3834
|
+
fromText(iusdAssetInfo.iassetTokenNameAscii),
|
|
3835
|
+
),
|
|
3836
|
+
collateralAsset: collateralAssetN,
|
|
3837
|
+
assetExtraDecimals: 0n,
|
|
3838
|
+
assetPriceInfo: { OracleNft: priceOranceNft },
|
|
3839
|
+
interestOracleNft: interestOracleNft,
|
|
3840
|
+
redemptionRatio: rationalFromInt(2n),
|
|
3841
|
+
maintenanceRatio: { numerator: 150n, denominator: 100n },
|
|
3842
|
+
liquidationRatio: { numerator: 120n, denominator: 100n },
|
|
3843
|
+
minCollateralAmt: 1_000_000n,
|
|
3844
|
+
},
|
|
3845
|
+
},
|
|
3846
|
+
null,
|
|
3847
|
+
sysParams,
|
|
3848
|
+
context.lucid,
|
|
3849
|
+
context.emulator.slot,
|
|
3850
|
+
govUtxo.utxo,
|
|
3851
|
+
allIassetOrefs,
|
|
3852
|
+
);
|
|
3853
|
+
|
|
3854
|
+
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
3855
|
+
|
|
3856
|
+
await runCreateAllShards(pollId, sysParams, context);
|
|
3857
|
+
|
|
3858
|
+
await runVote(pollId, 'Yes', sysParams, context);
|
|
3859
|
+
|
|
3860
|
+
await waitForVotingEnd(pollId, sysParams, context);
|
|
3861
|
+
|
|
3862
|
+
await runMergeAllShards(pollId, sysParams, context);
|
|
3863
|
+
|
|
3864
|
+
await runEndProposal(pollId, sysParams, context);
|
|
3865
|
+
|
|
3866
|
+
const executeUtxo = await findExecute(
|
|
3867
|
+
context.lucid,
|
|
3868
|
+
sysParams.validatorHashes.executeHash,
|
|
3869
|
+
fromSystemParamsAsset(sysParams.executeParams.upgradeToken),
|
|
3870
|
+
pollId,
|
|
3871
|
+
);
|
|
3872
|
+
|
|
3873
|
+
const iassetOutput = await findIAsset(
|
|
3874
|
+
context.lucid,
|
|
3875
|
+
sysParams.validatorHashes.iassetHash,
|
|
3876
|
+
fromSystemParamsAsset(sysParams.executeParams.iAssetToken),
|
|
3877
|
+
iusdAssetInfo.iassetTokenNameAscii,
|
|
3878
|
+
);
|
|
3879
|
+
|
|
3880
|
+
await expectScriptFailure(
|
|
3881
|
+
'Max collateral assets reached',
|
|
3882
|
+
executeProposal(
|
|
3883
|
+
executeUtxo.utxo,
|
|
3884
|
+
(
|
|
3885
|
+
await findGov(
|
|
3886
|
+
context.lucid,
|
|
3887
|
+
sysParams.validatorHashes.govHash,
|
|
3888
|
+
fromSystemParamsAsset(sysParams.govParams.govNFT),
|
|
3889
|
+
)
|
|
3890
|
+
).utxo,
|
|
3891
|
+
null,
|
|
3892
|
+
null,
|
|
3893
|
+
iassetOutput.utxo,
|
|
3894
|
+
(
|
|
3895
|
+
await findAllCollateralAssetsOfIAsset(
|
|
3896
|
+
context.lucid,
|
|
3897
|
+
sysParams.validatorHashes.iassetHash,
|
|
3898
|
+
fromSystemParamsAsset(sysParams.executeParams.collateralAssetToken),
|
|
3899
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
3900
|
+
)
|
|
3901
|
+
).map((o) => o.utxo),
|
|
3902
|
+
null,
|
|
3903
|
+
null,
|
|
3904
|
+
sysParams,
|
|
3905
|
+
context.lucid,
|
|
3906
|
+
context.emulator.slot,
|
|
3907
|
+
),
|
|
3908
|
+
);
|
|
3909
|
+
});
|
|
3910
|
+
|
|
3048
3911
|
test<MyContext>('Execute update collateral asset proposal', async (context: MyContext) => {
|
|
3049
3912
|
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
3050
3913
|
|