@indigo-labs/indigo-sdk 0.3.27 → 0.3.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.d.mts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/src/contracts/cdp/helpers.ts +4 -7
- package/tests/cdp/cdp-queries.ts +1 -1
- package/tests/rob/rob-leverage.test.ts +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _lucid_evolution_lucid from '@lucid-evolution/lucid';
|
|
2
|
-
import { Data, UTxO, Credential, OutRef, LucidEvolution, TxBuilder, Network, WithdrawalValidator, SpendingValidator,
|
|
2
|
+
import { Data, UTxO, Credential, OutRef, LucidEvolution, TxBuilder, Assets, Network, WithdrawalValidator, SpendingValidator, MintingPolicy, Address, PolicyId, ScriptHash, ProtocolParameters, OutputDatum, Script, Datum } from '@lucid-evolution/lucid';
|
|
3
3
|
import { AssetClass } from '@3rd-eye-labs/cardano-offchain-common';
|
|
4
4
|
import * as Core from '@evolution-sdk/evolution';
|
|
5
5
|
import { TSchema, Schema, Data as Data$1 } from '@evolution-sdk/evolution';
|
|
@@ -822,10 +822,7 @@ declare function rationalToFloat(a: Rational): number;
|
|
|
822
822
|
* Amount of iasset equal in value to the given number of collateral amount.
|
|
823
823
|
*/
|
|
824
824
|
declare function iassetValueOfCollateral(collateralAmt: bigint, oraclePrice: Rational): bigint;
|
|
825
|
-
|
|
826
|
-
* This is mostly for debugging purposes.
|
|
827
|
-
*/
|
|
828
|
-
declare function cdpCollateralRatioPercentage(currentSlot: number, iassetPrice: Rational, cdpUtxo: UTxO, cdpContent: CDPContent, interestOracleDatum: InterestOracleDatum, network: Network): number;
|
|
825
|
+
declare function cdpCollateralRatioPercentage(currentSlot: number, iassetPrice: Rational, cdpUtxoAssets: Assets, cdpContent: CDPContent, interestOracleDatum: InterestOracleDatum, network: Network): number;
|
|
829
826
|
/**
|
|
830
827
|
* The amount of iassets to redeem to reach the RMR.
|
|
831
828
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _lucid_evolution_lucid from '@lucid-evolution/lucid';
|
|
2
|
-
import { Data, UTxO, Credential, OutRef, LucidEvolution, TxBuilder, Network, WithdrawalValidator, SpendingValidator,
|
|
2
|
+
import { Data, UTxO, Credential, OutRef, LucidEvolution, TxBuilder, Assets, Network, WithdrawalValidator, SpendingValidator, MintingPolicy, Address, PolicyId, ScriptHash, ProtocolParameters, OutputDatum, Script, Datum } from '@lucid-evolution/lucid';
|
|
3
3
|
import { AssetClass } from '@3rd-eye-labs/cardano-offchain-common';
|
|
4
4
|
import * as Core from '@evolution-sdk/evolution';
|
|
5
5
|
import { TSchema, Schema, Data as Data$1 } from '@evolution-sdk/evolution';
|
|
@@ -822,10 +822,7 @@ declare function rationalToFloat(a: Rational): number;
|
|
|
822
822
|
* Amount of iasset equal in value to the given number of collateral amount.
|
|
823
823
|
*/
|
|
824
824
|
declare function iassetValueOfCollateral(collateralAmt: bigint, oraclePrice: Rational): bigint;
|
|
825
|
-
|
|
826
|
-
* This is mostly for debugging purposes.
|
|
827
|
-
*/
|
|
828
|
-
declare function cdpCollateralRatioPercentage(currentSlot: number, iassetPrice: Rational, cdpUtxo: UTxO, cdpContent: CDPContent, interestOracleDatum: InterestOracleDatum, network: Network): number;
|
|
825
|
+
declare function cdpCollateralRatioPercentage(currentSlot: number, iassetPrice: Rational, cdpUtxoAssets: Assets, cdpContent: CDPContent, interestOracleDatum: InterestOracleDatum, network: Network): number;
|
|
829
826
|
/**
|
|
830
827
|
* The amount of iassets to redeem to reach the RMR.
|
|
831
828
|
*/
|
package/dist/index.js
CHANGED
|
@@ -836,7 +836,7 @@ function iassetValueOfCollateral(collateralAmt, oraclePrice) {
|
|
|
836
836
|
rationalDiv(rationalFromInt(collateralAmt), oraclePrice)
|
|
837
837
|
);
|
|
838
838
|
}
|
|
839
|
-
function cdpCollateralRatioPercentage(currentSlot, iassetPrice,
|
|
839
|
+
function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum, network) {
|
|
840
840
|
const currentTime = BigInt((0, import_lucid4.slotToUnixTime)(network, currentSlot));
|
|
841
841
|
return (0, import_ts_pattern5.match)(cdpContent.cdpFees).with({ ActiveCDPInterestTracking: import_ts_pattern5.P.select() }, (interest) => {
|
|
842
842
|
const interestAmt = calculateAccruedInterest(
|
|
@@ -847,7 +847,7 @@ function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxo, cdpCont
|
|
|
847
847
|
interestOracleDatum
|
|
848
848
|
);
|
|
849
849
|
const collateral = (0, import_cardano_offchain_common.assetClassValueOf)(
|
|
850
|
-
|
|
850
|
+
cdpUtxoAssets,
|
|
851
851
|
cdpContent.collateralAsset
|
|
852
852
|
);
|
|
853
853
|
const ratio = rationalDiv(
|
|
@@ -857,7 +857,7 @@ function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxo, cdpCont
|
|
|
857
857
|
iassetPrice
|
|
858
858
|
)
|
|
859
859
|
);
|
|
860
|
-
return Number(ratio.numerator *
|
|
860
|
+
return Number(ratio.numerator) * 100 / Number(ratio.denominator);
|
|
861
861
|
}).with({ FrozenCDPAccumulatedFees: import_ts_pattern5.P.any }, () => 0).exhaustive();
|
|
862
862
|
}
|
|
863
863
|
function calculateIAssetRedemptionAmt(collateralAmt, mintedAmt, price, rmr) {
|
package/dist/index.mjs
CHANGED
|
@@ -471,7 +471,7 @@ function iassetValueOfCollateral(collateralAmt, oraclePrice) {
|
|
|
471
471
|
rationalDiv(rationalFromInt(collateralAmt), oraclePrice)
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
|
-
function cdpCollateralRatioPercentage(currentSlot, iassetPrice,
|
|
474
|
+
function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum, network) {
|
|
475
475
|
const currentTime = BigInt(slotToUnixTime2(network, currentSlot));
|
|
476
476
|
return match4(cdpContent.cdpFees).with({ ActiveCDPInterestTracking: P4.select() }, (interest) => {
|
|
477
477
|
const interestAmt = calculateAccruedInterest(
|
|
@@ -482,7 +482,7 @@ function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxo, cdpCont
|
|
|
482
482
|
interestOracleDatum
|
|
483
483
|
);
|
|
484
484
|
const collateral = assetClassValueOf(
|
|
485
|
-
|
|
485
|
+
cdpUtxoAssets,
|
|
486
486
|
cdpContent.collateralAsset
|
|
487
487
|
);
|
|
488
488
|
const ratio = rationalDiv(
|
|
@@ -492,7 +492,7 @@ function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxo, cdpCont
|
|
|
492
492
|
iassetPrice
|
|
493
493
|
)
|
|
494
494
|
);
|
|
495
|
-
return Number(ratio.numerator *
|
|
495
|
+
return Number(ratio.numerator) * 100 / Number(ratio.denominator);
|
|
496
496
|
}).with({ FrozenCDPAccumulatedFees: P4.any }, () => 0).exhaustive();
|
|
497
497
|
}
|
|
498
498
|
function calculateIAssetRedemptionAmt(collateralAmt, mintedAmt, price, rmr) {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network, slotToUnixTime
|
|
1
|
+
import { Assets, Network, slotToUnixTime } from '@lucid-evolution/lucid';
|
|
2
2
|
import { calculateAccruedInterest } from '../interest-oracle/helpers';
|
|
3
3
|
import { match, P } from 'ts-pattern';
|
|
4
4
|
import { calculateFeeFromRatio } from '../../utils/indigo-helpers';
|
|
@@ -29,13 +29,10 @@ export function iassetValueOfCollateral(
|
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* This is mostly for debugging purposes.
|
|
34
|
-
*/
|
|
35
32
|
export function cdpCollateralRatioPercentage(
|
|
36
33
|
currentSlot: number,
|
|
37
34
|
iassetPrice: Rational,
|
|
38
|
-
|
|
35
|
+
cdpUtxoAssets: Assets,
|
|
39
36
|
cdpContent: CDPContent,
|
|
40
37
|
interestOracleDatum: InterestOracleDatum,
|
|
41
38
|
network: Network,
|
|
@@ -53,7 +50,7 @@ export function cdpCollateralRatioPercentage(
|
|
|
53
50
|
);
|
|
54
51
|
|
|
55
52
|
const collateral = assetClassValueOf(
|
|
56
|
-
|
|
53
|
+
cdpUtxoAssets,
|
|
57
54
|
cdpContent.collateralAsset,
|
|
58
55
|
);
|
|
59
56
|
|
|
@@ -65,7 +62,7 @@ export function cdpCollateralRatioPercentage(
|
|
|
65
62
|
),
|
|
66
63
|
);
|
|
67
64
|
|
|
68
|
-
return Number(
|
|
65
|
+
return (Number(ratio.numerator) * 100) / Number(ratio.denominator);
|
|
69
66
|
})
|
|
70
67
|
.with({ FrozenCDPAccumulatedFees: P.any }, () => 0)
|
|
71
68
|
.exhaustive();
|
package/tests/cdp/cdp-queries.ts
CHANGED
|
@@ -1412,7 +1412,7 @@ describe('LRP leverage', () => {
|
|
|
1412
1412
|
cdpCollateralRatioPercentage(
|
|
1413
1413
|
context.emulator.slot,
|
|
1414
1414
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
1415
|
-
res.utxo,
|
|
1415
|
+
res.utxo.assets,
|
|
1416
1416
|
res.datum,
|
|
1417
1417
|
parseInterestOracleDatum(
|
|
1418
1418
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -1555,7 +1555,7 @@ describe('LRP leverage', () => {
|
|
|
1555
1555
|
cdpCollateralRatioPercentage(
|
|
1556
1556
|
context.emulator.slot,
|
|
1557
1557
|
price,
|
|
1558
|
-
res.utxo,
|
|
1558
|
+
res.utxo.assets,
|
|
1559
1559
|
res.datum,
|
|
1560
1560
|
parseInterestOracleDatum(
|
|
1561
1561
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -1667,7 +1667,7 @@ describe('LRP leverage', () => {
|
|
|
1667
1667
|
cdpCollateralRatioPercentage(
|
|
1668
1668
|
context.emulator.slot,
|
|
1669
1669
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
1670
|
-
res.utxo,
|
|
1670
|
+
res.utxo.assets,
|
|
1671
1671
|
res.datum,
|
|
1672
1672
|
parseInterestOracleDatum(
|
|
1673
1673
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -1790,7 +1790,7 @@ describe('LRP leverage', () => {
|
|
|
1790
1790
|
cdpCollateralRatioPercentage(
|
|
1791
1791
|
context.emulator.slot,
|
|
1792
1792
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
1793
|
-
res.utxo,
|
|
1793
|
+
res.utxo.assets,
|
|
1794
1794
|
res.datum,
|
|
1795
1795
|
parseInterestOracleDatum(
|
|
1796
1796
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -1913,7 +1913,7 @@ describe('LRP leverage', () => {
|
|
|
1913
1913
|
cdpCollateralRatioPercentage(
|
|
1914
1914
|
context.emulator.slot,
|
|
1915
1915
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
1916
|
-
res.utxo,
|
|
1916
|
+
res.utxo.assets,
|
|
1917
1917
|
res.datum,
|
|
1918
1918
|
parseInterestOracleDatum(
|
|
1919
1919
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -2036,7 +2036,7 @@ describe('LRP leverage', () => {
|
|
|
2036
2036
|
cdpCollateralRatioPercentage(
|
|
2037
2037
|
context.emulator.slot,
|
|
2038
2038
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
2039
|
-
res.utxo,
|
|
2039
|
+
res.utxo.assets,
|
|
2040
2040
|
res.datum,
|
|
2041
2041
|
parseInterestOracleDatum(
|
|
2042
2042
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -2159,7 +2159,7 @@ describe('LRP leverage', () => {
|
|
|
2159
2159
|
cdpCollateralRatioPercentage(
|
|
2160
2160
|
context.emulator.slot,
|
|
2161
2161
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
2162
|
-
res.utxo,
|
|
2162
|
+
res.utxo.assets,
|
|
2163
2163
|
res.datum,
|
|
2164
2164
|
parseInterestOracleDatum(
|
|
2165
2165
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -2298,7 +2298,7 @@ describe('LRP leverage', () => {
|
|
|
2298
2298
|
cdpCollateralRatioPercentage(
|
|
2299
2299
|
context.emulator.slot,
|
|
2300
2300
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
2301
|
-
res.utxo,
|
|
2301
|
+
res.utxo.assets,
|
|
2302
2302
|
res.datum,
|
|
2303
2303
|
parseInterestOracleDatum(
|
|
2304
2304
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -2444,7 +2444,7 @@ describe('LRP leverage', () => {
|
|
|
2444
2444
|
cdpCollateralRatioPercentage(
|
|
2445
2445
|
context.emulator.slot,
|
|
2446
2446
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
2447
|
-
res.utxo,
|
|
2447
|
+
res.utxo.assets,
|
|
2448
2448
|
res.datum,
|
|
2449
2449
|
parseInterestOracleDatum(
|
|
2450
2450
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|
|
@@ -2581,7 +2581,7 @@ describe('LRP leverage', () => {
|
|
|
2581
2581
|
cdpCollateralRatioPercentage(
|
|
2582
2582
|
context.emulator.slot,
|
|
2583
2583
|
parsePriceOracleDatum(getInlineDatumOrThrow(priceOracleUtxo)).price,
|
|
2584
|
-
res.utxo,
|
|
2584
|
+
res.utxo.assets,
|
|
2585
2585
|
res.datum,
|
|
2586
2586
|
parseInterestOracleDatum(
|
|
2587
2587
|
getInlineDatumOrThrow(orefs.interestOracleUtxo),
|