@indigo-labs/indigo-sdk 0.1.26 → 0.1.28
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.js +10 -4
- package/dist/index.mjs +10 -4
- package/package.json +1 -1
- package/src/contracts/cdp.ts +13 -8
package/dist/index.js
CHANGED
|
@@ -940,10 +940,12 @@ var CDPContract = class _CDPContract {
|
|
|
940
940
|
const cdpDatum = parseCDPDatum(cdp.datum);
|
|
941
941
|
console.log("cdpDatum.iasset", cdpDatum.iasset);
|
|
942
942
|
const iAsset = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, lucid) : IAssetHelpers.findIAssetByName(cdpDatum.iasset, params, lucid));
|
|
943
|
+
console.log("iasset output", iAsset.utxo.txHash, iAsset.utxo.outputIndex);
|
|
943
944
|
const gov = govRef ? (await lucid.utxosByOutRef([govRef]))[0] : await lucid.utxoByUnit(
|
|
944
945
|
params.govParams.govNFT[0].unCurrencySymbol + (0, import_lucid13.fromText)(params.govParams.govNFT[1].unTokenName)
|
|
945
946
|
);
|
|
946
947
|
if (!gov.datum) throw new Error("Unable to find Gov Datum");
|
|
948
|
+
console.log("gov output", gov.txHash, gov.outputIndex);
|
|
947
949
|
const govData = parseGovDatum(gov.datum);
|
|
948
950
|
const cdpScriptRefUtxo = await _CDPContract.scriptRef(
|
|
949
951
|
params.scriptReferences,
|
|
@@ -952,8 +954,9 @@ var CDPContract = class _CDPContract {
|
|
|
952
954
|
const cdpAssets = Object.assign({}, cdp.assets);
|
|
953
955
|
cdpAssets["lovelace"] = cdp.assets["lovelace"] + collateralAmount;
|
|
954
956
|
const interestOracleAsset = iAsset.datum.interestOracleNft;
|
|
957
|
+
console.log("interestOracleAsset", interestOracleAsset.currencySymbol + interestOracleAsset.tokenName);
|
|
955
958
|
const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
|
|
956
|
-
interestOracleAsset.currencySymbol +
|
|
959
|
+
interestOracleAsset.currencySymbol + interestOracleAsset.tokenName
|
|
957
960
|
);
|
|
958
961
|
if (!interestOracleOut.datum)
|
|
959
962
|
return Promise.reject(new Error("Interest Oracle datum not found"));
|
|
@@ -993,8 +996,9 @@ var CDPContract = class _CDPContract {
|
|
|
993
996
|
const oracleAsset = iAsset.datum.price;
|
|
994
997
|
if (!("Oracle" in oracleAsset)) throw new Error("Invalid oracle asset");
|
|
995
998
|
const oracleRefInput = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
|
|
996
|
-
oracleAsset.Oracle.oracleNft.asset.currencySymbol +
|
|
999
|
+
oracleAsset.Oracle.oracleNft.asset.currencySymbol + oracleAsset.Oracle.oracleNft.asset.tokenName
|
|
997
1000
|
);
|
|
1001
|
+
console.log("oracleRefInput", oracleRefInput.txHash, oracleRefInput.outputIndex);
|
|
998
1002
|
if (!oracleRefInput.datum)
|
|
999
1003
|
return Promise.reject(new Error("Invalid oracle input"));
|
|
1000
1004
|
const od = parsePriceOracleDatum(oracleRefInput.datum);
|
|
@@ -1077,8 +1081,9 @@ var CDPContract = class _CDPContract {
|
|
|
1077
1081
|
lucid
|
|
1078
1082
|
);
|
|
1079
1083
|
const interestOracleAsset = iAsset.datum.interestOracleNft;
|
|
1084
|
+
console.log("interestOracleAsset", interestOracleAsset.currencySymbol + interestOracleAsset.tokenName);
|
|
1080
1085
|
const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
|
|
1081
|
-
interestOracleAsset.currencySymbol +
|
|
1086
|
+
interestOracleAsset.currencySymbol + interestOracleAsset.tokenName
|
|
1082
1087
|
);
|
|
1083
1088
|
if (!interestOracleOut.datum)
|
|
1084
1089
|
return Promise.reject(new Error("Interest Oracle datum not found"));
|
|
@@ -1094,8 +1099,9 @@ var CDPContract = class _CDPContract {
|
|
|
1094
1099
|
throw new Error("iAsset is delisted");
|
|
1095
1100
|
const oracleAsset = iAsset.datum.price.Oracle.oracleNft.asset;
|
|
1096
1101
|
const oracleRefInput = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
|
|
1097
|
-
oracleAsset.currencySymbol +
|
|
1102
|
+
oracleAsset.currencySymbol + oracleAsset.tokenName
|
|
1098
1103
|
);
|
|
1104
|
+
console.log("oracleRefInput", oracleRefInput.txHash, oracleRefInput.outputIndex);
|
|
1099
1105
|
if (!oracleRefInput.datum)
|
|
1100
1106
|
return Promise.reject(new Error("Invalid oracle input"));
|
|
1101
1107
|
const od = parsePriceOracleDatum(oracleRefInput.datum);
|
package/dist/index.mjs
CHANGED
|
@@ -811,10 +811,12 @@ var CDPContract = class _CDPContract {
|
|
|
811
811
|
const cdpDatum = parseCDPDatum(cdp.datum);
|
|
812
812
|
console.log("cdpDatum.iasset", cdpDatum.iasset);
|
|
813
813
|
const iAsset = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, lucid) : IAssetHelpers.findIAssetByName(cdpDatum.iasset, params, lucid));
|
|
814
|
+
console.log("iasset output", iAsset.utxo.txHash, iAsset.utxo.outputIndex);
|
|
814
815
|
const gov = govRef ? (await lucid.utxosByOutRef([govRef]))[0] : await lucid.utxoByUnit(
|
|
815
816
|
params.govParams.govNFT[0].unCurrencySymbol + fromText4(params.govParams.govNFT[1].unTokenName)
|
|
816
817
|
);
|
|
817
818
|
if (!gov.datum) throw new Error("Unable to find Gov Datum");
|
|
819
|
+
console.log("gov output", gov.txHash, gov.outputIndex);
|
|
818
820
|
const govData = parseGovDatum(gov.datum);
|
|
819
821
|
const cdpScriptRefUtxo = await _CDPContract.scriptRef(
|
|
820
822
|
params.scriptReferences,
|
|
@@ -823,8 +825,9 @@ var CDPContract = class _CDPContract {
|
|
|
823
825
|
const cdpAssets = Object.assign({}, cdp.assets);
|
|
824
826
|
cdpAssets["lovelace"] = cdp.assets["lovelace"] + collateralAmount;
|
|
825
827
|
const interestOracleAsset = iAsset.datum.interestOracleNft;
|
|
828
|
+
console.log("interestOracleAsset", interestOracleAsset.currencySymbol + interestOracleAsset.tokenName);
|
|
826
829
|
const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
|
|
827
|
-
interestOracleAsset.currencySymbol +
|
|
830
|
+
interestOracleAsset.currencySymbol + interestOracleAsset.tokenName
|
|
828
831
|
);
|
|
829
832
|
if (!interestOracleOut.datum)
|
|
830
833
|
return Promise.reject(new Error("Interest Oracle datum not found"));
|
|
@@ -864,8 +867,9 @@ var CDPContract = class _CDPContract {
|
|
|
864
867
|
const oracleAsset = iAsset.datum.price;
|
|
865
868
|
if (!("Oracle" in oracleAsset)) throw new Error("Invalid oracle asset");
|
|
866
869
|
const oracleRefInput = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
|
|
867
|
-
oracleAsset.Oracle.oracleNft.asset.currencySymbol +
|
|
870
|
+
oracleAsset.Oracle.oracleNft.asset.currencySymbol + oracleAsset.Oracle.oracleNft.asset.tokenName
|
|
868
871
|
);
|
|
872
|
+
console.log("oracleRefInput", oracleRefInput.txHash, oracleRefInput.outputIndex);
|
|
869
873
|
if (!oracleRefInput.datum)
|
|
870
874
|
return Promise.reject(new Error("Invalid oracle input"));
|
|
871
875
|
const od = parsePriceOracleDatum(oracleRefInput.datum);
|
|
@@ -948,8 +952,9 @@ var CDPContract = class _CDPContract {
|
|
|
948
952
|
lucid
|
|
949
953
|
);
|
|
950
954
|
const interestOracleAsset = iAsset.datum.interestOracleNft;
|
|
955
|
+
console.log("interestOracleAsset", interestOracleAsset.currencySymbol + interestOracleAsset.tokenName);
|
|
951
956
|
const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
|
|
952
|
-
interestOracleAsset.currencySymbol +
|
|
957
|
+
interestOracleAsset.currencySymbol + interestOracleAsset.tokenName
|
|
953
958
|
);
|
|
954
959
|
if (!interestOracleOut.datum)
|
|
955
960
|
return Promise.reject(new Error("Interest Oracle datum not found"));
|
|
@@ -965,8 +970,9 @@ var CDPContract = class _CDPContract {
|
|
|
965
970
|
throw new Error("iAsset is delisted");
|
|
966
971
|
const oracleAsset = iAsset.datum.price.Oracle.oracleNft.asset;
|
|
967
972
|
const oracleRefInput = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
|
|
968
|
-
oracleAsset.currencySymbol +
|
|
973
|
+
oracleAsset.currencySymbol + oracleAsset.tokenName
|
|
969
974
|
);
|
|
975
|
+
console.log("oracleRefInput", oracleRefInput.txHash, oracleRefInput.outputIndex);
|
|
970
976
|
if (!oracleRefInput.datum)
|
|
971
977
|
return Promise.reject(new Error("Invalid oracle input"));
|
|
972
978
|
const od = parsePriceOracleDatum(oracleRefInput.datum);
|
package/package.json
CHANGED
package/src/contracts/cdp.ts
CHANGED
|
@@ -352,6 +352,7 @@ export class CDPContract {
|
|
|
352
352
|
const iAsset = await (assetRef
|
|
353
353
|
? IAssetHelpers.findIAssetByRef(assetRef, lucid)
|
|
354
354
|
: IAssetHelpers.findIAssetByName(cdpDatum.iasset, params, lucid));
|
|
355
|
+
console.log('iasset output', iAsset.utxo.txHash, iAsset.utxo.outputIndex);
|
|
355
356
|
|
|
356
357
|
const gov = govRef
|
|
357
358
|
? (await lucid.utxosByOutRef([govRef]))[0]
|
|
@@ -360,6 +361,8 @@ export class CDPContract {
|
|
|
360
361
|
fromText(params.govParams.govNFT[1].unTokenName),
|
|
361
362
|
);
|
|
362
363
|
if (!gov.datum) throw new Error('Unable to find Gov Datum');
|
|
364
|
+
|
|
365
|
+
console.log('gov output', gov.txHash, gov.outputIndex);
|
|
363
366
|
const govData = parseGovDatum(gov.datum);
|
|
364
367
|
const cdpScriptRefUtxo = await CDPContract.scriptRef(
|
|
365
368
|
params.scriptReferences,
|
|
@@ -369,11 +372,11 @@ export class CDPContract {
|
|
|
369
372
|
cdpAssets['lovelace'] = cdp.assets['lovelace'] + collateralAmount;
|
|
370
373
|
|
|
371
374
|
const interestOracleAsset = iAsset.datum.interestOracleNft;
|
|
375
|
+
console.log('interestOracleAsset', interestOracleAsset.currencySymbol + interestOracleAsset.tokenName);
|
|
372
376
|
const interestOracleOut = interestOracleRef
|
|
373
377
|
? (await lucid.utxosByOutRef([interestOracleRef]))[0]
|
|
374
378
|
: await lucid.utxoByUnit(
|
|
375
|
-
interestOracleAsset.currencySymbol +
|
|
376
|
-
fromText(interestOracleAsset.tokenName),
|
|
379
|
+
interestOracleAsset.currencySymbol + interestOracleAsset.tokenName,
|
|
377
380
|
);
|
|
378
381
|
if (!interestOracleOut.datum)
|
|
379
382
|
return Promise.reject(new Error('Interest Oracle datum not found'));
|
|
@@ -427,10 +430,10 @@ export class CDPContract {
|
|
|
427
430
|
const oracleRefInput = priceOracleRef
|
|
428
431
|
? (await lucid.utxosByOutRef([priceOracleRef]))[0]
|
|
429
432
|
: await lucid.utxoByUnit(
|
|
430
|
-
oracleAsset.Oracle.oracleNft.asset.currencySymbol +
|
|
431
|
-
fromText(oracleAsset.Oracle.oracleNft.asset.tokenName),
|
|
433
|
+
oracleAsset.Oracle.oracleNft.asset.currencySymbol + oracleAsset.Oracle.oracleNft.asset.tokenName,
|
|
432
434
|
);
|
|
433
435
|
|
|
436
|
+
console.log('oracleRefInput', oracleRefInput.txHash, oracleRefInput.outputIndex);
|
|
434
437
|
// Fail if delisted asset
|
|
435
438
|
if (!oracleRefInput.datum)
|
|
436
439
|
return Promise.reject(new Error('Invalid oracle input'));
|
|
@@ -551,13 +554,13 @@ export class CDPContract {
|
|
|
551
554
|
params.scriptReferences,
|
|
552
555
|
lucid,
|
|
553
556
|
);
|
|
554
|
-
|
|
557
|
+
|
|
555
558
|
const interestOracleAsset = iAsset.datum.interestOracleNft;
|
|
559
|
+
console.log('interestOracleAsset', interestOracleAsset.currencySymbol + interestOracleAsset.tokenName);
|
|
556
560
|
const interestOracleOut = interestOracleRef
|
|
557
561
|
? (await lucid.utxosByOutRef([interestOracleRef]))[0]
|
|
558
562
|
: await lucid.utxoByUnit(
|
|
559
|
-
interestOracleAsset.currencySymbol +
|
|
560
|
-
fromText(interestOracleAsset.tokenName),
|
|
563
|
+
interestOracleAsset.currencySymbol + interestOracleAsset.tokenName,
|
|
561
564
|
);
|
|
562
565
|
if (!interestOracleOut.datum)
|
|
563
566
|
return Promise.reject(new Error('Interest Oracle datum not found'));
|
|
@@ -582,9 +585,11 @@ export class CDPContract {
|
|
|
582
585
|
const oracleRefInput = priceOracleRef
|
|
583
586
|
? (await lucid.utxosByOutRef([priceOracleRef]))[0]
|
|
584
587
|
: await lucid.utxoByUnit(
|
|
585
|
-
oracleAsset.currencySymbol +
|
|
588
|
+
oracleAsset.currencySymbol + oracleAsset.tokenName,
|
|
586
589
|
);
|
|
587
590
|
|
|
591
|
+
console.log('oracleRefInput', oracleRefInput.txHash, oracleRefInput.outputIndex);
|
|
592
|
+
|
|
588
593
|
// Fail if delisted asset
|
|
589
594
|
if (!oracleRefInput.datum)
|
|
590
595
|
return Promise.reject(new Error('Invalid oracle input'));
|