@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
|
fromText,
|
|
6
6
|
LucidEvolution,
|
|
7
7
|
OutRef,
|
|
8
|
-
slotToUnixTime,
|
|
9
8
|
toHex,
|
|
10
9
|
TxBuilder,
|
|
11
10
|
} from '@lucid-evolution/lucid';
|
|
@@ -130,11 +129,9 @@ export async function adjustStakingPosition(
|
|
|
130
129
|
amount: bigint,
|
|
131
130
|
params: SystemParams,
|
|
132
131
|
lucid: LucidEvolution,
|
|
133
|
-
currentSlot: number,
|
|
134
132
|
stakingManagerRef?: OutRef,
|
|
135
133
|
): Promise<TxBuilder> {
|
|
136
|
-
const
|
|
137
|
-
const now = BigInt(slotToUnixTime(network, currentSlot));
|
|
134
|
+
const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
138
135
|
|
|
139
136
|
const stakingPositionOut = await findStakingPositionByOutRef(
|
|
140
137
|
stakingPositionRef,
|
|
@@ -210,11 +207,9 @@ export async function closeStakingPosition(
|
|
|
210
207
|
stakingPositionRef: OutRef,
|
|
211
208
|
params: SystemParams,
|
|
212
209
|
lucid: LucidEvolution,
|
|
213
|
-
currentSlot: number,
|
|
214
210
|
stakingManagerRef?: OutRef,
|
|
215
211
|
): Promise<TxBuilder> {
|
|
216
|
-
const
|
|
217
|
-
const now = BigInt(slotToUnixTime(network, currentSlot));
|
|
212
|
+
const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
218
213
|
|
|
219
214
|
const stakingPositionOut = await findStakingPositionByOutRef(
|
|
220
215
|
stakingPositionRef,
|
package/tests/cdp/actions.ts
CHANGED
|
@@ -103,7 +103,6 @@ export async function runOpenCdp(
|
|
|
103
103
|
orefs.interestOracleUtxo,
|
|
104
104
|
directTreasuryPayment ? undefined : orefs.treasuryUtxo,
|
|
105
105
|
context.lucid,
|
|
106
|
-
context.emulator.slot,
|
|
107
106
|
pythMessage,
|
|
108
107
|
pythStateOref,
|
|
109
108
|
);
|
|
@@ -142,7 +141,6 @@ export async function runDepositCdp(
|
|
|
142
141
|
orefs.interestCollectorUtxo,
|
|
143
142
|
sysParams,
|
|
144
143
|
context.lucid,
|
|
145
|
-
context.emulator.slot,
|
|
146
144
|
);
|
|
147
145
|
}
|
|
148
146
|
|
|
@@ -194,7 +192,6 @@ export async function runWithdrawCdp(
|
|
|
194
192
|
orefs.interestCollectorUtxo,
|
|
195
193
|
sysParams,
|
|
196
194
|
context.lucid,
|
|
197
|
-
context.emulator.slot,
|
|
198
195
|
pythMessage,
|
|
199
196
|
pythStateOref,
|
|
200
197
|
);
|
|
@@ -249,7 +246,6 @@ export async function runMintCdp(
|
|
|
249
246
|
orefs.interestCollectorUtxo,
|
|
250
247
|
sysParams,
|
|
251
248
|
context.lucid,
|
|
252
|
-
context.emulator.slot,
|
|
253
249
|
pythMessage,
|
|
254
250
|
pythStateOref,
|
|
255
251
|
);
|
|
@@ -288,7 +284,6 @@ export async function runBurnCdp(
|
|
|
288
284
|
orefs.interestCollectorUtxo,
|
|
289
285
|
sysParams,
|
|
290
286
|
context.lucid,
|
|
291
|
-
context.emulator.slot,
|
|
292
287
|
);
|
|
293
288
|
}
|
|
294
289
|
|
|
@@ -321,7 +316,6 @@ export async function runCloseCdp(
|
|
|
321
316
|
orefs.interestCollectorUtxo,
|
|
322
317
|
sysParams,
|
|
323
318
|
context.lucid,
|
|
324
|
-
context.emulator.slot,
|
|
325
319
|
);
|
|
326
320
|
}
|
|
327
321
|
|
|
@@ -367,7 +361,6 @@ export async function runRedeemCdp(
|
|
|
367
361
|
orefs.govUtxo,
|
|
368
362
|
sysParams,
|
|
369
363
|
context.lucid,
|
|
370
|
-
context.emulator.slot,
|
|
371
364
|
);
|
|
372
365
|
}
|
|
373
366
|
|
|
@@ -415,7 +408,6 @@ export async function runFreezeCdp(
|
|
|
415
408
|
orefs.interestOracleUtxo,
|
|
416
409
|
sysParams,
|
|
417
410
|
context.lucid,
|
|
418
|
-
context.emulator.slot,
|
|
419
411
|
pythMessage,
|
|
420
412
|
pythStateOref,
|
|
421
413
|
);
|
|
@@ -463,7 +455,6 @@ export async function runCreateAndFreezeCdps(
|
|
|
463
455
|
orefs.interestOracleUtxo,
|
|
464
456
|
orefs.treasuryUtxo,
|
|
465
457
|
context.lucid,
|
|
466
|
-
context.emulator.slot,
|
|
467
458
|
),
|
|
468
459
|
);
|
|
469
460
|
});
|
|
@@ -475,7 +466,6 @@ export async function runCreateAndFreezeCdps(
|
|
|
475
466
|
priceOracleUtxo!,
|
|
476
467
|
{ numerator: 18n, denominator: 10n }, // 1.8
|
|
477
468
|
assetInfo.collateralAssets[0].oracleParams!,
|
|
478
|
-
context.emulator.slot,
|
|
479
469
|
),
|
|
480
470
|
);
|
|
481
471
|
|
|
@@ -515,7 +505,6 @@ export async function runCreateAndFreezeCdps(
|
|
|
515
505
|
orefs.interestOracleUtxo,
|
|
516
506
|
sysParams,
|
|
517
507
|
context.lucid,
|
|
518
|
-
context.emulator.slot,
|
|
519
508
|
),
|
|
520
509
|
);
|
|
521
510
|
}
|
package/tests/cdp/cdp-helpers.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { match, P } from 'ts-pattern';
|
|
|
2
2
|
import { CDPContent } from '../../src/contracts/cdp/types-new';
|
|
3
3
|
import { calculateAccruedInterest } from '../../src/contracts/interest-oracle/helpers';
|
|
4
4
|
import { LucidContext } from '../test-helpers';
|
|
5
|
-
import {
|
|
5
|
+
import { toHex, toText } from '@lucid-evolution/lucid';
|
|
6
6
|
import { findCollateralAsset } from '../queries/iasset-queries';
|
|
7
7
|
import {
|
|
8
8
|
fromSystemParamsAsset,
|
|
@@ -18,7 +18,7 @@ export async function calculateCdpInterest(
|
|
|
18
18
|
sysParams: SystemParams,
|
|
19
19
|
): Promise<bigint> {
|
|
20
20
|
const currentTime = BigInt(
|
|
21
|
-
|
|
21
|
+
context.lucid.slotToUnixTime(context.lucid.currentSlot()),
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
const collateralAsset = await findCollateralAsset(
|
package/tests/cdp/cdp-queries.ts
CHANGED
|
@@ -385,7 +385,6 @@ export async function findCdpCR(
|
|
|
385
385
|
lucid: LucidEvolution,
|
|
386
386
|
sysParams: SystemParams,
|
|
387
387
|
cdp: { utxo: UTxO; datum: CDPContent },
|
|
388
|
-
slot: number,
|
|
389
388
|
): Promise<number> {
|
|
390
389
|
const iassetAscii = toText(toHex(cdp.datum.iasset));
|
|
391
390
|
|
|
@@ -410,7 +409,7 @@ export async function findCdpCR(
|
|
|
410
409
|
);
|
|
411
410
|
|
|
412
411
|
return cdpCollateralRatioPercentage(
|
|
413
|
-
|
|
412
|
+
BigInt(lucid.slotToUnixTime(lucid.currentSlot())),
|
|
414
413
|
adjustedPrice,
|
|
415
414
|
cdp.utxo.assets,
|
|
416
415
|
cdp.datum,
|
|
@@ -420,6 +419,5 @@ export async function findCdpCR(
|
|
|
420
419
|
iassetAscii,
|
|
421
420
|
cdp.datum.collateralAsset,
|
|
422
421
|
),
|
|
423
|
-
lucid.config().network!,
|
|
424
422
|
);
|
|
425
423
|
}
|