@indigo-labs/indigo-sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +62 -0
- package/.github/workflows/test.yml +44 -0
- package/.husky/pre-commit +1 -0
- package/.prettierrc +1 -1
- package/README.md +52 -7
- package/dist/index.d.mts +1064 -182
- package/dist/index.d.ts +1064 -182
- package/dist/index.js +2565 -561
- package/dist/index.mjs +2546 -593
- package/eslint.config.mjs +35 -0
- package/package.json +61 -43
- package/src/contracts/cdp.ts +208 -359
- package/src/contracts/collector.ts +13 -6
- package/src/contracts/gov.ts +1 -58
- package/src/contracts/interest-oracle.ts +139 -39
- package/src/contracts/lrp.ts +223 -0
- package/src/contracts/one-shot.ts +67 -0
- package/src/contracts/stability-pool.ts +684 -0
- package/src/contracts/staking.ts +348 -0
- package/src/contracts/treasury.ts +30 -13
- package/src/helpers/asset-helpers.ts +51 -22
- package/src/helpers/helper-txs.ts +30 -0
- package/src/helpers/helpers.ts +29 -8
- package/src/helpers/indigo-helpers.ts +19 -0
- package/src/helpers/interest-oracle.ts +57 -0
- package/src/helpers/lucid-utils.ts +62 -16
- package/src/helpers/price-oracle-helpers.ts +36 -0
- package/src/helpers/stability-pool-helpers.ts +207 -0
- package/src/helpers/staking-helpers.ts +94 -0
- package/src/helpers/time-helpers.ts +4 -3
- package/src/helpers/value-helpers.ts +16 -0
- package/src/index.ts +15 -4
- package/src/scripts/always-fail-validator.ts +7 -0
- package/src/scripts/auth-token-policy.ts +23 -0
- package/src/scripts/cdp-creator-validator.ts +46 -2
- package/src/scripts/collector-validator.ts +2 -2
- package/src/scripts/execute-validator.ts +52 -0
- package/src/scripts/gov-validator.ts +44 -0
- package/src/scripts/iasset-policy.ts +22 -0
- package/src/scripts/interest-oracle-validator.ts +18 -3
- package/src/scripts/lrp-validator.ts +23 -0
- package/src/scripts/one-shot-policy.ts +62 -0
- package/src/scripts/poll-manager-validator.ts +52 -0
- package/src/scripts/poll-shard-validator.ts +47 -0
- package/src/scripts/price-oracle-validator.ts +26 -0
- package/src/scripts/stability-pool-validator.ts +60 -0
- package/src/scripts/staking-validator.ts +8 -0
- package/src/scripts/version-record-policy.ts +26 -0
- package/src/scripts/version-registry.ts +15 -0
- package/src/types/generic.ts +99 -6
- package/src/types/indigo/cdp-creator.ts +46 -0
- package/src/types/indigo/cdp.ts +86 -31
- package/src/types/indigo/execute.ts +21 -0
- package/src/types/indigo/gov.ts +50 -20
- package/src/types/indigo/interest-oracle.ts +55 -5
- package/src/types/indigo/lrp.ts +54 -0
- package/src/types/indigo/poll-manager.ts +21 -0
- package/src/types/indigo/poll-shard.ts +16 -0
- package/src/types/indigo/price-oracle.ts +38 -4
- package/src/types/indigo/stability-pool.ts +233 -0
- package/src/types/indigo/staking.ts +99 -0
- package/src/types/indigo/version-record.ts +17 -0
- package/src/types/on-chain-decimal.ts +23 -0
- package/src/types/one-shot.ts +22 -0
- package/src/types/system-params.ts +95 -77
- package/tests/data/system-params.json +972 -972
- package/tests/datums.test.ts +279 -44
- package/tests/endpoints/initialize.ts +1013 -0
- package/tests/hash-checks.test.ts +71 -15
- package/tests/indigo-test-helpers.ts +115 -0
- package/tests/initialize.test.ts +27 -0
- package/tests/interest-calculations.test.ts +110 -133
- package/tests/interest-oracle.test.ts +90 -0
- package/tests/lrp.test.ts +149 -0
- package/tests/queries/governance-queries.ts +31 -0
- package/tests/queries/iasset-queries.ts +39 -0
- package/tests/queries/interest-oracle-queries.ts +13 -0
- package/tests/queries/lrp-queries.ts +39 -0
- package/tests/queries/price-oracle-queries.ts +27 -0
- package/tests/queries/stability-pool-queries.ts +75 -0
- package/tests/queries/staking-queries.ts +43 -0
- package/tests/stability-pool.test.ts +364 -0
- package/tests/staking.test.ts +105 -0
- package/tests/test-helpers.ts +38 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +8 -27
- package/vitest.config.ts +9 -0
- package/babel.config.cjs +0 -13
- package/examples/sample-cdp.ts +0 -43
- package/jest.config.js +0 -13
- package/src/contracts/cdp-creator.ts +0 -86
- package/src/contracts/price-oracle.ts +0 -24
- package/src/helpers/cdp-helpers.ts +0 -9
|
@@ -1,24 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
addAssets,
|
|
3
|
+
Address,
|
|
4
|
+
Assets,
|
|
5
|
+
Credential,
|
|
6
|
+
credentialToAddress,
|
|
7
|
+
Datum,
|
|
8
|
+
LucidEvolution,
|
|
9
|
+
Network,
|
|
10
|
+
OutRef,
|
|
11
|
+
paymentCredentialOf,
|
|
12
|
+
ScriptHash,
|
|
13
|
+
scriptHashToCredential,
|
|
14
|
+
stakeCredentialOf,
|
|
15
|
+
UTxO,
|
|
16
|
+
} from '@lucid-evolution/lucid';
|
|
17
|
+
import { ScriptReference } from '../types/system-params';
|
|
3
18
|
|
|
4
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Returns the inline datum.
|
|
21
|
+
* Throws when the UTXO doesn't have an inline datum
|
|
22
|
+
* (i.e. in case it has hash datum or no datum).
|
|
23
|
+
*/
|
|
24
|
+
export function getInlineDatumOrThrow(utxo: UTxO): Datum {
|
|
25
|
+
if (utxo.datum != null) {
|
|
26
|
+
return utxo.datum;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw new Error(
|
|
30
|
+
'Expected an inline datum for OutRef: ' +
|
|
31
|
+
JSON.stringify({
|
|
32
|
+
txHash: utxo.txHash,
|
|
33
|
+
outputIndex: utxo.outputIndex,
|
|
34
|
+
} as OutRef),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function addrDetails(
|
|
39
|
+
lucid: LucidEvolution,
|
|
40
|
+
): Promise<[Credential, Credential | undefined]> {
|
|
5
41
|
const addr = await lucid.wallet().address();
|
|
6
|
-
return [
|
|
7
|
-
paymentCredentialOf(addr),
|
|
8
|
-
stakeCredentialOf(addr)
|
|
9
|
-
]
|
|
42
|
+
return [paymentCredentialOf(addr), stakeCredentialOf(addr)];
|
|
10
43
|
}
|
|
11
44
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
45
|
+
export function createScriptAddress(
|
|
46
|
+
network: Network,
|
|
47
|
+
scriptHash: ScriptHash,
|
|
48
|
+
stakeCredential?: Credential,
|
|
49
|
+
): Address {
|
|
50
|
+
return credentialToAddress(
|
|
51
|
+
network,
|
|
52
|
+
scriptHashToCredential(scriptHash),
|
|
53
|
+
stakeCredential,
|
|
54
|
+
);
|
|
17
55
|
}
|
|
18
56
|
|
|
19
|
-
export function
|
|
20
|
-
|
|
57
|
+
export async function scriptRef(
|
|
58
|
+
ref: ScriptReference,
|
|
59
|
+
lucid: LucidEvolution,
|
|
60
|
+
): Promise<UTxO> {
|
|
61
|
+
const utxos = await lucid.utxosByOutRef([
|
|
62
|
+
{ txHash: ref.input.transactionId, outputIndex: ref.input.index },
|
|
63
|
+
]);
|
|
64
|
+
if (utxos.length === 0) throw Error('Unable to locate script ref.');
|
|
65
|
+
return utxos[0];
|
|
21
66
|
}
|
|
22
67
|
|
|
23
|
-
export
|
|
24
|
-
|
|
68
|
+
export function balance(utxos: UTxO[]): Assets {
|
|
69
|
+
return utxos.reduce((acc, utxo) => addAssets(acc, utxo.assets), {});
|
|
70
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Network,
|
|
3
|
+
slotToUnixTime,
|
|
4
|
+
unixTimeToSlot,
|
|
5
|
+
} from '@lucid-evolution/lucid';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the validity range based on the oracle expiration,
|
|
9
|
+
* and caps the upper bound when necessary.
|
|
10
|
+
*/
|
|
11
|
+
export function oracleExpirationAwareValidity(
|
|
12
|
+
currentSlot: number,
|
|
13
|
+
biasTime: number,
|
|
14
|
+
oracleExpiration: number,
|
|
15
|
+
network: Network,
|
|
16
|
+
): {
|
|
17
|
+
validFrom: number;
|
|
18
|
+
validTo: number;
|
|
19
|
+
} {
|
|
20
|
+
const validateFrom = slotToUnixTime(network, currentSlot - 1);
|
|
21
|
+
const defaultValidateTo = validateFrom + biasTime;
|
|
22
|
+
/// Take the oracle expiration time - 1 slot which is the last acceptable non-expired valid_to time
|
|
23
|
+
/// for the current oracle.
|
|
24
|
+
const cappedValidateTo = slotToUnixTime(
|
|
25
|
+
network,
|
|
26
|
+
unixTimeToSlot(network, oracleExpiration) - 1,
|
|
27
|
+
);
|
|
28
|
+
const isOracleActuallyExpired = cappedValidateTo <= validateFrom;
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
validFrom: validateFrom,
|
|
32
|
+
validTo: isOracleActuallyExpired
|
|
33
|
+
? defaultValidateTo
|
|
34
|
+
: Math.min(defaultValidateTo, cappedValidateTo),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { UTxO } from '@lucid-evolution/lucid';
|
|
2
|
+
import {
|
|
3
|
+
EpochToScaleToSum,
|
|
4
|
+
fromSPInteger,
|
|
5
|
+
mkSPInteger,
|
|
6
|
+
parseSnapshotEpochToScaleToSumDatum,
|
|
7
|
+
parseStabilityPoolDatum,
|
|
8
|
+
spAdd,
|
|
9
|
+
spDiv,
|
|
10
|
+
SPInteger,
|
|
11
|
+
spMul,
|
|
12
|
+
spSub,
|
|
13
|
+
StabilityPoolSnapshot,
|
|
14
|
+
} from '../types/indigo/stability-pool';
|
|
15
|
+
|
|
16
|
+
const newScaleMultiplier = 1000000000n;
|
|
17
|
+
|
|
18
|
+
export function getSumFromEpochToScaleToSum(
|
|
19
|
+
e2s2s: EpochToScaleToSum,
|
|
20
|
+
epoch: bigint,
|
|
21
|
+
scale: bigint,
|
|
22
|
+
): SPInteger | undefined {
|
|
23
|
+
for (const [key, value] of e2s2s.entries()) {
|
|
24
|
+
if (key.epoch === epoch && key.scale === scale) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function setSumInEpochToScaleToSum(
|
|
32
|
+
e2s2s: EpochToScaleToSum,
|
|
33
|
+
epoch: bigint,
|
|
34
|
+
scale: bigint,
|
|
35
|
+
sum: SPInteger,
|
|
36
|
+
): EpochToScaleToSum {
|
|
37
|
+
const map = new Map<{ epoch: bigint; scale: bigint }, SPInteger>();
|
|
38
|
+
for (const [key, value] of e2s2s.entries()) {
|
|
39
|
+
if (!(key.epoch === epoch && key.scale === scale)) {
|
|
40
|
+
map.set(key, value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
map.set({ epoch, scale }, sum);
|
|
45
|
+
|
|
46
|
+
return map;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getAccountReward(
|
|
50
|
+
account: StabilityPoolSnapshot,
|
|
51
|
+
e2s2s: EpochToScaleToSum,
|
|
52
|
+
): SPInteger {
|
|
53
|
+
const s1 = getSumFromEpochToScaleToSum(e2s2s, account.epoch, account.scale);
|
|
54
|
+
if (!s1) throw new Error('No scale found for epoch and scale');
|
|
55
|
+
const s2 =
|
|
56
|
+
getSumFromEpochToScaleToSum(e2s2s, account.epoch, account.scale + 1n) ?? s1;
|
|
57
|
+
const a1 = spSub(s1, account.sumVal);
|
|
58
|
+
const a2 = spDiv(spSub(s2, s1), mkSPInteger(newScaleMultiplier));
|
|
59
|
+
|
|
60
|
+
return spDiv(spMul(spAdd(a1, a2), account.depositVal), account.productVal);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getAccountFund(
|
|
64
|
+
pool: StabilityPoolSnapshot,
|
|
65
|
+
account: StabilityPoolSnapshot,
|
|
66
|
+
): SPInteger {
|
|
67
|
+
let fund = spDiv(
|
|
68
|
+
spMul(account.depositVal, pool.productVal),
|
|
69
|
+
account.productVal,
|
|
70
|
+
);
|
|
71
|
+
if (pool.epoch > account.epoch) fund = mkSPInteger(0n);
|
|
72
|
+
if (pool.scale - account.scale > 1n) fund = mkSPInteger(0n);
|
|
73
|
+
if (pool.scale > account.scale)
|
|
74
|
+
fund = spDiv(spMul(account.depositVal, pool.productVal), {
|
|
75
|
+
value: account.productVal.value * newScaleMultiplier,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (fund.value < spDiv(account.depositVal, mkSPInteger(1000000000n)).value)
|
|
79
|
+
return mkSPInteger(0n);
|
|
80
|
+
return fund;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function adjust(
|
|
84
|
+
pool: StabilityPoolSnapshot,
|
|
85
|
+
account: StabilityPoolSnapshot,
|
|
86
|
+
e2s2s: EpochToScaleToSum,
|
|
87
|
+
): [StabilityPoolSnapshot, bigint] {
|
|
88
|
+
const newAccountSnapshot: StabilityPoolSnapshot = {
|
|
89
|
+
...pool,
|
|
90
|
+
depositVal: getAccountFund(pool, account),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const accountReward = fromSPInteger(getAccountReward(account, e2s2s));
|
|
94
|
+
|
|
95
|
+
return [newAccountSnapshot, accountReward];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type SnapshotESSSearchResult = { utxo: UTxO; e2s2s: EpochToScaleToSum };
|
|
99
|
+
|
|
100
|
+
function findEpochToScaleToSum(
|
|
101
|
+
snapshotEpochToScaleToSumTokenRef1: UTxO,
|
|
102
|
+
snapshotEpochToScaleToSumTokenRef2: UTxO | undefined,
|
|
103
|
+
): [SnapshotESSSearchResult, SnapshotESSSearchResult | undefined] {
|
|
104
|
+
let ess1: EpochToScaleToSum;
|
|
105
|
+
try {
|
|
106
|
+
ess1 = parseSnapshotEpochToScaleToSumDatum(
|
|
107
|
+
snapshotEpochToScaleToSumTokenRef1.datum,
|
|
108
|
+
).snapshot;
|
|
109
|
+
} catch (_) {
|
|
110
|
+
ess1 = parseStabilityPoolDatum(
|
|
111
|
+
snapshotEpochToScaleToSumTokenRef1.datum,
|
|
112
|
+
).epochToScaleToSum;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const ess1Ref: SnapshotESSSearchResult = {
|
|
116
|
+
utxo: snapshotEpochToScaleToSumTokenRef1,
|
|
117
|
+
e2s2s: ess1,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (snapshotEpochToScaleToSumTokenRef2) {
|
|
121
|
+
const ess2 = parseSnapshotEpochToScaleToSumDatum(
|
|
122
|
+
snapshotEpochToScaleToSumTokenRef2.datum,
|
|
123
|
+
);
|
|
124
|
+
const ess2Ref: SnapshotESSSearchResult = {
|
|
125
|
+
utxo: snapshotEpochToScaleToSumTokenRef2,
|
|
126
|
+
e2s2s: ess2.snapshot,
|
|
127
|
+
};
|
|
128
|
+
return [ess1Ref, ess2Ref];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return [ess1Ref, undefined];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function adjustmentHelper(
|
|
135
|
+
spESTSTokenRef1: UTxO,
|
|
136
|
+
spESTSTokenRef2: UTxO | undefined,
|
|
137
|
+
pool: StabilityPoolSnapshot,
|
|
138
|
+
e2s2s: EpochToScaleToSum,
|
|
139
|
+
account: StabilityPoolSnapshot,
|
|
140
|
+
): [StabilityPoolSnapshot, bigint, UTxO[]] {
|
|
141
|
+
let accumulatedEpochToScaleToSum: EpochToScaleToSum;
|
|
142
|
+
let refInputs: UTxO[];
|
|
143
|
+
|
|
144
|
+
const value = getSumFromEpochToScaleToSum(
|
|
145
|
+
e2s2s,
|
|
146
|
+
account.epoch,
|
|
147
|
+
account.scale,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
if (value) {
|
|
151
|
+
accumulatedEpochToScaleToSum = e2s2s;
|
|
152
|
+
refInputs = [];
|
|
153
|
+
} else {
|
|
154
|
+
const [ess1, ess2] = findEpochToScaleToSum(
|
|
155
|
+
spESTSTokenRef1,
|
|
156
|
+
spESTSTokenRef2,
|
|
157
|
+
);
|
|
158
|
+
if (ess2) {
|
|
159
|
+
accumulatedEpochToScaleToSum = new Map<
|
|
160
|
+
{ epoch: bigint; scale: bigint },
|
|
161
|
+
SPInteger
|
|
162
|
+
>([
|
|
163
|
+
...Array.from(ess1.e2s2s.entries()),
|
|
164
|
+
...Array.from(ess2.e2s2s.entries()),
|
|
165
|
+
...Array.from(e2s2s.entries()),
|
|
166
|
+
]);
|
|
167
|
+
refInputs = [ess1.utxo, ess2.utxo];
|
|
168
|
+
} else {
|
|
169
|
+
accumulatedEpochToScaleToSum = new Map<
|
|
170
|
+
{ epoch: bigint; scale: bigint },
|
|
171
|
+
SPInteger
|
|
172
|
+
>([...Array.from(ess1.e2s2s.entries()), ...Array.from(e2s2s.entries())]);
|
|
173
|
+
refInputs = [ess1.utxo];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const [newAccountSnapshot, accountReward] = adjust(
|
|
178
|
+
pool,
|
|
179
|
+
account,
|
|
180
|
+
accumulatedEpochToScaleToSum,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return [newAccountSnapshot, accountReward, refInputs];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function updatePoolSnapshotWithdrawalFee(
|
|
187
|
+
withdrawalFeeAmount: SPInteger,
|
|
188
|
+
newPoolDepositExcludingFee: SPInteger,
|
|
189
|
+
pool: StabilityPoolSnapshot,
|
|
190
|
+
): [SPInteger, SPInteger] {
|
|
191
|
+
const newPoolDepositVal = spAdd(
|
|
192
|
+
newPoolDepositExcludingFee,
|
|
193
|
+
withdrawalFeeAmount,
|
|
194
|
+
);
|
|
195
|
+
const newPoolProduct =
|
|
196
|
+
withdrawalFeeAmount.value === 0n
|
|
197
|
+
? pool.productVal
|
|
198
|
+
: spMul(
|
|
199
|
+
pool.productVal,
|
|
200
|
+
spAdd(
|
|
201
|
+
mkSPInteger(1n),
|
|
202
|
+
spDiv(withdrawalFeeAmount, newPoolDepositExcludingFee),
|
|
203
|
+
),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return [newPoolDepositVal, newPoolProduct];
|
|
207
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { fromText, OutRef, UTxO } from '@lucid-evolution/lucid';
|
|
2
|
+
import { LucidEvolution } from '@lucid-evolution/lucid';
|
|
3
|
+
import { StakingContract } from '../contracts/staking';
|
|
4
|
+
import { SystemParams } from '../types/system-params';
|
|
5
|
+
import {
|
|
6
|
+
parseStakingManagerDatum,
|
|
7
|
+
parseStakingPositionDatum,
|
|
8
|
+
StakingManagerContent,
|
|
9
|
+
StakingPositionContent,
|
|
10
|
+
} from '../types/indigo/staking';
|
|
11
|
+
|
|
12
|
+
export type StakingPositionOutput = {
|
|
13
|
+
utxo: UTxO;
|
|
14
|
+
datum: StakingPositionContent;
|
|
15
|
+
};
|
|
16
|
+
export type StakingManagerOutput = { utxo: UTxO; datum: StakingManagerContent };
|
|
17
|
+
|
|
18
|
+
export class StakingHelpers {
|
|
19
|
+
static async findStakingManagerByOutRef(
|
|
20
|
+
stakingManagerRef: OutRef,
|
|
21
|
+
lucid: LucidEvolution,
|
|
22
|
+
): Promise<StakingManagerOutput> {
|
|
23
|
+
return lucid
|
|
24
|
+
.utxosByOutRef([stakingManagerRef])
|
|
25
|
+
.then((utxos) =>
|
|
26
|
+
utxos
|
|
27
|
+
.map((utxo) => {
|
|
28
|
+
if (!utxo.datum) return undefined;
|
|
29
|
+
const datum = parseStakingManagerDatum(utxo.datum);
|
|
30
|
+
return { utxo, datum };
|
|
31
|
+
})
|
|
32
|
+
.find((utxo) => utxo !== undefined),
|
|
33
|
+
)
|
|
34
|
+
.then((result) => {
|
|
35
|
+
if (!result)
|
|
36
|
+
throw new Error(
|
|
37
|
+
'Unable to locate Staking Manager by output reference.',
|
|
38
|
+
);
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static async findStakingManager(
|
|
44
|
+
params: SystemParams,
|
|
45
|
+
lucid: LucidEvolution,
|
|
46
|
+
): Promise<StakingManagerOutput> {
|
|
47
|
+
return lucid
|
|
48
|
+
.utxosAtWithUnit(
|
|
49
|
+
StakingContract.address(params.stakingParams, lucid),
|
|
50
|
+
params.stakingParams.stakingManagerNFT[0].unCurrencySymbol +
|
|
51
|
+
fromText(params.stakingParams.stakingManagerNFT[1].unTokenName),
|
|
52
|
+
)
|
|
53
|
+
.then((utxos) =>
|
|
54
|
+
utxos
|
|
55
|
+
.map((utxo) => {
|
|
56
|
+
if (!utxo.datum) return undefined;
|
|
57
|
+
const datum = parseStakingManagerDatum(utxo.datum);
|
|
58
|
+
return { utxo, datum };
|
|
59
|
+
})
|
|
60
|
+
.find((utxo) => utxo !== undefined),
|
|
61
|
+
)
|
|
62
|
+
.then((result) => {
|
|
63
|
+
if (!result)
|
|
64
|
+
throw new Error(
|
|
65
|
+
'Unable to locate Staking Manager by output reference.',
|
|
66
|
+
);
|
|
67
|
+
return result;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static async findStakingPositionByOutRef(
|
|
72
|
+
stakingPositionRef: OutRef,
|
|
73
|
+
lucid: LucidEvolution,
|
|
74
|
+
): Promise<StakingPositionOutput> {
|
|
75
|
+
return lucid
|
|
76
|
+
.utxosByOutRef([stakingPositionRef])
|
|
77
|
+
.then((utxos) =>
|
|
78
|
+
utxos
|
|
79
|
+
.map((utxo) => {
|
|
80
|
+
if (!utxo.datum) return undefined;
|
|
81
|
+
const datum = parseStakingPositionDatum(utxo.datum);
|
|
82
|
+
return { utxo, datum };
|
|
83
|
+
})
|
|
84
|
+
.find((utxo) => utxo !== undefined),
|
|
85
|
+
)
|
|
86
|
+
.then((result) => {
|
|
87
|
+
if (!result)
|
|
88
|
+
throw new Error(
|
|
89
|
+
'Unable to locate Staking Position by output reference.',
|
|
90
|
+
);
|
|
91
|
+
return result;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
1
|
+
export const ONE_SECOND: number = 1_000;
|
|
2
|
+
export const oneHour: bigint = 3_600_000n;
|
|
3
|
+
export const oneDay: bigint = 86_400_000n;
|
|
4
|
+
export const oneYear: bigint = 31_536_000_000n;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Assets, toUnit, Unit } from '@lucid-evolution/lucid';
|
|
2
|
+
import { AssetClass } from '../types/generic';
|
|
3
|
+
|
|
4
|
+
export function mkLovelacesOf(amount: bigint): Assets {
|
|
5
|
+
return { lovelace: amount };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function assetClassToUnit(ac: AssetClass): Unit {
|
|
9
|
+
return toUnit(ac.currencySymbol, ac.tokenName);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function mkAssetsOf(assetClass: AssetClass, amount: bigint): Assets {
|
|
13
|
+
return {
|
|
14
|
+
[assetClassToUnit(assetClass)]: amount,
|
|
15
|
+
};
|
|
16
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export * from './contracts/cdp-creator';
|
|
2
1
|
export * from './contracts/cdp';
|
|
3
2
|
export * from './contracts/collector';
|
|
4
3
|
export * from './contracts/gov';
|
|
4
|
+
export * from './contracts/stability-pool';
|
|
5
|
+
export * from './contracts/staking';
|
|
5
6
|
export * from './contracts/interest-oracle';
|
|
6
|
-
export * from './contracts/price-oracle';
|
|
7
7
|
export * from './contracts/treasury';
|
|
8
8
|
export * from './helpers/asset-helpers';
|
|
9
|
-
export * from './helpers/cdp-helpers';
|
|
10
9
|
export * from './helpers/helpers';
|
|
11
10
|
export * from './helpers/lucid-utils';
|
|
12
11
|
export * from './helpers/time-helpers';
|
|
@@ -14,10 +13,22 @@ export * from './scripts/cdp-creator-validator';
|
|
|
14
13
|
export * from './scripts/cdp-validator';
|
|
15
14
|
export * from './scripts/collector-validator';
|
|
16
15
|
export * from './scripts/interest-oracle-validator';
|
|
16
|
+
export * from './scripts/poll-shard-validator';
|
|
17
|
+
export * from './scripts/poll-manager-validator';
|
|
17
18
|
export * from './scripts/treasury-validator';
|
|
18
19
|
export * from './types/indigo/cdp';
|
|
20
|
+
export * from './types/indigo/execute';
|
|
19
21
|
export * from './types/indigo/gov';
|
|
20
22
|
export * from './types/indigo/interest-oracle';
|
|
21
23
|
export * from './types/indigo/price-oracle';
|
|
24
|
+
export * from './types/indigo/stability-pool';
|
|
25
|
+
export * from './types/indigo/lrp';
|
|
26
|
+
export * from './types/indigo/poll-shard';
|
|
27
|
+
export * from './types/indigo/poll-manager';
|
|
22
28
|
export * from './types/generic';
|
|
23
|
-
export * from './types/system-params';
|
|
29
|
+
export * from './types/system-params';
|
|
30
|
+
export * from './contracts/lrp';
|
|
31
|
+
export * from './scripts/lrp-validator';
|
|
32
|
+
export * from './helpers/helper-txs';
|
|
33
|
+
export * from './contracts/one-shot';
|
|
34
|
+
export * from './helpers/helpers';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SpendingValidator } from '@lucid-evolution/lucid';
|
|
2
|
+
|
|
3
|
+
export const alwaysFailValidator: SpendingValidator = {
|
|
4
|
+
type: 'PlutusV2',
|
|
5
|
+
script:
|
|
6
|
+
'587f010000323232323232232253330044a029309b2b19299980199b874800000454ccc018c014dd50010a4c2c2a66600666e1d2002001132325333008300a002149858dd7180400098029baa002153330033370e900200089919299980418050010a4c2c6010002600a6ea800858c00cdd5000ab9a5573aaae7955cfaba157441',
|
|
7
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyParamsToScript,
|
|
3
|
+
Constr,
|
|
4
|
+
MintingPolicy,
|
|
5
|
+
ScriptType,
|
|
6
|
+
} from '@lucid-evolution/lucid';
|
|
7
|
+
import { AssetClass } from '../types/generic';
|
|
8
|
+
|
|
9
|
+
const authPolicyData = {
|
|
10
|
+
type: 'PlutusV2' as ScriptType,
|
|
11
|
+
cborHex:
|
|
12
|
+
'5904d95904d60100003232323232323232323232323232323232323232323232323232223232223232323253355335533357346042660166018a00200e03026464666ae68cdc419806980728019980b9999aa999ab9a3370e90030008990911118020029aba1302400215333573466e1d20040011321222230020053574260480042a666ae68c08c0044c848888c004014d5d098120010a999ab9a30220011321222230030053574260480040424c40024c4c016900100a80d98120009baa3500201d01813357389213d4d75737420636f6e73756d65204e4654206f7220746f6b656e2070726576696f75736c79206d696e746564207573696e67207468697320706f6c6963790001301415335738920103505435001613253335734604060460022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118118011aba1302200101f37546a002036a666ae68c078c0840084c8c848cc00400c008d5d09aba2302100335742604000403aa666ae68c074c080dd500180880e1baa00153335734603260380022646601e6ae84004d5d09aba2001301b00101837540044464646603a4466a0029000111a801112999ab9a3375e0040102660464466a0029000111a801112999ab9a3375e00401a20022600c0060022600c0060086a00402a6a0020264666aa6020026660144466aa601c02a46a002446601e00466aa602203046a0024466024004666a0026e012000700466e0000520000013355300e015235001223300f00233350012335530120192350012233013002300e0010012233300a0090020012335530120192350012233013002301000100133300500400200100e232333008200133008200175a6aa666ae68c05cc0680044c8c8c8c8c8c848cccc00401c01400c008d5d09aba2002357420026ae88008d5d08009aba2301a00235742603200202c44440066ea8d400404ccc06488cccd55cf800900891919809a999ab9a3019301c001132321233001003002357426ae88c070008d5d0980d80080c18021aba200337546ae84008054dd61a80091111111111100611199ab9a3375e00400201c010444666aa601602601e66aa601802646a002446601a0046010002666aa6016026446a00444a66a666aa602802e6601c4466601402e004002601002c46a002446601400400a00c200626602600800601c00266aa601802646a002446601a0046603844a66a002260180064426a00444a66a6601800401022444660040140082600c00600800446600244a66a004018200200a4244460060084446602c446666aae7c00480388c8cc040cc02cc01cc064004c018c060004c010d5d10019aba1002012375600242444600200820142014442466002006004601c4422444a66a00220044426600a004666aa600e01e00a008002601a442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660124422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90001b874800955cf2ab9d2323001001223300330020020011',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function mkAuthTokenPolicy(ac: AssetClass, tn: string): MintingPolicy {
|
|
16
|
+
return {
|
|
17
|
+
type: authPolicyData.type,
|
|
18
|
+
script: applyParamsToScript(authPolicyData.cborHex, [
|
|
19
|
+
new Constr(0, [ac.currencySymbol, ac.tokenName]),
|
|
20
|
+
tn,
|
|
21
|
+
]),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,9 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
applyParamsToScript,
|
|
3
|
+
ScriptType,
|
|
4
|
+
SpendingValidator,
|
|
5
|
+
} from '@lucid-evolution/lucid';
|
|
6
|
+
import {
|
|
7
|
+
castCDPCreatorParams,
|
|
8
|
+
CDPCreatorParams,
|
|
9
|
+
} from '../types/indigo/cdp-creator';
|
|
10
|
+
import {
|
|
11
|
+
CDPCreatorParamsSP,
|
|
12
|
+
fromSystemParamsAsset,
|
|
13
|
+
} from '../types/system-params';
|
|
2
14
|
|
|
3
15
|
/* Automatically generated by serialise-contract executable in smart-contracts */
|
|
4
|
-
export const
|
|
16
|
+
export const cdpCreatorValidator = {
|
|
5
17
|
type: 'PlutusV2' as ScriptType,
|
|
6
18
|
description: '',
|
|
7
19
|
cborHex:
|
|
8
20
|
'591a6c591a6901000032323232323232322232322323225333009323232533300c3006300e37540022646464646464646464646464646464646464a66603c603660406ea80644c8c8c8ccccc8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c88888c8c8c8c8c8c94ccc0f8c0ecc100dd50008991919192999821181e18221baa00213232533304433034490115496e636f72726563742074782076616c69646974790032325333046325333047302d00114a22a66608e6082002294452818241baa3301d303930493754004607260926ea80044c94ccc11cc1100045288a99982398208008a5114a060906ea8cc074c0c4c124dd5001181898249baa00114a06034606e66094606e660946036660946ea0cdc08071bad30163048375408897ae03304a3330454a298103d87a80004c0103d87980004bd7019825181b99825180d998251ba83370001c6eb4c058c120dd502225eb80cc128ccc11528a6103d87a80004c0103d87980004bd7025eb80c064c058c11cdd501d0a9998221981a24811754582069736e74207369676e6564206279206f776e657200330283758602a608e6ea80e804054ccc110cc0d124011543445043726561746f724e4654206d697373696e67003302e3756605e608e6ea8c0bcc11cdd5003181b98239baa04315333044330344912043445043726561746f72206f757470757420646f6573206e6f74206d617463680033333014008301a330490054bd70260107d87b9fd87980ff00301330373047375408698103d87a80001533304433034491174d696e7465642076616c756520697320696e76616c6964003375e6e98c0c8dd5981898239baa03a374c66660306026604e608e6ea810cdd7181798239baa043375c606e608e6ea800803c54ccc110cc0d1240115434450206f757470757420697320696e76616c69640033333014008303633049301a33049304a304b304b304b304b304b3047375408697ae04bd7019ba548010cc124c0d8cc124c0d8cc124c0d8cc124dd480825eb80cc124c0dcc11cdd5001198249ba800f33049303633049375001a660926ea0cdc01bad303730473754002a66608866e20dd6981398239baa00100d13370666e0ccdc119b823370201a6eb4c09cc11cdd50009bad303730473754605e608e6ea8005208080a0f6f4acdbe01b48202c227efa8052080897a15330454901254d75737420686f6c643a206e6f77203e206c61737420696e7465726573742075706461746500164bd7025eb812f5c097ae033012301330273047375408601c980103d87980001325332330463303649115556e646572636f6c6c61746572697a65642043445000337126eb4c0e4c124dd51980c9980c981998249baa00430383304b3750600202297ae03039304937540046eb4c0e4c124dd51980c981c198259ba830010104bd70181c198259ba833704906400a410112f497ae01533304633036491164e6f6e706f736974697665206d696e74656420616d7400302e011153330463303649012e4d7573742070726f76696465206d6f7265207468616e206d696e436f6c6c61746572616c496e4c6f76656c61636500337126eb4c060c124dd50228080a9998231981b249174f7261636c652063616e2774206265206578706972656400333046325333047304130493754002266e24dd6981918251baa003375a609a60946ea800454cc121240124496e636f7272656374207472616e73616374696f6e2076616c69646974792072616e67650016303930493754606260926ea8c060c124dd501e2504a226606c9201194d757374207061792064656274206d696e74696e67206665650033322232533304a3032002132533304b3232302c00232533304d304a00115333051305037540042930b0a99982698238008a99982898281baa00214985854ccc134c0cc00454ccc144c140dd50010a4c2c2c609c6ea8004c94ccc130c124c138dd50008982918279baa001153304d49117436f756c64206e6f742066696e642072656465656d6572001632323300100100722533305200114c0103d87a8000132323253330513375e00c60a600626086660ac00297ae0133005005002305300230560023054001302133050303e304e375400297ae013333301b00f302133050303d33050002330504c103d87a80004bd7025eb8130107d87b9fd87980ff00330193756606c609c6ea8c0d8c138dd5000801a60103d879800014a064a66609e0022a66098921284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400161533304f305200113051001153304c4901284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400163303301123375e607c609c6ea8c0f8c138dd5181b18271baa00100214a2603e6609c6ea40092f5c06eacc130c134c134c134c134c134c134c134c134c134c124dd501e1bae30133049375408a6644a66609066e2400520001480004dd6981d98259baa303a3304d375066e0cc00cdd6981d98259baa3301b303a3304d375000297ae0002375a607660966ea8c0e8cc134dd419b8248320052080897a4bd7025eb80c04cc124dd50021bad303930493754660326070660966ea00452f5c0607260926ea80085280a5014a06e092080897a14a064a66608a6084608e6ea800454cc11924012543616e6e6f74206f70656e206120434450206f6620612064656c69737465642061737365740016132320025333046304330483754002264646464a66609c60a20042649318118018b1bad304f001304f002304d001304937540022c6054605060906ea8c0c0c120dd51929998250008a99823a492145787065637465642065786163746c79206f6e65206f7261636c6520696e70757400161533304a304d0011304c001153304749012145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001633302c00a304b30483754609660906ea8005300103d8798000302f3047375400429405280a5014a0294052819190012999822182098231baa0011323232323232533304e3051002132498c08c00c58dd698278009827801182680098268011bad304b001304737540022c6050604c608c6ea8c0b8c118dd51929998240008a99822a492a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001615333048304b0011304a001153304549012a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001633302a008302630463754002980103d87980003048304537540042c64a666084607e00226464a6660906096004264932999822182098231baa001132323232323232325333050305300213232498c94ccc138c12c0044c8c8c8c94ccc158c16400852616375a60ae00260ae0046eb4c154004c144dd50018a9998271824000899191919299982b182c8010a4c2c6eb4c15c004c15c008dd6982a80098289baa00316304f3754004604800e2c60a200260a20046eb4c13c004c13c008dd718268009826801182580098239baa00116163049001304537540042a666084607800226464a6660906096004264932999822182098231baa001132323232323232323232323232323232323232323232323232323232533306430670021323232323232323232323232498c10c030c10c03cc108040c104044c100048c0fc04cc0f8050c0f4054c0f0058c0ec05cc0f4060c94ccc184c1780044c8c94ccc19cc1a80084c926303c001163068001306437540342a6660c260b600226464a6660ce60d4004264932999831983018329baa001132325333069306c002132498c10400458c1a8004c198dd50008b0b183400098321baa01a16306237540322c60ca00260ca00464a6660c460c20022a6660bc60b060c0002294454ccc178c16cc1800045280b0b1baa3063001306300230610013061002305f001305f002305d001305d002305b001305b0023059001305900230570013057002305500130550023053001305300230510013051002304f001304f002304d001304d002375c6096002608e6ea80045858c124004c114dd50010b18219baa0013025302330433754605660866ea8c94ccc11400454cc10924012145787065637465642065786163746c79206f6e652069617373657420696e707574001615333045304800113047001153304249012145787065637465642065786163746c79206f6e652069617373657420696e707574001633302700530463047304730473043375407e980103d8798000303230423754605460846ea8004c110c104dd50008b198170020189bac304230430023758608200260820046eb0c0fc004c0ecdd50171181d181d981d981d981d981d981d800911999804001244100488100001233225333034302e4800052f5bded8c0264646600200297adef6c6022533303b00113303c337606ea4014dd3001a5eb7bdb1804c8c8c8c94ccc0ecc068cc0540240084cc100cdd81ba9009374c00e00a2a66607666e3c0240084cc100cdd81ba9009374c00e00626608066ec0dd48011ba6001330060060033756607a0066eb8c0ec008c0fc008c0f4004c8cc0040052f5bded8c044a66607400226607666ec0dd4801a610101004bd6f7b630099191919299981d180c9980a00380109981f99bb0375200e9810101000051533303a3371e00e00426607e66ec0dd4803a6101010000313303f337606ea4008dd4000998030030019bad303c003375c6074004607c00460780026eb8c094c0d4dd50009bae301d303537540024444464660020026603e00ca66606c606660706ea80144c88cdd79815981d9baa302b303b3754002004607860726ea80144c88cdd79815981d9baa001002303c3039375400a44a66607600229404c94ccc0e0c94ccc0e4cdd7980e181e1baa001007132533303e00114a22a66607c60820022646464a66607a60586eb8c10c00c54ccc0f4c0b000454ccc0f4c0e8c0fcdd50048a99981e99b89480000084cdc48012410137dc0429404cdc4a400000429405281bae30423043002375a6082608460840026eb0c1000045281919800800991998008009bab3026303e3754006646600200201244a666082002297adef6c6013233043337606ea4dd718200009ba632330010013756608400444a666088002297adef6c6013233046337606ea4dd718218009ba83370290001bad3044001330030033048002304600133003003304500230430012225333041002100113233300400430450033333301b002375c60800026eacc104004888c94ccc108c0740045300103d87a80001303433047374c00297ae03233300100100300222253330480021001132333004004304c00333333023002375c608e0026eb4c120004888c94ccc124c1180045300103d87a80001303b3304e375000297ae03370000400203e6094004030608600444a66607e002297ae01323332223233001001003225333045001100313233047374e6608e6ea4018cc11cdd49bae30440013304737506eb4c1140052f5c0660060066092004608e0026eb8c0f8004dd5981f80099801801982180118208008a50303e00214a2266006006002607c0024606c606e606e606e606e606e606e606e606e0024606a606c606c606c606c606c606c606c002446042660686ea0cdc199b82375a604460646ea8008dd6981118191baa0014820225e92f5c04444a666060605a002200826666601a0080066464004646600200200444a66606e002293099299981c0008a4c26464a66606c606660706ea8cc040dd7181c181e0021bae30380021330050053303b0020011533037491326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016303c002303a001303a00133035337606ea4008dd4000a5eb7bdb180888c94ccc0d0c03c004530103d87a80001302633039374c00297ae033333011001005004222325333037303400114c103d87a8000130293303c375000297ae03370000200401a0144603c6606264a66605a604e605e6ea80044c94ccc0b8c94ccc0ccc0c800454ccc0bcc0a4c0c40045288a999817981618188008a5016163754603260626ea8c084c0c4dd500189802198199ba80014bd7009802198199ba833700002900125eb80dd6981998181baa0011001301f302f3754603e605e6ea8004cc0c4c94ccc0b4c09cc0bcdd5000899299981719299981998190008a999817981498188008a511533302f302c303100114a02c2c6ea8c064c0c4dd5180c98189baa0031300433033375000297ae01300433033375066e0000520014bd701bad3033303037540022002603e605e6ea8c05cc0bcdd5000a5eb80dd2a40044464a66605860520022a6660586052605c6ea8008530103d87a800014c103d87980001533302c30120011533302c3012302e3754004298103d87a800014c103d87b800013232533302e3028001132533302f33710006002298103d87980001533302f337100020062980103d87b800014c103d87a8000375a606860626ea801054ccc0b8c0ac004530103d87b800014c103d8798000302f37540066eb4c0c8c0bcdd500198169baa002232533302a30270011323253330303033002149858dd7181880098169baa0021533302a30240011533302e302d37540042930b0b18159baa001253330283025302a375400226464a66605c60620042930b1bad302f001302b37540022c44a66605066e40008004530103d8798000153330283371e0040022980103d87a800014c103d87b80002533302a00114a2294094ccc094c088c09cdd5000899191919299981698180010a4c2c6eb8c0b8004c0b8008dd7181600098141baa0011622222323300100100622533302e00113302f337606ea4018dd3002a5eb7bdb1804c8c8c8c94ccc0b8c034cc01c0280084cc0cccdd81ba900a374c01200a2a66605c66e3c0280084c94ccc0bcc0b0c0c4dd500089981a19bb03752016606a60646ea80040104010ccc0200280240044cc0cccdd81ba9002374c0026600c00c0066eacc0c000cdd718170011819001181800091111191980080080311299981680089981719bb0375200c6ea00152f5bded8c0264646464a66605a60186600e01400426606466ec0dd48051ba80090051533302d3371e014004264a66605c605660606ea80044cc0cccdd81ba900b303430313754002008200866601001401200226606466ec0dd48011ba800133006006003375a605e0066eb8c0b4008c0c4008c0bc004dd7a6103d8798000375c604e0066eb4c09c008dd698138009bad302730280013027001302600130213754032266646464446464646464a666050604a60546ea80044c94ccc0a4c08cc0acdd500089919192999818181980109919192999817981618189baa00113301f3300f3303437526e61241084d697373696e6720003303437526e60038cc0d0dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd7024900330133010301d009375c606a60646ea800454cc0c0cc03ccc0d0dd49b98491084d697373696e6720003303437526e60038cc0d0dd49b9849010d20757067726164652070617468004bd70249001632533302f302930313754002298103d87a8000130213303437526eb8c0c8c8cdd8181b000981b181b8009bac30353032375400297ae032330010013756603460646ea800c894ccc0d00045300103d87a80001323253330323371e6eb8c0d00080244c090cc0dcdd39981b981a0011981b981a80125eb812f5c02660080080026070004606c002a66605a6054605e6ea80044c8c8c8c94ccc0d4c0e00084c926323300100100222533303700114984c8cc00c00cc0ec008c8c8dd7181c0011bae30360013039001163756606c002606c0046eb4c0d0004c0c0dd50008b1808980798179baa3017302f37540022c606200266602200a01098103d8798000375c605e60586ea800458c06cc0acdd5180d98159baa3013302b3754605c60566ea800458cc060dd6181680200d9bab302c302d302d302d002375860560026056002604c6ea806488dcc9919199800800802244100222533302a0021001132333004004302e00353330273024371a00426e600044cdc500119b8a00537300026e64dd718160011b98001300100122533302400114bd7009981298111813000998010011813800a490a43445043726561746f7200300b3021375403a46048604a604a00244646600200200644a66604800229404c94ccc084cdc79bae302700200414a2266006006002604e0024a6660386004603c6ea80044c088c07cdd50008a9980ea481134e6f7420616e20696e6c696e6520646174756d0016370e9002111191980300211801180498109baa001533301c3019301e3754002246600e6eacc020c080dd50008018918029998049bab3008302037540026eb8c040c080dd50019bae3008302037540066e21200022323300100100322533301f00114bd7009919299980e980280109981100119802002000899802002000981180118108009118091998020011bae300b301b37540026eb8c00cc06cdd50009180e180e80091119299980c1809180d1baa0011480004dd6980f180d9baa0013253330183012301a37540022980103d87a8000132330010013756603e60386ea8008894ccc078004530103d87a80001323232533301d3371e00e6eb8c07c00c4c03ccc088dd4000a5eb804cc014014008dd6980f80118110011810000991980080080211299980e8008a6103d87a80001323232533301c3371e00e6eb8c07800c4c038cc084dd3000a5eb804cc014014008dd5980f0011810801180f8009180d180d980d980d980d8009191980080080111299980c8008a5eb7bdb1804c8c8c8c94ccc064c020008400c4cc078cdd81ba9002374c0026600c00c0066eacc06c00cdd7180c801180e801180d8009b8f4881002253330123330120014a094454cc04c0084004400488c8cc00400400c894ccc05c0045300103d87a80001323253330153375e601060306ea80080144c01ccc0680092f5c0266008008002603600460320026e952000230140013012300f37540022c60226024004602000260186ea80045261365632533300830050011323232323232323253330143017002149858dd6980a800980a8011bad30130013013002375a602200260220046eb8c03c004c02cdd50018a99980418010008a99980618059baa00314985858c024dd50011b8748008c94ccc014c008c01c00454ccc024c020004526161637540046e1d20005734ae7155ceaab9e5573eae815d0aba21',
|
|
9
21
|
};
|
|
22
|
+
|
|
23
|
+
export const mkCDPCreatorValidator = (
|
|
24
|
+
params: CDPCreatorParams,
|
|
25
|
+
): SpendingValidator => {
|
|
26
|
+
return {
|
|
27
|
+
type: cdpCreatorValidator.type,
|
|
28
|
+
script: applyParamsToScript(cdpCreatorValidator.cborHex, [
|
|
29
|
+
castCDPCreatorParams(params),
|
|
30
|
+
]),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const mkCDPCreatorValidatorFromSP = (
|
|
35
|
+
params: CDPCreatorParamsSP,
|
|
36
|
+
): SpendingValidator => {
|
|
37
|
+
return {
|
|
38
|
+
type: cdpCreatorValidator.type,
|
|
39
|
+
script: applyParamsToScript(cdpCreatorValidator.cborHex, [
|
|
40
|
+
castCDPCreatorParams({
|
|
41
|
+
cdpCreatorNft: fromSystemParamsAsset(params.cdpCreatorNft),
|
|
42
|
+
cdpAssetCs: params.cdpAssetCs.unCurrencySymbol,
|
|
43
|
+
cdpAuthTk: fromSystemParamsAsset(params.cdpAuthTk),
|
|
44
|
+
iAssetAuthTk: fromSystemParamsAsset(params.iAssetAuthTk),
|
|
45
|
+
versionRecordToken: fromSystemParamsAsset(params.versionRecordToken),
|
|
46
|
+
cdpScriptHash: params.cdpScriptHash,
|
|
47
|
+
collectorValHash: params.collectorValHash,
|
|
48
|
+
minCollateralInLovelace: BigInt(params.minCollateralInLovelace),
|
|
49
|
+
biasTime: BigInt(params.biasTime),
|
|
50
|
+
}),
|
|
51
|
+
]),
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ScriptType } from
|
|
1
|
+
import { ScriptType } from '@lucid-evolution/lucid';
|
|
2
2
|
|
|
3
3
|
export const _collectorValidator = {
|
|
4
|
-
type:
|
|
4
|
+
type: 'PlutusV2' as ScriptType,
|
|
5
5
|
description: 'Generated by Aiken',
|
|
6
6
|
cborHex:
|
|
7
7
|
'590e7f590e7c010000323232323232323222323223232322533300a323232533300d3007300f37540022646464646464646464a6466602e60280122646464646464a66603a6034603e6ea80044c8c94ccc07ccc03524012f4d757374207370656e642073696e676c6520636f6c6c6563746f7220696e7075742077697468206f6e6c79204144410032533302400114a02a666048604e00226466ebcc058c090dd5180b18121baa001374c64a666044603e002297adef6c6013232330010014bd6f7b63011299981480089981519bb04c01014000374c00697adef6c60132323232533302930123300e48810000213302e337609801014000374c00e00a2a666052602600426605c66ec13001014000374c00e00626605c66ec0dd48011ba600133006006003375660560066eb8c0a4008c0b4008c0ac004c8cc0040052f5bded8c044a66605000226605266ec13001014000375000697adef6c60132323232533302830113300d48810000213302d337609801014000375000e00a2a666050602400426605a66ec13001014000375000e00626605a66ec0dd48011ba800133006006003375a60540066eb8c0a0008c0b0008c0a8004ccc030dd5980b18121baa30163024375400291100488100302600114a0660166eb0c040c088dd500a919baf301130233754602260466ea8c054c08cdd5000801099806a49364d7573742070726f6475636520636f6c6c6563746f72206f7574707574207769746820696e63726561736564204144412076616c75650033322232330010013300f0045333023302030253754006264466ebcc058c0a0dd5180b18141baa001002302930263754006264466ebcc058c0a0dd5000801181498131baa00322533302800114a0264a66604a64a66604c66ebcc04cc0a4dd5000a60107d87b9fd87980ff00132533302b00114a22a666056605c0022646464a66605460286eb8c0c000c54ccc0a8c05000454ccc0a8c09cc0b0dd526103d87a80001533302a337129000001099b89002482026fb808528099b89480000085280a50375c605e60600046eb4c0b8c0bcc0bc004dd618168008a503233001001323330010013756603a60566ea800cc8cc004004020894ccc0b800452f5bded8c02646606066ec0dd49bae302d001374c64660020026eacc0bc008894ccc0c400452f5bded8c02646606666ec0dd49bae3030001375066e052000375a606200266006006606a00460660026600600660640046060002444a66605c00420022646660080086064006666660240046eb8c0b4004dd59817000911192999817980a8008a60103d87a80001301f33034374c00297ae0323330010010030022225333035002100113233300400430390033333301a002375c60680026eb4c0d4004888c94ccc0d8c0cc0045300103d87a8000130263303b375000297ae03370000400202e606e004020606000444a666058002297ae01323332223233001001003225333032001100313233034374e660686ea4018cc0d0dd49bae30310013303437506eb4c0c80052f5c066006006606c00460680026eb8c0ac004dd5981600099801801981800118170008a50302b00214a226600600600260560026eb0c030c088dd500a99ba548008cc090c03ccc090004cc091300103d87a80004bd7025eb80c94ccc080c069200010011333330070014881003232002323300100100222533302700114984c94ccc0a0004526132325333026302330283754660166eb8c0a0c0b0010dd71814001099802802998158010008a99813a49326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016302c002302a001302a00133025337609810140004c010101004bd6f7b63011119299981218050008a60103d87a80001301433029374c00297ae03333300b0014890048008888c94ccc09cc090004530103d87a8000130173302c375000297ae03370000200401000a6eacc050c088dd5180a18111baa00214a0601e60426ea8c03cc084dd5180998109baa0013023302037540022c660166eb0c034c07cdd500900791299980e99b9000200114c103d87980001533301d3371e0040022980103d87a800014c103d87b80002533301f00114a2294088888c8cc004004018894ccc0900044cc094cdd81ba9006374c00a97adef6c601323232325333024300d3300700a002133029337606ea4028dd30048028a99981219b8f00a002132533302530223027375400226605466ec0dd4805981598141baa001004100433300800a009001133029337606ea4008dd3000998030030019bab3026003375c60480046050004604c00244444646600200200c44a66604600226604866ec0dd48031ba80054bd6f7b630099191919299981198061980380500109981419bb037520146ea002401454ccc08ccdc78050010992999812181098131baa001133029337606ea402cc0a8c09cdd5000802080219980400500480089981419bb037520046ea0004cc01801800cdd698128019bae302300230270023025001375e98103d87980001325333018301200a13233007491334d757374207370656e64207374616b696e67206d616e61676572207769746820446973747269627574652072656465656d65720032533301e00114a02a66603c60420022646466ebc009300103d87b800032533301c30190011323253330223025002149858dd71811800980f9baa0021533301c301600115333020301f37540042930b0a99980e180a8008a999810180f9baa00214985854ccc070cdc3a400c00226464a666044604a0042930b1bad3023001301f37540042a66603866e1d200800115333020301f37540042930b0a99980e19b874802800454ccc080c07cdd50010a4c2c2a66603866e1d200c00115333020301f37540042930b0b180e9baa00132533301b3018301d375400226042603c6ea800454cc071240117436f756c64206e6f742066696e642072656465656d6572001632323300100137566044604660466046604660466046604660466046603e6ea8048894ccc0840045300103d87a8000132323253330203375e00c6044006260206604a00297ae01330050050023022002302500230230013374a90011980f9805980e9baa30200014bd700a50330053758601460386ea803c8cc00cdd59807980e9baa300f301d3754002004601260366ea805c4cccc8c8c8888c8c8c8c8c94ccc08cc080c094dd50008992999812180f18131baa0011323232533302b302e0021323232533302a3027302c3754002266030660206605e6ea4dcc2481084d697373696e6720003302f37526e6003ccc0bcdd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003322323300100100322533303200114a0264a66605e66e3cdd7181a8010020a5113300300300130350013011323300100100a22533303000114bd6f7b6300991919192999818180d001080189981a99bb037520046e98004cc01801800cdd598190019bae303000230340023032001375c6060605a6ea800454cc0accc040cc0bcdd49b98491084d697373696e6720003302f37526e6003ccc0bcdd49b9849010d20757067726164652070617468004bd70249001632533302a3024302c3754002298103d87a80001301a3302f37526eb8c0b4c8cdd81818800981898190009bac3030302d375400297ae032330010013756603e605a6ea800c894ccc0bc0045300103d87a800013232533302d3371e6eb8c0bc0080244c074cc0c8dd399819181780119819181800125eb812f5c026600800800260660046062002a666050604a60546ea80044c8c8c8c94ccc0c0c0cc0084c926323300100100222533303200114984c8cc00c00cc0d8008c8c8dd718198011bae30310013034001163756606200260620046eb4c0bc004c0acdd50008b192999814181098151baa0011302e302b37540022a660529201134e6f7420616e20696e6c696e6520646174756d00163014302a3754603860546ea800458c0b0004c8cc0480188c008c070c0a8dd5000a999812981118139baa4c0103d8798000123300f3756603660526ea800402448cdc4240006660226eacc06cc0a4dd50009bae3017302937540126eb8c06cc0a4dd50049bae302a302737540022c6028604c6ea8c050c098dd5180c18131baa3029302637540022c660226eb0c0a0010054dd598139814181418140011bac3026001302600130213754004446e64c8c8ccc0040040112201002225333024002100113233300400430280035333021301e371a00426e600044cdc500119b8a00537300026e64dd718130011b98001300100122533301e00114bd7009980f980e1810000998010011810800a4909436f6c6c6563746f72003009301b375401e600a60366ea805c88c04cccc010008dd71805180e1baa001375c601c60386ea8004dc7a45002223253330193013301b37540022900009bad301f301c375400264a666032602660366ea8004530103d87a80001323300100137566040603a6ea8008894ccc07c004530103d87a80001323232533301e3371e00e6eb8c08000c4c038cc08cdd4000a5eb804cc014014008dd6981000118118011810800991980080080211299980f0008a6103d87a80001323232533301d3371e00e6eb8c07c00c4c034cc088dd3000a5eb804cc014014008dd5980f8011811001181000091191980080080191299980e0008a5eb804c8c94ccc068c0140084cc07c008cc0100100044cc010010004c080008c0780048c068c06cc06c004894ccc050ccc0500052825115330150021001100122323300100100322533301900114c103d87a80001323253330173375e601060346ea80080144c01ccc0700092f5c0266008008002603a00460360026e9520002301600130103754012602660206ea800458c004c03cdd5001918091809800980818069baa00114984d958c94ccc024c01800454ccc034c030dd50020a4c2c2a66601260060022a66601a60186ea8010526161533300930020011533300d300c37540082930b0b18051baa003370e90021b8748008c94ccc014c008c01c00454ccc024c020004526161637540046e1d20005734ae7155ceaab9e5573eae815d0aba21',
|