carbon-js-sdk 0.6.2 → 0.6.3
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/lib/CarbonSDK.d.ts +1 -0
- package/lib/CarbonSDK.js +8 -6
- package/lib/clients/BatchQueryClient.js +4 -4
- package/lib/clients/CarbonQueryClient.js +1 -1
- package/lib/clients/ETHClient.d.ts +1 -0
- package/lib/clients/ETHClient.js +17 -17
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/InsightsQueryClient.js +3 -3
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +2 -2
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/book/book.d.ts +14 -2
- package/lib/codec/book/book.js +80 -13
- package/lib/codec/book/legacy.d.ts +22 -0
- package/lib/codec/book/legacy.js +120 -0
- package/lib/codec/book/query.d.ts +48 -1
- package/lib/codec/book/query.js +224 -1
- package/lib/codec/cdp/event.d.ts +12 -6
- package/lib/codec/cdp/event.js +146 -68
- package/lib/codec/cdp/params.d.ts +0 -2
- package/lib/codec/cdp/params.js +8 -23
- package/lib/codec/cdp/query.d.ts +22 -1
- package/lib/codec/cdp/query.js +104 -17
- package/lib/codec/cosmos/gov/v1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1/tx.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/group/v1/events.js +2 -2
- package/lib/codec/cosmos/group/v1/tx.js +4 -4
- package/lib/codec/cosmos/tx/v1beta1/tx.js +4 -4
- package/lib/codec/index.d.ts +11 -9
- package/lib/codec/index.js +405 -133
- package/lib/codec/liquiditypool/event.d.ts +25 -1
- package/lib/codec/liquiditypool/event.js +147 -1
- package/lib/codec/liquiditypool/genesis.d.ts +4 -5
- package/lib/codec/liquiditypool/genesis.js +34 -49
- package/lib/codec/liquiditypool/query.d.ts +2 -51
- package/lib/codec/liquiditypool/query.js +18 -265
- package/lib/codec/liquiditypool/reward.d.ts +21 -21
- package/lib/codec/liquiditypool/reward.js +97 -111
- package/lib/codec/oracle/query.d.ts +37 -34
- package/lib/codec/oracle/query.js +37 -31
- package/lib/codec/position/position.d.ts +2 -0
- package/lib/codec/position/position.js +34 -0
- package/lib/codec/subaccount/genesis.d.ts +5 -1
- package/lib/codec/subaccount/genesis.js +48 -2
- package/lib/codec/subaccount/query.d.ts +110 -21
- package/lib/codec/subaccount/query.js +503 -47
- package/lib/codec/subaccount/subaccount.d.ts +29 -3
- package/lib/codec/subaccount/subaccount.js +234 -31
- package/lib/codec/subaccount/tx.d.ts +7 -1
- package/lib/codec/subaccount/tx.js +101 -16
- package/lib/constant/generic.js +1 -1
- package/lib/modules/cdp.js +45 -45
- package/lib/modules/cosmwasm.js +2 -2
- package/lib/modules/evm.js +5 -5
- package/lib/modules/gov.js +12 -12
- package/lib/modules/liquiditypool.js +1 -1
- package/lib/modules/order.js +2 -2
- package/lib/modules/subaccount.js +1 -1
- package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
- package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
- package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
- package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
- package/lib/provider/amino/types/admin.js +27 -27
- package/lib/provider/amino/types/bank.js +1 -1
- package/lib/provider/amino/types/broker.js +1 -1
- package/lib/provider/amino/types/cdp.js +25 -25
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/evm.js +2 -2
- package/lib/provider/amino/types/evmmerge.js +1 -1
- package/lib/provider/amino/types/feemarket.js +1 -1
- package/lib/provider/amino/types/gov.js +5 -5
- package/lib/provider/amino/types/ibc.js +1 -1
- package/lib/provider/amino/types/leverage.js +1 -1
- package/lib/provider/amino/types/liquidityPool.js +7 -7
- package/lib/provider/amino/types/market.js +6 -6
- package/lib/provider/amino/types/oracle.js +2 -2
- package/lib/provider/amino/types/order.js +4 -4
- package/lib/provider/amino/types/position.js +1 -1
- package/lib/provider/amino/types/profile.js +1 -1
- package/lib/provider/amino/types/staking.js +4 -4
- package/lib/provider/amino/types/subaccount.js +3 -3
- package/lib/provider/amino/utils.js +11 -11
- package/lib/provider/keplr/KeplrAccount.js +2 -2
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +13 -13
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +14 -14
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.d.ts +1 -1
- package/lib/util/blockchain.js +4 -4
- package/lib/util/eip712.js +3 -3
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/legacyEIP712.js +2 -2
- package/lib/util/network.js +3 -3
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +15 -15
- package/lib/wallet/CarbonWallet.js +9 -9
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -1
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.d.ts +0 -76
- package/lib/codec/ibc/applications/interchain_accounts/v1/genesis.js +0 -424
package/lib/modules/cdp.js
CHANGED
|
@@ -517,7 +517,7 @@ class CDPModule extends base_1.default {
|
|
|
517
517
|
let availableBorrowsUsd = number_1.BN_ZERO;
|
|
518
518
|
let currLiquidationThreshold = number_1.BN_ZERO;
|
|
519
519
|
for (let i = 0; i < collaterals.length; i++) {
|
|
520
|
-
const amount = number_1.bnOrZero(collaterals[i].collateralAmount);
|
|
520
|
+
const amount = (0, number_1.bnOrZero)(collaterals[i].collateralAmount);
|
|
521
521
|
if (amount.isZero()) {
|
|
522
522
|
continue; // no collateral for denom
|
|
523
523
|
}
|
|
@@ -534,9 +534,9 @@ class CDPModule extends base_1.default {
|
|
|
534
534
|
if (!assetParam) {
|
|
535
535
|
continue;
|
|
536
536
|
}
|
|
537
|
-
const ltv = number_1.bnOrZero(assetParam.loanToValue).div(number_1.BN_10000);
|
|
537
|
+
const ltv = (0, number_1.bnOrZero)(assetParam.loanToValue).div(number_1.BN_10000);
|
|
538
538
|
const availableBorrowUsd = collateralUsdVal.times(ltv);
|
|
539
|
-
const liquidationThreshold = number_1.bnOrZero(assetParam.liquidationThreshold).div(number_1.BN_10000);
|
|
539
|
+
const liquidationThreshold = (0, number_1.bnOrZero)(assetParam.liquidationThreshold).div(number_1.BN_10000);
|
|
540
540
|
const liquidationThresholdVal = collateralUsdVal.times(liquidationThreshold);
|
|
541
541
|
totalCollateralsUsd = totalCollateralsUsd.plus(collateralUsdVal);
|
|
542
542
|
availableBorrowsUsd = availableBorrowsUsd.plus(availableBorrowUsd);
|
|
@@ -547,7 +547,7 @@ class CDPModule extends base_1.default {
|
|
|
547
547
|
let totalDebtsUsd = number_1.BN_ZERO;
|
|
548
548
|
const debtsUsdRequests = [];
|
|
549
549
|
for (let i = 0; i < debts.length; i++) {
|
|
550
|
-
const amount = number_1.bnOrZero(debts[i].principalDebt);
|
|
550
|
+
const amount = (0, number_1.bnOrZero)(debts[i].principalDebt);
|
|
551
551
|
const denom = debts[i].denom;
|
|
552
552
|
if (amount.isZero()) {
|
|
553
553
|
continue;
|
|
@@ -570,7 +570,7 @@ class CDPModule extends base_1.default {
|
|
|
570
570
|
if (stablecoinDebtInfo) {
|
|
571
571
|
const accountStablecoin = yield sdk.query.cdp.AccountStablecoin({ address: account });
|
|
572
572
|
const stablecoinDecimals = (_a = (yield this.sdkProvider.getTokenClient().getDecimals(stablecoinDebtInfo.denom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
573
|
-
const stablecoinDebtAmount = number_1.bnOrZero(accountStablecoin.principalDebt).plus(number_1.bnOrZero(accountStablecoin.interestDebt));
|
|
573
|
+
const stablecoinDebtAmount = (0, number_1.bnOrZero)(accountStablecoin.principalDebt).plus((0, number_1.bnOrZero)(accountStablecoin.interestDebt));
|
|
574
574
|
stablecoinDebtUsd = stablecoinDebtAmount.shiftedBy(-stablecoinDecimals);
|
|
575
575
|
totalDebtsUsd = totalDebtsUsd.plus(stablecoinDebtUsd);
|
|
576
576
|
}
|
|
@@ -591,7 +591,7 @@ class CDPModule extends base_1.default {
|
|
|
591
591
|
const sdk = this.sdkProvider;
|
|
592
592
|
const cdpAddress = this.getCdpModuleAddress();
|
|
593
593
|
const balanceRsp = yield sdk.query.bank.Balance(query_2.QueryBalanceRequest.fromPartial({ address: cdpAddress, denom }));
|
|
594
|
-
return number_1.bnOrZero((_a = balanceRsp.balance) === null || _a === void 0 ? void 0 : _a.amount);
|
|
594
|
+
return (0, number_1.bnOrZero)((_a = balanceRsp.balance) === null || _a === void 0 ? void 0 : _a.amount);
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
597
|
getCdpToActualRatio(cdpDenom) {
|
|
@@ -605,11 +605,11 @@ class CDPModule extends base_1.default {
|
|
|
605
605
|
const cdpAmountRsp = supplyRsp.amount;
|
|
606
606
|
if (!cdpAmountRsp)
|
|
607
607
|
throw new Error("unable to retrieve cdp token supply");
|
|
608
|
-
const cdpAmount = number_1.bnOrZero(cdpAmountRsp.amount);
|
|
608
|
+
const cdpAmount = (0, number_1.bnOrZero)(cdpAmountRsp.amount);
|
|
609
609
|
if (!balanceRsp.balance)
|
|
610
610
|
throw new Error("unable to retrieve cdp module balance");
|
|
611
611
|
const owedAmount = yield this.getTotalTokenDebt(denom);
|
|
612
|
-
const actualAmount = number_1.bnOrZero(balanceRsp.balance.amount).plus(owedAmount);
|
|
612
|
+
const actualAmount = (0, number_1.bnOrZero)(balanceRsp.balance.amount).plus(owedAmount);
|
|
613
613
|
if (!owedAmount)
|
|
614
614
|
throw new Error("unable to retrieve total token debt");
|
|
615
615
|
return cdpAmount.div(actualAmount);
|
|
@@ -632,8 +632,8 @@ class CDPModule extends base_1.default {
|
|
|
632
632
|
const debtAmtRequests = [];
|
|
633
633
|
for (let i = 0; i < allDebts.length; i++) {
|
|
634
634
|
const denom = allDebts[i].denom;
|
|
635
|
-
const interest = number_1.bnOrZero(allDebts[i].totalAccumulatedInterest);
|
|
636
|
-
const principal = number_1.bnOrZero(allDebts[i].totalPrincipal);
|
|
635
|
+
const interest = (0, number_1.bnOrZero)(allDebts[i].totalAccumulatedInterest);
|
|
636
|
+
const principal = (0, number_1.bnOrZero)(allDebts[i].totalPrincipal);
|
|
637
637
|
const debtAmt = interest.plus(principal);
|
|
638
638
|
debtAmtRequests.push(this.getTokenUsdVal(denom, debtAmt));
|
|
639
639
|
}
|
|
@@ -649,7 +649,7 @@ class CDPModule extends base_1.default {
|
|
|
649
649
|
const stablecoinDebtRes = yield this.sdkProvider.query.cdp.StablecoinDebt({});
|
|
650
650
|
if (stablecoinDebtRes.stablecoinDebtInfo) {
|
|
651
651
|
const debtInfo = stablecoinDebtRes.stablecoinDebtInfo;
|
|
652
|
-
const debtAmt = number_1.bnOrZero(debtInfo.totalPrincipal).plus(number_1.bnOrZero(debtInfo.totalAccumulatedInterest));
|
|
652
|
+
const debtAmt = (0, number_1.bnOrZero)(debtInfo.totalPrincipal).plus((0, number_1.bnOrZero)(debtInfo.totalAccumulatedInterest));
|
|
653
653
|
const stablecoinDecimals = (_a = (yield sdk.getTokenClient().getDecimals(debtInfo.denom))) !== null && _a !== void 0 ? _a : 0;
|
|
654
654
|
const debtUsdVal = debtAmt.shiftedBy(-stablecoinDecimals);
|
|
655
655
|
totalDebt = totalDebt.plus(debtUsdVal);
|
|
@@ -664,8 +664,8 @@ class CDPModule extends base_1.default {
|
|
|
664
664
|
const collateralPoolAddress = address_1.SWTHAddress.getModuleAddress("collateral_pool", network);
|
|
665
665
|
const collateralPoolBalances = yield this.sdkProvider.query.bank.AllBalances({ address: collateralPoolAddress });
|
|
666
666
|
const cdpTokenBalances = ((_a = collateralPoolBalances === null || collateralPoolBalances === void 0 ? void 0 : collateralPoolBalances.balances) !== null && _a !== void 0 ? _a : []).filter(balance => TokenClient_1.default.isCdpToken(balance.denom));
|
|
667
|
-
const cdpTokenBalancePromises = cdpTokenBalances.map(balance => (this.getCdpTokenUsdVal(balance.denom, number_1.bnOrZero(balance.amount))
|
|
668
|
-
.then((val) => number_1.bnOrZero(val))
|
|
667
|
+
const cdpTokenBalancePromises = cdpTokenBalances.map(balance => (this.getCdpTokenUsdVal(balance.denom, (0, number_1.bnOrZero)(balance.amount))
|
|
668
|
+
.then((val) => (0, number_1.bnOrZero)(val))
|
|
669
669
|
.catch((err) => {
|
|
670
670
|
console.error(err);
|
|
671
671
|
return number_1.BN_ZERO;
|
|
@@ -692,7 +692,7 @@ class CDPModule extends base_1.default {
|
|
|
692
692
|
const priceResult = yield sdk.query.pricing.TokenPrice(codec_1.QueryTokenPriceRequest.fromPartial({ denom }));
|
|
693
693
|
if (!priceResult.tokenPrice)
|
|
694
694
|
throw new Error("unable to retrieve token price for " + denom);
|
|
695
|
-
const twap = number_1.bnOrZero(priceResult.tokenPrice.twap).shiftedBy(-18);
|
|
695
|
+
const twap = (0, number_1.bnOrZero)(priceResult.tokenPrice.twap).shiftedBy(-18);
|
|
696
696
|
return amount.multipliedBy(twap).shiftedBy(-decimals);
|
|
697
697
|
});
|
|
698
698
|
}
|
|
@@ -707,11 +707,11 @@ class CDPModule extends base_1.default {
|
|
|
707
707
|
throw new Error("unable to retrieve debt info");
|
|
708
708
|
const cimRsp = yield this.recalculateCIM(denom, debtInfo);
|
|
709
709
|
const newInterestRate = cimRsp.interest;
|
|
710
|
-
const principal = number_1.bnOrZero(debtInfo.totalPrincipal);
|
|
711
|
-
const accumInterest = number_1.bnOrZero(debtInfo.totalAccumulatedInterest);
|
|
710
|
+
const principal = (0, number_1.bnOrZero)(debtInfo.totalPrincipal);
|
|
711
|
+
const accumInterest = (0, number_1.bnOrZero)(debtInfo.totalAccumulatedInterest);
|
|
712
712
|
const newInterest = principal.times(newInterestRate).plus(accumInterest.times(number_1.BN_ONE.plus(newInterestRate)));
|
|
713
713
|
const cdpParamsRsp = yield this.sdkProvider.query.cdp.Params(query_1.QueryParamsRequest.fromPartial({}));
|
|
714
|
-
const interestFee = number_1.bnOrZero((_a = cdpParamsRsp.params) === null || _a === void 0 ? void 0 : _a.interestFee);
|
|
714
|
+
const interestFee = (0, number_1.bnOrZero)((_a = cdpParamsRsp.params) === null || _a === void 0 ? void 0 : _a.interestFee);
|
|
715
715
|
const interest = newInterest.times(number_1.BN_10000.minus(interestFee)).dividedToIntegerBy(number_1.BN_10000);
|
|
716
716
|
return principal.plus(interest);
|
|
717
717
|
});
|
|
@@ -729,8 +729,8 @@ class CDPModule extends base_1.default {
|
|
|
729
729
|
const debtRes = yield sdk.query.cdp.AccountDebt({ address: account, denom: denom });
|
|
730
730
|
debt = debtRes.debt;
|
|
731
731
|
}
|
|
732
|
-
const principalAmount = number_1.bnOrZero(debt === null || debt === void 0 ? void 0 : debt.principalDebt);
|
|
733
|
-
const initialCIM = number_1.bnOrZero(debt === null || debt === void 0 ? void 0 : debt.initialCumulativeInterestMultiplier);
|
|
732
|
+
const principalAmount = (0, number_1.bnOrZero)(debt === null || debt === void 0 ? void 0 : debt.principalDebt);
|
|
733
|
+
const initialCIM = (0, number_1.bnOrZero)(debt === null || debt === void 0 ? void 0 : debt.initialCumulativeInterestMultiplier);
|
|
734
734
|
if (principalAmount.isZero() || initialCIM.isZero())
|
|
735
735
|
return number_1.BN_ZERO;
|
|
736
736
|
const cimRsp = yield this.recalculateCIM(denom, debtInfo);
|
|
@@ -756,8 +756,8 @@ class CDPModule extends base_1.default {
|
|
|
756
756
|
const debtResp = yield sdk.query.cdp.AccountStablecoin(query_1.QueryAccountStablecoinRequest.fromPartial({ address: account }));
|
|
757
757
|
debt = debtResp;
|
|
758
758
|
}
|
|
759
|
-
principalAmount = number_1.bnOrZero(debt.principalDebt);
|
|
760
|
-
const initialCIM = number_1.bnOrZero(debt.initialCumulativeInterestMultiplier);
|
|
759
|
+
principalAmount = (0, number_1.bnOrZero)(debt.principalDebt);
|
|
760
|
+
const initialCIM = (0, number_1.bnOrZero)(debt.initialCumulativeInterestMultiplier);
|
|
761
761
|
const cim = yield this.recalculateStablecoinCIM(debtInfo);
|
|
762
762
|
if (!cim)
|
|
763
763
|
throw new Error("unable to retrieve account debt");
|
|
@@ -798,7 +798,7 @@ class CDPModule extends base_1.default {
|
|
|
798
798
|
return number_1.BN_ZERO;
|
|
799
799
|
}
|
|
800
800
|
const diffSeconds = new bignumber_js_1.BigNumber(diffMs).shiftedBy(-3).dp(0, bignumber_js_1.BigNumber.ROUND_CEIL);
|
|
801
|
-
const secondsAYear = number_1.bnOrZero(31536000);
|
|
801
|
+
const secondsAYear = (0, number_1.bnOrZero)(31536000);
|
|
802
802
|
const numPeriods = secondsAYear.div(diffSeconds).dp(18);
|
|
803
803
|
return apy.div(numPeriods).dp(18); // carbon backend sdk.dec max 18 dp
|
|
804
804
|
}
|
|
@@ -822,8 +822,8 @@ class CDPModule extends base_1.default {
|
|
|
822
822
|
throw new Error("unable to retrieve cdp params for " + denom);
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
|
-
const interestFeeRate = number_1.bnOrZero(params.interestFee).div(number_1.BN_10000);
|
|
826
|
-
const utilizationRate = number_1.bnOrZero(debtInfo.utilizationRate).shiftedBy(-18);
|
|
825
|
+
const interestFeeRate = (0, number_1.bnOrZero)(params.interestFee).div(number_1.BN_10000);
|
|
826
|
+
const utilizationRate = (0, number_1.bnOrZero)(debtInfo.utilizationRate).shiftedBy(-18);
|
|
827
827
|
return borrowInterest.times(utilizationRate).times(number_1.BN_ONE.minus(interestFeeRate));
|
|
828
828
|
});
|
|
829
829
|
}
|
|
@@ -838,7 +838,7 @@ class CDPModule extends base_1.default {
|
|
|
838
838
|
return { cim: number_1.BN_ZERO, interest: number_1.BN_ZERO };
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
|
-
const cim = number_1.bnOrZero(debtInfo.cumulativeInterestMultiplier);
|
|
841
|
+
const cim = (0, number_1.bnOrZero)(debtInfo.cumulativeInterestMultiplier);
|
|
842
842
|
const apy = yield this.calculateAPY(denom, debtInfo);
|
|
843
843
|
const newInterest = CDPModule.calculateInterestForTimePeriod(apy, (_a = debtInfo.lastUpdatedTime) !== null && _a !== void 0 ? _a : new Date(0), new Date());
|
|
844
844
|
const newCIM = cim.times(newInterest.plus(1));
|
|
@@ -856,9 +856,9 @@ class CDPModule extends base_1.default {
|
|
|
856
856
|
return number_1.BN_ZERO;
|
|
857
857
|
}
|
|
858
858
|
}
|
|
859
|
-
const
|
|
860
|
-
const cim = number_1.bnOrZero(debtInfo.cumulativeInterestMultiplier);
|
|
861
|
-
const apy = number_1.bnOrZero((_a =
|
|
859
|
+
const stablecoinInterestResponse = yield sdk.query.cdp.StablecoinInterest({});
|
|
860
|
+
const cim = (0, number_1.bnOrZero)(debtInfo.cumulativeInterestMultiplier);
|
|
861
|
+
const apy = (0, number_1.bnOrZero)((_a = stablecoinInterestResponse.stablecoinInterestInfo) === null || _a === void 0 ? void 0 : _a.stablecoinInterestRate);
|
|
862
862
|
if (!apy) {
|
|
863
863
|
return number_1.BN_ZERO;
|
|
864
864
|
}
|
|
@@ -887,7 +887,7 @@ class CDPModule extends base_1.default {
|
|
|
887
887
|
cdpDenom: cdpDenom,
|
|
888
888
|
});
|
|
889
889
|
const [accountData, tokenPrice, accountCollateral] = yield Promise.all([accountDataRequest, tokenPriceRequest, accountCollateralRequest]);
|
|
890
|
-
const tokenTwap = number_1.bnOrZero((_a = tokenPrice.tokenPrice) === null || _a === void 0 ? void 0 : _a.twap);
|
|
890
|
+
const tokenTwap = (0, number_1.bnOrZero)((_a = tokenPrice.tokenPrice) === null || _a === void 0 ? void 0 : _a.twap);
|
|
891
891
|
if (tokenTwap.isZero())
|
|
892
892
|
throw new Error("unable to retrieve token price for " + denom);
|
|
893
893
|
const tokenDecimals = (_b = (yield sdk.getTokenClient().getDecimals(denom))) !== null && _b !== void 0 ? _b : 0;
|
|
@@ -896,7 +896,7 @@ class CDPModule extends base_1.default {
|
|
|
896
896
|
const tokenAmt = unlockableUsd.div(tokenTwap.shiftedBy(-18)).shiftedBy(tokenDecimals);
|
|
897
897
|
const cdpToActualRatio = (_c = (yield this.getCdpToActualRatio(cdpDenom))) !== null && _c !== void 0 ? _c : number_1.BN_ZERO;
|
|
898
898
|
const cdpTokenAmt = tokenAmt.multipliedBy(cdpToActualRatio);
|
|
899
|
-
const lockedAmount = number_1.bnOrZero((_e = (_d = accountCollateral.collateral) === null || _d === void 0 ? void 0 : _d.collateralAmount) !== null && _e !== void 0 ? _e : "0");
|
|
899
|
+
const lockedAmount = (0, number_1.bnOrZero)((_e = (_d = accountCollateral.collateral) === null || _d === void 0 ? void 0 : _d.collateralAmount) !== null && _e !== void 0 ? _e : "0");
|
|
900
900
|
return lockedAmount.lt(cdpTokenAmt) ? lockedAmount : cdpTokenAmt;
|
|
901
901
|
});
|
|
902
902
|
}
|
|
@@ -914,7 +914,7 @@ class CDPModule extends base_1.default {
|
|
|
914
914
|
const denom = this.getUnderlyingDenom(cdpDenom);
|
|
915
915
|
const cdpToActualRatio = (_a = (yield this.getCdpToActualRatio(cdpDenom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
916
916
|
const tokenPrice = yield sdk.query.pricing.TokenPrice({ denom: denom });
|
|
917
|
-
const tokenTwap = number_1.bnOrZero((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap).shiftedBy(-18);
|
|
917
|
+
const tokenTwap = (0, number_1.bnOrZero)((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap).shiftedBy(-18);
|
|
918
918
|
return tokenTwap.multipliedBy(cdpToActualRatio);
|
|
919
919
|
});
|
|
920
920
|
}
|
|
@@ -947,22 +947,22 @@ class CDPModule extends base_1.default {
|
|
|
947
947
|
if (!debtorAccountCollateral.collateral) {
|
|
948
948
|
throw Error("unable to retrieve debtor's collateral amount");
|
|
949
949
|
}
|
|
950
|
-
const bonus = number_1.bnOrZero(asset.assetParams.liquidationDiscount).div(number_1.BN_10000);
|
|
950
|
+
const bonus = (0, number_1.bnOrZero)(asset.assetParams.liquidationDiscount).div(number_1.BN_10000);
|
|
951
951
|
const cdpTokenPrice = yield this.getCdpTokenPrice(cdpDenom);
|
|
952
952
|
const cdpTokenDiscountedPrice = cdpTokenPrice.multipliedBy(number_1.BN_ONE.minus(bonus));
|
|
953
953
|
// get close factor
|
|
954
954
|
const debtorAccountData = yield sdk.query.cdp.AccountData({
|
|
955
955
|
address: debtor,
|
|
956
956
|
});
|
|
957
|
-
const debtorTotalCollateralVal = number_1.bnOrZero(debtorAccountData.totalCollateralsUsd);
|
|
958
|
-
const debtorTotalDebtVal = number_1.bnOrZero(debtorAccountData.totalDebtsUsd);
|
|
959
|
-
const currentLiqThreshold = number_1.bnOrZero(debtorAccountData.currLiquidationThreshold);
|
|
960
|
-
const smallLiqSize = number_1.bnOrZero(params.params.smallLiquidationSize);
|
|
961
|
-
const minCloseFactor = number_1.bnOrZero(params.params.minimumCloseFactor);
|
|
962
|
-
const completeLiqThreshold = number_1.bnOrZero(params.params.completeLiquidationThreshold);
|
|
957
|
+
const debtorTotalCollateralVal = (0, number_1.bnOrZero)(debtorAccountData.totalCollateralsUsd);
|
|
958
|
+
const debtorTotalDebtVal = (0, number_1.bnOrZero)(debtorAccountData.totalDebtsUsd);
|
|
959
|
+
const currentLiqThreshold = (0, number_1.bnOrZero)(debtorAccountData.currLiquidationThreshold);
|
|
960
|
+
const smallLiqSize = (0, number_1.bnOrZero)(params.params.smallLiquidationSize);
|
|
961
|
+
const minCloseFactor = (0, number_1.bnOrZero)(params.params.minimumCloseFactor);
|
|
962
|
+
const completeLiqThreshold = (0, number_1.bnOrZero)(params.params.completeLiquidationThreshold);
|
|
963
963
|
const closeFactor = this.computeCloseFactor(debtorTotalDebtVal, debtorTotalCollateralVal, currentLiqThreshold, smallLiqSize, minCloseFactor, completeLiqThreshold);
|
|
964
964
|
// get max repayable amount given the debtor's debt and how much liquidator wants to repay
|
|
965
|
-
const debtDecimals = number_1.bnOrZero(yield sdk.getTokenClient().getDecimals(debtDenom));
|
|
965
|
+
const debtDecimals = (0, number_1.bnOrZero)(yield sdk.getTokenClient().getDecimals(debtDenom));
|
|
966
966
|
const maxRepayableValue = debtorTotalDebtVal.multipliedBy(closeFactor);
|
|
967
967
|
const maxRepayableAmt = maxRepayableValue.shiftedBy(debtDecimals.toNumber());
|
|
968
968
|
if (debtRepaymentAmount.isGreaterThan(maxRepayableAmt)) {
|
|
@@ -970,7 +970,7 @@ class CDPModule extends base_1.default {
|
|
|
970
970
|
}
|
|
971
971
|
// calculate collateral amount that can be obtained given that debt amount and debtor's collateral balance
|
|
972
972
|
// AND, recalculate debt repay amount if needed
|
|
973
|
-
const cdpTokenDecimals = number_1.bnOrZero(yield sdk.getTokenClient().getDecimals(cdpActualDenom));
|
|
973
|
+
const cdpTokenDecimals = (0, number_1.bnOrZero)(yield sdk.getTokenClient().getDecimals(cdpActualDenom));
|
|
974
974
|
let collateralAmtToLiquidate = this.calculateCollateralRequiredForDebt(number_1.BN_ONE, // assumes USC is $1
|
|
975
975
|
cdpTokenDiscountedPrice, debtRepaymentAmount, cdpTokenDecimals, debtDecimals);
|
|
976
976
|
const debtorCollateralAmt = new bignumber_js_1.BigNumber(debtorAccountCollateral.collateral.collateralAmount);
|
|
@@ -1035,11 +1035,11 @@ class CDPModule extends base_1.default {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
exports.CDPModule = CDPModule;
|
|
1037
1037
|
CDPModule.calculateInterestAPY = (debtInfo, rateStrategy) => {
|
|
1038
|
-
const utilizationRate = number_1.bnOrZero(debtInfo.utilizationRate).shiftedBy(-18);
|
|
1039
|
-
const optimalUsage = number_1.bnOrZero(rateStrategy.optimalUsage).shiftedBy(-4);
|
|
1040
|
-
const variableRate1 = number_1.bnOrZero(rateStrategy.variableRateSlope1).shiftedBy(-4);
|
|
1041
|
-
const variableRate2 = number_1.bnOrZero(rateStrategy.variableRateSlope2).shiftedBy(-4);
|
|
1042
|
-
const baseVariableBorrowRate = number_1.bnOrZero(rateStrategy.baseVariableBorrowRate).shiftedBy(-4);
|
|
1038
|
+
const utilizationRate = (0, number_1.bnOrZero)(debtInfo.utilizationRate).shiftedBy(-18);
|
|
1039
|
+
const optimalUsage = (0, number_1.bnOrZero)(rateStrategy.optimalUsage).shiftedBy(-4);
|
|
1040
|
+
const variableRate1 = (0, number_1.bnOrZero)(rateStrategy.variableRateSlope1).shiftedBy(-4);
|
|
1041
|
+
const variableRate2 = (0, number_1.bnOrZero)(rateStrategy.variableRateSlope2).shiftedBy(-4);
|
|
1042
|
+
const baseVariableBorrowRate = (0, number_1.bnOrZero)(rateStrategy.baseVariableBorrowRate).shiftedBy(-4);
|
|
1043
1043
|
if (utilizationRate.lte(optimalUsage)) {
|
|
1044
1044
|
const vRate = utilizationRate.times(variableRate1).div(optimalUsage).dp(4, bignumber_js_1.BigNumber.ROUND_CEIL);
|
|
1045
1045
|
return vRate.plus(baseVariableBorrowRate);
|
package/lib/modules/cosmwasm.js
CHANGED
|
@@ -33,7 +33,7 @@ class CosmWasmModule extends base_1.default {
|
|
|
33
33
|
}
|
|
34
34
|
catch (error) { }
|
|
35
35
|
}
|
|
36
|
-
const { client, rpcUrl } = yield generic_1.getBestRpcTmClient(chainInfo.bestRpcs.map(r => r.address));
|
|
36
|
+
const { client, rpcUrl } = yield (0, generic_1.getBestRpcTmClient)(chainInfo.bestRpcs.map(r => r.address));
|
|
37
37
|
chainInfo.activeRpc = rpcUrl;
|
|
38
38
|
return CosmWasmModule.instanceWithTmClient(sdkProvider, client);
|
|
39
39
|
});
|
|
@@ -41,7 +41,7 @@ class CosmWasmModule extends base_1.default {
|
|
|
41
41
|
static instanceWithTmClient(sdkProvider, tmClient) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
const baseClient = new stargate_1.QueryClient(tmClient);
|
|
44
|
-
const rpcClient = stargate_1.createProtobufRpcClient(baseClient);
|
|
44
|
+
const rpcClient = (0, stargate_1.createProtobufRpcClient)(baseClient);
|
|
45
45
|
const cosmWasmClient = new query_1.QueryClientImpl(rpcClient);
|
|
46
46
|
return new CosmWasmModule(sdkProvider, cosmWasmClient);
|
|
47
47
|
});
|
package/lib/modules/evm.js
CHANGED
|
@@ -88,7 +88,7 @@ function constructTxDataAny(req) {
|
|
|
88
88
|
value: (_d = (_c = req.value) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0",
|
|
89
89
|
gas: (_f = (_e = req.gasLimit) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : "0",
|
|
90
90
|
gasPrice: (_h = (_g = req.gasPrice) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : "0",
|
|
91
|
-
data: req.data ? utils_1.arrayify(req.data) : undefined,
|
|
91
|
+
data: req.data ? (0, utils_1.arrayify)(req.data) : undefined,
|
|
92
92
|
});
|
|
93
93
|
txType = 'LegacyTx';
|
|
94
94
|
}
|
|
@@ -101,8 +101,8 @@ function constructTxDataAny(req) {
|
|
|
101
101
|
gas: (_r = (_q = req.gasLimit) === null || _q === void 0 ? void 0 : _q.toString()) !== null && _r !== void 0 ? _r : "0",
|
|
102
102
|
gasTipCap: (_t = (_s = req.maxPriorityFeePerGas) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : "0",
|
|
103
103
|
gasFeeCap: (_v = (_u = req.maxFeePerGas) === null || _u === void 0 ? void 0 : _u.toString()) !== null && _v !== void 0 ? _v : "0",
|
|
104
|
-
data: req.data ? utils_1.arrayify(req.data) : undefined,
|
|
105
|
-
accesses: req.accessList ? utils_1.accessListify(req.accessList) : undefined,
|
|
104
|
+
data: req.data ? (0, utils_1.arrayify)(req.data) : undefined,
|
|
105
|
+
accesses: req.accessList ? (0, utils_1.accessListify)(req.accessList) : undefined,
|
|
106
106
|
});
|
|
107
107
|
txType = 'DynamicFeeTx';
|
|
108
108
|
}
|
|
@@ -114,8 +114,8 @@ function constructTxDataAny(req) {
|
|
|
114
114
|
value: (_1 = (_0 = req.value) === null || _0 === void 0 ? void 0 : _0.toString()) !== null && _1 !== void 0 ? _1 : "0",
|
|
115
115
|
gas: parseInt((_3 = (_2 = req.gasLimit) === null || _2 === void 0 ? void 0 : _2.toString()) !== null && _3 !== void 0 ? _3 : "0", 10),
|
|
116
116
|
gasPrice: (_5 = (_4 = req.gasPrice) === null || _4 === void 0 ? void 0 : _4.toString()) !== null && _5 !== void 0 ? _5 : "0",
|
|
117
|
-
data: req.data ? utils_1.arrayify(req.data) : undefined,
|
|
118
|
-
accesses: req.accessList ? utils_1.accessListify(req.accessList) : undefined,
|
|
117
|
+
data: req.data ? (0, utils_1.arrayify)(req.data) : undefined,
|
|
118
|
+
accesses: req.accessList ? (0, utils_1.accessListify)(req.accessList) : undefined,
|
|
119
119
|
});
|
|
120
120
|
txType = 'AccessListTx';
|
|
121
121
|
}
|
package/lib/modules/gov.js
CHANGED
|
@@ -48,7 +48,7 @@ class GovModule extends base_1.default {
|
|
|
48
48
|
const value = tx_1.MsgDeposit.fromPartial({
|
|
49
49
|
proposalId: new long_1.default(params.proposalId),
|
|
50
50
|
depositor: wallet.bech32Address,
|
|
51
|
-
amount: amino_1.coins(params.amount, params.denom),
|
|
51
|
+
amount: (0, amino_1.coins)(params.amount, params.denom),
|
|
52
52
|
});
|
|
53
53
|
return yield wallet.sendTx({
|
|
54
54
|
typeUrl: util_1.CarbonTx.Types.MsgDeposit,
|
|
@@ -78,21 +78,21 @@ class GovModule extends base_1.default {
|
|
|
78
78
|
const createTokenMsg = {
|
|
79
79
|
title: title,
|
|
80
80
|
description: description,
|
|
81
|
-
msg: admin_1.transfromCreateTokenParams(msg, wallet.bech32Address),
|
|
81
|
+
msg: (0, admin_1.transfromCreateTokenParams)(msg, wallet.bech32Address),
|
|
82
82
|
};
|
|
83
83
|
return proposal_1.CreateTokenProposal.encode(createTokenMsg).finish();
|
|
84
84
|
case "SetMsgGasCostProposal":
|
|
85
85
|
const setMsgGasCostMsg = {
|
|
86
86
|
title: title,
|
|
87
87
|
description: description,
|
|
88
|
-
msg: admin_1.transfromSetMsgGasCostParams(msg),
|
|
88
|
+
msg: (0, admin_1.transfromSetMsgGasCostParams)(msg),
|
|
89
89
|
};
|
|
90
90
|
return proposal_2.SetMsgGasCostProposal.encode(setMsgGasCostMsg).finish();
|
|
91
91
|
case "SetMinGasPriceProposal":
|
|
92
92
|
const setMinGasPriceMsg = {
|
|
93
93
|
title: title,
|
|
94
94
|
description: description,
|
|
95
|
-
msg: admin_1.transfromSetMinGasPriceParams(msg),
|
|
95
|
+
msg: (0, admin_1.transfromSetMinGasPriceParams)(msg),
|
|
96
96
|
};
|
|
97
97
|
return proposal_2.SetMinGasPriceProposal.encode(setMinGasPriceMsg).finish();
|
|
98
98
|
case "RemoveMsgGasCostProposal":
|
|
@@ -113,49 +113,49 @@ class GovModule extends base_1.default {
|
|
|
113
113
|
const setRewardCurveMsg = {
|
|
114
114
|
title: title,
|
|
115
115
|
description: description,
|
|
116
|
-
msg: admin_1.transfromSetRewardCurveParams(msg),
|
|
116
|
+
msg: (0, admin_1.transfromSetRewardCurveParams)(msg),
|
|
117
117
|
};
|
|
118
118
|
return proposal_3.SetRewardCurveProposal.encode(setRewardCurveMsg).finish();
|
|
119
119
|
case "SetCommitmentCurveProposal":
|
|
120
120
|
const setCommitmentCurveMsg = {
|
|
121
121
|
title: title,
|
|
122
122
|
description: description,
|
|
123
|
-
msg: admin_1.transfromSetCommitmentCurveParams(msg),
|
|
123
|
+
msg: (0, admin_1.transfromSetCommitmentCurveParams)(msg),
|
|
124
124
|
};
|
|
125
125
|
return proposal_3.SetCommitmentCurveProposal.encode(setCommitmentCurveMsg).finish();
|
|
126
126
|
case "SetRewardsWeightsProposal":
|
|
127
127
|
const setRewardsWeightsMsg = {
|
|
128
128
|
title: title,
|
|
129
129
|
description: description,
|
|
130
|
-
msg: admin_1.transfromSetRewardsWeightsParams(msg),
|
|
130
|
+
msg: (0, admin_1.transfromSetRewardsWeightsParams)(msg),
|
|
131
131
|
};
|
|
132
132
|
return proposal_3.SetRewardsWeightsProposal.encode(setRewardsWeightsMsg).finish();
|
|
133
133
|
case "UpdatePoolProposal":
|
|
134
134
|
const updatePoolProposalMsg = {
|
|
135
135
|
title: title,
|
|
136
136
|
description: description,
|
|
137
|
-
msg: admin_1.transfromUpdatePoolParams(msg),
|
|
137
|
+
msg: (0, admin_1.transfromUpdatePoolParams)(msg),
|
|
138
138
|
};
|
|
139
139
|
return proposal_3.UpdatePoolProposal.encode(updatePoolProposalMsg).finish();
|
|
140
140
|
case "UpdateMarketProposal":
|
|
141
141
|
const updateMarketProposalMsg = {
|
|
142
142
|
title: title,
|
|
143
143
|
description: description,
|
|
144
|
-
msg: market_1.transfromUpdateMarketParams(msg),
|
|
144
|
+
msg: (0, market_1.transfromUpdateMarketParams)(msg),
|
|
145
145
|
};
|
|
146
146
|
return proposal_4.UpdateMarketProposal.encode(updateMarketProposalMsg).finish();
|
|
147
147
|
case "CreateOracleProposal":
|
|
148
148
|
const createOracleProposalMsg = {
|
|
149
149
|
title: title,
|
|
150
150
|
description: description,
|
|
151
|
-
msg: admin_1.transfromCreateOracleParams(msg, wallet.bech32Address),
|
|
151
|
+
msg: (0, admin_1.transfromCreateOracleParams)(msg, wallet.bech32Address),
|
|
152
152
|
};
|
|
153
153
|
return proposal_5.CreateOracleProposal.encode(createOracleProposalMsg).finish();
|
|
154
154
|
case "SettlementPriceProposal":
|
|
155
155
|
const settlementPriceProposalMsg = {
|
|
156
156
|
title: title,
|
|
157
157
|
description: description,
|
|
158
|
-
msg: admin_1.transformSetSettlementPriceParams(msg),
|
|
158
|
+
msg: (0, admin_1.transformSetSettlementPriceParams)(msg),
|
|
159
159
|
};
|
|
160
160
|
return proposal_6.SettlementPriceProposal.encode(settlementPriceProposalMsg).finish();
|
|
161
161
|
case "ParameterChangeProposal":
|
|
@@ -177,7 +177,7 @@ class GovModule extends base_1.default {
|
|
|
177
177
|
title: title,
|
|
178
178
|
description: description,
|
|
179
179
|
recipient: proposalMsg.recipient,
|
|
180
|
-
amount: admin_1.transformCommunityPoolSpendAmount(proposalMsg.amount),
|
|
180
|
+
amount: (0, admin_1.transformCommunityPoolSpendAmount)(proposalMsg.amount),
|
|
181
181
|
};
|
|
182
182
|
return distribution_1.CommunityPoolSpendProposal.encode(communityPoolSpendProposalMsg).finish();
|
|
183
183
|
case "CancelSoftwareUpgradeProposal":
|
|
@@ -145,7 +145,7 @@ class LiquidityPoolModule extends base_1.default {
|
|
|
145
145
|
const SECONDS_IN_A_WEEK = new bignumber_js_1.BigNumber(604800);
|
|
146
146
|
const mintDataResponse = yield this.sdkProvider.query.inflation.MintData({});
|
|
147
147
|
const mintData = mintDataResponse.mintData;
|
|
148
|
-
const nowTime = new bignumber_js_1.BigNumber(dayjs_1.default().unix());
|
|
148
|
+
const nowTime = new bignumber_js_1.BigNumber((0, dayjs_1.default)().unix());
|
|
149
149
|
const firstBlockTime = (_b = (_a = mintData === null || mintData === void 0 ? void 0 : mintData.firstBlockTime) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0;
|
|
150
150
|
const difference = nowTime.minus(firstBlockTime / 1000);
|
|
151
151
|
const currentWeek = difference.div(SECONDS_IN_A_WEEK).dp(0, bignumber_js_1.BigNumber.ROUND_DOWN);
|
package/lib/modules/order.js
CHANGED
|
@@ -33,7 +33,7 @@ class OrderModule extends base_1.default {
|
|
|
33
33
|
quantity: params.quantity.toString(10),
|
|
34
34
|
side: params.side,
|
|
35
35
|
stopPrice: (_b = params.stopPrice) === null || _b === void 0 ? void 0 : _b.shiftedBy(18).toString(10),
|
|
36
|
-
timeInForce: params.timeInForce || order_1.getDefaultTimeInForce(order_1.isMarket(params.orderType)),
|
|
36
|
+
timeInForce: params.timeInForce || (0, order_1.getDefaultTimeInForce)((0, order_1.isMarket)(params.orderType)),
|
|
37
37
|
triggerType: params.triggerType,
|
|
38
38
|
referralAddress: params.referralAddress,
|
|
39
39
|
referralCommission: params.referralCommission,
|
|
@@ -60,7 +60,7 @@ class OrderModule extends base_1.default {
|
|
|
60
60
|
quantity: params.quantity.toString(10),
|
|
61
61
|
side: params.side,
|
|
62
62
|
stopPrice: (_b = params.stopPrice) === null || _b === void 0 ? void 0 : _b.shiftedBy(18).toString(10),
|
|
63
|
-
timeInForce: params.timeInForce || order_1.getDefaultTimeInForce(order_1.isMarket(params.orderType)),
|
|
63
|
+
timeInForce: params.timeInForce || (0, order_1.getDefaultTimeInForce)((0, order_1.isMarket)(params.orderType)),
|
|
64
64
|
triggerType: params.triggerType,
|
|
65
65
|
referralAddress: params.referralAddress,
|
|
66
66
|
referralCommission: params.referralCommission,
|
|
@@ -35,7 +35,7 @@ class SubAccountModule extends base_1.default {
|
|
|
35
35
|
const wallet = this.getWallet();
|
|
36
36
|
const value = tx_1.MsgActivateSubAccount.fromPartial({
|
|
37
37
|
creator: wallet.bech32Address,
|
|
38
|
-
|
|
38
|
+
mainAddress: params.expectedMainAccount,
|
|
39
39
|
});
|
|
40
40
|
return yield wallet.sendTx({
|
|
41
41
|
typeUrl: util_1.CarbonTx.Types.MsgActivateSubAccount,
|
|
@@ -87,7 +87,7 @@ class EthLedgerAccount {
|
|
|
87
87
|
static tryConnect() {
|
|
88
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
89
|
try {
|
|
90
|
-
const transport = yield ledger_1.getLedgerTransport();
|
|
90
|
+
const transport = yield (0, ledger_1.getLedgerTransport)();
|
|
91
91
|
// get public key to assert that NEO app is open
|
|
92
92
|
const ethApp = new hw_app_eth_1.default(transport);
|
|
93
93
|
const bipString = EthLedgerAccount.getETHBIP44String();
|
|
@@ -39,7 +39,7 @@ exports.looksLikeTransportStatusError = looksLikeTransportStatusError;
|
|
|
39
39
|
* @returns error with modified message if found.
|
|
40
40
|
*/
|
|
41
41
|
function evalTransportError(err) {
|
|
42
|
-
const transportErr = lodash_1.cloneDeep(err);
|
|
42
|
+
const transportErr = (0, lodash_1.cloneDeep)(err);
|
|
43
43
|
switch (transportErr.statusCode) {
|
|
44
44
|
case StatusWord.APP_CLOSED:
|
|
45
45
|
transportErr.message = "Your NEO app is closed! Please login.";
|
|
@@ -49,8 +49,8 @@ function getAppName(ledger) {
|
|
|
49
49
|
return version.substring(0, version.length - 2); // take of status word
|
|
50
50
|
}
|
|
51
51
|
catch (e) {
|
|
52
|
-
if (ErrorCode_1.looksLikeTransportStatusError(e)) {
|
|
53
|
-
throw ErrorCode_1.evalTransportError(e);
|
|
52
|
+
if ((0, ErrorCode_1.looksLikeTransportStatusError)(e)) {
|
|
53
|
+
throw (0, ErrorCode_1.evalTransportError)(e);
|
|
54
54
|
}
|
|
55
55
|
throw e;
|
|
56
56
|
}
|
|
@@ -72,8 +72,8 @@ function getAppVersion(ledger) {
|
|
|
72
72
|
return major.toString() + "." + minor.toString() + "." + patch.toString();
|
|
73
73
|
}
|
|
74
74
|
catch (e) {
|
|
75
|
-
if (ErrorCode_1.looksLikeTransportStatusError(e)) {
|
|
76
|
-
throw ErrorCode_1.evalTransportError(e);
|
|
75
|
+
if ((0, ErrorCode_1.looksLikeTransportStatusError)(e)) {
|
|
76
|
+
throw (0, ErrorCode_1.evalTransportError)(e);
|
|
77
77
|
}
|
|
78
78
|
throw e;
|
|
79
79
|
}
|
|
@@ -109,8 +109,8 @@ function getPublicKey(ledger, bip44String, showAddressOnDevice = false) {
|
|
|
109
109
|
return response.toString("hex").substring(0, 130);
|
|
110
110
|
}
|
|
111
111
|
catch (e) {
|
|
112
|
-
if (ErrorCode_1.looksLikeTransportStatusError(e)) {
|
|
113
|
-
throw ErrorCode_1.evalTransportError(e);
|
|
112
|
+
if ((0, ErrorCode_1.looksLikeTransportStatusError)(e)) {
|
|
113
|
+
throw (0, ErrorCode_1.evalTransportError)(e);
|
|
114
114
|
}
|
|
115
115
|
throw e;
|
|
116
116
|
}
|
|
@@ -142,8 +142,8 @@ function getSignature(ledger, payload, bip44String, network) {
|
|
|
142
142
|
return DerToHexSignature(response.toString("hex"));
|
|
143
143
|
}
|
|
144
144
|
catch (e) {
|
|
145
|
-
if (ErrorCode_1.looksLikeTransportStatusError(e)) {
|
|
146
|
-
throw ErrorCode_1.evalTransportError(e);
|
|
145
|
+
if ((0, ErrorCode_1.looksLikeTransportStatusError)(e)) {
|
|
146
|
+
throw (0, ErrorCode_1.evalTransportError)(e);
|
|
147
147
|
}
|
|
148
148
|
throw e;
|
|
149
149
|
}
|
|
@@ -111,8 +111,8 @@ class NeoLedgerAccount {
|
|
|
111
111
|
*/
|
|
112
112
|
static tryConnect(version = "neo") {
|
|
113
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
const bipString = NeonLedger_1.getNEOBIP44String();
|
|
115
|
-
const ledger = yield ledger_1.getLedgerTransport();
|
|
114
|
+
const bipString = (0, NeonLedger_1.getNEOBIP44String)();
|
|
115
|
+
const ledger = yield (0, ledger_1.getLedgerTransport)();
|
|
116
116
|
// get public key to assert that NEO app is open
|
|
117
117
|
const ledgerAdapter = adapterForVersion(version);
|
|
118
118
|
const publicKey = yield ledgerAdapter.getPublicKey(ledger, bipString);
|
|
@@ -129,7 +129,7 @@ class NeoLedgerAccount {
|
|
|
129
129
|
}
|
|
130
130
|
sign(msg, magic = neon_core_next_1.CONST.MAGIC_NUMBER.MainNet) {
|
|
131
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const bipString = NeonLedger_1.getNEOBIP44String();
|
|
132
|
+
const bipString = (0, NeonLedger_1.getNEOBIP44String)();
|
|
133
133
|
const ledger = this.useLedger();
|
|
134
134
|
const ledgerAdapter = adapterForVersion(this.version);
|
|
135
135
|
const publicKey = this.publicKey;
|
|
@@ -40,7 +40,7 @@ function evalTransportError(err) {
|
|
|
40
40
|
transportErr.message = "Transaction signing denied";
|
|
41
41
|
break;
|
|
42
42
|
default:
|
|
43
|
-
transportErr.message = hw_transport_1.getAltStatusMessage(transportErr.statusCode);
|
|
43
|
+
transportErr.message = (0, hw_transport_1.getAltStatusMessage)(transportErr.statusCode);
|
|
44
44
|
}
|
|
45
45
|
return err;
|
|
46
46
|
}
|
|
@@ -231,32 +231,32 @@ const MsgSetSmallLiquidationSize = {
|
|
|
231
231
|
},
|
|
232
232
|
};
|
|
233
233
|
const AdminAmino = {
|
|
234
|
-
[CarbonTx.Types.MsgCreateOracle]: utils_1.generateAminoType(MsgCreateOracle),
|
|
235
|
-
[CarbonTx.Types.MsgBindToken]: utils_1.generateAminoType(MsgBindToken),
|
|
236
|
-
[CarbonTx.Types.MsgCreateToken]: utils_1.generateAminoType(MsgCreateToken),
|
|
237
|
-
[CarbonTx.Types.MsgLinkToken]: utils_1.generateAminoType(MsgLinkToken),
|
|
238
|
-
[CarbonTx.Types.MsgSyncToken]: utils_1.generateAminoType(MsgSyncToken),
|
|
239
|
-
[CarbonTx.Types.MsgCreateMarket]: utils_1.generateAminoType(MsgCreateMarket),
|
|
240
|
-
[CarbonTx.Types.MsgUpdatePool]: utils_1.generateAminoType(MsgUpdatePool),
|
|
241
|
-
[CarbonTx.Types.MsgSetRewardsWeights]: utils_1.generateAminoType(MsgSetRewardsWeights),
|
|
242
|
-
[CarbonTx.Types.MsgSetRewardCurve]: utils_1.generateAminoType(MsgSetRewardCurve),
|
|
243
|
-
[CarbonTx.Types.MsgSetCommitmentCurve]: utils_1.generateAminoType(MsgSetCommitmentCurve),
|
|
244
|
-
[CarbonTx.Types.MsgSetTradingFlag]: utils_1.generateAminoType(MsgSetTradingFlag),
|
|
245
|
-
[CarbonTx.Types.MsgSetGasCost]: utils_1.generateAminoType(MsgSetGasCost),
|
|
246
|
-
[CarbonTx.Types.MsgSetMinGasPrice]: utils_1.generateAminoType(MsgSetMinGasPrice),
|
|
247
|
-
[CarbonTx.Types.MsgRemoveGasCost]: utils_1.generateAminoType(MsgRemoveGasCost),
|
|
248
|
-
[CarbonTx.Types.MsgRemoveMinGasPrice]: utils_1.generateAminoType(MsgRemoveMinGasPrice),
|
|
249
|
-
[CarbonTx.Types.MsgCreateValidator]: utils_1.generateAminoType(MsgCreateValidator),
|
|
250
|
-
[CarbonTx.Types.MsgEditValidator]: utils_1.generateAminoType(MsgEditValidator),
|
|
251
|
-
[CarbonTx.Types.MsgAddRateStrategy]: utils_1.generateAminoType(MsgAddRateStrategy),
|
|
252
|
-
[CarbonTx.Types.MsgUpdateRateStrategy]: utils_1.generateAminoType(MsgUpdateRateStrategy),
|
|
253
|
-
[CarbonTx.Types.MsgRemoveRateStrategy]: utils_1.generateAminoType(MsgRemoveRateStrategy),
|
|
254
|
-
[CarbonTx.Types.MsgAddAsset]: utils_1.generateAminoType(MsgAddAsset),
|
|
255
|
-
[CarbonTx.Types.MsgUpdateAsset]: utils_1.generateAminoType(MsgUpdateAsset),
|
|
256
|
-
[CarbonTx.Types.MsgSetLiquidationFee]: utils_1.generateAminoType(MsgSetLiquidationFee),
|
|
257
|
-
[CarbonTx.Types.MsgSetInterestFee]: utils_1.generateAminoType(MsgSetInterestFee),
|
|
258
|
-
[CarbonTx.Types.MsgSetCompleteLiquidationThreshold]: utils_1.generateAminoType(MsgSetCompleteLiquidationThreshold),
|
|
259
|
-
[CarbonTx.Types.MsgSetMinimumCloseFactor]: utils_1.generateAminoType(MsgSetMinimumCloseFactor),
|
|
260
|
-
[CarbonTx.Types.MsgSetSmallLiquidationSize]: utils_1.generateAminoType(MsgSetSmallLiquidationSize),
|
|
234
|
+
[CarbonTx.Types.MsgCreateOracle]: (0, utils_1.generateAminoType)(MsgCreateOracle),
|
|
235
|
+
[CarbonTx.Types.MsgBindToken]: (0, utils_1.generateAminoType)(MsgBindToken),
|
|
236
|
+
[CarbonTx.Types.MsgCreateToken]: (0, utils_1.generateAminoType)(MsgCreateToken),
|
|
237
|
+
[CarbonTx.Types.MsgLinkToken]: (0, utils_1.generateAminoType)(MsgLinkToken),
|
|
238
|
+
[CarbonTx.Types.MsgSyncToken]: (0, utils_1.generateAminoType)(MsgSyncToken),
|
|
239
|
+
[CarbonTx.Types.MsgCreateMarket]: (0, utils_1.generateAminoType)(MsgCreateMarket),
|
|
240
|
+
[CarbonTx.Types.MsgUpdatePool]: (0, utils_1.generateAminoType)(MsgUpdatePool),
|
|
241
|
+
[CarbonTx.Types.MsgSetRewardsWeights]: (0, utils_1.generateAminoType)(MsgSetRewardsWeights),
|
|
242
|
+
[CarbonTx.Types.MsgSetRewardCurve]: (0, utils_1.generateAminoType)(MsgSetRewardCurve),
|
|
243
|
+
[CarbonTx.Types.MsgSetCommitmentCurve]: (0, utils_1.generateAminoType)(MsgSetCommitmentCurve),
|
|
244
|
+
[CarbonTx.Types.MsgSetTradingFlag]: (0, utils_1.generateAminoType)(MsgSetTradingFlag),
|
|
245
|
+
[CarbonTx.Types.MsgSetGasCost]: (0, utils_1.generateAminoType)(MsgSetGasCost),
|
|
246
|
+
[CarbonTx.Types.MsgSetMinGasPrice]: (0, utils_1.generateAminoType)(MsgSetMinGasPrice),
|
|
247
|
+
[CarbonTx.Types.MsgRemoveGasCost]: (0, utils_1.generateAminoType)(MsgRemoveGasCost),
|
|
248
|
+
[CarbonTx.Types.MsgRemoveMinGasPrice]: (0, utils_1.generateAminoType)(MsgRemoveMinGasPrice),
|
|
249
|
+
[CarbonTx.Types.MsgCreateValidator]: (0, utils_1.generateAminoType)(MsgCreateValidator),
|
|
250
|
+
[CarbonTx.Types.MsgEditValidator]: (0, utils_1.generateAminoType)(MsgEditValidator),
|
|
251
|
+
[CarbonTx.Types.MsgAddRateStrategy]: (0, utils_1.generateAminoType)(MsgAddRateStrategy),
|
|
252
|
+
[CarbonTx.Types.MsgUpdateRateStrategy]: (0, utils_1.generateAminoType)(MsgUpdateRateStrategy),
|
|
253
|
+
[CarbonTx.Types.MsgRemoveRateStrategy]: (0, utils_1.generateAminoType)(MsgRemoveRateStrategy),
|
|
254
|
+
[CarbonTx.Types.MsgAddAsset]: (0, utils_1.generateAminoType)(MsgAddAsset),
|
|
255
|
+
[CarbonTx.Types.MsgUpdateAsset]: (0, utils_1.generateAminoType)(MsgUpdateAsset),
|
|
256
|
+
[CarbonTx.Types.MsgSetLiquidationFee]: (0, utils_1.generateAminoType)(MsgSetLiquidationFee),
|
|
257
|
+
[CarbonTx.Types.MsgSetInterestFee]: (0, utils_1.generateAminoType)(MsgSetInterestFee),
|
|
258
|
+
[CarbonTx.Types.MsgSetCompleteLiquidationThreshold]: (0, utils_1.generateAminoType)(MsgSetCompleteLiquidationThreshold),
|
|
259
|
+
[CarbonTx.Types.MsgSetMinimumCloseFactor]: (0, utils_1.generateAminoType)(MsgSetMinimumCloseFactor),
|
|
260
|
+
[CarbonTx.Types.MsgSetSmallLiquidationSize]: (0, utils_1.generateAminoType)(MsgSetSmallLiquidationSize),
|
|
261
261
|
};
|
|
262
262
|
exports.default = AdminAmino;
|
|
@@ -29,6 +29,6 @@ const MsgInitiateLiquidation = {
|
|
|
29
29
|
valueMap: {},
|
|
30
30
|
};
|
|
31
31
|
const BrokerAmino = {
|
|
32
|
-
[CarbonTx.Types.MsgInitiateLiquidation]: utils_1.generateAminoType(MsgInitiateLiquidation),
|
|
32
|
+
[CarbonTx.Types.MsgInitiateLiquidation]: (0, utils_1.generateAminoType)(MsgInitiateLiquidation),
|
|
33
33
|
};
|
|
34
34
|
exports.default = BrokerAmino;
|