@indigo-labs/indigo-sdk 0.4.4 → 0.5.0
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 +102 -40
- package/dist/index.d.ts +102 -40
- package/dist/index.js +900 -801
- package/dist/index.mjs +339 -256
- package/package.json +2 -2
- package/src/contracts/cdp/helpers.ts +7 -6
- package/src/contracts/cdp/transactions.ts +8 -29
- package/src/contracts/gov/transactions.ts +12 -16
- package/src/contracts/iasset/helpers.ts +2 -7
- package/src/contracts/initialize/actions.ts +0 -2
- package/src/contracts/initialize/helpers.ts +0 -4
- package/src/contracts/interest-collection/transactions.ts +2 -5
- package/src/contracts/interest-oracle/helpers.ts +4 -0
- package/src/contracts/interest-oracle/transactions.ts +1 -4
- package/src/contracts/price-oracle/helpers.ts +5 -11
- package/src/contracts/price-oracle/transactions.ts +2 -7
- package/src/contracts/rob/transactions.ts +0 -2
- package/src/contracts/rob-leverage/transactions.ts +1 -4
- package/src/contracts/stability-pool/transactions.ts +2 -8
- package/src/contracts/stableswap/helpers.ts +369 -1
- package/src/contracts/stableswap/transactions.ts +43 -191
- package/src/contracts/staking/transactions.ts +2 -7
- package/tests/cdp/actions.ts +0 -11
- package/tests/cdp/cdp-helpers.ts +2 -2
- package/tests/cdp/cdp-queries.ts +1 -3
- package/tests/cdp/cdp.test.ts +409 -620
- package/tests/cdp/transactions-mutated.ts +30 -25
- package/tests/endpoints/initialize.ts +0 -2
- package/tests/gov/actions.ts +7 -32
- package/tests/gov/gov.test.ts +169 -401
- package/tests/indigo-test-helpers.ts +0 -1
- package/tests/initialize.test.ts +15 -20
- package/tests/interest-collection/interest-collection.test.ts +0 -4
- package/tests/interest-oracle.test.ts +1 -8
- package/tests/price-oracle/actions.ts +6 -8
- package/tests/price-oracle/price-oracle.test.ts +1 -13
- package/tests/price-oracle/transactions-mutated.ts +1 -4
- package/tests/pyth/pyth-indigo.test.ts +8 -12
- package/tests/pyth/pyth.test.ts +1 -2
- package/tests/rob/actions.ts +0 -2
- package/tests/rob/rob-leverage.test.ts +164 -220
- package/tests/rob/rob.test.ts +158 -263
- package/tests/rob/transactions-mutated.ts +7 -18
- package/tests/stability-pool/actions.ts +4 -8
- package/tests/stability-pool.test.ts +164 -255
- package/tests/stableswap/stableswap-actions.ts +0 -1
- package/tests/stableswap/stableswap.test.ts +226 -4
- package/tests/staking.test.ts +2 -13
- package/tests/treasury/treasury.test.ts +6 -30
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
LucidEvolution,
|
|
6
6
|
Credential,
|
|
7
7
|
OutRef,
|
|
8
|
-
slotToUnixTime,
|
|
9
8
|
toHex,
|
|
10
9
|
TxBuilder,
|
|
11
10
|
UTxO,
|
|
@@ -109,11 +108,9 @@ export async function mutatedRedeemCdp(
|
|
|
109
108
|
govOref: OutRef,
|
|
110
109
|
sysParams: SystemParams,
|
|
111
110
|
lucid: LucidEvolution,
|
|
112
|
-
currentSlot: number,
|
|
113
111
|
pythMessage?: string,
|
|
114
112
|
): Promise<TxBuilder> {
|
|
115
|
-
const
|
|
116
|
-
const currentTime = BigInt(slotToUnixTime(network, currentSlot));
|
|
113
|
+
const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
117
114
|
|
|
118
115
|
const cdpRefScriptUtxo = matchSingle(
|
|
119
116
|
await lucid.utxosByOutRef([
|
|
@@ -325,10 +322,9 @@ export async function mutatedRedeemCdp(
|
|
|
325
322
|
getInlineDatumOrThrow(priceOracleUtxo),
|
|
326
323
|
);
|
|
327
324
|
const txValidity = oracleExpirationAwareValidity(
|
|
328
|
-
|
|
325
|
+
lucid,
|
|
329
326
|
Number(sysParams.cdpCreatorParams.biasTime),
|
|
330
327
|
Number(priceOracleDatum.expirationTime),
|
|
331
|
-
network,
|
|
332
328
|
);
|
|
333
329
|
|
|
334
330
|
referenceInputs.push(priceOracleUtxo);
|
|
@@ -337,7 +333,7 @@ export async function mutatedRedeemCdp(
|
|
|
337
333
|
.validTo(txValidity.validTo)
|
|
338
334
|
.readFrom([priceOracleUtxo]);
|
|
339
335
|
} else {
|
|
340
|
-
const validateFrom = slotToUnixTime(
|
|
336
|
+
const validateFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
|
|
341
337
|
const validateTo =
|
|
342
338
|
validateFrom + Number(sysParams.cdpCreatorParams.biasTime);
|
|
343
339
|
|
|
@@ -419,7 +415,9 @@ export async function runOpenCdpDelisted(
|
|
|
419
415
|
);
|
|
420
416
|
|
|
421
417
|
const network = context.lucid.config().network!;
|
|
422
|
-
const currentTime = BigInt(
|
|
418
|
+
const currentTime = BigInt(
|
|
419
|
+
context.lucid.slotToUnixTime(context.lucid.currentSlot()),
|
|
420
|
+
);
|
|
423
421
|
|
|
424
422
|
const [pkh, skh] = await addrDetails(context.lucid);
|
|
425
423
|
|
|
@@ -568,7 +566,9 @@ export async function runOpenCdpDelisted(
|
|
|
568
566
|
)
|
|
569
567
|
: undefined;
|
|
570
568
|
|
|
571
|
-
const validFrom =
|
|
569
|
+
const validFrom = context.lucid.slotToUnixTime(
|
|
570
|
+
context.lucid.currentSlot() - 1,
|
|
571
|
+
);
|
|
572
572
|
const validTo = validFrom + Number(sysParams.cdpCreatorParams.biasTime);
|
|
573
573
|
|
|
574
574
|
tx.validFrom(validFrom).validTo(validTo);
|
|
@@ -622,7 +622,9 @@ export async function runOpenCdpAndUpdateOracle(
|
|
|
622
622
|
);
|
|
623
623
|
|
|
624
624
|
const network = context.lucid.config().network!;
|
|
625
|
-
const currentTime = BigInt(
|
|
625
|
+
const currentTime = BigInt(
|
|
626
|
+
context.lucid.slotToUnixTime(context.lucid.currentSlot()),
|
|
627
|
+
);
|
|
626
628
|
|
|
627
629
|
const [pkh, skh] = await addrDetails(context.lucid);
|
|
628
630
|
|
|
@@ -842,8 +844,9 @@ export async function runTestAdjustCdpDelisted(
|
|
|
842
844
|
collateralAdjustment: bigint,
|
|
843
845
|
debtAdjustment: bigint,
|
|
844
846
|
): Promise<TxBuilder> {
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
+
const currentTime = BigInt(
|
|
848
|
+
context.lucid.slotToUnixTime(context.lucid.currentSlot()),
|
|
849
|
+
);
|
|
847
850
|
const [pkh, skh] = await addrDetails(context.lucid);
|
|
848
851
|
|
|
849
852
|
const cdp = await findCdp(
|
|
@@ -912,7 +915,9 @@ export async function runTestAdjustCdpDelisted(
|
|
|
912
915
|
sysParams,
|
|
913
916
|
);
|
|
914
917
|
|
|
915
|
-
const validateFrom =
|
|
918
|
+
const validateFrom = context.lucid.slotToUnixTime(
|
|
919
|
+
context.lucid.currentSlot() - 1,
|
|
920
|
+
);
|
|
916
921
|
const validateTo =
|
|
917
922
|
validateFrom + Number(sysParams.cdpParams.biasTime) - 60_000;
|
|
918
923
|
|
|
@@ -1064,8 +1069,9 @@ export async function runTestDepositCdpWithInterestVar(
|
|
|
1064
1069
|
|
|
1065
1070
|
amount: bigint = 1_000_000n,
|
|
1066
1071
|
): Promise<TxBuilder> {
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1072
|
+
const currentTime = BigInt(
|
|
1073
|
+
context.lucid.slotToUnixTime(context.lucid.currentSlot()),
|
|
1074
|
+
);
|
|
1069
1075
|
const [pkh, skh] = await addrDetails(context.lucid);
|
|
1070
1076
|
|
|
1071
1077
|
const cdp = await findCdp(
|
|
@@ -1125,7 +1131,9 @@ export async function runTestDepositCdpWithInterestVar(
|
|
|
1125
1131
|
getInlineDatumOrThrow(interestOracleUtxo),
|
|
1126
1132
|
);
|
|
1127
1133
|
|
|
1128
|
-
const validateFrom =
|
|
1134
|
+
const validateFrom = context.lucid.slotToUnixTime(
|
|
1135
|
+
context.lucid.currentSlot() - 1,
|
|
1136
|
+
);
|
|
1129
1137
|
const validateTo =
|
|
1130
1138
|
validateFrom + Number(sysParams.cdpParams.biasTime) - 60_000;
|
|
1131
1139
|
|
|
@@ -1241,7 +1249,6 @@ export async function runTestDepositCdpWithInterestVar(
|
|
|
1241
1249
|
|
|
1242
1250
|
export async function runCloseCdpWrongOracle(
|
|
1243
1251
|
lucid: LucidEvolution,
|
|
1244
|
-
currentSlot: number,
|
|
1245
1252
|
sysParams: SystemParams,
|
|
1246
1253
|
iasset: string,
|
|
1247
1254
|
wrongAsset: string,
|
|
@@ -1268,8 +1275,7 @@ export async function runCloseCdpWrongOracle(
|
|
|
1268
1275
|
orefs.collateralAsset,
|
|
1269
1276
|
);
|
|
1270
1277
|
|
|
1271
|
-
const
|
|
1272
|
-
const currentTime = BigInt(slotToUnixTime(network, currentSlot));
|
|
1278
|
+
const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
1273
1279
|
|
|
1274
1280
|
const cdpRefScriptUtxo = matchSingle(
|
|
1275
1281
|
await lucid.utxosByOutRef([
|
|
@@ -1336,10 +1342,9 @@ export async function runCloseCdpWrongOracle(
|
|
|
1336
1342
|
);
|
|
1337
1343
|
|
|
1338
1344
|
const txValidity = oracleExpirationAwareValidity(
|
|
1339
|
-
|
|
1345
|
+
lucid,
|
|
1340
1346
|
Number(sysParams.cdpCreatorParams.biasTime),
|
|
1341
1347
|
Number(priceOracleDatum.expirationTime),
|
|
1342
|
-
network,
|
|
1343
1348
|
);
|
|
1344
1349
|
|
|
1345
1350
|
const tx = lucid
|
|
@@ -1485,8 +1490,9 @@ export async function runRedeemCdpWrongOracle(
|
|
|
1485
1490
|
getInlineDatumOrThrow(wrongPriceOracleUtxo),
|
|
1486
1491
|
);
|
|
1487
1492
|
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1493
|
+
const currentTime = BigInt(
|
|
1494
|
+
context.lucid.slotToUnixTime(context.lucid.currentSlot()),
|
|
1495
|
+
);
|
|
1490
1496
|
|
|
1491
1497
|
const cdpRefScriptUtxo = matchSingle(
|
|
1492
1498
|
await context.lucid.utxosByOutRef([
|
|
@@ -1577,10 +1583,9 @@ export async function runRedeemCdpWrongOracle(
|
|
|
1577
1583
|
);
|
|
1578
1584
|
|
|
1579
1585
|
const txValidity = oracleExpirationAwareValidity(
|
|
1580
|
-
context.
|
|
1586
|
+
context.lucid,
|
|
1581
1587
|
Number(sysParams.cdpCreatorParams.biasTime),
|
|
1582
1588
|
Number(wrongPriceOracleDatum.expirationTime),
|
|
1583
|
-
network,
|
|
1584
1589
|
);
|
|
1585
1590
|
|
|
1586
1591
|
const referenceInputs = [
|
|
@@ -41,7 +41,6 @@ export { initPythConfig, mintOneTimeToken, DEFAULT_INIT_OPTIONS };
|
|
|
41
41
|
export async function init(
|
|
42
42
|
lucid: LucidEvolution,
|
|
43
43
|
defaultInitialAssets: InitialAssetParam[],
|
|
44
|
-
currentSlot: number,
|
|
45
44
|
mkPythBasedAssets: (
|
|
46
45
|
pythStateNft: AssetClass,
|
|
47
46
|
) => InitialAssetParam[] = () => [],
|
|
@@ -70,7 +69,6 @@ export async function init(
|
|
|
70
69
|
return initContract(
|
|
71
70
|
lucid,
|
|
72
71
|
defaultInitialAssets,
|
|
73
|
-
currentSlot,
|
|
74
72
|
mkPythBasedAssets,
|
|
75
73
|
protocolParams,
|
|
76
74
|
initOptions,
|
package/tests/gov/actions.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
fromText,
|
|
4
4
|
OutRef,
|
|
5
5
|
paymentCredentialOf,
|
|
6
|
-
unixTimeToSlot,
|
|
7
6
|
} from '@lucid-evolution/lucid';
|
|
8
7
|
import {
|
|
9
8
|
addrDetails,
|
|
@@ -70,14 +69,7 @@ export async function runVote(
|
|
|
70
69
|
|
|
71
70
|
await runAndAwaitTx(
|
|
72
71
|
context.lucid,
|
|
73
|
-
vote(
|
|
74
|
-
option,
|
|
75
|
-
pollShard.utxo,
|
|
76
|
-
stakingPosOref.utxo,
|
|
77
|
-
sysParams,
|
|
78
|
-
context.lucid,
|
|
79
|
-
context.emulator.slot,
|
|
80
|
-
),
|
|
72
|
+
vote(option, pollShard.utxo, stakingPosOref.utxo, sysParams, context.lucid),
|
|
81
73
|
);
|
|
82
74
|
}
|
|
83
75
|
|
|
@@ -106,13 +98,7 @@ export async function runCreateAllShards(
|
|
|
106
98
|
|
|
107
99
|
await runAndAwaitTx(
|
|
108
100
|
context.lucid,
|
|
109
|
-
createShardsChunks(
|
|
110
|
-
2n,
|
|
111
|
-
pollUtxo.utxo,
|
|
112
|
-
sysParams,
|
|
113
|
-
context.emulator.slot,
|
|
114
|
-
context.lucid,
|
|
115
|
-
),
|
|
101
|
+
createShardsChunks(2n, pollUtxo.utxo, sysParams, context.lucid),
|
|
116
102
|
);
|
|
117
103
|
}
|
|
118
104
|
}
|
|
@@ -154,7 +140,6 @@ export async function runMergeAllShards(
|
|
|
154
140
|
A.takeLeft(2)(allPollShards).map((u) => u.utxo),
|
|
155
141
|
sysParams,
|
|
156
142
|
context.lucid,
|
|
157
|
-
context.emulator.slot,
|
|
158
143
|
),
|
|
159
144
|
);
|
|
160
145
|
}
|
|
@@ -180,13 +165,7 @@ export async function runEndProposal(
|
|
|
180
165
|
|
|
181
166
|
await runAndAwaitTx(
|
|
182
167
|
context.lucid,
|
|
183
|
-
endProposal(
|
|
184
|
-
pollUtxo.utxo,
|
|
185
|
-
govUtxo.utxo,
|
|
186
|
-
sysParams,
|
|
187
|
-
context.lucid,
|
|
188
|
-
context.emulator.slot,
|
|
189
|
-
),
|
|
168
|
+
endProposal(pollUtxo.utxo, govUtxo.utxo, sysParams, context.lucid),
|
|
190
169
|
);
|
|
191
170
|
}
|
|
192
171
|
|
|
@@ -202,15 +181,14 @@ export async function waitForVotingEnd(
|
|
|
202
181
|
pollId,
|
|
203
182
|
);
|
|
204
183
|
|
|
205
|
-
const targetSlot = unixTimeToSlot(
|
|
206
|
-
context.lucid.config().network!,
|
|
184
|
+
const targetSlot = context.lucid.unixTimeToSlot(
|
|
207
185
|
Number(pollUtxo.datum.votingEndTime),
|
|
208
186
|
);
|
|
209
187
|
|
|
210
|
-
if (targetSlot > context.
|
|
211
|
-
expect(targetSlot).toBeGreaterThan(context.
|
|
188
|
+
if (targetSlot > context.lucid.currentSlot()) {
|
|
189
|
+
expect(targetSlot).toBeGreaterThan(context.lucid.currentSlot());
|
|
212
190
|
|
|
213
|
-
context.emulator.awaitSlot(targetSlot - context.
|
|
191
|
+
context.emulator.awaitSlot(targetSlot - context.lucid.currentSlot() + 1);
|
|
214
192
|
}
|
|
215
193
|
}
|
|
216
194
|
|
|
@@ -251,7 +229,6 @@ export async function runExecuteProposal(
|
|
|
251
229
|
stableswapPoolOrCdpCreatorOref,
|
|
252
230
|
sysParams,
|
|
253
231
|
context.lucid,
|
|
254
|
-
context.emulator.slot,
|
|
255
232
|
),
|
|
256
233
|
);
|
|
257
234
|
}
|
|
@@ -334,7 +311,6 @@ export async function whitelistCollateralAsset(
|
|
|
334
311
|
'COLLATERAL_ORACLE',
|
|
335
312
|
initialPrice,
|
|
336
313
|
oracleParams,
|
|
337
|
-
context.emulator.slot,
|
|
338
314
|
);
|
|
339
315
|
await runAndAwaitTxBuilder(context.lucid, priceOracleTx);
|
|
340
316
|
|
|
@@ -355,7 +331,6 @@ export async function whitelistCollateralAsset(
|
|
|
355
331
|
null,
|
|
356
332
|
sysParams,
|
|
357
333
|
context.lucid,
|
|
358
|
-
context.emulator.slot,
|
|
359
334
|
(
|
|
360
335
|
await findGov(
|
|
361
336
|
context.lucid,
|