@indigo-labs/indigo-sdk 0.4.0 → 0.4.1
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/.claude/settings.local.json +7 -0
- package/.github/workflows/ci.yml +0 -1
- package/README.md +16 -0
- package/dist/index.d.mts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.js +587 -355
- package/dist/index.mjs +422 -187
- package/package.json +12 -20
- package/scripts/bench.sh +0 -0
- package/src/contracts/cdp-creator/queries.ts +30 -0
- package/src/contracts/iasset/queries.ts +102 -0
- package/src/contracts/initialize/actions.ts +12 -5
- package/{tests/interest-collection/interest-collector-queries.ts → src/contracts/interest-collection/queries.ts} +28 -12
- package/src/contracts/pyth-feed/helpers.ts +24 -0
- package/{tests/treasury/treasury-queries.ts → src/contracts/treasury/queries.ts} +15 -24
- package/src/index.ts +6 -1
- package/tests/cdp/actions.ts +1 -1
- package/tests/cdp/cdp-queries.ts +3 -23
- package/tests/cdp/transactions-mutated.ts +3 -4
- package/tests/gov/gov.test.ts +18 -18
- package/tests/interest-collection/interest-collection.test.ts +17 -62
- package/tests/queries/iasset-queries.ts +1 -84
- package/tests/rob/rob.test.ts +52 -52
- package/tests/stableswap/stableswap.test.ts +1 -1
- package/tests/treasury/actions.ts +1 -1
- package/tests/treasury/treasury.test.ts +1 -1
package/package.json
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigo-labs/indigo-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --clean --tsconfig tsconfig.build.json",
|
|
10
|
-
"type-check": "tsc --noEmit",
|
|
11
|
-
"lint": "pnpm eslint .",
|
|
12
|
-
"lint:fix": "npx eslint --fix .",
|
|
13
|
-
"repack": "pnpm run build && pnpm pack",
|
|
14
|
-
"format": "npx prettier --write src/ tests/",
|
|
15
|
-
"format:check": "npx prettier --check src/ tests/",
|
|
16
|
-
"test": "vitest run",
|
|
17
|
-
"prepare": "husky",
|
|
18
|
-
"lint-staged": "lint-staged"
|
|
19
|
-
},
|
|
20
8
|
"lint-staged": {
|
|
21
9
|
"*.{js,ts,jsx,tsx}": [
|
|
22
10
|
"prettier --write",
|
|
@@ -39,7 +27,6 @@
|
|
|
39
27
|
],
|
|
40
28
|
"author": "3rd Eye Labs",
|
|
41
29
|
"license": "MIT",
|
|
42
|
-
"packageManager": "pnpm@10.33.4",
|
|
43
30
|
"dependencies": {
|
|
44
31
|
"@3rd-eye-labs/cardano-offchain-common": "1.4.7",
|
|
45
32
|
"@evolution-sdk/evolution": "^0.3.22",
|
|
@@ -71,10 +58,15 @@
|
|
|
71
58
|
"typescript-eslint": "^8.39.0",
|
|
72
59
|
"vitest": "^4.0.14"
|
|
73
60
|
},
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean --tsconfig tsconfig.build.json",
|
|
63
|
+
"type-check": "tsc --noEmit",
|
|
64
|
+
"lint": "pnpm eslint .",
|
|
65
|
+
"lint:fix": "npx eslint --fix .",
|
|
66
|
+
"repack": "pnpm run build && pnpm pack",
|
|
67
|
+
"format": "npx prettier --write src/ tests/",
|
|
68
|
+
"format:check": "npx prettier --check src/ tests/",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"lint-staged": "lint-staged"
|
|
79
71
|
}
|
|
80
|
-
}
|
|
72
|
+
}
|
package/scripts/bench.sh
CHANGED
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assetClassToUnit,
|
|
3
|
+
getRandomElement,
|
|
4
|
+
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
5
|
+
import { LucidEvolution, UTxO } from '@lucid-evolution/lucid';
|
|
6
|
+
import { option as O, function as F } from 'fp-ts';
|
|
7
|
+
import { createScriptAddress } from '../../utils/lucid-utils';
|
|
8
|
+
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
9
|
+
|
|
10
|
+
export async function findRandomCdpCreator(
|
|
11
|
+
lucid: LucidEvolution,
|
|
12
|
+
sysParams: SystemParams,
|
|
13
|
+
): Promise<UTxO> {
|
|
14
|
+
const cdpCreatorUtxos = await lucid.utxosAtWithUnit(
|
|
15
|
+
createScriptAddress(
|
|
16
|
+
lucid.config().network!,
|
|
17
|
+
sysParams.validatorHashes.cdpCreatorHash,
|
|
18
|
+
),
|
|
19
|
+
assetClassToUnit(
|
|
20
|
+
fromSystemParamsAsset(sysParams.cdpCreatorParams.cdpCreatorNft),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return F.pipe(
|
|
25
|
+
O.fromNullable(getRandomElement(cdpCreatorUtxos)),
|
|
26
|
+
O.match(() => {
|
|
27
|
+
throw new Error('Expected some cdp creator UTXOs.');
|
|
28
|
+
}, F.identity),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { LucidEvolution, toHex } from '@lucid-evolution/lucid';
|
|
2
|
+
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
3
|
+
import {
|
|
4
|
+
AssetClass,
|
|
5
|
+
assetClassToUnit,
|
|
6
|
+
isSameAssetClass,
|
|
7
|
+
matchSingle,
|
|
8
|
+
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
9
|
+
import {
|
|
10
|
+
CollateralAssetOutput,
|
|
11
|
+
IAssetOutput,
|
|
12
|
+
parseCollateralAssetDatum,
|
|
13
|
+
parseIAssetDatum,
|
|
14
|
+
} from './types';
|
|
15
|
+
import { createScriptAddress } from '../../utils/lucid-utils';
|
|
16
|
+
import { option as O, array as A, function as F } from 'fp-ts';
|
|
17
|
+
|
|
18
|
+
export async function findIAsset(
|
|
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<IAssetOutput> {
|
|
26
|
+
const iassetUtxos = await lucid.utxosAtWithUnit(
|
|
27
|
+
createScriptAddress(
|
|
28
|
+
lucid.config().network!,
|
|
29
|
+
sysParams.validatorHashes.iassetHash,
|
|
30
|
+
),
|
|
31
|
+
assetClassToUnit(
|
|
32
|
+
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return matchSingle(
|
|
37
|
+
F.pipe(
|
|
38
|
+
iassetUtxos.map((utxo) =>
|
|
39
|
+
F.pipe(
|
|
40
|
+
O.fromNullable(utxo.datum),
|
|
41
|
+
O.flatMap(parseIAssetDatum),
|
|
42
|
+
O.flatMap((datum) => {
|
|
43
|
+
if (toHex(datum.assetName) === toHex(iassetName)) {
|
|
44
|
+
return O.some({ utxo, datum: datum });
|
|
45
|
+
} else {
|
|
46
|
+
return O.none;
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
A.compact,
|
|
52
|
+
),
|
|
53
|
+
(res) =>
|
|
54
|
+
new Error('Expected a single IAsset UTXO.: ' + JSON.stringify(res)),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function findCollateralAsset(
|
|
59
|
+
lucid: LucidEvolution,
|
|
60
|
+
sysParams: SystemParams,
|
|
61
|
+
/**
|
|
62
|
+
* For conversion from hex use the `fromHex` function from lucid-evolution.
|
|
63
|
+
*/
|
|
64
|
+
iassetName: Uint8Array<ArrayBufferLike>,
|
|
65
|
+
collateralAsset: AssetClass,
|
|
66
|
+
): Promise<CollateralAssetOutput> {
|
|
67
|
+
const collateralAssetUtxos = await lucid.utxosAtWithUnit(
|
|
68
|
+
createScriptAddress(
|
|
69
|
+
lucid.config().network!,
|
|
70
|
+
sysParams.validatorHashes.iassetHash,
|
|
71
|
+
),
|
|
72
|
+
assetClassToUnit(
|
|
73
|
+
fromSystemParamsAsset(sysParams.cdpParams.collateralAssetAuthToken),
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return matchSingle(
|
|
78
|
+
F.pipe(
|
|
79
|
+
collateralAssetUtxos.map((utxo) =>
|
|
80
|
+
F.pipe(
|
|
81
|
+
O.fromNullable(utxo.datum),
|
|
82
|
+
O.flatMap(parseCollateralAssetDatum),
|
|
83
|
+
O.flatMap((datum) => {
|
|
84
|
+
if (
|
|
85
|
+
isSameAssetClass(datum.collateralAsset, collateralAsset) &&
|
|
86
|
+
toHex(iassetName) === toHex(datum.iasset)
|
|
87
|
+
) {
|
|
88
|
+
return O.some({ utxo, datum: datum });
|
|
89
|
+
} else {
|
|
90
|
+
return O.none;
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
A.compact,
|
|
96
|
+
),
|
|
97
|
+
(res) =>
|
|
98
|
+
new Error(
|
|
99
|
+
'Expected a single Collateral Asset UTXO.: ' + JSON.stringify(res),
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
@@ -131,11 +131,14 @@ export async function initPythConfig(
|
|
|
131
131
|
}),
|
|
132
132
|
),
|
|
133
133
|
);
|
|
134
|
-
|
|
135
134
|
} catch (error) {
|
|
136
|
-
const message =
|
|
135
|
+
const message =
|
|
136
|
+
error instanceof Error ? error.message : String(error);
|
|
137
137
|
if (
|
|
138
|
-
!message.includes('StakeKeyRegisteredDELEG') &&
|
|
138
|
+
!message.includes('StakeKeyRegisteredDELEG') &&
|
|
139
|
+
!message.includes(
|
|
140
|
+
'Trying to re-register some already known credentials.',
|
|
141
|
+
)
|
|
139
142
|
) {
|
|
140
143
|
throw error;
|
|
141
144
|
}
|
|
@@ -377,11 +380,15 @@ export async function init(
|
|
|
377
380
|
);
|
|
378
381
|
|
|
379
382
|
try {
|
|
380
|
-
await runAndAwaitTxBuilder(
|
|
383
|
+
await runAndAwaitTxBuilder(
|
|
384
|
+
lucid,
|
|
385
|
+
lucid.newTx().register.Stake(cdpRedeemRewardAddr),
|
|
386
|
+
);
|
|
381
387
|
} catch (error) {
|
|
382
388
|
const message = error instanceof Error ? error.message : String(error);
|
|
383
389
|
if (
|
|
384
|
-
!message.includes('StakeKeyRegisteredDELEG') &&
|
|
390
|
+
!message.includes('StakeKeyRegisteredDELEG') &&
|
|
391
|
+
!message.includes('Trying to re-register some already known credentials.')
|
|
385
392
|
) {
|
|
386
393
|
throw error;
|
|
387
394
|
}
|
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
import { LucidEvolution, UTxO } from '@lucid-evolution/lucid';
|
|
2
|
-
import { createScriptAddress } from '../../src';
|
|
3
2
|
import { option as O, function as F } from 'fp-ts';
|
|
4
3
|
import {
|
|
5
|
-
AssetClass,
|
|
6
4
|
assetClassToUnit,
|
|
7
5
|
assetClassValueOf,
|
|
8
6
|
getRandomElement,
|
|
9
7
|
matchSingle,
|
|
10
8
|
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
9
|
+
import { createScriptAddress } from '../../utils/lucid-utils';
|
|
10
|
+
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
11
11
|
|
|
12
12
|
export async function findAllInterestCollectors(
|
|
13
13
|
lucid: LucidEvolution,
|
|
14
|
-
|
|
14
|
+
sysParams: SystemParams,
|
|
15
15
|
): Promise<UTxO[]> {
|
|
16
16
|
return lucid.utxosAt(
|
|
17
|
-
createScriptAddress(
|
|
17
|
+
createScriptAddress(
|
|
18
|
+
lucid.config().network!,
|
|
19
|
+
sysParams.validatorHashes.interestCollectionHash,
|
|
20
|
+
),
|
|
18
21
|
);
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export async function findAdminInterestCollectors(
|
|
22
25
|
lucid: LucidEvolution,
|
|
23
|
-
|
|
24
|
-
multisigUtxoNft: AssetClass,
|
|
26
|
+
sysParams: SystemParams,
|
|
25
27
|
): Promise<UTxO> {
|
|
26
28
|
return matchSingle(
|
|
27
29
|
await lucid.utxosAtWithUnit(
|
|
28
|
-
createScriptAddress(
|
|
29
|
-
|
|
30
|
+
createScriptAddress(
|
|
31
|
+
lucid.config().network!,
|
|
32
|
+
sysParams.validatorHashes.interestCollectionHash,
|
|
33
|
+
),
|
|
34
|
+
assetClassToUnit(
|
|
35
|
+
fromSystemParamsAsset(
|
|
36
|
+
sysParams.interestCollectionParams.multisigUtxoNft,
|
|
37
|
+
),
|
|
38
|
+
),
|
|
30
39
|
),
|
|
31
40
|
(_) => new Error('Expected a single admin interest collector UTXO'),
|
|
32
41
|
);
|
|
@@ -34,12 +43,19 @@ export async function findAdminInterestCollectors(
|
|
|
34
43
|
|
|
35
44
|
export async function findRandomNonAdminInterestCollector(
|
|
36
45
|
lucid: LucidEvolution,
|
|
37
|
-
|
|
38
|
-
multisigUtxoNft: AssetClass,
|
|
46
|
+
sysParams: SystemParams,
|
|
39
47
|
): Promise<UTxO> {
|
|
40
48
|
const allCollectors = (
|
|
41
|
-
await findAllInterestCollectors(lucid,
|
|
42
|
-
).filter(
|
|
49
|
+
await findAllInterestCollectors(lucid, sysParams)
|
|
50
|
+
).filter(
|
|
51
|
+
(utxo) =>
|
|
52
|
+
!assetClassValueOf(
|
|
53
|
+
utxo.assets,
|
|
54
|
+
fromSystemParamsAsset(
|
|
55
|
+
sysParams.interestCollectionParams.multisigUtxoNft,
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
);
|
|
43
59
|
|
|
44
60
|
return F.pipe(
|
|
45
61
|
O.fromNullable(getRandomElement(allCollectors)),
|
|
@@ -8,6 +8,30 @@ import {
|
|
|
8
8
|
} from './types';
|
|
9
9
|
import { ParsedFeedPayload } from '@pythnetwork/pyth-lazer-sdk';
|
|
10
10
|
import { fromHex } from '@lucid-evolution/lucid';
|
|
11
|
+
import { array as A, function as F } from 'fp-ts';
|
|
12
|
+
import { BigIntOrd } from '../../utils/bigint-utils';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Collect all unique price feed IDs in the derived price sorted ascending.
|
|
16
|
+
*/
|
|
17
|
+
export function collectPriceFeedIds(
|
|
18
|
+
derivedPythPrice: DerivedPythPrice,
|
|
19
|
+
): bigint[] {
|
|
20
|
+
const ids = match(derivedPythPrice)
|
|
21
|
+
.with({ Value: P.select() }, (value) => [
|
|
22
|
+
BigInt(value.configuration.priceFeedId),
|
|
23
|
+
])
|
|
24
|
+
.with({ Inverse: P.select() }, (inverse) =>
|
|
25
|
+
collectPriceFeedIds(fromDataDerivedPythPrice(inverse.value)),
|
|
26
|
+
)
|
|
27
|
+
.with({ Divide: P.select() }, (divide) => [
|
|
28
|
+
...collectPriceFeedIds(fromDataDerivedPythPrice(divide.x)),
|
|
29
|
+
...collectPriceFeedIds(fromDataDerivedPythPrice(divide.y)),
|
|
30
|
+
])
|
|
31
|
+
.exhaustive();
|
|
32
|
+
|
|
33
|
+
return F.pipe(ids, A.uniq(BigIntOrd), A.sort(BigIntOrd));
|
|
34
|
+
}
|
|
11
35
|
|
|
12
36
|
/** Rational form { num, den } so we can do exact division (e.g. 1/0.00001 = 100000). */
|
|
13
37
|
export function derivePythPrice(
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LucidEvolution, UTxO } from '@lucid-evolution/lucid';
|
|
2
|
-
import { fromSystemParamsAsset, SystemParams } from '../../src';
|
|
3
2
|
import { option as O, function as F } from 'fp-ts';
|
|
4
3
|
import {
|
|
5
4
|
AssetClass,
|
|
@@ -7,16 +6,25 @@ import {
|
|
|
7
6
|
assetClassValueOf,
|
|
8
7
|
getRandomElement,
|
|
9
8
|
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
9
|
+
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
10
10
|
|
|
11
|
-
export async function
|
|
11
|
+
export async function findAllTreasuryUtxos(
|
|
12
12
|
lucid: LucidEvolution,
|
|
13
13
|
sysParams: SystemParams,
|
|
14
|
-
): Promise<UTxO> {
|
|
14
|
+
): Promise<UTxO[]> {
|
|
15
15
|
// We need to consider both with staking credential and without.
|
|
16
|
-
|
|
17
|
-
hash: sysParams.validatorHashes.treasuryHash,
|
|
16
|
+
return lucid.utxosAt({
|
|
18
17
|
type: 'Script',
|
|
18
|
+
hash: sysParams.validatorHashes.treasuryHash,
|
|
19
19
|
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function findRandomTreasuryUtxo(
|
|
23
|
+
lucid: LucidEvolution,
|
|
24
|
+
sysParams: SystemParams,
|
|
25
|
+
): Promise<UTxO> {
|
|
26
|
+
// We need to consider both with staking credential and without.
|
|
27
|
+
const treasuryUtxos = await findAllTreasuryUtxos(lucid, sysParams);
|
|
20
28
|
|
|
21
29
|
return F.pipe(
|
|
22
30
|
O.fromNullable(getRandomElement(treasuryUtxos)),
|
|
@@ -31,10 +39,7 @@ export async function findRandomTreasuryUtxoWithOnlyAda(
|
|
|
31
39
|
sysParams: SystemParams,
|
|
32
40
|
): Promise<UTxO> {
|
|
33
41
|
// We need to consider both with staking credential and without.
|
|
34
|
-
const treasuryUtxos = await lucid
|
|
35
|
-
hash: sysParams.validatorHashes.treasuryHash,
|
|
36
|
-
type: 'Script',
|
|
37
|
-
});
|
|
42
|
+
const treasuryUtxos = await findAllTreasuryUtxos(lucid, sysParams);
|
|
38
43
|
|
|
39
44
|
const adaOnlyTreasuryUtxos = treasuryUtxos.filter(
|
|
40
45
|
(utxo) => Object.keys(utxo.assets).length == 1,
|
|
@@ -72,27 +77,13 @@ export async function findRandomTreasuryUtxoWithAsset(
|
|
|
72
77
|
);
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
export async function findAllTreasuryUtxos(
|
|
76
|
-
lucid: LucidEvolution,
|
|
77
|
-
sysParams: SystemParams,
|
|
78
|
-
): Promise<UTxO[]> {
|
|
79
|
-
// We need to consider both with staking credential and without.
|
|
80
|
-
return lucid.utxosAt({
|
|
81
|
-
type: 'Script',
|
|
82
|
-
hash: sysParams.validatorHashes.treasuryHash,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
export async function findAllTreasuryUtxosWithNonAdaAsset(
|
|
87
81
|
lucid: LucidEvolution,
|
|
88
82
|
sysParams: SystemParams,
|
|
89
83
|
includeDaoToken: boolean = true,
|
|
90
84
|
): Promise<UTxO[]> {
|
|
91
85
|
// We need to consider both with staking credential and without.
|
|
92
|
-
const treasuryUtxos = await lucid
|
|
93
|
-
hash: sysParams.validatorHashes.treasuryHash,
|
|
94
|
-
type: 'Script',
|
|
95
|
-
});
|
|
86
|
+
const treasuryUtxos = await findAllTreasuryUtxos(lucid, sysParams);
|
|
96
87
|
|
|
97
88
|
const treasuryUtxosWithNonAdaAsset = treasuryUtxos.filter(
|
|
98
89
|
(utxo) =>
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './contracts/cdp/types-new';
|
|
|
5
5
|
export * from './contracts/cdp/scripts';
|
|
6
6
|
export * from './contracts/cdp-creator/types';
|
|
7
7
|
export * from './contracts/cdp-creator/scripts';
|
|
8
|
+
export * from './contracts/cdp-creator/queries';
|
|
8
9
|
export * from './contracts/poll/scripts';
|
|
9
10
|
export * from './contracts/collector/transactions';
|
|
10
11
|
export * from './contracts/collector/types-new';
|
|
@@ -28,16 +29,18 @@ export * from './contracts/interest-collection/types';
|
|
|
28
29
|
export * from './contracts/interest-collection/types-new';
|
|
29
30
|
export * from './contracts/interest-collection/scripts';
|
|
30
31
|
export * from './contracts/interest-collection/transactions';
|
|
32
|
+
export * from './contracts/interest-collection/queries';
|
|
31
33
|
export * from './contracts/interest-oracle/scripts';
|
|
32
34
|
export * from './contracts/version-registry/types';
|
|
33
35
|
export * from './contracts/version-registry/scripts';
|
|
34
36
|
export * from './contracts/treasury/transactions';
|
|
35
37
|
export * from './contracts/treasury/helpers';
|
|
38
|
+
export * from './contracts/treasury/scripts';
|
|
39
|
+
export * from './contracts/treasury/queries';
|
|
36
40
|
export * from './contracts/stability-pool/helpers';
|
|
37
41
|
export * from './utils/time-helpers';
|
|
38
42
|
export * from './contracts/cdp/scripts';
|
|
39
43
|
export * from './contracts/collector/scripts';
|
|
40
|
-
export * from './contracts/treasury/scripts';
|
|
41
44
|
export * from './contracts/execute/types';
|
|
42
45
|
export * from './contracts/execute/types-new';
|
|
43
46
|
export * from './contracts/execute/scripts';
|
|
@@ -75,9 +78,11 @@ export * from './contracts/initialize/actions';
|
|
|
75
78
|
export * from './utils/pyth';
|
|
76
79
|
export * from './contracts/pyth-feed/types';
|
|
77
80
|
export * from './contracts/pyth-feed/scripts';
|
|
81
|
+
export * from './contracts/pyth-feed/helpers';
|
|
78
82
|
export * from './contracts/iasset/types';
|
|
79
83
|
export * from './contracts/iasset/scripts';
|
|
80
84
|
export * from './contracts/iasset/helpers';
|
|
85
|
+
export * from './contracts/iasset/queries';
|
|
81
86
|
export * from './contracts/stableswap/helpers';
|
|
82
87
|
export * from './contracts/stableswap/transactions';
|
|
83
88
|
export * from './contracts/stableswap/types-new';
|
package/tests/cdp/actions.ts
CHANGED
|
@@ -59,7 +59,7 @@ import { runFeedPriceToOracle } from '../price-oracle/actions';
|
|
|
59
59
|
import { rationalFromInt, rationalMul } from '../../src/types/rational';
|
|
60
60
|
import { array as A } from 'fp-ts';
|
|
61
61
|
import { sendValueTo } from '../utils';
|
|
62
|
-
import { findRandomTreasuryUtxoWithAsset } from '
|
|
62
|
+
import { findRandomTreasuryUtxoWithAsset } from '../../src/contracts/treasury/queries';
|
|
63
63
|
|
|
64
64
|
// Selects users wallet and opens a CDP with the given initial collateral and mint amount
|
|
65
65
|
export async function runOpenCdp(
|
package/tests/cdp/cdp-queries.ts
CHANGED
|
@@ -40,14 +40,13 @@ import { findPriceOracle } from '../price-oracle/price-oracle-queries';
|
|
|
40
40
|
import { findInterestOracle } from '../queries/interest-oracle-queries';
|
|
41
41
|
import { findRandomCollector } from '../queries/collector-queries';
|
|
42
42
|
import { findGov } from '../gov/governance-queries';
|
|
43
|
-
import { findRandomTreasuryUtxoWithOnlyAda } from '
|
|
43
|
+
import { findRandomTreasuryUtxoWithOnlyAda } from '../../src/contracts/treasury/queries';
|
|
44
44
|
import { parsePriceOracleDatum } from '../../src/contracts/price-oracle/types-new';
|
|
45
45
|
import {
|
|
46
46
|
CollateralAssetOutput,
|
|
47
47
|
IAssetOutput,
|
|
48
48
|
} from '../../src/contracts/iasset/types';
|
|
49
|
-
import { findRandomNonAdminInterestCollector } from '
|
|
50
|
-
import { LucidContext } from '../test-helpers';
|
|
49
|
+
import { findRandomNonAdminInterestCollector } from '../../src/contracts/interest-collection/queries';
|
|
51
50
|
import { Rational } from '../../src/types/rational';
|
|
52
51
|
|
|
53
52
|
export async function findAllActiveCdps(
|
|
@@ -245,24 +244,6 @@ export async function findRandomCdpCreator(
|
|
|
245
244
|
);
|
|
246
245
|
}
|
|
247
246
|
|
|
248
|
-
export async function findRandomCdpCreatorNew(
|
|
249
|
-
context: LucidContext,
|
|
250
|
-
sysParams: SystemParams,
|
|
251
|
-
): Promise<UTxO> {
|
|
252
|
-
const cdpCreatorUtxos = await findAllCdpCreators(
|
|
253
|
-
context.lucid,
|
|
254
|
-
sysParams.validatorHashes.cdpCreatorHash,
|
|
255
|
-
fromSystemParamsAsset(sysParams.cdpCreatorParams.cdpCreatorNft),
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
return F.pipe(
|
|
259
|
-
O.fromNullable(getRandomElement(cdpCreatorUtxos)),
|
|
260
|
-
O.match(() => {
|
|
261
|
-
throw new Error('Expected some cdp creator UTXOs.');
|
|
262
|
-
}, F.identity),
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
247
|
export function findPriceOracleFromCollateralAsset(
|
|
267
248
|
lucid: LucidEvolution,
|
|
268
249
|
collateralAsset: CollateralAssetOutput,
|
|
@@ -329,8 +310,7 @@ export async function findAllNecessaryOrefs(
|
|
|
329
310
|
),
|
|
330
311
|
interestCollectorUtxo: await findRandomNonAdminInterestCollector(
|
|
331
312
|
lucid,
|
|
332
|
-
sysParams
|
|
333
|
-
fromSystemParamsAsset(sysParams.interestCollectionParams.multisigUtxoNft),
|
|
313
|
+
sysParams,
|
|
334
314
|
),
|
|
335
315
|
govUtxo: (
|
|
336
316
|
await findGov(
|
|
@@ -75,7 +75,7 @@ import { AssetInfo } from '../endpoints/initialize';
|
|
|
75
75
|
import { LucidContext } from '../test-helpers';
|
|
76
76
|
import { option as O, function as F } from 'fp-ts';
|
|
77
77
|
import { findPriceOracle } from '../price-oracle/price-oracle-queries';
|
|
78
|
-
import { findRandomNonAdminInterestCollector } from '
|
|
78
|
+
import { findRandomNonAdminInterestCollector } from '../../src/contracts/interest-collection/queries';
|
|
79
79
|
import {
|
|
80
80
|
serialiseCDPCreatorDatum,
|
|
81
81
|
serialiseCDPCreatorRedeemer,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
CollectInterestVariation,
|
|
85
85
|
testCollectInterest,
|
|
86
86
|
} from '../interest-collection/transactions-mutated';
|
|
87
|
-
import { findRandomTreasuryUtxoWithOnlyAda } from '
|
|
87
|
+
import { findRandomTreasuryUtxoWithOnlyAda } from '../../src/contracts/treasury/queries';
|
|
88
88
|
import {
|
|
89
89
|
Rational,
|
|
90
90
|
rationalFloor,
|
|
@@ -909,8 +909,7 @@ export async function runTestAdjustCdpDelisted(
|
|
|
909
909
|
|
|
910
910
|
const interestCollectorUtxo = await findRandomNonAdminInterestCollector(
|
|
911
911
|
context.lucid,
|
|
912
|
-
sysParams
|
|
913
|
-
fromSystemParamsAsset(sysParams.interestCollectionParams.multisigUtxoNft),
|
|
912
|
+
sysParams,
|
|
914
913
|
);
|
|
915
914
|
|
|
916
915
|
const validateFrom = slotToUnixTime(network, context.emulator.slot - 1);
|
package/tests/gov/gov.test.ts
CHANGED
|
@@ -76,7 +76,7 @@ import { benchmarkAndAwaitTx } from '../utils/benchmark-utils';
|
|
|
76
76
|
import {
|
|
77
77
|
findAllTreasuryUtxos,
|
|
78
78
|
findAllTreasuryUtxosWithNonAdaAsset,
|
|
79
|
-
} from '
|
|
79
|
+
} from '../../src/contracts/treasury/queries';
|
|
80
80
|
import {
|
|
81
81
|
createIndyUtxoAtTreasury,
|
|
82
82
|
createUtxoAtTreasury,
|
|
@@ -97,10 +97,10 @@ import {
|
|
|
97
97
|
import {
|
|
98
98
|
findAllCollateralAssetsOfIAsset,
|
|
99
99
|
findAllIAssets,
|
|
100
|
-
findCollateralAssetNew,
|
|
101
100
|
findIAsset,
|
|
102
101
|
} from '../queries/iasset-queries';
|
|
103
102
|
import { startPriceOracleTx } from '../../src/contracts/price-oracle/transactions';
|
|
103
|
+
import { findCollateralAsset as findCollateralAssetNew } from '../../src/contracts/iasset/queries';
|
|
104
104
|
import { rationalFromInt, rationalZero } from '../../src/types/rational';
|
|
105
105
|
import { expectScriptFailure } from '../utils/asserts';
|
|
106
106
|
import { MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET } from '../../src/contracts/iasset/helpers';
|
|
@@ -2072,9 +2072,9 @@ describe('Gov', () => {
|
|
|
2072
2072
|
);
|
|
2073
2073
|
|
|
2074
2074
|
const res = await findCollateralAssetNew(
|
|
2075
|
-
context,
|
|
2075
|
+
context.lucid,
|
|
2076
2076
|
sysParams,
|
|
2077
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
2077
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
2078
2078
|
collateralAsset1,
|
|
2079
2079
|
);
|
|
2080
2080
|
|
|
@@ -2256,9 +2256,9 @@ describe('Gov', () => {
|
|
|
2256
2256
|
);
|
|
2257
2257
|
|
|
2258
2258
|
const res = await findCollateralAssetNew(
|
|
2259
|
-
context,
|
|
2259
|
+
context.lucid,
|
|
2260
2260
|
sysParams,
|
|
2261
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
2261
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
2262
2262
|
collateralAsset2,
|
|
2263
2263
|
);
|
|
2264
2264
|
|
|
@@ -2451,15 +2451,15 @@ describe('Gov', () => {
|
|
|
2451
2451
|
);
|
|
2452
2452
|
|
|
2453
2453
|
const newCollateralAsset = await findCollateralAssetNew(
|
|
2454
|
-
context,
|
|
2454
|
+
context.lucid,
|
|
2455
2455
|
sysParams,
|
|
2456
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
2456
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
2457
2457
|
collateralAsset2,
|
|
2458
2458
|
);
|
|
2459
2459
|
const collateralAssetFirst = await findCollateralAssetNew(
|
|
2460
|
-
context,
|
|
2460
|
+
context.lucid,
|
|
2461
2461
|
sysParams,
|
|
2462
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
2462
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
2463
2463
|
collateralAsset1,
|
|
2464
2464
|
);
|
|
2465
2465
|
|
|
@@ -2659,15 +2659,15 @@ describe('Gov', () => {
|
|
|
2659
2659
|
);
|
|
2660
2660
|
|
|
2661
2661
|
const newCollateralAsset = await findCollateralAssetNew(
|
|
2662
|
-
context,
|
|
2662
|
+
context.lucid,
|
|
2663
2663
|
sysParams,
|
|
2664
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
2664
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
2665
2665
|
collateralAsset2,
|
|
2666
2666
|
);
|
|
2667
2667
|
const collateralAssetFirst = await findCollateralAssetNew(
|
|
2668
|
-
context,
|
|
2668
|
+
context.lucid,
|
|
2669
2669
|
sysParams,
|
|
2670
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
2670
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
2671
2671
|
collateralAsset1,
|
|
2672
2672
|
);
|
|
2673
2673
|
|
|
@@ -4085,9 +4085,9 @@ describe('Gov', () => {
|
|
|
4085
4085
|
null,
|
|
4086
4086
|
(
|
|
4087
4087
|
await findCollateralAssetNew(
|
|
4088
|
-
context,
|
|
4088
|
+
context.lucid,
|
|
4089
4089
|
sysParams,
|
|
4090
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
4090
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
4091
4091
|
iusdAssetInfo.collateralAssets[0].collateralAsset,
|
|
4092
4092
|
)
|
|
4093
4093
|
).utxo,
|
|
@@ -4236,9 +4236,9 @@ describe('Gov', () => {
|
|
|
4236
4236
|
null,
|
|
4237
4237
|
(
|
|
4238
4238
|
await findCollateralAssetNew(
|
|
4239
|
-
context,
|
|
4239
|
+
context.lucid,
|
|
4240
4240
|
sysParams,
|
|
4241
|
-
iusdAssetInfo.iassetTokenNameAscii,
|
|
4241
|
+
fromHex(fromText(iusdAssetInfo.iassetTokenNameAscii)),
|
|
4242
4242
|
iusdAssetInfo.collateralAssets[0].collateralAsset,
|
|
4243
4243
|
)
|
|
4244
4244
|
).utxo,
|