@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,132 +0,0 @@
|
|
|
1
|
-
import { LucidEvolution, toHex, UTxO } from '@lucid-evolution/lucid';
|
|
2
|
-
import {
|
|
3
|
-
assetClassToUnit,
|
|
4
|
-
matchSingle,
|
|
5
|
-
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
6
|
-
import { option as O, array as A, function as F } from 'fp-ts';
|
|
7
|
-
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
8
|
-
import {
|
|
9
|
-
AccountContent,
|
|
10
|
-
parseAccountDatum,
|
|
11
|
-
parseSnapshotEpochToScaleToSumDatum,
|
|
12
|
-
parseStabilityPoolDatum,
|
|
13
|
-
SnapshotEpochToScaleToSumContent,
|
|
14
|
-
StabilityPoolContent,
|
|
15
|
-
} from './types-new';
|
|
16
|
-
import { mkStabilityPoolAddr } from './helpers';
|
|
17
|
-
|
|
18
|
-
export async function findStabilityPool(
|
|
19
|
-
lucid: LucidEvolution,
|
|
20
|
-
sysParams: SystemParams,
|
|
21
|
-
/**
|
|
22
|
-
* For conversion from hex use the `fromHex` function from lucid-evolution.
|
|
23
|
-
*/
|
|
24
|
-
iassetName: Uint8Array<ArrayBufferLike>,
|
|
25
|
-
): Promise<{ utxo: UTxO; datum: StabilityPoolContent }> {
|
|
26
|
-
// We need to consider both with staking credential and without.
|
|
27
|
-
const spUtxos = await lucid.utxosAtWithUnit(
|
|
28
|
-
{ hash: sysParams.validatorHashes.stabilityPoolHash, type: 'Script' },
|
|
29
|
-
assetClassToUnit(
|
|
30
|
-
fromSystemParamsAsset(sysParams.stabilityPoolParams.stabilityPoolToken),
|
|
31
|
-
),
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return matchSingle(
|
|
35
|
-
F.pipe(
|
|
36
|
-
spUtxos.map((utxo) =>
|
|
37
|
-
F.pipe(
|
|
38
|
-
O.fromNullable(utxo.datum),
|
|
39
|
-
O.flatMap(parseStabilityPoolDatum),
|
|
40
|
-
O.flatMap((datum) => {
|
|
41
|
-
if (toHex(datum.iasset) == toHex(iassetName)) {
|
|
42
|
-
return O.some({ utxo, datum: datum });
|
|
43
|
-
} else {
|
|
44
|
-
return O.none;
|
|
45
|
-
}
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
48
|
-
),
|
|
49
|
-
A.compact,
|
|
50
|
-
),
|
|
51
|
-
(res) =>
|
|
52
|
-
new Error(
|
|
53
|
-
'Expected a single Stability Pool UTXO.: ' + JSON.stringify(res),
|
|
54
|
-
),
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function findStabilityPoolAccount(
|
|
59
|
-
lucid: LucidEvolution,
|
|
60
|
-
sysParams: SystemParams,
|
|
61
|
-
owner: string,
|
|
62
|
-
/**
|
|
63
|
-
* For conversion from hex use the `fromHex` function from lucid-evolution.
|
|
64
|
-
*/
|
|
65
|
-
iassetName: Uint8Array<ArrayBufferLike>,
|
|
66
|
-
): Promise<{ utxo: UTxO; datum: AccountContent }> {
|
|
67
|
-
// We need to consider both with staking credential and without.
|
|
68
|
-
const spUtxos = await lucid.utxosAt({
|
|
69
|
-
hash: sysParams.validatorHashes.stabilityPoolHash,
|
|
70
|
-
type: 'Script',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return matchSingle(
|
|
74
|
-
F.pipe(
|
|
75
|
-
spUtxos.map((utxo) =>
|
|
76
|
-
F.pipe(
|
|
77
|
-
O.fromNullable(utxo.datum),
|
|
78
|
-
O.flatMap(parseAccountDatum),
|
|
79
|
-
O.flatMap((datum) => {
|
|
80
|
-
if (
|
|
81
|
-
toHex(datum.iasset) == toHex(iassetName) &&
|
|
82
|
-
toHex(datum.owner) == owner
|
|
83
|
-
) {
|
|
84
|
-
return O.some({ utxo, datum: datum });
|
|
85
|
-
} else {
|
|
86
|
-
return O.none;
|
|
87
|
-
}
|
|
88
|
-
}),
|
|
89
|
-
),
|
|
90
|
-
),
|
|
91
|
-
A.compact,
|
|
92
|
-
),
|
|
93
|
-
(res) =>
|
|
94
|
-
new Error('Expected a single Account UTXO.: ' + JSON.stringify(res)),
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export async function findE2s2sSnapshots(
|
|
99
|
-
lucid: LucidEvolution,
|
|
100
|
-
sysParams: SystemParams,
|
|
101
|
-
/**
|
|
102
|
-
* For conversion from hex use the `fromHex` function from lucid-evolution.
|
|
103
|
-
*/
|
|
104
|
-
iassetName: Uint8Array<ArrayBufferLike>,
|
|
105
|
-
): Promise<{ utxo: UTxO; datum: SnapshotEpochToScaleToSumContent }[]> {
|
|
106
|
-
// No need to query the ones without stake cred, e2s2s will always have stake cred based on script params.
|
|
107
|
-
const spUtxos = await lucid.utxosAtWithUnit(
|
|
108
|
-
mkStabilityPoolAddr(lucid, sysParams),
|
|
109
|
-
assetClassToUnit(
|
|
110
|
-
fromSystemParamsAsset(
|
|
111
|
-
sysParams.stabilityPoolParams.snapshotEpochToScaleToSumToken,
|
|
112
|
-
),
|
|
113
|
-
),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
return F.pipe(
|
|
117
|
-
spUtxos.map((utxo) =>
|
|
118
|
-
F.pipe(
|
|
119
|
-
O.fromNullable(utxo.datum),
|
|
120
|
-
O.flatMap(parseSnapshotEpochToScaleToSumDatum),
|
|
121
|
-
O.flatMap((datum) => {
|
|
122
|
-
if (toHex(datum.iasset) == toHex(iassetName)) {
|
|
123
|
-
return O.some({ utxo, datum: datum });
|
|
124
|
-
} else {
|
|
125
|
-
return O.none;
|
|
126
|
-
}
|
|
127
|
-
}),
|
|
128
|
-
),
|
|
129
|
-
),
|
|
130
|
-
A.compact,
|
|
131
|
-
);
|
|
132
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { applyParamsToScript, SpendingValidator } from '@lucid-evolution/lucid';
|
|
2
|
-
import { castStabilityPoolParams, StabilityPoolParams } from './types';
|
|
3
|
-
import {
|
|
4
|
-
fromSysParamsStakeCredential,
|
|
5
|
-
fromSystemParamsAssetLucid,
|
|
6
|
-
StabilityPoolParamsSP,
|
|
7
|
-
} from '../../types/system-params';
|
|
8
|
-
import { _stabilityPoolValidator } from '../../validators/stability-pool-validator';
|
|
9
|
-
|
|
10
|
-
export const mkStabilityPoolValidator = (
|
|
11
|
-
params: StabilityPoolParams,
|
|
12
|
-
): SpendingValidator => {
|
|
13
|
-
return {
|
|
14
|
-
type: 'PlutusV3',
|
|
15
|
-
script: applyParamsToScript(_stabilityPoolValidator.cborHex, [
|
|
16
|
-
castStabilityPoolParams(params),
|
|
17
|
-
]),
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const mkStabilityPoolValidatorFromSP = (
|
|
22
|
-
params: StabilityPoolParamsSP,
|
|
23
|
-
): SpendingValidator => {
|
|
24
|
-
return {
|
|
25
|
-
type: 'PlutusV3',
|
|
26
|
-
script: applyParamsToScript(_stabilityPoolValidator.cborHex, [
|
|
27
|
-
castStabilityPoolParams({
|
|
28
|
-
assetSymbol: params.assetSymbol.unCurrencySymbol,
|
|
29
|
-
stabilityPoolToken: fromSystemParamsAssetLucid(
|
|
30
|
-
params.stabilityPoolToken,
|
|
31
|
-
),
|
|
32
|
-
snapshotEpochToScaleToSumToken: fromSystemParamsAssetLucid(
|
|
33
|
-
params.snapshotEpochToScaleToSumToken,
|
|
34
|
-
),
|
|
35
|
-
accountToken: fromSystemParamsAssetLucid(params.accountToken),
|
|
36
|
-
cdpToken: fromSystemParamsAssetLucid(params.cdpToken),
|
|
37
|
-
iAssetAuthToken: fromSystemParamsAssetLucid(params.iAssetAuthToken),
|
|
38
|
-
versionRecordToken: fromSystemParamsAssetLucid(
|
|
39
|
-
params.versionRecordToken,
|
|
40
|
-
),
|
|
41
|
-
iassetValHash: params.iassetValHash,
|
|
42
|
-
accountCreateFeeLovelaces: BigInt(params.accountCreateFeeLovelaces),
|
|
43
|
-
accountProcessingCooldownMs: BigInt(params.accountProcessingCooldownMs),
|
|
44
|
-
accountProcessingBiasMs: BigInt(params.accountProcessingBiasMs),
|
|
45
|
-
stakeCredential: params.stakeCredential
|
|
46
|
-
? fromSysParamsStakeCredential(params.stakeCredential)
|
|
47
|
-
: null,
|
|
48
|
-
}),
|
|
49
|
-
]),
|
|
50
|
-
};
|
|
51
|
-
};
|