carbon-js-sdk 0.4.5 → 0.4.6-dev.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/lib/CarbonSDK.js +1 -1
- package/lib/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.d.ts +11 -4
- package/lib/clients/ETHClient.js +32 -18
- package/lib/clients/HydrogenClient.d.ts +16 -7
- package/lib/clients/HydrogenClient.js +56 -10
- package/lib/clients/InsightsQueryClient.d.ts +1 -0
- package/lib/clients/InsightsQueryClient.js +8 -0
- package/lib/clients/NEOClient.d.ts +1 -1
- package/lib/clients/NEOClient.js +15 -10
- package/lib/clients/TokenClient.d.ts +29 -5
- package/lib/clients/TokenClient.js +258 -53
- package/lib/clients/ZILClient.d.ts +1 -1
- package/lib/clients/ZILClient.js +25 -20
- package/lib/codec/cdp/e_mode_category.d.ts +23 -0
- package/lib/codec/cdp/e_mode_category.js +135 -0
- 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/ethermint/crypto/v1/ethsecp256k1/export.d.ts +1 -0
- package/lib/codec/ethermint/crypto/v1/ethsecp256k1/export.js +6 -0
- package/lib/codec/ethermint/evm/v1/export.d.ts +5 -0
- package/lib/codec/ethermint/evm/v1/export.js +53 -0
- package/lib/codec/ethermint/feemarket/v1/export.d.ts +4 -0
- package/lib/codec/ethermint/feemarket/v1/export.js +18 -0
- package/lib/codec/ethermint/types/v1/export.d.ts +4 -0
- package/lib/codec/ethermint/types/v1/export.js +11 -0
- package/lib/codec/ethermint-models.d.ts +4 -0
- package/lib/codec/ethermint-models.js +26 -0
- package/lib/constant/eip712.d.ts +28 -0
- package/lib/constant/eip712.js +40 -0
- package/lib/constant/generic.js +1 -1
- package/lib/constant/ibc.d.ts +7 -0
- package/lib/constant/ibc.js +4 -1
- package/lib/constant/network.d.ts +2 -0
- package/lib/constant/network.js +5 -1
- package/lib/hydrogen/transfer.d.ts +5 -5
- package/lib/insights/common.d.ts +1 -0
- package/lib/insights/common.js +1 -0
- package/lib/insights/competition.d.ts +20 -0
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/evm.d.ts +46 -0
- package/lib/modules/evm.js +127 -0
- package/lib/modules/evmmerge.d.ts +12 -0
- package/lib/modules/evmmerge.js +35 -0
- package/lib/modules/feemarket.d.ts +20 -0
- package/lib/modules/feemarket.js +45 -0
- package/lib/modules/gov.js +12 -12
- package/lib/modules/ibc.d.ts +5 -1
- package/lib/modules/ibc.js +78 -0
- package/lib/modules/liquiditypool.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 +22 -22
- package/lib/provider/amino/types/coin.js +4 -4
- package/lib/provider/amino/types/gov.js +4 -4
- 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 +1 -1
- package/lib/provider/amino/types/oracle.js +1 -1
- 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/KeplrStore.d.ts +1 -1
- package/lib/provider/keplr/KeplrStore.js +2 -5
- package/lib/provider/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.d.ts +5 -5
- package/lib/provider/metamask/MetaMask.js +37 -37
- package/lib/provider/o3/O3Wallet.js +2 -2
- package/lib/util/address.js +13 -13
- package/lib/util/api.js +4 -4
- package/lib/util/blockchain.d.ts +26 -0
- package/lib/util/blockchain.js +160 -1
- package/lib/util/eip712.d.ts +10 -0
- package/lib/util/eip712.js +46 -0
- package/lib/util/ethermint.d.ts +4 -0
- package/lib/util/ethermint.js +26 -0
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/ibc.d.ts +5 -3
- package/lib/util/ibc.js +26 -1
- package/lib/util/number.js +5 -5
- package/lib/wallet/CarbonSigner.js +2 -2
- package/lib/wallet/CarbonSigningClient.js +8 -8
- package/lib/wallet/CarbonWallet.js +6 -6
- package/lib/websocket/connector.js +3 -3
- package/package.json +1 -1
package/lib/insights/common.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.InsightsEndpoints = {
|
|
|
37
37
|
"competition/list": "/competition/list",
|
|
38
38
|
"competition/leaderboard": "/competition/leaderboard",
|
|
39
39
|
"competition/leaderboardpnl": "/competition/leaderboardpnl",
|
|
40
|
+
"competition/leaderboardlottery": "/competition/leaderboardlottery",
|
|
40
41
|
//Coin Gecko Tokens api
|
|
41
42
|
"info/denom_gecko_map": "/info/denom_gecko_map",
|
|
42
43
|
//funding
|
|
@@ -52,6 +52,19 @@ export interface PNLLeaderboardEntry {
|
|
|
52
52
|
username: string | null;
|
|
53
53
|
twitter: string | null;
|
|
54
54
|
}
|
|
55
|
+
export interface LotteryLeaderboardEntry {
|
|
56
|
+
rank: string;
|
|
57
|
+
competitionId: string;
|
|
58
|
+
address: string;
|
|
59
|
+
twitter: string | null;
|
|
60
|
+
username: string | null;
|
|
61
|
+
longestPosition: string;
|
|
62
|
+
maxLeverage: string;
|
|
63
|
+
referralTickets: string;
|
|
64
|
+
liquidationTickets: string;
|
|
65
|
+
positionTickets: string;
|
|
66
|
+
totalTickets: string;
|
|
67
|
+
}
|
|
55
68
|
export interface QueryGetPNLCompetitionLeaderboardResponse {
|
|
56
69
|
entries: PNLLeaderboardEntry[];
|
|
57
70
|
meta: TimeMeta;
|
|
@@ -60,3 +73,10 @@ export interface QueryGetPNLCompetitionLeaderboardRequest {
|
|
|
60
73
|
competitionId: string;
|
|
61
74
|
market?: string;
|
|
62
75
|
}
|
|
76
|
+
export interface QueryGetLotteryCompetitionLeaderboardResponse {
|
|
77
|
+
entries: LotteryLeaderboardEntry[];
|
|
78
|
+
}
|
|
79
|
+
export interface QueryGetLotteryCompetitionLeaderboardRequest {
|
|
80
|
+
competitionId: string;
|
|
81
|
+
market?: string;
|
|
82
|
+
}
|
package/lib/modules/cdp.js
CHANGED
|
@@ -458,7 +458,7 @@ class CDPModule extends base_1.default {
|
|
|
458
458
|
let availableBorrowsUsd = number_1.BN_ZERO;
|
|
459
459
|
let currLiquidationThreshold = number_1.BN_ZERO;
|
|
460
460
|
for (let i = 0; i < collaterals.length; i++) {
|
|
461
|
-
const amount =
|
|
461
|
+
const amount = number_1.bnOrZero(collaterals[i].collateralAmount);
|
|
462
462
|
if (amount.isZero()) {
|
|
463
463
|
continue; // no collateral for denom
|
|
464
464
|
}
|
|
@@ -475,9 +475,9 @@ class CDPModule extends base_1.default {
|
|
|
475
475
|
if (!assetParam) {
|
|
476
476
|
continue;
|
|
477
477
|
}
|
|
478
|
-
const ltv =
|
|
478
|
+
const ltv = number_1.bnOrZero(assetParam.loanToValue).div(number_1.BN_10000);
|
|
479
479
|
const availableBorrowUsd = collateralUsdVal.times(ltv);
|
|
480
|
-
const liquidationThreshold =
|
|
480
|
+
const liquidationThreshold = number_1.bnOrZero(assetParam.liquidationThreshold).div(number_1.BN_10000);
|
|
481
481
|
const liquidationThresholdVal = collateralUsdVal.times(liquidationThreshold);
|
|
482
482
|
totalCollateralsUsd = totalCollateralsUsd.plus(collateralUsdVal);
|
|
483
483
|
availableBorrowsUsd = availableBorrowsUsd.plus(availableBorrowUsd);
|
|
@@ -488,7 +488,7 @@ class CDPModule extends base_1.default {
|
|
|
488
488
|
const debts = debtsRsp.debts;
|
|
489
489
|
let totalDebtsUsd = number_1.BN_ZERO;
|
|
490
490
|
for (let i = 0; i < debts.length; i++) {
|
|
491
|
-
const amount =
|
|
491
|
+
const amount = number_1.bnOrZero(debts[i].principalDebt);
|
|
492
492
|
const denom = debts[i].denom;
|
|
493
493
|
if (amount.isZero()) {
|
|
494
494
|
continue;
|
|
@@ -510,7 +510,7 @@ class CDPModule extends base_1.default {
|
|
|
510
510
|
if (stablecoinDebtInfo) {
|
|
511
511
|
const accountStablecoin = yield sdk.query.cdp.AccountStablecoin({ address: account });
|
|
512
512
|
const stablecoinDecimals = (_a = (yield this.sdkProvider.getTokenClient().getDecimals(stablecoinDebtInfo.denom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
513
|
-
const stablecoinDebtAmount =
|
|
513
|
+
const stablecoinDebtAmount = number_1.bnOrZero(accountStablecoin.principalDebt).plus(number_1.bnOrZero(accountStablecoin.interestDebt));
|
|
514
514
|
stablecoinDebtUsd = stablecoinDebtAmount.shiftedBy(-stablecoinDecimals);
|
|
515
515
|
totalDebtsUsd = totalDebtsUsd.plus(stablecoinDebtUsd);
|
|
516
516
|
}
|
|
@@ -531,7 +531,7 @@ class CDPModule extends base_1.default {
|
|
|
531
531
|
const sdk = this.sdkProvider;
|
|
532
532
|
const cdpAddress = this.getCdpModuleAddress();
|
|
533
533
|
const balanceRsp = yield sdk.query.bank.Balance(query_2.QueryBalanceRequest.fromPartial({ address: cdpAddress, denom }));
|
|
534
|
-
return
|
|
534
|
+
return number_1.bnOrZero((_a = balanceRsp.balance) === null || _a === void 0 ? void 0 : _a.amount);
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
537
|
getCdpToActualRatio(cdpDenom) {
|
|
@@ -542,13 +542,13 @@ class CDPModule extends base_1.default {
|
|
|
542
542
|
const cdpAmountRsp = supplyRsp.amount;
|
|
543
543
|
if (!cdpAmountRsp)
|
|
544
544
|
throw new Error("unable to retrieve cdp token supply");
|
|
545
|
-
const cdpAmount =
|
|
545
|
+
const cdpAmount = number_1.bnOrZero(cdpAmountRsp.amount);
|
|
546
546
|
const cdpAddress = this.getCdpModuleAddress();
|
|
547
547
|
const balanceRsp = yield sdk.query.bank.Balance(query_2.QueryBalanceRequest.fromPartial({ address: cdpAddress, denom }));
|
|
548
548
|
if (!balanceRsp.balance)
|
|
549
549
|
throw new Error("unable to retrieve cdp module balance");
|
|
550
550
|
const owedAmount = yield this.getTotalTokenDebt(denom);
|
|
551
|
-
const actualAmount =
|
|
551
|
+
const actualAmount = number_1.bnOrZero(balanceRsp.balance.amount).plus(owedAmount);
|
|
552
552
|
if (!owedAmount)
|
|
553
553
|
throw new Error("unable to retrieve total token debt");
|
|
554
554
|
return cdpAmount.div(actualAmount);
|
|
@@ -570,8 +570,8 @@ class CDPModule extends base_1.default {
|
|
|
570
570
|
const allDebts = allDebtsRes.debtInfosAll;
|
|
571
571
|
for (let i = 0; i < allDebts.length; i++) {
|
|
572
572
|
const denom = allDebts[i].denom;
|
|
573
|
-
const interest =
|
|
574
|
-
const principal =
|
|
573
|
+
const interest = number_1.bnOrZero(allDebts[i].totalAccumulatedInterest);
|
|
574
|
+
const principal = number_1.bnOrZero(allDebts[i].totalPrincipal);
|
|
575
575
|
const debtAmt = interest.plus(principal);
|
|
576
576
|
const debtUsdVal = yield this.getTokenUsdVal(denom, debtAmt);
|
|
577
577
|
if (!debtUsdVal) {
|
|
@@ -583,7 +583,7 @@ class CDPModule extends base_1.default {
|
|
|
583
583
|
const stablecoinDebtRes = yield this.sdkProvider.query.cdp.StablecoinDebt({});
|
|
584
584
|
if (stablecoinDebtRes.stablecoinDebtInfo) {
|
|
585
585
|
const debtInfo = stablecoinDebtRes.stablecoinDebtInfo;
|
|
586
|
-
const debtAmt =
|
|
586
|
+
const debtAmt = number_1.bnOrZero(debtInfo.totalPrincipal).plus(number_1.bnOrZero(debtInfo.totalAccumulatedInterest));
|
|
587
587
|
const stablecoinDecimals = (_a = (yield sdk.getTokenClient().getDecimals(debtInfo.denom))) !== null && _a !== void 0 ? _a : 0;
|
|
588
588
|
const debtUsdVal = debtAmt.shiftedBy(-stablecoinDecimals);
|
|
589
589
|
totalDebt = totalDebt.plus(debtUsdVal);
|
|
@@ -601,7 +601,7 @@ class CDPModule extends base_1.default {
|
|
|
601
601
|
if (!TokenClient_1.default.isCdpToken(balance.denom)) {
|
|
602
602
|
continue;
|
|
603
603
|
}
|
|
604
|
-
const amount =
|
|
604
|
+
const amount = number_1.bnOrZero(balance.amount);
|
|
605
605
|
const collateralUsdValue = yield this.getCdpTokenUsdVal(balance.denom, amount);
|
|
606
606
|
allCollateralsUsdValue = allCollateralsUsdValue.plus(collateralUsdValue);
|
|
607
607
|
}
|
|
@@ -625,7 +625,7 @@ class CDPModule extends base_1.default {
|
|
|
625
625
|
const priceResult = yield sdk.query.pricing.TokenPrice(codec_1.QueryTokenPriceRequest.fromPartial({ denom }));
|
|
626
626
|
if (!priceResult.tokenPrice)
|
|
627
627
|
throw new Error("unable to retrieve token price for " + denom);
|
|
628
|
-
const twap =
|
|
628
|
+
const twap = number_1.bnOrZero(priceResult.tokenPrice.twap).shiftedBy(-18);
|
|
629
629
|
return amount.multipliedBy(twap).shiftedBy(-decimals);
|
|
630
630
|
});
|
|
631
631
|
}
|
|
@@ -640,11 +640,11 @@ class CDPModule extends base_1.default {
|
|
|
640
640
|
throw new Error("unable to retrieve debt info");
|
|
641
641
|
const cimRsp = yield this.recalculateCIM(denom, debtInfo);
|
|
642
642
|
const newInterestRate = cimRsp.interest;
|
|
643
|
-
const principal =
|
|
644
|
-
const accumInterest =
|
|
643
|
+
const principal = number_1.bnOrZero(debtInfo.totalPrincipal);
|
|
644
|
+
const accumInterest = number_1.bnOrZero(debtInfo.totalAccumulatedInterest);
|
|
645
645
|
const newInterest = principal.times(newInterestRate).plus(accumInterest.times(number_1.BN_ONE.plus(newInterestRate)));
|
|
646
646
|
const cdpParamsRsp = yield this.sdkProvider.query.cdp.Params(query_1.QueryParamsRequest.fromPartial({}));
|
|
647
|
-
const interestFee =
|
|
647
|
+
const interestFee = number_1.bnOrZero((_a = cdpParamsRsp.params) === null || _a === void 0 ? void 0 : _a.interestFee);
|
|
648
648
|
const interest = newInterest.times(number_1.BN_10000.minus(interestFee)).dividedToIntegerBy(number_1.BN_10000);
|
|
649
649
|
return principal.plus(interest);
|
|
650
650
|
});
|
|
@@ -662,8 +662,8 @@ class CDPModule extends base_1.default {
|
|
|
662
662
|
const debtRes = yield sdk.query.cdp.AccountDebt({ address: account, denom: denom });
|
|
663
663
|
debt = debtRes.debt;
|
|
664
664
|
}
|
|
665
|
-
const principalAmount =
|
|
666
|
-
const initialCIM =
|
|
665
|
+
const principalAmount = number_1.bnOrZero(debt === null || debt === void 0 ? void 0 : debt.principalDebt);
|
|
666
|
+
const initialCIM = number_1.bnOrZero(debt === null || debt === void 0 ? void 0 : debt.initialCumulativeInterestMultiplier);
|
|
667
667
|
if (principalAmount.isZero() || initialCIM.isZero())
|
|
668
668
|
return number_1.BN_ZERO;
|
|
669
669
|
const cimRsp = yield this.recalculateCIM(denom, debtInfo);
|
|
@@ -689,8 +689,8 @@ class CDPModule extends base_1.default {
|
|
|
689
689
|
const debtResp = yield sdk.query.cdp.AccountStablecoin(query_1.QueryAccountStablecoinRequest.fromPartial({ address: account }));
|
|
690
690
|
debt = debtResp;
|
|
691
691
|
}
|
|
692
|
-
principalAmount =
|
|
693
|
-
const initialCIM =
|
|
692
|
+
principalAmount = number_1.bnOrZero(debt.principalDebt);
|
|
693
|
+
const initialCIM = number_1.bnOrZero(debt.initialCumulativeInterestMultiplier);
|
|
694
694
|
const cim = yield this.recalculateStablecoinCIM(debtInfo);
|
|
695
695
|
if (!cim)
|
|
696
696
|
throw new Error("unable to retrieve account debt");
|
|
@@ -731,7 +731,7 @@ class CDPModule extends base_1.default {
|
|
|
731
731
|
return number_1.BN_ZERO;
|
|
732
732
|
}
|
|
733
733
|
const diffSeconds = new bignumber_js_1.BigNumber(diffMs).shiftedBy(-3).dp(0, bignumber_js_1.BigNumber.ROUND_CEIL);
|
|
734
|
-
const secondsAYear =
|
|
734
|
+
const secondsAYear = number_1.bnOrZero(31536000);
|
|
735
735
|
const numPeriods = secondsAYear.div(diffSeconds).dp(18);
|
|
736
736
|
return apy.div(numPeriods).dp(18); // carbon backend sdk.dec max 18 dp
|
|
737
737
|
}
|
|
@@ -755,8 +755,8 @@ class CDPModule extends base_1.default {
|
|
|
755
755
|
throw new Error("unable to retrieve cdp params for " + denom);
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
|
-
const interestFeeRate =
|
|
759
|
-
const utilizationRate =
|
|
758
|
+
const interestFeeRate = number_1.bnOrZero(params.interestFee).div(number_1.BN_10000);
|
|
759
|
+
const utilizationRate = number_1.bnOrZero(debtInfo.utilizationRate).shiftedBy(-18);
|
|
760
760
|
return borrowInterest.times(utilizationRate).times(number_1.BN_ONE.minus(interestFeeRate));
|
|
761
761
|
});
|
|
762
762
|
}
|
|
@@ -771,7 +771,7 @@ class CDPModule extends base_1.default {
|
|
|
771
771
|
return { cim: number_1.BN_ZERO, interest: number_1.BN_ZERO };
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
|
-
const cim =
|
|
774
|
+
const cim = number_1.bnOrZero(debtInfo.cumulativeInterestMultiplier);
|
|
775
775
|
const apy = yield this.calculateAPY(denom, debtInfo);
|
|
776
776
|
const newInterest = CDPModule.calculateInterestForTimePeriod(apy, (_a = debtInfo.lastUpdatedTime) !== null && _a !== void 0 ? _a : new Date(0), new Date());
|
|
777
777
|
const newCIM = cim.times(newInterest.plus(1));
|
|
@@ -790,8 +790,8 @@ class CDPModule extends base_1.default {
|
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
792
|
const paramsResponse = yield sdk.query.cdp.Params(codec_1.QueryCdpParamsRequest.fromPartial({}));
|
|
793
|
-
const cim =
|
|
794
|
-
const apy =
|
|
793
|
+
const cim = number_1.bnOrZero(debtInfo.cumulativeInterestMultiplier);
|
|
794
|
+
const apy = number_1.bnOrZero((_a = paramsResponse.params) === null || _a === void 0 ? void 0 : _a.stablecoinInterestRate);
|
|
795
795
|
if (!apy) {
|
|
796
796
|
return number_1.BN_ZERO;
|
|
797
797
|
}
|
|
@@ -817,7 +817,7 @@ class CDPModule extends base_1.default {
|
|
|
817
817
|
const availableBorrowsUsd = accountData.AvailableBorrowsUsd.minus(accountData.TotalDebtsUsd);
|
|
818
818
|
const unlockableUsd = availableBorrowsUsd.multipliedBy(number_1.BN_10000).div(unlockRatio);
|
|
819
819
|
const tokenPrice = yield sdk.query.pricing.TokenPrice({ denom });
|
|
820
|
-
const tokenTwap =
|
|
820
|
+
const tokenTwap = number_1.bnOrZero((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap);
|
|
821
821
|
if (tokenTwap.isZero())
|
|
822
822
|
throw new Error("unable to retrieve token price for " + denom);
|
|
823
823
|
const tokenAmt = unlockableUsd.div(tokenTwap.shiftedBy(-18)).shiftedBy(tokenDecimals);
|
|
@@ -828,7 +828,7 @@ class CDPModule extends base_1.default {
|
|
|
828
828
|
address: account,
|
|
829
829
|
cdpDenom: cdpDenom,
|
|
830
830
|
});
|
|
831
|
-
const lockedAmount =
|
|
831
|
+
const lockedAmount = number_1.bnOrZero((_e = (_d = accountCollateral.collateral) === null || _d === void 0 ? void 0 : _d.collateralAmount) !== null && _e !== void 0 ? _e : "0");
|
|
832
832
|
return lockedAmount.lt(cdpTokenAmt) ? lockedAmount : cdpTokenAmt;
|
|
833
833
|
});
|
|
834
834
|
}
|
|
@@ -846,7 +846,7 @@ class CDPModule extends base_1.default {
|
|
|
846
846
|
const denom = this.getUnderlyingDenom(cdpDenom);
|
|
847
847
|
const cdpToActualRatio = (_a = (yield this.getCdpToActualRatio(cdpDenom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
848
848
|
const tokenPrice = yield sdk.query.pricing.TokenPrice({ denom: denom });
|
|
849
|
-
const tokenTwap =
|
|
849
|
+
const tokenTwap = number_1.bnOrZero((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap).shiftedBy(-18);
|
|
850
850
|
return tokenTwap.multipliedBy(cdpToActualRatio);
|
|
851
851
|
});
|
|
852
852
|
}
|
|
@@ -867,26 +867,26 @@ class CDPModule extends base_1.default {
|
|
|
867
867
|
});
|
|
868
868
|
if (!asset.assetParams)
|
|
869
869
|
throw new Error("unable to retrieve asset param for " + cdpActualDenom);
|
|
870
|
-
const bonus =
|
|
870
|
+
const bonus = number_1.bnOrZero(asset.assetParams.liquidationDiscount).div(number_1.BN_10000);
|
|
871
871
|
const cdpTokenPrice = yield this.getCdpTokenPrice(cdpDenom);
|
|
872
872
|
const cdpTokenDiscountedPrice = cdpTokenPrice.multipliedBy(number_1.BN_ONE.minus(bonus));
|
|
873
873
|
// get close factor
|
|
874
874
|
const debtorAccountData = yield sdk.query.cdp.AccountData({
|
|
875
875
|
address: debtor,
|
|
876
876
|
});
|
|
877
|
-
const debtorTotalCollateralVal =
|
|
878
|
-
const debtorTotalDebtVal =
|
|
879
|
-
const currentLiqThreshold =
|
|
877
|
+
const debtorTotalCollateralVal = number_1.bnOrZero(debtorAccountData.totalCollateralsUsd);
|
|
878
|
+
const debtorTotalDebtVal = number_1.bnOrZero(debtorAccountData.totalDebtsUsd);
|
|
879
|
+
const currentLiqThreshold = number_1.bnOrZero(debtorAccountData.currLiquidationThreshold);
|
|
880
880
|
const params = yield sdk.query.cdp.Params({});
|
|
881
881
|
if (!params.params) {
|
|
882
882
|
throw new Error("unable to retrieve cdp params");
|
|
883
883
|
}
|
|
884
|
-
const smallLiqSize =
|
|
885
|
-
const minCloseFactor =
|
|
886
|
-
const completeLiqThreshold =
|
|
884
|
+
const smallLiqSize = number_1.bnOrZero(params.params.smallLiquidationSize);
|
|
885
|
+
const minCloseFactor = number_1.bnOrZero(params.params.minimumCloseFactor);
|
|
886
|
+
const completeLiqThreshold = number_1.bnOrZero(params.params.completeLiquidationThreshold);
|
|
887
887
|
const closeFactor = this.computeCloseFactor(debtorTotalDebtVal, debtorTotalCollateralVal, currentLiqThreshold, smallLiqSize, minCloseFactor, completeLiqThreshold);
|
|
888
888
|
// get max repayable amount given the debtor's debt and how much liquidator wants to repay
|
|
889
|
-
const debtDecimals =
|
|
889
|
+
const debtDecimals = number_1.bnOrZero(yield sdk.getTokenClient().getDecimals(debtDenom));
|
|
890
890
|
const maxRepayableValue = debtorTotalDebtVal.multipliedBy(closeFactor);
|
|
891
891
|
const maxRepayableAmt = maxRepayableValue.shiftedBy(debtDecimals.toNumber());
|
|
892
892
|
if (debtRepaymentAmount.isGreaterThan(maxRepayableAmt)) {
|
|
@@ -894,7 +894,7 @@ class CDPModule extends base_1.default {
|
|
|
894
894
|
}
|
|
895
895
|
// calculate collateral amount that can be obtained given that debt amount and debtor's collateral balance
|
|
896
896
|
// AND, recalculate debt repay amount if needed
|
|
897
|
-
const cdpTokenDecimals =
|
|
897
|
+
const cdpTokenDecimals = number_1.bnOrZero(yield sdk.getTokenClient().getDecimals(cdpActualDenom));
|
|
898
898
|
let collateralAmtToLiquidate = this.calculateCollateralRequiredForDebt(number_1.BN_ONE, // assumes USC is $1
|
|
899
899
|
cdpTokenDiscountedPrice, debtRepaymentAmount, cdpTokenDecimals, debtDecimals);
|
|
900
900
|
const debtorAccountCollateral = yield sdk.query.cdp.AccountCollateral({
|
|
@@ -966,11 +966,11 @@ class CDPModule extends base_1.default {
|
|
|
966
966
|
}
|
|
967
967
|
exports.CDPModule = CDPModule;
|
|
968
968
|
CDPModule.calculateInterestAPY = (debtInfo, rateStrategy) => {
|
|
969
|
-
const utilizationRate =
|
|
970
|
-
const optimalUsage =
|
|
971
|
-
const variableRate1 =
|
|
972
|
-
const variableRate2 =
|
|
973
|
-
const baseVariableBorrowRate =
|
|
969
|
+
const utilizationRate = number_1.bnOrZero(debtInfo.utilizationRate).shiftedBy(-18);
|
|
970
|
+
const optimalUsage = number_1.bnOrZero(rateStrategy.optimalUsage).shiftedBy(-4);
|
|
971
|
+
const variableRate1 = number_1.bnOrZero(rateStrategy.variableRateSlope1).shiftedBy(-4);
|
|
972
|
+
const variableRate2 = number_1.bnOrZero(rateStrategy.variableRateSlope2).shiftedBy(-4);
|
|
973
|
+
const baseVariableBorrowRate = number_1.bnOrZero(rateStrategy.baseVariableBorrowRate).shiftedBy(-4);
|
|
974
974
|
if (utilizationRate.lte(optimalUsage)) {
|
|
975
975
|
const vRate = utilizationRate.times(variableRate1).div(optimalUsage).dp(4, bignumber_js_1.BigNumber.ROUND_CEIL);
|
|
976
976
|
return vRate.plus(baseVariableBorrowRate);
|
package/lib/modules/cosmwasm.js
CHANGED
|
@@ -27,7 +27,7 @@ class CosmWasmModule extends base_1.default {
|
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
const tmClient = util_1.GenericUtils.modifyTmClient(yield tendermint_rpc_1.Tendermint34Client.connect(tmRpcUrl));
|
|
29
29
|
const baseClient = new stargate_1.QueryClient(tmClient);
|
|
30
|
-
const rpcClient =
|
|
30
|
+
const rpcClient = stargate_1.createProtobufRpcClient(baseClient);
|
|
31
31
|
const cosmWasmClient = new query_1.QueryClientImpl(rpcClient);
|
|
32
32
|
return new CosmWasmModule(cosmWasmClient, sdkProvider);
|
|
33
33
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Any } from "../codec";
|
|
2
|
+
import { AccessListTx, DynamicFeeTx, LegacyTx } from "../codec/ethermint/evm/v1/tx";
|
|
3
|
+
import { CarbonTx } from "../util";
|
|
4
|
+
import { ethers } from "ethers";
|
|
5
|
+
import BaseModule from "./base";
|
|
6
|
+
export declare type TxData = LegacyTx | AccessListTx | DynamicFeeTx;
|
|
7
|
+
export declare class EvmModule extends BaseModule {
|
|
8
|
+
sendEvmTx(req: ethers.providers.TransactionRequest, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
9
|
+
updateParams(p: EvmModule.UpdateParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
10
|
+
}
|
|
11
|
+
export declare function constructTxDataAny(req: ethers.providers.TransactionRequest): Any;
|
|
12
|
+
export declare namespace EvmModule {
|
|
13
|
+
interface UpdateParams {
|
|
14
|
+
creator: string;
|
|
15
|
+
params: Params;
|
|
16
|
+
chainConfig: ChainConfig;
|
|
17
|
+
}
|
|
18
|
+
interface Params {
|
|
19
|
+
evmDenom: string;
|
|
20
|
+
enableCreate: boolean;
|
|
21
|
+
enableCall: boolean;
|
|
22
|
+
extraEIPs: Array<number>;
|
|
23
|
+
allowUnprotectedTxs: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface ChainConfig {
|
|
26
|
+
homesteadBlock: number;
|
|
27
|
+
daoForkBlock: number;
|
|
28
|
+
daoForkSupport: boolean;
|
|
29
|
+
eip150Block: number;
|
|
30
|
+
eip150Hash: string;
|
|
31
|
+
eip155Block: number;
|
|
32
|
+
eip158Block: number;
|
|
33
|
+
byzantiumBlock: number;
|
|
34
|
+
constantinopleBlock: number;
|
|
35
|
+
petersburgBlock: number;
|
|
36
|
+
istanbulBlock: number;
|
|
37
|
+
muirGlacierBlock: number;
|
|
38
|
+
berlinBlock: number;
|
|
39
|
+
londonBlock: number;
|
|
40
|
+
arrowGlacierBlock: number;
|
|
41
|
+
grayGlacierBlock: number;
|
|
42
|
+
mergeNetsplitBlock: number;
|
|
43
|
+
shanghaiBlock: number;
|
|
44
|
+
cancunBlock: number;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.constructTxDataAny = exports.EvmModule = void 0;
|
|
16
|
+
const codec_1 = require("../codec");
|
|
17
|
+
const evm_1 = require("../codec/ethermint/evm/v1/evm");
|
|
18
|
+
const tx_1 = require("../codec/ethermint/evm/v1/tx");
|
|
19
|
+
const util_1 = require("../util");
|
|
20
|
+
const utils_1 = require("ethers/lib/utils");
|
|
21
|
+
const base_1 = __importDefault(require("./base"));
|
|
22
|
+
const tx_2 = require("../codec/ethermint/evm/v1/tx");
|
|
23
|
+
class EvmModule extends base_1.default {
|
|
24
|
+
sendEvmTx(req, opts) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const wallet = this.getWallet();
|
|
27
|
+
const value = tx_1.MsgEthereumTx.fromPartial({
|
|
28
|
+
data: constructTxDataAny(req)
|
|
29
|
+
});
|
|
30
|
+
return yield wallet.sendTx({
|
|
31
|
+
typeUrl: util_1.CarbonTx.Types.MsgEthereumTx,
|
|
32
|
+
value,
|
|
33
|
+
}, opts);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
updateParams(p, opts) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const wallet = this.getWallet();
|
|
39
|
+
const value = tx_1.MsgUpdateParams.fromPartial({
|
|
40
|
+
authority: p.creator,
|
|
41
|
+
params: evm_1.Params.fromPartial({
|
|
42
|
+
evmDenom: p.params.evmDenom,
|
|
43
|
+
enableCreate: p.params.enableCreate,
|
|
44
|
+
enableCall: p.params.enableCall,
|
|
45
|
+
extraEips: p.params.extraEIPs,
|
|
46
|
+
allowUnprotectedTxs: p.params.allowUnprotectedTxs,
|
|
47
|
+
chainConfig: evm_1.ChainConfig.fromPartial({
|
|
48
|
+
homesteadBlock: p.chainConfig.homesteadBlock.toString(10),
|
|
49
|
+
daoForkBlock: p.chainConfig.daoForkBlock.toString(10),
|
|
50
|
+
daoForkSupport: p.chainConfig.daoForkSupport,
|
|
51
|
+
eip150Block: p.chainConfig.eip150Block.toString(10),
|
|
52
|
+
eip150Hash: p.chainConfig.eip150Hash,
|
|
53
|
+
eip155Block: p.chainConfig.eip155Block.toString(10),
|
|
54
|
+
eip158Block: p.chainConfig.eip158Block.toString(10),
|
|
55
|
+
byzantiumBlock: p.chainConfig.byzantiumBlock.toString(10),
|
|
56
|
+
constantinopleBlock: p.chainConfig.constantinopleBlock.toString(10),
|
|
57
|
+
petersburgBlock: p.chainConfig.petersburgBlock.toString(10),
|
|
58
|
+
istanbulBlock: p.chainConfig.istanbulBlock.toString(10),
|
|
59
|
+
muirGlacierBlock: p.chainConfig.muirGlacierBlock.toString(10),
|
|
60
|
+
berlinBlock: p.chainConfig.berlinBlock.toString(10),
|
|
61
|
+
londonBlock: p.chainConfig.londonBlock.toString(10),
|
|
62
|
+
arrowGlacierBlock: p.chainConfig.arrowGlacierBlock.toString(10),
|
|
63
|
+
grayGlacierBlock: p.chainConfig.grayGlacierBlock.toString(10),
|
|
64
|
+
mergeNetsplitBlock: p.chainConfig.mergeNetsplitBlock.toString(10),
|
|
65
|
+
shanghaiBlock: p.chainConfig.shanghaiBlock.toString(10),
|
|
66
|
+
cancunBlock: p.chainConfig.cancunBlock.toString(10)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
return yield wallet.sendTx({
|
|
71
|
+
typeUrl: util_1.CarbonTx.Types.MsgEvmUpdateParams,
|
|
72
|
+
value,
|
|
73
|
+
}, opts);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.EvmModule = EvmModule;
|
|
78
|
+
// Referenced from ethermint v0.21.0 Switcheo/ethermint/x/evm/types/msg.go
|
|
79
|
+
function constructTxDataAny(req) {
|
|
80
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
81
|
+
const accessList = (req === null || req === void 0 ? void 0 : req.accessList) && req.accessList.length > 0;
|
|
82
|
+
let txData = tx_1.LegacyTx.fromPartial({});
|
|
83
|
+
let txType = "";
|
|
84
|
+
if (!accessList) {
|
|
85
|
+
txData = tx_1.LegacyTx.fromPartial({
|
|
86
|
+
nonce: (_b = (_a = req.nonce) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "0",
|
|
87
|
+
to: req.to,
|
|
88
|
+
value: (_d = (_c = req.value) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0",
|
|
89
|
+
gas: (_f = (_e = req.gasLimit) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : "0",
|
|
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
|
|
92
|
+
});
|
|
93
|
+
txType = 'LegacyTx';
|
|
94
|
+
}
|
|
95
|
+
if (accessList && (req === null || req === void 0 ? void 0 : req.maxPriorityFeePerGas) && (req === null || req === void 0 ? void 0 : req.maxFeePerGas)) {
|
|
96
|
+
txData = tx_1.DynamicFeeTx.fromPartial({
|
|
97
|
+
chainId: (_k = (_j = req.chainId) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : "0",
|
|
98
|
+
nonce: (_m = (_l = req.nonce) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : "0",
|
|
99
|
+
to: req.to,
|
|
100
|
+
value: (_p = (_o = req.value) === null || _o === void 0 ? void 0 : _o.toString()) !== null && _p !== void 0 ? _p : "0",
|
|
101
|
+
gas: (_r = (_q = req.gasLimit) === null || _q === void 0 ? void 0 : _q.toString()) !== null && _r !== void 0 ? _r : "0",
|
|
102
|
+
gasTipCap: (_t = (_s = req.maxPriorityFeePerGas) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : "0",
|
|
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
|
|
106
|
+
});
|
|
107
|
+
txType = 'DynamicFeeTx';
|
|
108
|
+
}
|
|
109
|
+
if (accessList) {
|
|
110
|
+
txData = tx_1.AccessListTx.fromPartial({
|
|
111
|
+
chainId: (_x = (_w = req.chainId) === null || _w === void 0 ? void 0 : _w.toString()) !== null && _x !== void 0 ? _x : "0",
|
|
112
|
+
nonce: (_z = (_y = req.nonce) === null || _y === void 0 ? void 0 : _y.toString()) !== null && _z !== void 0 ? _z : "0",
|
|
113
|
+
to: req.to,
|
|
114
|
+
value: (_1 = (_0 = req.value) === null || _0 === void 0 ? void 0 : _0.toString()) !== null && _1 !== void 0 ? _1 : "0",
|
|
115
|
+
gas: parseInt((_3 = (_2 = req.gasLimit) === null || _2 === void 0 ? void 0 : _2.toString()) !== null && _3 !== void 0 ? _3 : "0", 10),
|
|
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
|
|
119
|
+
});
|
|
120
|
+
txType = 'AccessListTx';
|
|
121
|
+
}
|
|
122
|
+
return codec_1.registry.encodeAsAny({
|
|
123
|
+
typeUrl: `/${tx_2.protobufPackage}.${txType}`,
|
|
124
|
+
value: txData
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
exports.constructTxDataAny = constructTxDataAny;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CarbonTx } from "../util";
|
|
2
|
+
import BaseModule from "./base";
|
|
3
|
+
export declare class EvmMergeModule extends BaseModule {
|
|
4
|
+
mergeAccount(params: EvmMergeModule.MergeAccountParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace EvmMergeModule {
|
|
7
|
+
interface MergeAccountParams {
|
|
8
|
+
creator: string;
|
|
9
|
+
pubKey: string;
|
|
10
|
+
pubKeySig: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EvmMergeModule = void 0;
|
|
16
|
+
const codec_1 = require("../codec");
|
|
17
|
+
const util_1 = require("../util");
|
|
18
|
+
const base_1 = __importDefault(require("./base"));
|
|
19
|
+
class EvmMergeModule extends base_1.default {
|
|
20
|
+
mergeAccount(params, opts) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const wallet = this.getWallet();
|
|
23
|
+
const value = codec_1.MsgMergeAccount.fromPartial({
|
|
24
|
+
creator: params.creator,
|
|
25
|
+
pubKey: params.pubKey,
|
|
26
|
+
pubKeySig: params.pubKeySig
|
|
27
|
+
});
|
|
28
|
+
return yield wallet.sendTx({
|
|
29
|
+
typeUrl: util_1.CarbonTx.Types.MsgEvmUpdateParams,
|
|
30
|
+
value,
|
|
31
|
+
}, opts);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.EvmMergeModule = EvmMergeModule;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CarbonTx } from "../util";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import BaseModule from "./base";
|
|
4
|
+
export declare class FeemarketModule extends BaseModule {
|
|
5
|
+
updateParams(params: FeemarketModule.UpdateParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace FeemarketModule {
|
|
8
|
+
interface UpdateParams {
|
|
9
|
+
creator: string;
|
|
10
|
+
noBaseFee: boolean;
|
|
11
|
+
baseFeeChangeDenominator: number;
|
|
12
|
+
elasticityMulitplier: number;
|
|
13
|
+
enableHeight: number;
|
|
14
|
+
baseFee: BigNumber;
|
|
15
|
+
minGasPrice: BigNumber;
|
|
16
|
+
minGasMulitplier: number;
|
|
17
|
+
gasLimitPerBlock: number;
|
|
18
|
+
maxBaseFee: BigNumber;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FeemarketModule = void 0;
|
|
16
|
+
const feemarket_1 = require("../codec/ethermint/feemarket/v1/feemarket");
|
|
17
|
+
const tx_1 = require("../codec/ethermint/feemarket/v1/tx");
|
|
18
|
+
const util_1 = require("../util");
|
|
19
|
+
const base_1 = __importDefault(require("./base"));
|
|
20
|
+
class FeemarketModule extends base_1.default {
|
|
21
|
+
updateParams(params, opts) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const wallet = this.getWallet();
|
|
24
|
+
const value = tx_1.MsgUpdateParams.fromPartial({
|
|
25
|
+
authority: params.creator,
|
|
26
|
+
params: feemarket_1.Params.fromPartial({
|
|
27
|
+
noBaseFee: params.noBaseFee,
|
|
28
|
+
baseFeeChangeDenominator: params.baseFeeChangeDenominator,
|
|
29
|
+
elasticityMultiplier: params.elasticityMulitplier,
|
|
30
|
+
enableHeight: params.enableHeight,
|
|
31
|
+
baseFee: params.baseFee.toString(10),
|
|
32
|
+
minGasPrice: params.minGasPrice.toString(10),
|
|
33
|
+
minGasMultiplier: params.minGasMulitplier.toString(10),
|
|
34
|
+
gasLimitPerBlock: params.gasLimitPerBlock.toString(10),
|
|
35
|
+
maxBaseFee: params.maxBaseFee.toString(10)
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
return yield wallet.sendTx({
|
|
39
|
+
typeUrl: util_1.CarbonTx.Types.MsgUpdateParams,
|
|
40
|
+
value,
|
|
41
|
+
}, opts);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.FeemarketModule = FeemarketModule;
|