carbon-js-sdk 0.4.20 → 0.4.21
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/clients/CarbonQueryClient.js +2 -2
- package/lib/clients/ETHClient.js +15 -15
- package/lib/clients/HydrogenClient.js +1 -1
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +3 -3
- package/lib/clients/ZILClient.js +17 -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/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/codec/market/fee.d.ts +123 -0
- package/lib/codec/market/fee.js +334 -0
- package/lib/codec/perpsliquidity/event.d.ts +102 -0
- package/lib/codec/perpsliquidity/event.js +581 -0
- package/lib/codec/perpsliquidity/genesis.d.ts +35 -0
- package/lib/codec/perpsliquidity/genesis.js +162 -0
- package/lib/codec/perpsliquidity/params.d.ts +24 -0
- package/lib/codec/perpsliquidity/params.js +103 -0
- package/lib/codec/perpsliquidity/pool.d.ts +137 -0
- package/lib/codec/perpsliquidity/pool.js +747 -0
- package/lib/codec/perpsliquidity/query.d.ts +167 -0
- package/lib/codec/perpsliquidity/query.js +719 -0
- package/lib/codec/perpsliquidity/tx.d.ts +199 -0
- package/lib/codec/perpsliquidity/tx.js +940 -0
- package/lib/constant/eip712.d.ts +46 -0
- package/lib/constant/eip712.js +106 -0
- package/lib/constant/generic.js +1 -1
- package/lib/constant/network.js +2 -2
- 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/liquiditypool.js +1 -1
- package/lib/modules/vault.d.ts +44 -0
- package/lib/modules/vault.js +95 -0
- 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.d.ts +4 -0
- package/lib/provider/amino/types/evm.js +40 -0
- package/lib/provider/amino/types/evmmerge.d.ts +4 -0
- package/lib/provider/amino/types/evmmerge.js +34 -0
- package/lib/provider/amino/types/feemarket.d.ts +4 -0
- package/lib/provider/amino/types/feemarket.js +34 -0
- 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 +2 -2
- 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/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +1 -1
- package/lib/provider/metamask/legacy-accounts.d.ts +6 -0
- package/lib/provider/metamask/legacy-accounts.js +44 -0
- 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/eip712.d.ts +10 -0
- package/lib/util/eip712.js +195 -0
- package/lib/util/ethermint.d.ts +8 -0
- package/lib/util/ethermint.js +68 -0
- package/lib/util/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/legacyEIP712.d.ts +20 -0
- package/lib/util/legacyEIP712.js +98 -0
- 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/clients/EvmIbcClient.d.ts +0 -86
- package/lib/clients/EvmIbcClient.js +0 -90
- package/lib/codec/broker/incoming_pool_swap.d.ts +0 -23
- package/lib/codec/broker/incoming_pool_swap.js +0 -136
- package/lib/util/ethermint/evm-ibc.d.ts +0 -97
- package/lib/util/ethermint/evm-ibc.js +0 -134
- package/lib/util/ethermint/index.d.ts +0 -3
- package/lib/util/ethermint/index.js +0 -12
- package/lib/util/ethermint/keys.d.ts +0 -39
- package/lib/util/ethermint/keys.js +0 -138
- package/lib/util/ethermint/web3.d.ts +0 -36
- package/lib/util/ethermint/web3.js +0 -124
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const LEGACY_DEFAULT_EIP712_TYPES: {
|
|
2
|
+
EIP712Domain: {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
}[];
|
|
6
|
+
Tx: {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
}[];
|
|
10
|
+
Fee: {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
}[];
|
|
14
|
+
Coin: {
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}[];
|
|
18
|
+
Msg: {
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export declare const DEFAULT_EIP712_TYPES: {
|
|
24
|
+
Coin: {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
EIP712Domain: {
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
Fee: {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
}[];
|
|
36
|
+
Tx: {
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
export declare const DEFAULT_CARBON_DOMAIN_FIELDS: {
|
|
42
|
+
name: string;
|
|
43
|
+
version: string;
|
|
44
|
+
verifyingContract: string;
|
|
45
|
+
salt: string;
|
|
46
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_CARBON_DOMAIN_FIELDS = exports.DEFAULT_EIP712_TYPES = exports.LEGACY_DEFAULT_EIP712_TYPES = void 0;
|
|
4
|
+
exports.LEGACY_DEFAULT_EIP712_TYPES = {
|
|
5
|
+
EIP712Domain: [
|
|
6
|
+
{ name: 'name', type: 'string' },
|
|
7
|
+
{ name: 'version', type: 'string' },
|
|
8
|
+
{ name: 'chainId', type: 'uint256' },
|
|
9
|
+
{ name: 'verifyingContract', type: 'string' },
|
|
10
|
+
{ name: 'salt', type: 'string' },
|
|
11
|
+
],
|
|
12
|
+
Tx: [
|
|
13
|
+
{ name: 'account_number', type: 'string' },
|
|
14
|
+
{ name: 'chain_id', type: 'string' },
|
|
15
|
+
{ name: 'fee', type: 'Fee' },
|
|
16
|
+
{ name: 'memo', type: 'string' },
|
|
17
|
+
{ name: 'msgs', type: 'Msg[]' },
|
|
18
|
+
{ name: 'sequence', type: 'string' },
|
|
19
|
+
],
|
|
20
|
+
Fee: [
|
|
21
|
+
{ name: 'feePayer', type: 'string' },
|
|
22
|
+
{ name: 'amount', type: 'Coin[]' },
|
|
23
|
+
{ name: 'gas', type: 'string' },
|
|
24
|
+
],
|
|
25
|
+
Coin: [
|
|
26
|
+
{ name: 'denom', type: 'string' },
|
|
27
|
+
{ name: 'amount', type: 'string' },
|
|
28
|
+
],
|
|
29
|
+
Msg: [
|
|
30
|
+
{ name: 'type', type: 'string' },
|
|
31
|
+
{ name: 'value', type: 'MsgValue' },
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
exports.DEFAULT_EIP712_TYPES = {
|
|
35
|
+
Coin: [
|
|
36
|
+
{
|
|
37
|
+
name: 'denom',
|
|
38
|
+
type: 'string'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'amount',
|
|
42
|
+
type: 'string'
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
EIP712Domain: [
|
|
46
|
+
{
|
|
47
|
+
name: 'name',
|
|
48
|
+
type: 'string'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'version',
|
|
52
|
+
type: 'string'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'chainId',
|
|
56
|
+
type: 'uint256'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'verifyingContract',
|
|
60
|
+
type: 'string'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'salt',
|
|
64
|
+
type: 'string'
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
Fee: [
|
|
68
|
+
{
|
|
69
|
+
name: 'amount',
|
|
70
|
+
type: 'Coin[]'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'gas',
|
|
74
|
+
type: 'string'
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
Tx: [
|
|
78
|
+
{
|
|
79
|
+
name: 'account_number',
|
|
80
|
+
type: 'string'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'chain_id',
|
|
84
|
+
type: 'string'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'fee',
|
|
88
|
+
type: 'Fee'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'memo',
|
|
92
|
+
type: 'string'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'sequence',
|
|
96
|
+
type: 'string'
|
|
97
|
+
},
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
// Note that the chainId field is delibrately omitted because it is dynamic
|
|
101
|
+
exports.DEFAULT_CARBON_DOMAIN_FIELDS = {
|
|
102
|
+
name: 'Carbon',
|
|
103
|
+
version: '1.0.0',
|
|
104
|
+
verifyingContract: 'cosmos',
|
|
105
|
+
salt: '1',
|
|
106
|
+
};
|
package/lib/constant/generic.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.DEFAULT_FEE_DENOM = "swth";
|
|
|
12
12
|
exports.DEFAULT_GAS_PRICE = new bignumber_js_1.default(10);
|
|
13
13
|
exports.DEFAULT_GAS = new bignumber_js_1.default(10000000);
|
|
14
14
|
exports.DEFAULT_FEE = {
|
|
15
|
-
amount:
|
|
15
|
+
amount: proto_signing_1.coins(exports.DEFAULT_GAS_PRICE.times(exports.DEFAULT_GAS).dp(0).toString(), "swth"),
|
|
16
16
|
gas: exports.DEFAULT_GAS.toString(10),
|
|
17
17
|
};
|
|
18
18
|
exports.CARBON_GAS_PRICE = {
|
package/lib/constant/network.js
CHANGED
|
@@ -183,7 +183,7 @@ exports.NetworkConfigs = {
|
|
|
183
183
|
feeURL: `https://dev-fees.carbon.network`,
|
|
184
184
|
feeAddress: "989761fb0c0eb0c05605e849cae77d239f98ac7f",
|
|
185
185
|
eth: {
|
|
186
|
-
rpcURL: "https://eth-
|
|
186
|
+
rpcURL: "https://eth-goerli.g.alchemy.com/v2/OTTRiEhTje49mmrrm4WbuPbZmuZMivEu",
|
|
187
187
|
wsURL: "",
|
|
188
188
|
payerURL: `https://dev-payer.carbon.network`,
|
|
189
189
|
lockProxyAddr: "0x7f7317167e90afa38972e46b031bb4da0b1f6f73",
|
|
@@ -258,7 +258,7 @@ exports.NetworkConfigs = {
|
|
|
258
258
|
feeURL: `http://localhost:9001`,
|
|
259
259
|
feeAddress: "989761fb0c0eb0c05605e849cae77d239f98ac7f",
|
|
260
260
|
eth: {
|
|
261
|
-
rpcURL: "https://
|
|
261
|
+
rpcURL: "https://eth-goerli.g.alchemy.com/v2/OTTRiEhTje49mmrrm4WbuPbZmuZMivEu",
|
|
262
262
|
wsURL: "wss://ropsten.dagger.matic.network",
|
|
263
263
|
payerURL: `http://localhost:8001`,
|
|
264
264
|
bridgeEntranceAddr: "",
|
package/lib/modules/cdp.js
CHANGED
|
@@ -513,7 +513,7 @@ class CDPModule extends base_1.default {
|
|
|
513
513
|
let availableBorrowsUsd = number_1.BN_ZERO;
|
|
514
514
|
let currLiquidationThreshold = number_1.BN_ZERO;
|
|
515
515
|
for (let i = 0; i < collaterals.length; i++) {
|
|
516
|
-
const amount =
|
|
516
|
+
const amount = number_1.bnOrZero(collaterals[i].collateralAmount);
|
|
517
517
|
if (amount.isZero()) {
|
|
518
518
|
continue; // no collateral for denom
|
|
519
519
|
}
|
|
@@ -530,9 +530,9 @@ class CDPModule extends base_1.default {
|
|
|
530
530
|
if (!assetParam) {
|
|
531
531
|
continue;
|
|
532
532
|
}
|
|
533
|
-
const ltv =
|
|
533
|
+
const ltv = number_1.bnOrZero(assetParam.loanToValue).div(number_1.BN_10000);
|
|
534
534
|
const availableBorrowUsd = collateralUsdVal.times(ltv);
|
|
535
|
-
const liquidationThreshold =
|
|
535
|
+
const liquidationThreshold = number_1.bnOrZero(assetParam.liquidationThreshold).div(number_1.BN_10000);
|
|
536
536
|
const liquidationThresholdVal = collateralUsdVal.times(liquidationThreshold);
|
|
537
537
|
totalCollateralsUsd = totalCollateralsUsd.plus(collateralUsdVal);
|
|
538
538
|
availableBorrowsUsd = availableBorrowsUsd.plus(availableBorrowUsd);
|
|
@@ -543,7 +543,7 @@ class CDPModule extends base_1.default {
|
|
|
543
543
|
const debts = debtsRsp.debts;
|
|
544
544
|
let totalDebtsUsd = number_1.BN_ZERO;
|
|
545
545
|
for (let i = 0; i < debts.length; i++) {
|
|
546
|
-
const amount =
|
|
546
|
+
const amount = number_1.bnOrZero(debts[i].principalDebt);
|
|
547
547
|
const denom = debts[i].denom;
|
|
548
548
|
if (amount.isZero()) {
|
|
549
549
|
continue;
|
|
@@ -565,7 +565,7 @@ class CDPModule extends base_1.default {
|
|
|
565
565
|
if (stablecoinDebtInfo) {
|
|
566
566
|
const accountStablecoin = yield sdk.query.cdp.AccountStablecoin({ address: account });
|
|
567
567
|
const stablecoinDecimals = (_a = (yield this.sdkProvider.getTokenClient().getDecimals(stablecoinDebtInfo.denom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
568
|
-
const stablecoinDebtAmount =
|
|
568
|
+
const stablecoinDebtAmount = number_1.bnOrZero(accountStablecoin.principalDebt).plus(number_1.bnOrZero(accountStablecoin.interestDebt));
|
|
569
569
|
stablecoinDebtUsd = stablecoinDebtAmount.shiftedBy(-stablecoinDecimals);
|
|
570
570
|
totalDebtsUsd = totalDebtsUsd.plus(stablecoinDebtUsd);
|
|
571
571
|
}
|
|
@@ -586,7 +586,7 @@ class CDPModule extends base_1.default {
|
|
|
586
586
|
const sdk = this.sdkProvider;
|
|
587
587
|
const cdpAddress = this.getCdpModuleAddress();
|
|
588
588
|
const balanceRsp = yield sdk.query.bank.Balance(query_2.QueryBalanceRequest.fromPartial({ address: cdpAddress, denom }));
|
|
589
|
-
return
|
|
589
|
+
return number_1.bnOrZero((_a = balanceRsp.balance) === null || _a === void 0 ? void 0 : _a.amount);
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
592
|
getCdpToActualRatio(cdpDenom) {
|
|
@@ -597,13 +597,13 @@ class CDPModule extends base_1.default {
|
|
|
597
597
|
const cdpAmountRsp = supplyRsp.amount;
|
|
598
598
|
if (!cdpAmountRsp)
|
|
599
599
|
throw new Error("unable to retrieve cdp token supply");
|
|
600
|
-
const cdpAmount =
|
|
600
|
+
const cdpAmount = number_1.bnOrZero(cdpAmountRsp.amount);
|
|
601
601
|
const cdpAddress = this.getCdpModuleAddress();
|
|
602
602
|
const balanceRsp = yield sdk.query.bank.Balance(query_2.QueryBalanceRequest.fromPartial({ address: cdpAddress, denom }));
|
|
603
603
|
if (!balanceRsp.balance)
|
|
604
604
|
throw new Error("unable to retrieve cdp module balance");
|
|
605
605
|
const owedAmount = yield this.getTotalTokenDebt(denom);
|
|
606
|
-
const actualAmount =
|
|
606
|
+
const actualAmount = number_1.bnOrZero(balanceRsp.balance.amount).plus(owedAmount);
|
|
607
607
|
if (!owedAmount)
|
|
608
608
|
throw new Error("unable to retrieve total token debt");
|
|
609
609
|
return cdpAmount.div(actualAmount);
|
|
@@ -625,8 +625,8 @@ class CDPModule extends base_1.default {
|
|
|
625
625
|
const allDebts = allDebtsRes.debtInfosAll;
|
|
626
626
|
for (let i = 0; i < allDebts.length; i++) {
|
|
627
627
|
const denom = allDebts[i].denom;
|
|
628
|
-
const interest =
|
|
629
|
-
const principal =
|
|
628
|
+
const interest = number_1.bnOrZero(allDebts[i].totalAccumulatedInterest);
|
|
629
|
+
const principal = number_1.bnOrZero(allDebts[i].totalPrincipal);
|
|
630
630
|
const debtAmt = interest.plus(principal);
|
|
631
631
|
const debtUsdVal = yield this.getTokenUsdVal(denom, debtAmt);
|
|
632
632
|
if (!debtUsdVal) {
|
|
@@ -638,7 +638,7 @@ class CDPModule extends base_1.default {
|
|
|
638
638
|
const stablecoinDebtRes = yield this.sdkProvider.query.cdp.StablecoinDebt({});
|
|
639
639
|
if (stablecoinDebtRes.stablecoinDebtInfo) {
|
|
640
640
|
const debtInfo = stablecoinDebtRes.stablecoinDebtInfo;
|
|
641
|
-
const debtAmt =
|
|
641
|
+
const debtAmt = number_1.bnOrZero(debtInfo.totalPrincipal).plus(number_1.bnOrZero(debtInfo.totalAccumulatedInterest));
|
|
642
642
|
const stablecoinDecimals = (_a = (yield sdk.getTokenClient().getDecimals(debtInfo.denom))) !== null && _a !== void 0 ? _a : 0;
|
|
643
643
|
const debtUsdVal = debtAmt.shiftedBy(-stablecoinDecimals);
|
|
644
644
|
totalDebt = totalDebt.plus(debtUsdVal);
|
|
@@ -656,7 +656,7 @@ class CDPModule extends base_1.default {
|
|
|
656
656
|
if (!TokenClient_1.default.isCdpToken(balance.denom)) {
|
|
657
657
|
continue;
|
|
658
658
|
}
|
|
659
|
-
const amount =
|
|
659
|
+
const amount = number_1.bnOrZero(balance.amount);
|
|
660
660
|
const collateralUsdValue = yield this.getCdpTokenUsdVal(balance.denom, amount);
|
|
661
661
|
allCollateralsUsdValue = allCollateralsUsdValue.plus(collateralUsdValue);
|
|
662
662
|
}
|
|
@@ -680,7 +680,7 @@ class CDPModule extends base_1.default {
|
|
|
680
680
|
const priceResult = yield sdk.query.pricing.TokenPrice(codec_1.QueryTokenPriceRequest.fromPartial({ denom }));
|
|
681
681
|
if (!priceResult.tokenPrice)
|
|
682
682
|
throw new Error("unable to retrieve token price for " + denom);
|
|
683
|
-
const twap =
|
|
683
|
+
const twap = number_1.bnOrZero(priceResult.tokenPrice.twap).shiftedBy(-18);
|
|
684
684
|
return amount.multipliedBy(twap).shiftedBy(-decimals);
|
|
685
685
|
});
|
|
686
686
|
}
|
|
@@ -695,11 +695,11 @@ class CDPModule extends base_1.default {
|
|
|
695
695
|
throw new Error("unable to retrieve debt info");
|
|
696
696
|
const cimRsp = yield this.recalculateCIM(denom, debtInfo);
|
|
697
697
|
const newInterestRate = cimRsp.interest;
|
|
698
|
-
const principal =
|
|
699
|
-
const accumInterest =
|
|
698
|
+
const principal = number_1.bnOrZero(debtInfo.totalPrincipal);
|
|
699
|
+
const accumInterest = number_1.bnOrZero(debtInfo.totalAccumulatedInterest);
|
|
700
700
|
const newInterest = principal.times(newInterestRate).plus(accumInterest.times(number_1.BN_ONE.plus(newInterestRate)));
|
|
701
701
|
const cdpParamsRsp = yield this.sdkProvider.query.cdp.Params(query_1.QueryParamsRequest.fromPartial({}));
|
|
702
|
-
const interestFee =
|
|
702
|
+
const interestFee = number_1.bnOrZero((_a = cdpParamsRsp.params) === null || _a === void 0 ? void 0 : _a.interestFee);
|
|
703
703
|
const interest = newInterest.times(number_1.BN_10000.minus(interestFee)).dividedToIntegerBy(number_1.BN_10000);
|
|
704
704
|
return principal.plus(interest);
|
|
705
705
|
});
|
|
@@ -717,8 +717,8 @@ class CDPModule extends base_1.default {
|
|
|
717
717
|
const debtRes = yield sdk.query.cdp.AccountDebt({ address: account, denom: denom });
|
|
718
718
|
debt = debtRes.debt;
|
|
719
719
|
}
|
|
720
|
-
const principalAmount =
|
|
721
|
-
const initialCIM =
|
|
720
|
+
const principalAmount = number_1.bnOrZero(debt === null || debt === void 0 ? void 0 : debt.principalDebt);
|
|
721
|
+
const initialCIM = number_1.bnOrZero(debt === null || debt === void 0 ? void 0 : debt.initialCumulativeInterestMultiplier);
|
|
722
722
|
if (principalAmount.isZero() || initialCIM.isZero())
|
|
723
723
|
return number_1.BN_ZERO;
|
|
724
724
|
const cimRsp = yield this.recalculateCIM(denom, debtInfo);
|
|
@@ -744,8 +744,8 @@ class CDPModule extends base_1.default {
|
|
|
744
744
|
const debtResp = yield sdk.query.cdp.AccountStablecoin(query_1.QueryAccountStablecoinRequest.fromPartial({ address: account }));
|
|
745
745
|
debt = debtResp;
|
|
746
746
|
}
|
|
747
|
-
principalAmount =
|
|
748
|
-
const initialCIM =
|
|
747
|
+
principalAmount = number_1.bnOrZero(debt.principalDebt);
|
|
748
|
+
const initialCIM = number_1.bnOrZero(debt.initialCumulativeInterestMultiplier);
|
|
749
749
|
const cim = yield this.recalculateStablecoinCIM(debtInfo);
|
|
750
750
|
if (!cim)
|
|
751
751
|
throw new Error("unable to retrieve account debt");
|
|
@@ -786,7 +786,7 @@ class CDPModule extends base_1.default {
|
|
|
786
786
|
return number_1.BN_ZERO;
|
|
787
787
|
}
|
|
788
788
|
const diffSeconds = new bignumber_js_1.BigNumber(diffMs).shiftedBy(-3).dp(0, bignumber_js_1.BigNumber.ROUND_CEIL);
|
|
789
|
-
const secondsAYear =
|
|
789
|
+
const secondsAYear = number_1.bnOrZero(31536000);
|
|
790
790
|
const numPeriods = secondsAYear.div(diffSeconds).dp(18);
|
|
791
791
|
return apy.div(numPeriods).dp(18); // carbon backend sdk.dec max 18 dp
|
|
792
792
|
}
|
|
@@ -810,8 +810,8 @@ class CDPModule extends base_1.default {
|
|
|
810
810
|
throw new Error("unable to retrieve cdp params for " + denom);
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
const interestFeeRate =
|
|
814
|
-
const utilizationRate =
|
|
813
|
+
const interestFeeRate = number_1.bnOrZero(params.interestFee).div(number_1.BN_10000);
|
|
814
|
+
const utilizationRate = number_1.bnOrZero(debtInfo.utilizationRate).shiftedBy(-18);
|
|
815
815
|
return borrowInterest.times(utilizationRate).times(number_1.BN_ONE.minus(interestFeeRate));
|
|
816
816
|
});
|
|
817
817
|
}
|
|
@@ -826,7 +826,7 @@ class CDPModule extends base_1.default {
|
|
|
826
826
|
return { cim: number_1.BN_ZERO, interest: number_1.BN_ZERO };
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
|
-
const cim =
|
|
829
|
+
const cim = number_1.bnOrZero(debtInfo.cumulativeInterestMultiplier);
|
|
830
830
|
const apy = yield this.calculateAPY(denom, debtInfo);
|
|
831
831
|
const newInterest = CDPModule.calculateInterestForTimePeriod(apy, (_a = debtInfo.lastUpdatedTime) !== null && _a !== void 0 ? _a : new Date(0), new Date());
|
|
832
832
|
const newCIM = cim.times(newInterest.plus(1));
|
|
@@ -845,8 +845,8 @@ class CDPModule extends base_1.default {
|
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
const paramsResponse = yield sdk.query.cdp.Params(codec_1.QueryCdpParamsRequest.fromPartial({}));
|
|
848
|
-
const cim =
|
|
849
|
-
const apy =
|
|
848
|
+
const cim = number_1.bnOrZero(debtInfo.cumulativeInterestMultiplier);
|
|
849
|
+
const apy = number_1.bnOrZero((_a = paramsResponse.params) === null || _a === void 0 ? void 0 : _a.stablecoinInterestRate);
|
|
850
850
|
if (!apy) {
|
|
851
851
|
return number_1.BN_ZERO;
|
|
852
852
|
}
|
|
@@ -872,7 +872,7 @@ class CDPModule extends base_1.default {
|
|
|
872
872
|
const availableBorrowsUsd = accountData.AvailableBorrowsUsd.minus(accountData.TotalDebtsUsd);
|
|
873
873
|
const unlockableUsd = availableBorrowsUsd.multipliedBy(number_1.BN_10000).div(unlockRatio);
|
|
874
874
|
const tokenPrice = yield sdk.query.pricing.TokenPrice({ denom });
|
|
875
|
-
const tokenTwap =
|
|
875
|
+
const tokenTwap = number_1.bnOrZero((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap);
|
|
876
876
|
if (tokenTwap.isZero())
|
|
877
877
|
throw new Error("unable to retrieve token price for " + denom);
|
|
878
878
|
const tokenAmt = unlockableUsd.div(tokenTwap.shiftedBy(-18)).shiftedBy(tokenDecimals);
|
|
@@ -883,7 +883,7 @@ class CDPModule extends base_1.default {
|
|
|
883
883
|
address: account,
|
|
884
884
|
cdpDenom: cdpDenom,
|
|
885
885
|
});
|
|
886
|
-
const lockedAmount =
|
|
886
|
+
const lockedAmount = number_1.bnOrZero((_e = (_d = accountCollateral.collateral) === null || _d === void 0 ? void 0 : _d.collateralAmount) !== null && _e !== void 0 ? _e : "0");
|
|
887
887
|
return lockedAmount.lt(cdpTokenAmt) ? lockedAmount : cdpTokenAmt;
|
|
888
888
|
});
|
|
889
889
|
}
|
|
@@ -901,7 +901,7 @@ class CDPModule extends base_1.default {
|
|
|
901
901
|
const denom = this.getUnderlyingDenom(cdpDenom);
|
|
902
902
|
const cdpToActualRatio = (_a = (yield this.getCdpToActualRatio(cdpDenom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
|
|
903
903
|
const tokenPrice = yield sdk.query.pricing.TokenPrice({ denom: denom });
|
|
904
|
-
const tokenTwap =
|
|
904
|
+
const tokenTwap = number_1.bnOrZero((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap).shiftedBy(-18);
|
|
905
905
|
return tokenTwap.multipliedBy(cdpToActualRatio);
|
|
906
906
|
});
|
|
907
907
|
}
|
|
@@ -922,26 +922,26 @@ class CDPModule extends base_1.default {
|
|
|
922
922
|
});
|
|
923
923
|
if (!asset.assetParams)
|
|
924
924
|
throw new Error("unable to retrieve asset param for " + cdpActualDenom);
|
|
925
|
-
const bonus =
|
|
925
|
+
const bonus = number_1.bnOrZero(asset.assetParams.liquidationDiscount).div(number_1.BN_10000);
|
|
926
926
|
const cdpTokenPrice = yield this.getCdpTokenPrice(cdpDenom);
|
|
927
927
|
const cdpTokenDiscountedPrice = cdpTokenPrice.multipliedBy(number_1.BN_ONE.minus(bonus));
|
|
928
928
|
// get close factor
|
|
929
929
|
const debtorAccountData = yield sdk.query.cdp.AccountData({
|
|
930
930
|
address: debtor,
|
|
931
931
|
});
|
|
932
|
-
const debtorTotalCollateralVal =
|
|
933
|
-
const debtorTotalDebtVal =
|
|
934
|
-
const currentLiqThreshold =
|
|
932
|
+
const debtorTotalCollateralVal = number_1.bnOrZero(debtorAccountData.totalCollateralsUsd);
|
|
933
|
+
const debtorTotalDebtVal = number_1.bnOrZero(debtorAccountData.totalDebtsUsd);
|
|
934
|
+
const currentLiqThreshold = number_1.bnOrZero(debtorAccountData.currLiquidationThreshold);
|
|
935
935
|
const params = yield sdk.query.cdp.Params({});
|
|
936
936
|
if (!params.params) {
|
|
937
937
|
throw new Error("unable to retrieve cdp params");
|
|
938
938
|
}
|
|
939
|
-
const smallLiqSize =
|
|
940
|
-
const minCloseFactor =
|
|
941
|
-
const completeLiqThreshold =
|
|
939
|
+
const smallLiqSize = number_1.bnOrZero(params.params.smallLiquidationSize);
|
|
940
|
+
const minCloseFactor = number_1.bnOrZero(params.params.minimumCloseFactor);
|
|
941
|
+
const completeLiqThreshold = number_1.bnOrZero(params.params.completeLiquidationThreshold);
|
|
942
942
|
const closeFactor = this.computeCloseFactor(debtorTotalDebtVal, debtorTotalCollateralVal, currentLiqThreshold, smallLiqSize, minCloseFactor, completeLiqThreshold);
|
|
943
943
|
// get max repayable amount given the debtor's debt and how much liquidator wants to repay
|
|
944
|
-
const debtDecimals =
|
|
944
|
+
const debtDecimals = number_1.bnOrZero(yield sdk.getTokenClient().getDecimals(debtDenom));
|
|
945
945
|
const maxRepayableValue = debtorTotalDebtVal.multipliedBy(closeFactor);
|
|
946
946
|
const maxRepayableAmt = maxRepayableValue.shiftedBy(debtDecimals.toNumber());
|
|
947
947
|
if (debtRepaymentAmount.isGreaterThan(maxRepayableAmt)) {
|
|
@@ -949,7 +949,7 @@ class CDPModule extends base_1.default {
|
|
|
949
949
|
}
|
|
950
950
|
// calculate collateral amount that can be obtained given that debt amount and debtor's collateral balance
|
|
951
951
|
// AND, recalculate debt repay amount if needed
|
|
952
|
-
const cdpTokenDecimals =
|
|
952
|
+
const cdpTokenDecimals = number_1.bnOrZero(yield sdk.getTokenClient().getDecimals(cdpActualDenom));
|
|
953
953
|
let collateralAmtToLiquidate = this.calculateCollateralRequiredForDebt(number_1.BN_ONE, // assumes USC is $1
|
|
954
954
|
cdpTokenDiscountedPrice, debtRepaymentAmount, cdpTokenDecimals, debtDecimals);
|
|
955
955
|
const debtorAccountCollateral = yield sdk.query.cdp.AccountCollateral({
|
|
@@ -1021,11 +1021,11 @@ class CDPModule extends base_1.default {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
exports.CDPModule = CDPModule;
|
|
1023
1023
|
CDPModule.calculateInterestAPY = (debtInfo, rateStrategy) => {
|
|
1024
|
-
const utilizationRate =
|
|
1025
|
-
const optimalUsage =
|
|
1026
|
-
const variableRate1 =
|
|
1027
|
-
const variableRate2 =
|
|
1028
|
-
const baseVariableBorrowRate =
|
|
1024
|
+
const utilizationRate = number_1.bnOrZero(debtInfo.utilizationRate).shiftedBy(-18);
|
|
1025
|
+
const optimalUsage = number_1.bnOrZero(rateStrategy.optimalUsage).shiftedBy(-4);
|
|
1026
|
+
const variableRate1 = number_1.bnOrZero(rateStrategy.variableRateSlope1).shiftedBy(-4);
|
|
1027
|
+
const variableRate2 = number_1.bnOrZero(rateStrategy.variableRateSlope2).shiftedBy(-4);
|
|
1028
|
+
const baseVariableBorrowRate = number_1.bnOrZero(rateStrategy.baseVariableBorrowRate).shiftedBy(-4);
|
|
1029
1029
|
if (utilizationRate.lte(optimalUsage)) {
|
|
1030
1030
|
const vRate = utilizationRate.times(variableRate1).div(optimalUsage).dp(4, bignumber_js_1.BigNumber.ROUND_CEIL);
|
|
1031
1031
|
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
|
+
}
|