@indigo-labs/indigo-sdk 0.1.1 → 0.1.2
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 +2 -2
- package/dist/index.mjs +2 -2
- package/examples/sample-cdp.ts +43 -0
- package/package.json +1 -1
- package/src/contracts/cdp.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -516,7 +516,7 @@ var CDPContract = class _CDPContract {
|
|
|
516
516
|
);
|
|
517
517
|
const debtMintingFee = calculateFeeFromPercentage(
|
|
518
518
|
BigInt(assetOut.datum.debtMintingFeePercentage.getOnChainInt),
|
|
519
|
-
mintedAmount * oracleDatum.price
|
|
519
|
+
mintedAmount * oracleDatum.price / 1000000n
|
|
520
520
|
);
|
|
521
521
|
const cappedValidateTo = oracleDatum.expiration - 20001n;
|
|
522
522
|
const timeValidFrom = now - 1e3;
|
|
@@ -682,7 +682,7 @@ var CDPContract = class _CDPContract {
|
|
|
682
682
|
if (mintAmount > 0) {
|
|
683
683
|
fee += calculateFeeFromPercentage(
|
|
684
684
|
iAsset.datum.debtMintingFeePercentage.getOnChainInt,
|
|
685
|
-
mintAmount * od.price
|
|
685
|
+
mintAmount * od.price / 1000000n
|
|
686
686
|
);
|
|
687
687
|
}
|
|
688
688
|
const interestPaymentAsset = InterestOracleContract.calculateAccruedInterest(
|
package/dist/index.mjs
CHANGED
|
@@ -486,7 +486,7 @@ var CDPContract = class _CDPContract {
|
|
|
486
486
|
);
|
|
487
487
|
const debtMintingFee = calculateFeeFromPercentage(
|
|
488
488
|
BigInt(assetOut.datum.debtMintingFeePercentage.getOnChainInt),
|
|
489
|
-
mintedAmount * oracleDatum.price
|
|
489
|
+
mintedAmount * oracleDatum.price / 1000000n
|
|
490
490
|
);
|
|
491
491
|
const cappedValidateTo = oracleDatum.expiration - 20001n;
|
|
492
492
|
const timeValidFrom = now - 1e3;
|
|
@@ -652,7 +652,7 @@ var CDPContract = class _CDPContract {
|
|
|
652
652
|
if (mintAmount > 0) {
|
|
653
653
|
fee += calculateFeeFromPercentage(
|
|
654
654
|
iAsset.datum.debtMintingFeePercentage.getOnChainInt,
|
|
655
|
-
mintAmount * od.price
|
|
655
|
+
mintAmount * od.price / 1000000n
|
|
656
656
|
);
|
|
657
657
|
}
|
|
658
658
|
const interestPaymentAsset = InterestOracleContract.calculateAccruedInterest(
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Blockfrost, Lucid, OutRef } from "@lucid-evolution/lucid";
|
|
2
|
+
import { balance, CDPContract, loadSystemParamsFromUrl } from "../src";
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
const lucid = await Lucid(
|
|
6
|
+
new Blockfrost(
|
|
7
|
+
'https://cardano-mainnet.blockfrost.io/api/v0',
|
|
8
|
+
'mainnetpb1Y1PczllObhmQKFMO6wm3la39p70k5'
|
|
9
|
+
),
|
|
10
|
+
'Mainnet'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
lucid.selectWallet.fromSeed('helmet coconut robot path message library verb lobster rigid taxi recall ribbon vacuum uniform horse thumb praise sibling wise frown cattle settle century sad');
|
|
14
|
+
|
|
15
|
+
const systemParams = await loadSystemParamsFromUrl('https://config.indigoprotocol.io/mainnet/mainnet-system-params-v21.json')
|
|
16
|
+
const address = await lucid.wallet().address();
|
|
17
|
+
const utxos = await lucid.wallet().getUtxos();
|
|
18
|
+
const walletBalance = balance(utxos);
|
|
19
|
+
|
|
20
|
+
console.log('Wallet Address', address);
|
|
21
|
+
console.log('Wallet Balance', walletBalance);
|
|
22
|
+
|
|
23
|
+
// const cdpOutRef: OutRef = {txHash: '70b09ded453b6122688d3cd51e2c75a007f2d801d1104eae734d8f5314b2b393', outputIndex: 0};
|
|
24
|
+
|
|
25
|
+
const cdpTx = await CDPContract.openPosition('iUSD', 10_000_000n, 7_820_000n, systemParams, lucid);
|
|
26
|
+
const cdpBTx = await cdpTx.complete();
|
|
27
|
+
const cdpBsTx = await cdpBTx.sign.withWallet().complete();
|
|
28
|
+
|
|
29
|
+
console.log(cdpBsTx.toCBOR());
|
|
30
|
+
// const cdpTx = await CDPContract.openPosition(
|
|
31
|
+
// 'iUSD',
|
|
32
|
+
// 10_000_000n,
|
|
33
|
+
// 1_000_000n,
|
|
34
|
+
// systemParams,
|
|
35
|
+
// lucid
|
|
36
|
+
// );
|
|
37
|
+
// const cdpBTx = await cdpTx.complete()
|
|
38
|
+
// const cdpBsTx = await cdpBTx.sign.withWallet().complete()
|
|
39
|
+
|
|
40
|
+
// console.log(cdpBsTx.toCBOR());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
main();
|
package/package.json
CHANGED
package/src/contracts/cdp.ts
CHANGED
|
@@ -136,7 +136,7 @@ export class CDPContract {
|
|
|
136
136
|
|
|
137
137
|
const debtMintingFee = calculateFeeFromPercentage(
|
|
138
138
|
BigInt(assetOut.datum.debtMintingFeePercentage.getOnChainInt),
|
|
139
|
-
mintedAmount * oracleDatum.price,
|
|
139
|
+
(mintedAmount * oracleDatum.price) / 1_000_000n,
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
// Oracle timestamp - 20s (length of a slot)
|
|
@@ -432,7 +432,7 @@ export class CDPContract {
|
|
|
432
432
|
if (mintAmount > 0) {
|
|
433
433
|
fee += calculateFeeFromPercentage(
|
|
434
434
|
iAsset.datum.debtMintingFeePercentage.getOnChainInt,
|
|
435
|
-
mintAmount * od.price,
|
|
435
|
+
(mintAmount * od.price) / 1_000_000n,
|
|
436
436
|
);
|
|
437
437
|
}
|
|
438
438
|
|