carbon-js-sdk 0.4.4 → 0.4.6
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/InsightsQueryClient.d.ts +1 -0
- package/lib/clients/InsightsQueryClient.js +8 -0
- package/lib/clients/NEOClient.js +7 -7
- package/lib/clients/TokenClient.js +11 -3
- package/lib/clients/ZILClient.js +17 -17
- 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/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/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/ledger/ledger.js +2 -2
- package/lib/provider/metamask/MetaMask.js +1 -1
- 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 +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/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
|
@@ -763,13 +763,13 @@ exports.ModeInfo_Single = {
|
|
|
763
763
|
const message = Object.assign({}, baseModeInfo_Single);
|
|
764
764
|
message.mode =
|
|
765
765
|
object.mode !== undefined && object.mode !== null
|
|
766
|
-
?
|
|
766
|
+
? signing_1.signModeFromJSON(object.mode)
|
|
767
767
|
: 0;
|
|
768
768
|
return message;
|
|
769
769
|
},
|
|
770
770
|
toJSON(message) {
|
|
771
771
|
const obj = {};
|
|
772
|
-
message.mode !== undefined && (obj.mode =
|
|
772
|
+
message.mode !== undefined && (obj.mode = signing_1.signModeToJSON(message.mode));
|
|
773
773
|
return obj;
|
|
774
774
|
},
|
|
775
775
|
fromPartial(object) {
|
|
@@ -1052,7 +1052,7 @@ exports.AuxSignerData = {
|
|
|
1052
1052
|
: undefined;
|
|
1053
1053
|
message.mode =
|
|
1054
1054
|
object.mode !== undefined && object.mode !== null
|
|
1055
|
-
?
|
|
1055
|
+
? signing_1.signModeFromJSON(object.mode)
|
|
1056
1056
|
: 0;
|
|
1057
1057
|
message.sig =
|
|
1058
1058
|
object.sig !== undefined && object.sig !== null
|
|
@@ -1067,7 +1067,7 @@ exports.AuxSignerData = {
|
|
|
1067
1067
|
(obj.signDoc = message.signDoc
|
|
1068
1068
|
? exports.SignDocDirectAux.toJSON(message.signDoc)
|
|
1069
1069
|
: undefined);
|
|
1070
|
-
message.mode !== undefined && (obj.mode =
|
|
1070
|
+
message.mode !== undefined && (obj.mode = signing_1.signModeToJSON(message.mode));
|
|
1071
1071
|
message.sig !== undefined &&
|
|
1072
1072
|
(obj.sig = base64FromBytes(message.sig !== undefined ? message.sig : new Uint8Array()));
|
|
1073
1073
|
return obj;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PubKey, PrivKey } from "./keys";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivKey = exports.PubKey = void 0;
|
|
4
|
+
var keys_1 = require("./keys");
|
|
5
|
+
Object.defineProperty(exports, "PubKey", { enumerable: true, get: function () { return keys_1.PubKey; } });
|
|
6
|
+
Object.defineProperty(exports, "PrivKey", { enumerable: true, get: function () { return keys_1.PrivKey; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EventEthereumTx, EventTxLog, EventMessage, EventBlockBloom } from "./events";
|
|
2
|
+
export { Params, ChainConfig, State, TransactionLogs, Log, TxResult, AccessTuple, TraceConfig } from "./evm";
|
|
3
|
+
export { GenesisAccount } from "./genesis";
|
|
4
|
+
export { QueryAccountRequest, QueryAccountResponse, QueryCosmosAccountRequest, QueryCosmosAccountResponse, QueryValidatorAccountRequest, QueryValidatorAccountResponse, QueryBalanceRequest, QueryBalanceResponse, QueryStorageRequest, QueryStorageResponse, QueryCodeRequest, QueryCodeResponse, QueryTxLogsRequest, QueryTxLogsResponse, QueryParamsRequest, QueryParamsResponse, EthCallRequest, EstimateGasResponse, QueryTraceTxRequest, QueryTraceTxResponse, QueryTraceBlockRequest, QueryTraceBlockResponse, QueryBaseFeeRequest, QueryBaseFeeResponse } from "./query";
|
|
5
|
+
export { MsgEthereumTx, LegacyTx, AccessListTx, DynamicFeeTx, ExtensionOptionsEthereumTx, MsgEthereumTxResponse, MsgUpdateParams, MsgUpdateParamsResponse } from "./tx";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MsgUpdateParamsResponse = exports.MsgUpdateParams = exports.MsgEthereumTxResponse = exports.ExtensionOptionsEthereumTx = exports.DynamicFeeTx = exports.AccessListTx = exports.LegacyTx = exports.MsgEthereumTx = exports.QueryBaseFeeResponse = exports.QueryBaseFeeRequest = exports.QueryTraceBlockResponse = exports.QueryTraceBlockRequest = exports.QueryTraceTxResponse = exports.QueryTraceTxRequest = exports.EstimateGasResponse = exports.EthCallRequest = exports.QueryParamsResponse = exports.QueryParamsRequest = exports.QueryTxLogsResponse = exports.QueryTxLogsRequest = exports.QueryCodeResponse = exports.QueryCodeRequest = exports.QueryStorageResponse = exports.QueryStorageRequest = exports.QueryBalanceResponse = exports.QueryBalanceRequest = exports.QueryValidatorAccountResponse = exports.QueryValidatorAccountRequest = exports.QueryCosmosAccountResponse = exports.QueryCosmosAccountRequest = exports.QueryAccountResponse = exports.QueryAccountRequest = exports.GenesisAccount = exports.TraceConfig = exports.AccessTuple = exports.TxResult = exports.Log = exports.TransactionLogs = exports.State = exports.ChainConfig = exports.Params = exports.EventBlockBloom = exports.EventMessage = exports.EventTxLog = exports.EventEthereumTx = void 0;
|
|
4
|
+
var events_1 = require("./events");
|
|
5
|
+
Object.defineProperty(exports, "EventEthereumTx", { enumerable: true, get: function () { return events_1.EventEthereumTx; } });
|
|
6
|
+
Object.defineProperty(exports, "EventTxLog", { enumerable: true, get: function () { return events_1.EventTxLog; } });
|
|
7
|
+
Object.defineProperty(exports, "EventMessage", { enumerable: true, get: function () { return events_1.EventMessage; } });
|
|
8
|
+
Object.defineProperty(exports, "EventBlockBloom", { enumerable: true, get: function () { return events_1.EventBlockBloom; } });
|
|
9
|
+
var evm_1 = require("./evm");
|
|
10
|
+
Object.defineProperty(exports, "Params", { enumerable: true, get: function () { return evm_1.Params; } });
|
|
11
|
+
Object.defineProperty(exports, "ChainConfig", { enumerable: true, get: function () { return evm_1.ChainConfig; } });
|
|
12
|
+
Object.defineProperty(exports, "State", { enumerable: true, get: function () { return evm_1.State; } });
|
|
13
|
+
Object.defineProperty(exports, "TransactionLogs", { enumerable: true, get: function () { return evm_1.TransactionLogs; } });
|
|
14
|
+
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return evm_1.Log; } });
|
|
15
|
+
Object.defineProperty(exports, "TxResult", { enumerable: true, get: function () { return evm_1.TxResult; } });
|
|
16
|
+
Object.defineProperty(exports, "AccessTuple", { enumerable: true, get: function () { return evm_1.AccessTuple; } });
|
|
17
|
+
Object.defineProperty(exports, "TraceConfig", { enumerable: true, get: function () { return evm_1.TraceConfig; } });
|
|
18
|
+
var genesis_1 = require("./genesis");
|
|
19
|
+
Object.defineProperty(exports, "GenesisAccount", { enumerable: true, get: function () { return genesis_1.GenesisAccount; } });
|
|
20
|
+
var query_1 = require("./query");
|
|
21
|
+
Object.defineProperty(exports, "QueryAccountRequest", { enumerable: true, get: function () { return query_1.QueryAccountRequest; } });
|
|
22
|
+
Object.defineProperty(exports, "QueryAccountResponse", { enumerable: true, get: function () { return query_1.QueryAccountResponse; } });
|
|
23
|
+
Object.defineProperty(exports, "QueryCosmosAccountRequest", { enumerable: true, get: function () { return query_1.QueryCosmosAccountRequest; } });
|
|
24
|
+
Object.defineProperty(exports, "QueryCosmosAccountResponse", { enumerable: true, get: function () { return query_1.QueryCosmosAccountResponse; } });
|
|
25
|
+
Object.defineProperty(exports, "QueryValidatorAccountRequest", { enumerable: true, get: function () { return query_1.QueryValidatorAccountRequest; } });
|
|
26
|
+
Object.defineProperty(exports, "QueryValidatorAccountResponse", { enumerable: true, get: function () { return query_1.QueryValidatorAccountResponse; } });
|
|
27
|
+
Object.defineProperty(exports, "QueryBalanceRequest", { enumerable: true, get: function () { return query_1.QueryBalanceRequest; } });
|
|
28
|
+
Object.defineProperty(exports, "QueryBalanceResponse", { enumerable: true, get: function () { return query_1.QueryBalanceResponse; } });
|
|
29
|
+
Object.defineProperty(exports, "QueryStorageRequest", { enumerable: true, get: function () { return query_1.QueryStorageRequest; } });
|
|
30
|
+
Object.defineProperty(exports, "QueryStorageResponse", { enumerable: true, get: function () { return query_1.QueryStorageResponse; } });
|
|
31
|
+
Object.defineProperty(exports, "QueryCodeRequest", { enumerable: true, get: function () { return query_1.QueryCodeRequest; } });
|
|
32
|
+
Object.defineProperty(exports, "QueryCodeResponse", { enumerable: true, get: function () { return query_1.QueryCodeResponse; } });
|
|
33
|
+
Object.defineProperty(exports, "QueryTxLogsRequest", { enumerable: true, get: function () { return query_1.QueryTxLogsRequest; } });
|
|
34
|
+
Object.defineProperty(exports, "QueryTxLogsResponse", { enumerable: true, get: function () { return query_1.QueryTxLogsResponse; } });
|
|
35
|
+
Object.defineProperty(exports, "QueryParamsRequest", { enumerable: true, get: function () { return query_1.QueryParamsRequest; } });
|
|
36
|
+
Object.defineProperty(exports, "QueryParamsResponse", { enumerable: true, get: function () { return query_1.QueryParamsResponse; } });
|
|
37
|
+
Object.defineProperty(exports, "EthCallRequest", { enumerable: true, get: function () { return query_1.EthCallRequest; } });
|
|
38
|
+
Object.defineProperty(exports, "EstimateGasResponse", { enumerable: true, get: function () { return query_1.EstimateGasResponse; } });
|
|
39
|
+
Object.defineProperty(exports, "QueryTraceTxRequest", { enumerable: true, get: function () { return query_1.QueryTraceTxRequest; } });
|
|
40
|
+
Object.defineProperty(exports, "QueryTraceTxResponse", { enumerable: true, get: function () { return query_1.QueryTraceTxResponse; } });
|
|
41
|
+
Object.defineProperty(exports, "QueryTraceBlockRequest", { enumerable: true, get: function () { return query_1.QueryTraceBlockRequest; } });
|
|
42
|
+
Object.defineProperty(exports, "QueryTraceBlockResponse", { enumerable: true, get: function () { return query_1.QueryTraceBlockResponse; } });
|
|
43
|
+
Object.defineProperty(exports, "QueryBaseFeeRequest", { enumerable: true, get: function () { return query_1.QueryBaseFeeRequest; } });
|
|
44
|
+
Object.defineProperty(exports, "QueryBaseFeeResponse", { enumerable: true, get: function () { return query_1.QueryBaseFeeResponse; } });
|
|
45
|
+
var tx_1 = require("./tx");
|
|
46
|
+
Object.defineProperty(exports, "MsgEthereumTx", { enumerable: true, get: function () { return tx_1.MsgEthereumTx; } });
|
|
47
|
+
Object.defineProperty(exports, "LegacyTx", { enumerable: true, get: function () { return tx_1.LegacyTx; } });
|
|
48
|
+
Object.defineProperty(exports, "AccessListTx", { enumerable: true, get: function () { return tx_1.AccessListTx; } });
|
|
49
|
+
Object.defineProperty(exports, "DynamicFeeTx", { enumerable: true, get: function () { return tx_1.DynamicFeeTx; } });
|
|
50
|
+
Object.defineProperty(exports, "ExtensionOptionsEthereumTx", { enumerable: true, get: function () { return tx_1.ExtensionOptionsEthereumTx; } });
|
|
51
|
+
Object.defineProperty(exports, "MsgEthereumTxResponse", { enumerable: true, get: function () { return tx_1.MsgEthereumTxResponse; } });
|
|
52
|
+
Object.defineProperty(exports, "MsgUpdateParams", { enumerable: true, get: function () { return tx_1.MsgUpdateParams; } });
|
|
53
|
+
Object.defineProperty(exports, "MsgUpdateParamsResponse", { enumerable: true, get: function () { return tx_1.MsgUpdateParamsResponse; } });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { EventFeeMarket, EventBlockGas } from "./events";
|
|
2
|
+
export { Params } from "./feemarket";
|
|
3
|
+
export { QueryParamsRequest, QueryParamsResponse, QueryBaseFeeRequest, QueryBaseFeeResponse, QueryBlockGasRequest, QueryBlockGasResponse } from "./query";
|
|
4
|
+
export { MsgUpdateParams, MsgUpdateParamsResponse } from "./tx";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MsgUpdateParamsResponse = exports.MsgUpdateParams = exports.QueryBlockGasResponse = exports.QueryBlockGasRequest = exports.QueryBaseFeeResponse = exports.QueryBaseFeeRequest = exports.QueryParamsResponse = exports.QueryParamsRequest = exports.Params = exports.EventBlockGas = exports.EventFeeMarket = void 0;
|
|
4
|
+
var events_1 = require("./events");
|
|
5
|
+
Object.defineProperty(exports, "EventFeeMarket", { enumerable: true, get: function () { return events_1.EventFeeMarket; } });
|
|
6
|
+
Object.defineProperty(exports, "EventBlockGas", { enumerable: true, get: function () { return events_1.EventBlockGas; } });
|
|
7
|
+
var feemarket_1 = require("./feemarket");
|
|
8
|
+
Object.defineProperty(exports, "Params", { enumerable: true, get: function () { return feemarket_1.Params; } });
|
|
9
|
+
var query_1 = require("./query");
|
|
10
|
+
Object.defineProperty(exports, "QueryParamsRequest", { enumerable: true, get: function () { return query_1.QueryParamsRequest; } });
|
|
11
|
+
Object.defineProperty(exports, "QueryParamsResponse", { enumerable: true, get: function () { return query_1.QueryParamsResponse; } });
|
|
12
|
+
Object.defineProperty(exports, "QueryBaseFeeRequest", { enumerable: true, get: function () { return query_1.QueryBaseFeeRequest; } });
|
|
13
|
+
Object.defineProperty(exports, "QueryBaseFeeResponse", { enumerable: true, get: function () { return query_1.QueryBaseFeeResponse; } });
|
|
14
|
+
Object.defineProperty(exports, "QueryBlockGasRequest", { enumerable: true, get: function () { return query_1.QueryBlockGasRequest; } });
|
|
15
|
+
Object.defineProperty(exports, "QueryBlockGasResponse", { enumerable: true, get: function () { return query_1.QueryBlockGasResponse; } });
|
|
16
|
+
var tx_1 = require("./tx");
|
|
17
|
+
Object.defineProperty(exports, "MsgUpdateParams", { enumerable: true, get: function () { return tx_1.MsgUpdateParams; } });
|
|
18
|
+
Object.defineProperty(exports, "MsgUpdateParamsResponse", { enumerable: true, get: function () { return tx_1.MsgUpdateParamsResponse; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtensionOptionsWeb3Tx = exports.TxResult = exports.ExtensionOptionDynamicFeeTx = exports.EthAccount = void 0;
|
|
4
|
+
var account_1 = require("./account");
|
|
5
|
+
Object.defineProperty(exports, "EthAccount", { enumerable: true, get: function () { return account_1.EthAccount; } });
|
|
6
|
+
var dynamic_fee_1 = require("./dynamic_fee");
|
|
7
|
+
Object.defineProperty(exports, "ExtensionOptionDynamicFeeTx", { enumerable: true, get: function () { return dynamic_fee_1.ExtensionOptionDynamicFeeTx; } });
|
|
8
|
+
var indexer_1 = require("./indexer");
|
|
9
|
+
Object.defineProperty(exports, "TxResult", { enumerable: true, get: function () { return indexer_1.TxResult; } });
|
|
10
|
+
var web3_1 = require("./web3");
|
|
11
|
+
Object.defineProperty(exports, "ExtensionOptionsWeb3Tx", { enumerable: true, get: function () { return web3_1.ExtensionOptionsWeb3Tx; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Types = exports.FeeMarket = exports.Evm = exports.Crypto = void 0;
|
|
23
|
+
exports.Crypto = __importStar(require("./ethermint/crypto/v1/ethsecp256k1/export"));
|
|
24
|
+
exports.Evm = __importStar(require("./ethermint/evm/v1/export"));
|
|
25
|
+
exports.FeeMarket = __importStar(require("./ethermint/feemarket/v1/export"));
|
|
26
|
+
exports.Types = __importStar(require("./ethermint/types/v1/export"));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const 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_CARBON_DOMAIN_FIELDS: {
|
|
24
|
+
name: string;
|
|
25
|
+
version: string;
|
|
26
|
+
verifyingContract: string;
|
|
27
|
+
salt: string;
|
|
28
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_CARBON_DOMAIN_FIELDS = exports.DEFAULT_EIP712_TYPES = void 0;
|
|
4
|
+
exports.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
|
+
// Note that the chainId field is delibrately omitted because it is dynamic
|
|
35
|
+
exports.DEFAULT_CARBON_DOMAIN_FIELDS = {
|
|
36
|
+
name: "Carbon",
|
|
37
|
+
version: "1.0.0",
|
|
38
|
+
verifyingContract: "cosmos",
|
|
39
|
+
salt: "1",
|
|
40
|
+
};
|
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/insights/common.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare const InsightsEndpoints: {
|
|
|
26
26
|
"competition/list": string;
|
|
27
27
|
"competition/leaderboard": string;
|
|
28
28
|
"competition/leaderboardpnl": string;
|
|
29
|
+
"competition/leaderboardlottery": string;
|
|
29
30
|
"info/denom_gecko_map": string;
|
|
30
31
|
"market/funding": string;
|
|
31
32
|
};
|
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
|
});
|