@indigo-labs/indigo-sdk 0.6.0 → 0.6.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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -21
- package/dist/index.mjs +37 -21
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -3676,7 +3676,7 @@ declare function processSpRequest(stabilityPoolUtxo: UTxO, accountUtxo: UTxO, iA
|
|
|
3676
3676
|
/**
|
|
3677
3677
|
* For performance provide only the ones related to the pool's iAsset.
|
|
3678
3678
|
*/
|
|
3679
|
-
allE2s2sSnapshotOrefs: OutRef[], sysParams: SystemParams, lucid: LucidEvolution
|
|
3679
|
+
allE2s2sSnapshotOrefs: OutRef[], sysParams: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
3680
3680
|
declare function createE2s2sSnapshots(stabilityPoolOref: OutRef, sysParams: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
3681
3681
|
declare function annulRequest(accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
3682
3682
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3676,7 +3676,7 @@ declare function processSpRequest(stabilityPoolUtxo: UTxO, accountUtxo: UTxO, iA
|
|
|
3676
3676
|
/**
|
|
3677
3677
|
* For performance provide only the ones related to the pool's iAsset.
|
|
3678
3678
|
*/
|
|
3679
|
-
allE2s2sSnapshotOrefs: OutRef[], sysParams: SystemParams, lucid: LucidEvolution
|
|
3679
|
+
allE2s2sSnapshotOrefs: OutRef[], sysParams: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
3680
3680
|
declare function createE2s2sSnapshots(stabilityPoolOref: OutRef, sysParams: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
3681
3681
|
declare function annulRequest(accountUtxo: UTxO, params: SystemParams, lucid: LucidEvolution): Promise<TxBuilder>;
|
|
3682
3682
|
|
package/dist/index.js
CHANGED
|
@@ -860,8 +860,9 @@ function calculateAccruedInterest(now, unitaryInterestSnapshot, mintedAmount, in
|
|
|
860
860
|
|
|
861
861
|
// src/contracts/price-oracle/helpers.ts
|
|
862
862
|
function oracleExpirationAwareValidity(lucid, biasTime, oracleExpiration) {
|
|
863
|
-
const
|
|
864
|
-
const
|
|
863
|
+
const currentTime = lucid.slotToUnixTime(lucid.currentSlot());
|
|
864
|
+
const validateFrom = currentTime - Math.floor(biasTime / 2);
|
|
865
|
+
const defaultValidateTo = currentTime + Math.floor(biasTime / 2);
|
|
865
866
|
const cappedValidateTo = lucid.slotToUnixTime(
|
|
866
867
|
lucid.unixTimeToSlot(oracleExpiration) - 1
|
|
867
868
|
);
|
|
@@ -2600,8 +2601,12 @@ async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef
|
|
|
2600
2601
|
referenceInputs,
|
|
2601
2602
|
false
|
|
2602
2603
|
);
|
|
2603
|
-
const validateFrom =
|
|
2604
|
-
|
|
2604
|
+
const validateFrom = Number(
|
|
2605
|
+
currentTime - BigInt(params.cdpParams.biasTime) / 2n
|
|
2606
|
+
);
|
|
2607
|
+
const validateTo = Number(
|
|
2608
|
+
currentTime + BigInt(params.cdpParams.biasTime) / 2n
|
|
2609
|
+
);
|
|
2605
2610
|
const tx = lucid.newTx().validFrom(validateFrom).validTo(validateTo).readFrom(referenceInputs).collectFrom([interestCollectorUtxo], {
|
|
2606
2611
|
kind: "selected",
|
|
2607
2612
|
makeRedeemer: (inputIndices) => {
|
|
@@ -4107,6 +4112,8 @@ function derivePythPrice(derivedPythPrice, messageHex) {
|
|
|
4107
4112
|
|
|
4108
4113
|
// src/contracts/iasset/helpers.ts
|
|
4109
4114
|
var Core = __toESM(require("@evolution-sdk/evolution"));
|
|
4115
|
+
var MAX_PYTH_FEED_DELAY = 280 * 1e3;
|
|
4116
|
+
var PYTH_FEED_LEDGER_TIME_BUFFER = 20 * 1e3;
|
|
4110
4117
|
var MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET = 9;
|
|
4111
4118
|
function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythStateOref, pythMessage, pythConfig, biasTime, lucid, tx) {
|
|
4112
4119
|
return (0, import_ts_pattern12.match)(priceInfo).returnType().with({ Delisted: import_ts_pattern12.P.any }, () => {
|
|
@@ -4187,9 +4194,8 @@ function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythS
|
|
|
4187
4194
|
auxiliaryData: Core.Data.fromCBORHex(import_lucid11.Data.void())
|
|
4188
4195
|
})
|
|
4189
4196
|
);
|
|
4190
|
-
const
|
|
4191
|
-
const
|
|
4192
|
-
const validTo = Number(pythTimestamp + pythMaxDelay);
|
|
4197
|
+
const validFrom = Number(pythTimestamp - PYTH_FEED_LEDGER_TIME_BUFFER);
|
|
4198
|
+
const validTo = Number(pythTimestamp + MAX_PYTH_FEED_DELAY);
|
|
4193
4199
|
return {
|
|
4194
4200
|
interval: {
|
|
4195
4201
|
validFrom,
|
|
@@ -4673,8 +4679,12 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
|
|
|
4673
4679
|
const interestOracleDatum = parseInterestOracleDatum(
|
|
4674
4680
|
getInlineDatumOrThrow(interestOracleUtxo)
|
|
4675
4681
|
);
|
|
4676
|
-
const validateFrom =
|
|
4677
|
-
|
|
4682
|
+
const validateFrom = Number(
|
|
4683
|
+
currentTime - BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4684
|
+
);
|
|
4685
|
+
const validateTo = Number(
|
|
4686
|
+
currentTime + BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4687
|
+
);
|
|
4678
4688
|
const tx = lucid.newTx().readFrom([
|
|
4679
4689
|
cdpRefScriptUtxo,
|
|
4680
4690
|
iAssetTokenPolicyRefScriptUtxo,
|
|
@@ -4869,8 +4879,12 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
|
|
|
4869
4879
|
referenceInputs.push(priceOracleUtxo);
|
|
4870
4880
|
tx.validFrom(txValidity.validFrom).validTo(txValidity.validTo);
|
|
4871
4881
|
} else {
|
|
4872
|
-
const validateFrom =
|
|
4873
|
-
|
|
4882
|
+
const validateFrom = Number(
|
|
4883
|
+
currentTime - BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4884
|
+
);
|
|
4885
|
+
const validateTo = Number(
|
|
4886
|
+
currentTime + BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4887
|
+
);
|
|
4874
4888
|
tx.validFrom(validateFrom).validTo(validateTo);
|
|
4875
4889
|
}
|
|
4876
4890
|
const partialRedemptionFee = import_fp_ts13.function.pipe(
|
|
@@ -8377,9 +8391,8 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
|
|
|
8377
8391
|
)
|
|
8378
8392
|
).addSignerKey((0, import_lucid47.toHex)(oldAccountDatum.owner));
|
|
8379
8393
|
}
|
|
8380
|
-
async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, txFee
|
|
8381
|
-
const
|
|
8382
|
-
const currentTime = BigInt(lucid.slotToUnixTime(slot));
|
|
8394
|
+
async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, txFee) {
|
|
8395
|
+
const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
8383
8396
|
const stabilityPoolScriptRef = (0, import_cardano_offchain_common24.matchSingle)(
|
|
8384
8397
|
await lucid.utxosByOutRef([
|
|
8385
8398
|
fromSystemParamsScriptRef(
|
|
@@ -8395,8 +8408,13 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
|
|
|
8395
8408
|
getInlineDatumOrThrow(stabilityPoolUtxo)
|
|
8396
8409
|
);
|
|
8397
8410
|
const baseRefInputs = [iAssetUtxo, stabilityPoolScriptRef];
|
|
8398
|
-
const
|
|
8399
|
-
|
|
8411
|
+
const validateFrom = Number(
|
|
8412
|
+
currentTime - BigInt(sysParams.stabilityPoolParams.accountProcessingBiasMs) / 2n
|
|
8413
|
+
);
|
|
8414
|
+
const validateTo = Number(
|
|
8415
|
+
currentTime + BigInt(sysParams.stabilityPoolParams.accountProcessingBiasMs) / 2n
|
|
8416
|
+
);
|
|
8417
|
+
const tx = lucid.newTx().validFrom(validateFrom).validTo(validateTo).readFrom(baseRefInputs).collectFrom([stabilityPoolUtxo], {
|
|
8400
8418
|
kind: "selected",
|
|
8401
8419
|
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
8402
8420
|
makeRedeemer: (indices) => serialiseStabilityPoolRedeemer({
|
|
@@ -8767,7 +8785,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
|
|
|
8767
8785
|
}).exhaustive();
|
|
8768
8786
|
return tx;
|
|
8769
8787
|
}
|
|
8770
|
-
async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid
|
|
8788
|
+
async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid) {
|
|
8771
8789
|
const draftTx = processSpRequestAuxiliary(
|
|
8772
8790
|
stabilityPoolUtxo,
|
|
8773
8791
|
accountUtxo,
|
|
@@ -8776,8 +8794,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
|
|
|
8776
8794
|
sysParams,
|
|
8777
8795
|
lucid,
|
|
8778
8796
|
// Placeholder transation fee
|
|
8779
|
-
1n
|
|
8780
|
-
currentSlot
|
|
8797
|
+
1n
|
|
8781
8798
|
);
|
|
8782
8799
|
const fee = (await (await draftTx).complete()).toTransaction().body().fee();
|
|
8783
8800
|
return processSpRequestAuxiliary(
|
|
@@ -8787,8 +8804,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
|
|
|
8787
8804
|
allE2s2sSnapshotOrefs,
|
|
8788
8805
|
sysParams,
|
|
8789
8806
|
lucid,
|
|
8790
|
-
fee
|
|
8791
|
-
currentSlot
|
|
8807
|
+
fee
|
|
8792
8808
|
);
|
|
8793
8809
|
}
|
|
8794
8810
|
async function createE2s2sSnapshots(stabilityPoolOref, sysParams, lucid) {
|
package/dist/index.mjs
CHANGED
|
@@ -465,8 +465,9 @@ function calculateAccruedInterest(now, unitaryInterestSnapshot, mintedAmount, in
|
|
|
465
465
|
|
|
466
466
|
// src/contracts/price-oracle/helpers.ts
|
|
467
467
|
function oracleExpirationAwareValidity(lucid, biasTime, oracleExpiration) {
|
|
468
|
-
const
|
|
469
|
-
const
|
|
468
|
+
const currentTime = lucid.slotToUnixTime(lucid.currentSlot());
|
|
469
|
+
const validateFrom = currentTime - Math.floor(biasTime / 2);
|
|
470
|
+
const defaultValidateTo = currentTime + Math.floor(biasTime / 2);
|
|
470
471
|
const cappedValidateTo = lucid.slotToUnixTime(
|
|
471
472
|
lucid.unixTimeToSlot(oracleExpiration) - 1
|
|
472
473
|
);
|
|
@@ -2244,8 +2245,12 @@ async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef
|
|
|
2244
2245
|
referenceInputs,
|
|
2245
2246
|
false
|
|
2246
2247
|
);
|
|
2247
|
-
const validateFrom =
|
|
2248
|
-
|
|
2248
|
+
const validateFrom = Number(
|
|
2249
|
+
currentTime - BigInt(params.cdpParams.biasTime) / 2n
|
|
2250
|
+
);
|
|
2251
|
+
const validateTo = Number(
|
|
2252
|
+
currentTime + BigInt(params.cdpParams.biasTime) / 2n
|
|
2253
|
+
);
|
|
2249
2254
|
const tx = lucid.newTx().validFrom(validateFrom).validTo(validateTo).readFrom(referenceInputs).collectFrom([interestCollectorUtxo], {
|
|
2250
2255
|
kind: "selected",
|
|
2251
2256
|
makeRedeemer: (inputIndices) => {
|
|
@@ -3788,6 +3793,8 @@ function derivePythPrice(derivedPythPrice, messageHex) {
|
|
|
3788
3793
|
|
|
3789
3794
|
// src/contracts/iasset/helpers.ts
|
|
3790
3795
|
import * as Core from "@evolution-sdk/evolution";
|
|
3796
|
+
var MAX_PYTH_FEED_DELAY = 280 * 1e3;
|
|
3797
|
+
var PYTH_FEED_LEDGER_TIME_BUFFER = 20 * 1e3;
|
|
3791
3798
|
var MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET = 9;
|
|
3792
3799
|
function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythStateOref, pythMessage, pythConfig, biasTime, lucid, tx) {
|
|
3793
3800
|
return match11(priceInfo).returnType().with({ Delisted: P12.any }, () => {
|
|
@@ -3868,9 +3875,8 @@ function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythS
|
|
|
3868
3875
|
auxiliaryData: Core.Data.fromCBORHex(Data18.void())
|
|
3869
3876
|
})
|
|
3870
3877
|
);
|
|
3871
|
-
const
|
|
3872
|
-
const
|
|
3873
|
-
const validTo = Number(pythTimestamp + pythMaxDelay);
|
|
3878
|
+
const validFrom = Number(pythTimestamp - PYTH_FEED_LEDGER_TIME_BUFFER);
|
|
3879
|
+
const validTo = Number(pythTimestamp + MAX_PYTH_FEED_DELAY);
|
|
3874
3880
|
return {
|
|
3875
3881
|
interval: {
|
|
3876
3882
|
validFrom,
|
|
@@ -4357,8 +4363,12 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
|
|
|
4357
4363
|
const interestOracleDatum = parseInterestOracleDatum(
|
|
4358
4364
|
getInlineDatumOrThrow(interestOracleUtxo)
|
|
4359
4365
|
);
|
|
4360
|
-
const validateFrom =
|
|
4361
|
-
|
|
4366
|
+
const validateFrom = Number(
|
|
4367
|
+
currentTime - BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4368
|
+
);
|
|
4369
|
+
const validateTo = Number(
|
|
4370
|
+
currentTime + BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4371
|
+
);
|
|
4362
4372
|
const tx = lucid.newTx().readFrom([
|
|
4363
4373
|
cdpRefScriptUtxo,
|
|
4364
4374
|
iAssetTokenPolicyRefScriptUtxo,
|
|
@@ -4553,8 +4563,12 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
|
|
|
4553
4563
|
referenceInputs.push(priceOracleUtxo);
|
|
4554
4564
|
tx.validFrom(txValidity.validFrom).validTo(txValidity.validTo);
|
|
4555
4565
|
} else {
|
|
4556
|
-
const validateFrom =
|
|
4557
|
-
|
|
4566
|
+
const validateFrom = Number(
|
|
4567
|
+
currentTime - BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4568
|
+
);
|
|
4569
|
+
const validateTo = Number(
|
|
4570
|
+
currentTime + BigInt(sysParams.cdpParams.biasTime) / 2n
|
|
4571
|
+
);
|
|
4558
4572
|
tx.validFrom(validateFrom).validTo(validateTo);
|
|
4559
4573
|
}
|
|
4560
4574
|
const partialRedemptionFee = F12.pipe(
|
|
@@ -8160,9 +8174,8 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
|
|
|
8160
8174
|
)
|
|
8161
8175
|
).addSignerKey(toHex12(oldAccountDatum.owner));
|
|
8162
8176
|
}
|
|
8163
|
-
async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, txFee
|
|
8164
|
-
const
|
|
8165
|
-
const currentTime = BigInt(lucid.slotToUnixTime(slot));
|
|
8177
|
+
async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, txFee) {
|
|
8178
|
+
const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
8166
8179
|
const stabilityPoolScriptRef = matchSingle5(
|
|
8167
8180
|
await lucid.utxosByOutRef([
|
|
8168
8181
|
fromSystemParamsScriptRef(
|
|
@@ -8178,8 +8191,13 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
|
|
|
8178
8191
|
getInlineDatumOrThrow(stabilityPoolUtxo)
|
|
8179
8192
|
);
|
|
8180
8193
|
const baseRefInputs = [iAssetUtxo, stabilityPoolScriptRef];
|
|
8181
|
-
const
|
|
8182
|
-
|
|
8194
|
+
const validateFrom = Number(
|
|
8195
|
+
currentTime - BigInt(sysParams.stabilityPoolParams.accountProcessingBiasMs) / 2n
|
|
8196
|
+
);
|
|
8197
|
+
const validateTo = Number(
|
|
8198
|
+
currentTime + BigInt(sysParams.stabilityPoolParams.accountProcessingBiasMs) / 2n
|
|
8199
|
+
);
|
|
8200
|
+
const tx = lucid.newTx().validFrom(validateFrom).validTo(validateTo).readFrom(baseRefInputs).collectFrom([stabilityPoolUtxo], {
|
|
8183
8201
|
kind: "selected",
|
|
8184
8202
|
inputs: [stabilityPoolUtxo, accountUtxo],
|
|
8185
8203
|
makeRedeemer: (indices) => serialiseStabilityPoolRedeemer({
|
|
@@ -8550,7 +8568,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
|
|
|
8550
8568
|
}).exhaustive();
|
|
8551
8569
|
return tx;
|
|
8552
8570
|
}
|
|
8553
|
-
async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid
|
|
8571
|
+
async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid) {
|
|
8554
8572
|
const draftTx = processSpRequestAuxiliary(
|
|
8555
8573
|
stabilityPoolUtxo,
|
|
8556
8574
|
accountUtxo,
|
|
@@ -8559,8 +8577,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
|
|
|
8559
8577
|
sysParams,
|
|
8560
8578
|
lucid,
|
|
8561
8579
|
// Placeholder transation fee
|
|
8562
|
-
1n
|
|
8563
|
-
currentSlot
|
|
8580
|
+
1n
|
|
8564
8581
|
);
|
|
8565
8582
|
const fee = (await (await draftTx).complete()).toTransaction().body().fee();
|
|
8566
8583
|
return processSpRequestAuxiliary(
|
|
@@ -8570,8 +8587,7 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
|
|
|
8570
8587
|
allE2s2sSnapshotOrefs,
|
|
8571
8588
|
sysParams,
|
|
8572
8589
|
lucid,
|
|
8573
|
-
fee
|
|
8574
|
-
currentSlot
|
|
8590
|
+
fee
|
|
8575
8591
|
);
|
|
8576
8592
|
}
|
|
8577
8593
|
async function createE2s2sSnapshots(stabilityPoolOref, sysParams, lucid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigo-labs/indigo-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@indigo-labs/cardano-offchain-common": "1.5.2",
|
|
42
42
|
"@evolution-sdk/evolution": "^0.3.22",
|
|
43
43
|
"@harmoniclabs/crypto": "^0.3.0",
|
|
44
|
-
"@lucid-evolution/lucid": "0.6.
|
|
44
|
+
"@lucid-evolution/lucid": "0.6.4",
|
|
45
45
|
"@noble/ed25519": "^3.0.0",
|
|
46
46
|
"@pythnetwork/pyth-lazer-sdk": "^6.0.0",
|
|
47
47
|
"decimal.js": "^10.6.0",
|