@indigo-labs/indigo-sdk 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +17 -0
- package/dist/index.mjs +15 -0
- package/package.json +11 -1
- package/.claude/settings.local.json +0 -7
- package/.github/workflows/ci.yml +0 -66
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/.prettierignore +0 -1
- package/.prettierrc +0 -6
- package/eslint.config.mjs +0 -42
- package/scripts/bench.sh +0 -62
- package/scripts/run-repeat.sh +0 -22
- package/src/contracts/cdp/helpers.ts +0 -173
- package/src/contracts/cdp/scripts.ts +0 -70
- package/src/contracts/cdp/transactions.ts +0 -1584
- package/src/contracts/cdp/types-new.ts +0 -277
- package/src/contracts/cdp/types.ts +0 -43
- package/src/contracts/cdp-creator/queries.ts +0 -30
- package/src/contracts/cdp-creator/scripts.ts +0 -45
- package/src/contracts/cdp-creator/types-new.ts +0 -50
- package/src/contracts/cdp-creator/types.ts +0 -24
- package/src/contracts/collector/scripts.ts +0 -32
- package/src/contracts/collector/transactions.ts +0 -50
- package/src/contracts/collector/types-new.ts +0 -17
- package/src/contracts/execute/scripts.ts +0 -57
- package/src/contracts/execute/types-new.ts +0 -44
- package/src/contracts/execute/types.ts +0 -24
- package/src/contracts/gov/helpers.ts +0 -351
- package/src/contracts/gov/scripts.ts +0 -41
- package/src/contracts/gov/transactions.ts +0 -1607
- package/src/contracts/gov/types-new.ts +0 -268
- package/src/contracts/gov/types.ts +0 -22
- package/src/contracts/iasset/helpers.ts +0 -170
- package/src/contracts/iasset/queries.ts +0 -102
- package/src/contracts/iasset/scripts.ts +0 -38
- package/src/contracts/iasset/types.ts +0 -154
- package/src/contracts/initialize/actions.ts +0 -789
- package/src/contracts/initialize/helpers.ts +0 -616
- package/src/contracts/initialize/types.ts +0 -116
- package/src/contracts/interest-collection/helpers.ts +0 -19
- package/src/contracts/interest-collection/queries.ts +0 -66
- package/src/contracts/interest-collection/scripts.ts +0 -44
- package/src/contracts/interest-collection/transactions.ts +0 -433
- package/src/contracts/interest-collection/types-new.ts +0 -50
- package/src/contracts/interest-collection/types.ts +0 -26
- package/src/contracts/interest-oracle/helpers.ts +0 -61
- package/src/contracts/interest-oracle/scripts.ts +0 -18
- package/src/contracts/interest-oracle/transactions.ts +0 -151
- package/src/contracts/interest-oracle/types-new.ts +0 -32
- package/src/contracts/interest-oracle/types.ts +0 -16
- package/src/contracts/one-shot/scripts.ts +0 -12
- package/src/contracts/one-shot/transactions.ts +0 -66
- package/src/contracts/one-shot/types.ts +0 -22
- package/src/contracts/poll/helpers.ts +0 -37
- package/src/contracts/poll/scripts.ts +0 -71
- package/src/contracts/poll/types-poll-manager.ts +0 -20
- package/src/contracts/poll/types-poll-new.ts +0 -196
- package/src/contracts/poll/types-poll-shard.ts +0 -16
- package/src/contracts/price-oracle/helpers.ts +0 -30
- package/src/contracts/price-oracle/scripts.ts +0 -18
- package/src/contracts/price-oracle/transactions.ts +0 -115
- package/src/contracts/price-oracle/types-new.ts +0 -50
- package/src/contracts/price-oracle/types.ts +0 -16
- package/src/contracts/pyth-feed/helpers.ts +0 -82
- package/src/contracts/pyth-feed/scripts.ts +0 -15
- package/src/contracts/pyth-feed/types.ts +0 -181
- package/src/contracts/rob/helpers.ts +0 -666
- package/src/contracts/rob/scripts.ts +0 -35
- package/src/contracts/rob/transactions.ts +0 -423
- package/src/contracts/rob/types-new.ts +0 -128
- package/src/contracts/rob/types.ts +0 -16
- package/src/contracts/rob-leverage/helpers.ts +0 -422
- package/src/contracts/rob-leverage/transactions.ts +0 -368
- package/src/contracts/stability-pool/helpers.ts +0 -798
- package/src/contracts/stability-pool/queries.ts +0 -132
- package/src/contracts/stability-pool/scripts.ts +0 -51
- package/src/contracts/stability-pool/transactions.ts +0 -921
- package/src/contracts/stability-pool/types-new.ts +0 -385
- package/src/contracts/stability-pool/types.ts +0 -25
- package/src/contracts/stableswap/helpers.ts +0 -507
- package/src/contracts/stableswap/scripts.ts +0 -37
- package/src/contracts/stableswap/transactions.ts +0 -475
- package/src/contracts/stableswap/types-new.ts +0 -131
- package/src/contracts/stableswap/types.ts +0 -17
- package/src/contracts/staking/helpers.ts +0 -136
- package/src/contracts/staking/scripts.ts +0 -41
- package/src/contracts/staking/transactions.ts +0 -349
- package/src/contracts/staking/types-new.ts +0 -137
- package/src/contracts/staking/types.ts +0 -17
- package/src/contracts/treasury/helpers.ts +0 -21
- package/src/contracts/treasury/queries.ts +0 -100
- package/src/contracts/treasury/scripts.ts +0 -27
- package/src/contracts/treasury/transactions.ts +0 -334
- package/src/contracts/treasury/types-new.ts +0 -69
- package/src/contracts/treasury/types.ts +0 -14
- package/src/contracts/version-registry/scripts.ts +0 -29
- package/src/contracts/version-registry/types-new.ts +0 -18
- package/src/contracts/version-registry/types.ts +0 -17
- package/src/index.ts +0 -93
- package/src/scripts/always-fail-validator.ts +0 -7
- package/src/scripts/auth-token-policy.ts +0 -24
- package/src/scripts/iasset-policy.ts +0 -23
- package/src/types/evolution-schema-options.ts +0 -16
- package/src/types/generic.ts +0 -52
- package/src/types/multisig.ts +0 -48
- package/src/types/on-chain-decimal.ts +0 -57
- package/src/types/rational.ts +0 -61
- package/src/types/system-params.ts +0 -463
- package/src/utils/array-utils.ts +0 -108
- package/src/utils/bigint-utils.ts +0 -35
- package/src/utils/helper-txs.ts +0 -31
- package/src/utils/indigo-helpers.ts +0 -17
- package/src/utils/lucid-utils.ts +0 -125
- package/src/utils/oracle-helpers.ts +0 -62
- package/src/utils/pyth/decode.ts +0 -223
- package/src/utils/pyth/encode.ts +0 -262
- package/src/utils/pyth/index.ts +0 -14
- package/src/utils/pyth/types.ts +0 -87
- package/src/utils/time-helpers.ts +0 -4
- package/src/utils/utils.ts +0 -25
- package/src/validators/always-succeed-validator.ts +0 -6
- package/src/validators/cdp-creator-validator.ts +0 -7
- package/src/validators/cdp-redeem-validator.ts +0 -7
- package/src/validators/cdp-validator.ts +0 -7
- package/src/validators/collector-validator.ts +0 -7
- package/src/validators/execute-validator.ts +0 -7
- package/src/validators/governance-validator.ts +0 -7
- package/src/validators/iasset-validator.ts +0 -7
- package/src/validators/interest-collection-validator.ts +0 -7
- package/src/validators/interest-oracle-validator.ts +0 -7
- package/src/validators/one-shot-policy.ts +0 -7
- package/src/validators/poll-manager-validator.ts +0 -7
- package/src/validators/poll-shard-validator.ts +0 -7
- package/src/validators/price-oracle-validator.ts +0 -7
- package/src/validators/pyth-feed-validator.ts +0 -7
- package/src/validators/rob-validator.ts +0 -7
- package/src/validators/stability-pool-validator.ts +0 -7
- package/src/validators/stableswap-validator.ts +0 -7
- package/src/validators/staking-validator.ts +0 -7
- package/src/validators/treasury-validator.ts +0 -7
- package/src/validators/version-record-policy.ts +0 -7
- package/src/validators/version-registry-validator.ts +0 -7
- package/tests/always-succeed/script.ts +0 -7
- package/tests/array-utils.test.ts +0 -92
- package/tests/bigint-utils.test.ts +0 -41
- package/tests/cdp/actions.ts +0 -680
- package/tests/cdp/cdp-helpers.ts +0 -55
- package/tests/cdp/cdp-queries.ts +0 -423
- package/tests/cdp/cdp.test.ts +0 -6730
- package/tests/cdp/transactions-mutated.ts +0 -1733
- package/tests/data/system-params.json +0 -1155
- package/tests/datums.test.ts +0 -302
- package/tests/endpoints/initialize.ts +0 -78
- package/tests/endpoints/interest-collector.ts +0 -37
- package/tests/endpoints/treasury.ts +0 -70
- package/tests/gov/actions.ts +0 -381
- package/tests/gov/gov.test.ts +0 -5147
- package/tests/gov/governance-queries.ts +0 -37
- package/tests/hash-checks.test.ts +0 -112
- package/tests/indigo-test-helpers.ts +0 -99
- package/tests/initialize.test.ts +0 -79
- package/tests/interest-calculations.test.ts +0 -120
- package/tests/interest-collection/interest-collection.test.ts +0 -843
- package/tests/interest-collection/transactions-mutated.ts +0 -260
- package/tests/interest-oracle.test.ts +0 -93
- package/tests/mock/assets-mock.ts +0 -243
- package/tests/mock/protocol-params-mock.ts +0 -21
- package/tests/price-oracle/actions.ts +0 -161
- package/tests/price-oracle/price-oracle-queries.ts +0 -12
- package/tests/price-oracle/price-oracle.test.ts +0 -228
- package/tests/price-oracle/transactions-mutated.ts +0 -59
- package/tests/pyth/endpoints.ts +0 -96
- package/tests/pyth/helpers.ts +0 -37
- package/tests/pyth/pyth-encoding.test.ts +0 -376
- package/tests/pyth/pyth-feeds.test.ts +0 -943
- package/tests/pyth/pyth-indigo.test.ts +0 -505
- package/tests/pyth/pyth.test.ts +0 -299
- package/tests/queries/collector-queries.ts +0 -27
- package/tests/queries/execute-queries.ts +0 -47
- package/tests/queries/iasset-queries.ts +0 -149
- package/tests/queries/interest-oracle-queries.ts +0 -12
- package/tests/queries/poll-queries.ts +0 -97
- package/tests/queries/staking-queries.ts +0 -54
- package/tests/rob/actions.ts +0 -56
- package/tests/rob/rob-leverage.test.ts +0 -2555
- package/tests/rob/rob-queries.ts +0 -95
- package/tests/rob/rob.test.ts +0 -3677
- package/tests/rob/transactions-mutated.ts +0 -844
- package/tests/script-size.test.ts +0 -240
- package/tests/setup.ts +0 -135
- package/tests/stability-pool/actions.ts +0 -229
- package/tests/stability-pool.test.ts +0 -6491
- package/tests/stableswap/stableswap-actions.ts +0 -83
- package/tests/stableswap/stableswap-queries.ts +0 -98
- package/tests/stableswap/stableswap.test.ts +0 -4471
- package/tests/stableswap/transactions-mutated.ts +0 -348
- package/tests/staking.test.ts +0 -172
- package/tests/test-helpers.ts +0 -94
- package/tests/treasury/actions.ts +0 -67
- package/tests/treasury/treasury.test.ts +0 -320
- package/tests/utils/asserts.ts +0 -87
- package/tests/utils/benchmark-utils.ts +0 -130
- package/tests/utils/index.ts +0 -168
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -27
- package/vitest.config.ts +0 -11
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { fromHex, fromText, paymentCredentialOf } from '@lucid-evolution/lucid';
|
|
2
|
-
import { createProposal, fromSystemParamsAsset } from '../../src';
|
|
3
|
-
import { processSuccessfulProposal } from '../gov/actions';
|
|
4
|
-
import { AssetClass } from '@3rd-eye-labs/cardano-offchain-common';
|
|
5
|
-
import { findGov } from '../gov/governance-queries';
|
|
6
|
-
import { IndigoTestContext, runAndAwaitTxBuilder } from '../test-helpers';
|
|
7
|
-
import { findRandomCdpCreator } from '../cdp/cdp-queries';
|
|
8
|
-
import { findIAsset } from '../queries/iasset-queries';
|
|
9
|
-
import { Rational, rationalFromInt } from '../../src/types/rational';
|
|
10
|
-
|
|
11
|
-
export async function runCreateStableswapPool(
|
|
12
|
-
iasset: string,
|
|
13
|
-
collateralAsset: AssetClass,
|
|
14
|
-
context: IndigoTestContext,
|
|
15
|
-
ratioAssets?: Rational,
|
|
16
|
-
mintingFeeRatio?: Rational,
|
|
17
|
-
redemptionFeeRatio?: Rational,
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
const feeManager = fromHex(
|
|
20
|
-
paymentCredentialOf(context.users.admin.address).hash,
|
|
21
|
-
);
|
|
22
|
-
const [tx, pollId] = await createProposal(
|
|
23
|
-
{
|
|
24
|
-
ProposeStableswapPool: {
|
|
25
|
-
iasset: fromHex(fromText(iasset)),
|
|
26
|
-
collateralAsset: collateralAsset,
|
|
27
|
-
collateralToIassetRatio: ratioAssets
|
|
28
|
-
? ratioAssets
|
|
29
|
-
: rationalFromInt(1n),
|
|
30
|
-
mintingFeeRatio: mintingFeeRatio
|
|
31
|
-
? mintingFeeRatio
|
|
32
|
-
: { numerator: 5n, denominator: 1_000n },
|
|
33
|
-
redemptionFeeRatio: redemptionFeeRatio
|
|
34
|
-
? redemptionFeeRatio
|
|
35
|
-
: { numerator: 5n, denominator: 1_000n },
|
|
36
|
-
feeManager: feeManager,
|
|
37
|
-
minMintingAmount: 0n,
|
|
38
|
-
minRedemptionAmount: 0n,
|
|
39
|
-
stableswapValHash: fromHex(
|
|
40
|
-
context.systemParams.validatorHashes.stableswapHash,
|
|
41
|
-
),
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
null,
|
|
45
|
-
context.systemParams,
|
|
46
|
-
context.lucid,
|
|
47
|
-
(
|
|
48
|
-
await findGov(
|
|
49
|
-
context.lucid,
|
|
50
|
-
context.systemParams.validatorHashes.govHash,
|
|
51
|
-
fromSystemParamsAsset(context.systemParams.govParams.govNFT),
|
|
52
|
-
)
|
|
53
|
-
).utxo,
|
|
54
|
-
undefined,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
await runAndAwaitTxBuilder(context.lucid, tx);
|
|
58
|
-
|
|
59
|
-
const iassetReference = await findIAsset(
|
|
60
|
-
context.lucid,
|
|
61
|
-
context.systemParams.validatorHashes.iassetHash,
|
|
62
|
-
fromSystemParamsAsset(context.systemParams.cdpParams.iAssetAuthToken),
|
|
63
|
-
'iUSD',
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const cdpCreatorUtxo = await findRandomCdpCreator(
|
|
67
|
-
context.lucid,
|
|
68
|
-
context.systemParams.validatorHashes.cdpCreatorHash,
|
|
69
|
-
fromSystemParamsAsset(context.systemParams.cdpCreatorParams.cdpCreatorNft),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
await processSuccessfulProposal(
|
|
73
|
-
pollId,
|
|
74
|
-
null,
|
|
75
|
-
null,
|
|
76
|
-
iassetReference.utxo,
|
|
77
|
-
null,
|
|
78
|
-
null,
|
|
79
|
-
cdpCreatorUtxo,
|
|
80
|
-
context.systemParams,
|
|
81
|
-
context,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { AssetClass, matchSingle } from '@3rd-eye-labs/cardano-offchain-common';
|
|
2
|
-
import {
|
|
3
|
-
LucidEvolution,
|
|
4
|
-
ScriptHash,
|
|
5
|
-
toHex,
|
|
6
|
-
UTxO,
|
|
7
|
-
} from '@lucid-evolution/lucid';
|
|
8
|
-
import {
|
|
9
|
-
parseStableswapOrderDatum,
|
|
10
|
-
StableswapOrderDatum,
|
|
11
|
-
} from '../../src/contracts/stableswap/types-new';
|
|
12
|
-
import { createScriptAddress } from '../../src';
|
|
13
|
-
import { array as A, function as F, option as O } from 'fp-ts';
|
|
14
|
-
|
|
15
|
-
export async function findSingleStableswapOrder(
|
|
16
|
-
lucid: LucidEvolution,
|
|
17
|
-
stableswapScriptHash: ScriptHash,
|
|
18
|
-
iassetName: string,
|
|
19
|
-
collateralAsset: AssetClass,
|
|
20
|
-
): Promise<{ utxo: UTxO; datum: StableswapOrderDatum }> {
|
|
21
|
-
const cdpUtxos = await lucid.utxosAt(
|
|
22
|
-
createScriptAddress(lucid.config().network!, stableswapScriptHash),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
return matchSingle(
|
|
26
|
-
F.pipe(
|
|
27
|
-
cdpUtxos.map((utxo) =>
|
|
28
|
-
F.pipe(
|
|
29
|
-
O.fromNullable(utxo.datum),
|
|
30
|
-
O.flatMap(parseStableswapOrderDatum),
|
|
31
|
-
O.flatMap((datum) => {
|
|
32
|
-
if (
|
|
33
|
-
toHex(datum.iasset) === iassetName &&
|
|
34
|
-
toHex(datum.collateralAsset.currencySymbol) ===
|
|
35
|
-
toHex(collateralAsset.currencySymbol) &&
|
|
36
|
-
toHex(datum.collateralAsset.tokenName) ===
|
|
37
|
-
toHex(collateralAsset.tokenName)
|
|
38
|
-
) {
|
|
39
|
-
return O.some({ utxo, datum: datum });
|
|
40
|
-
} else {
|
|
41
|
-
return O.none;
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
),
|
|
46
|
-
A.compact,
|
|
47
|
-
),
|
|
48
|
-
(res) =>
|
|
49
|
-
new Error(
|
|
50
|
-
'Expected a single stableswap order UTXO.: ' + JSON.stringify(res),
|
|
51
|
-
),
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export async function findAllStableswapOrders(
|
|
56
|
-
lucid: LucidEvolution,
|
|
57
|
-
stableswapScriptHash: ScriptHash,
|
|
58
|
-
): Promise<{ utxo: UTxO; datum: StableswapOrderDatum }[]> {
|
|
59
|
-
const psmUtxos = await lucid.utxosAt(
|
|
60
|
-
createScriptAddress(lucid.config().network!, stableswapScriptHash),
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const orders = F.pipe(
|
|
64
|
-
psmUtxos.map((utxo) =>
|
|
65
|
-
F.pipe(
|
|
66
|
-
O.fromNullable(utxo.datum),
|
|
67
|
-
O.flatMap(parseStableswapOrderDatum),
|
|
68
|
-
O.map((datum) => {
|
|
69
|
-
return { utxo, datum: datum };
|
|
70
|
-
}),
|
|
71
|
-
),
|
|
72
|
-
),
|
|
73
|
-
A.compact,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return orders;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function findStableswapOrders(
|
|
80
|
-
lucid: LucidEvolution,
|
|
81
|
-
stableswapScriptHash: ScriptHash,
|
|
82
|
-
iassetName: string,
|
|
83
|
-
collateralAsset: AssetClass,
|
|
84
|
-
): Promise<{ utxo: UTxO; datum: StableswapOrderDatum }[]> {
|
|
85
|
-
const allPsmOrders = await findAllStableswapOrders(
|
|
86
|
-
lucid,
|
|
87
|
-
stableswapScriptHash,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
return allPsmOrders.filter(
|
|
91
|
-
(order) =>
|
|
92
|
-
toHex(order.datum.iasset) === iassetName &&
|
|
93
|
-
toHex(order.datum.collateralAsset.currencySymbol) ===
|
|
94
|
-
toHex(collateralAsset.currencySymbol) &&
|
|
95
|
-
toHex(order.datum.collateralAsset.tokenName) ===
|
|
96
|
-
toHex(collateralAsset.tokenName),
|
|
97
|
-
);
|
|
98
|
-
}
|