carbon-js-sdk 0.2.11 → 0.2.13
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.d.ts +5 -2
- package/lib/clients/CarbonQueryClient.js +59 -54
- package/lib/clients/ETHClient.js +4 -4
- package/lib/clients/TokenClient.d.ts +2 -1
- package/lib/clients/TokenClient.js +1 -1
- package/lib/codec/cdp/asset_params.d.ts +1 -0
- package/lib/codec/cdp/asset_params.js +31 -15
- package/lib/codec/cdp/debt_info.d.ts +2 -3
- package/lib/codec/cdp/debt_info.js +31 -42
- package/lib/codec/cdp/stablecoin_debt_info.d.ts +2 -3
- package/lib/codec/cdp/stablecoin_debt_info.js +29 -40
- package/lib/constant/network.d.ts +3 -0
- package/lib/constant/network.js +12 -0
- package/lib/modules/fee.d.ts +2 -2
- package/lib/modules/fee.js +4 -5
- package/lib/provider/sdk/SDKProvider.d.ts +2 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { QueryClientImpl as CDPQueryClient } from "../codec/cdp/query";
|
|
|
5
5
|
import { QueryClientImpl as CoinQueryClient } from "../codec/coin/query";
|
|
6
6
|
import { QueryClientImpl as AuthQueryClient } from "../codec/cosmos/auth/v1beta1/query";
|
|
7
7
|
import { QueryClientImpl as BankQueryClient } from "../codec/cosmos/bank/v1beta1/query";
|
|
8
|
+
import { ServiceClientImpl as CosmosTmClient } from "../codec/cosmos/base/tendermint/v1beta1/query";
|
|
8
9
|
import { QueryClientImpl as DistributionQueryClient } from "../codec/cosmos/distribution/v1beta1/query";
|
|
9
10
|
import { QueryClientImpl as EvidenceQueryClient } from "../codec/cosmos/evidence/v1beta1/query";
|
|
10
11
|
import { QueryClientImpl as GovQueryClient } from "../codec/cosmos/gov/v1beta1/query";
|
|
@@ -13,10 +14,11 @@ import { QueryClientImpl as ParamsQueryClient } from "../codec/cosmos/params/v1b
|
|
|
13
14
|
import { QueryClientImpl as SlashingQueryClient } from "../codec/cosmos/slashing/v1beta1/query";
|
|
14
15
|
import { QueryClientImpl as StakingQueryClient } from "../codec/cosmos/staking/v1beta1/query";
|
|
15
16
|
import { QueryClientImpl as UpgradeQueryClient } from "../codec/cosmos/upgrade/v1beta1/query";
|
|
17
|
+
import { QueryClientImpl as FeeQueryClient } from "../codec/fee/query";
|
|
18
|
+
import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/query";
|
|
16
19
|
import { QueryClientImpl as IBCInterchainControlQueryClient } from "../codec/ibc/applications/interchain_accounts/controller/v1/query";
|
|
17
20
|
import { QueryClientImpl as IBCInterchainHostQueryClient } from "../codec/ibc/applications/interchain_accounts/host/v1/query";
|
|
18
21
|
import { QueryClientImpl as IBCTransferQueryClient } from "../codec/ibc/applications/transfer/v1/query";
|
|
19
|
-
import { QueryClientImpl as FeeQueryClient } from "../codec/fee/query";
|
|
20
22
|
import { QueryClientImpl as InflationQueryClient } from "../codec/inflation/query";
|
|
21
23
|
import { QueryClientImpl as InsuranceQueryClient } from "../codec/insurance/query";
|
|
22
24
|
import { QueryClientImpl as LeverageQueryClient } from "../codec/leverage/query";
|
|
@@ -31,7 +33,6 @@ import { QueryClientImpl as PositionQueryClient } from "../codec/position/query"
|
|
|
31
33
|
import { QueryClientImpl as PricingQueryClient } from "../codec/pricing/query";
|
|
32
34
|
import { QueryClientImpl as ProfileQueryClient } from "../codec/profile/query";
|
|
33
35
|
import { QueryClientImpl as SubaccountQueryClient } from "../codec/subaccount/query";
|
|
34
|
-
import { QueryClientImpl as HeadersyncQueryClient } from "../codec/headersync/query";
|
|
35
36
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
36
37
|
import BlockchainClient from "./BlockchainClient";
|
|
37
38
|
export interface IBCClientGroup {
|
|
@@ -72,9 +73,11 @@ declare class CarbonQueryClient {
|
|
|
72
73
|
slashing: SlashingQueryClient;
|
|
73
74
|
staking: StakingQueryClient;
|
|
74
75
|
upgrade: UpgradeQueryClient;
|
|
76
|
+
cosmosTm: CosmosTmClient;
|
|
75
77
|
chain: BlockchainClient;
|
|
76
78
|
ibc: IBCClientGroup;
|
|
77
79
|
private baseClient;
|
|
78
80
|
constructor(tmClient: Tendermint34Client);
|
|
81
|
+
getProtobufRpcClient(): import("@cosmjs/stargate").ProtobufRpcClient;
|
|
79
82
|
}
|
|
80
83
|
export default CarbonQueryClient;
|
|
@@ -10,33 +10,34 @@ const query_4 = require("../codec/cdp/query");
|
|
|
10
10
|
const query_5 = require("../codec/coin/query");
|
|
11
11
|
const query_6 = require("../codec/cosmos/auth/v1beta1/query");
|
|
12
12
|
const query_7 = require("../codec/cosmos/bank/v1beta1/query");
|
|
13
|
-
const query_8 = require("../codec/cosmos/
|
|
14
|
-
const query_9 = require("../codec/cosmos/
|
|
15
|
-
const query_10 = require("../codec/cosmos/
|
|
16
|
-
const query_11 = require("../codec/cosmos/
|
|
17
|
-
const query_12 = require("../codec/cosmos/
|
|
18
|
-
const query_13 = require("../codec/cosmos/
|
|
19
|
-
const query_14 = require("../codec/cosmos/
|
|
20
|
-
const query_15 = require("../codec/cosmos/
|
|
21
|
-
const query_16 = require("../codec/
|
|
22
|
-
const query_17 = require("../codec/
|
|
23
|
-
const query_18 = require("../codec/
|
|
24
|
-
const query_19 = require("../codec/
|
|
25
|
-
const query_20 = require("../codec/
|
|
26
|
-
const query_21 = require("../codec/
|
|
27
|
-
const query_22 = require("../codec/
|
|
28
|
-
const query_23 = require("../codec/
|
|
29
|
-
const query_24 = require("../codec/
|
|
30
|
-
const query_25 = require("../codec/
|
|
31
|
-
const query_26 = require("../codec/
|
|
32
|
-
const query_27 = require("../codec/
|
|
33
|
-
const query_28 = require("../codec/
|
|
34
|
-
const query_29 = require("../codec/
|
|
35
|
-
const query_30 = require("../codec/
|
|
36
|
-
const query_31 = require("../codec/
|
|
37
|
-
const query_32 = require("../codec/
|
|
38
|
-
const query_33 = require("../codec/
|
|
39
|
-
const query_34 = require("../codec/
|
|
13
|
+
const query_8 = require("../codec/cosmos/base/tendermint/v1beta1/query");
|
|
14
|
+
const query_9 = require("../codec/cosmos/distribution/v1beta1/query");
|
|
15
|
+
const query_10 = require("../codec/cosmos/evidence/v1beta1/query");
|
|
16
|
+
const query_11 = require("../codec/cosmos/gov/v1beta1/query");
|
|
17
|
+
const query_12 = require("../codec/cosmos/mint/v1beta1/query");
|
|
18
|
+
const query_13 = require("../codec/cosmos/params/v1beta1/query");
|
|
19
|
+
const query_14 = require("../codec/cosmos/slashing/v1beta1/query");
|
|
20
|
+
const query_15 = require("../codec/cosmos/staking/v1beta1/query");
|
|
21
|
+
const query_16 = require("../codec/cosmos/upgrade/v1beta1/query");
|
|
22
|
+
const query_17 = require("../codec/fee/query");
|
|
23
|
+
const query_18 = require("../codec/headersync/query");
|
|
24
|
+
const query_19 = require("../codec/ibc/applications/interchain_accounts/controller/v1/query");
|
|
25
|
+
const query_20 = require("../codec/ibc/applications/interchain_accounts/host/v1/query");
|
|
26
|
+
const query_21 = require("../codec/ibc/applications/transfer/v1/query");
|
|
27
|
+
const query_22 = require("../codec/inflation/query");
|
|
28
|
+
const query_23 = require("../codec/insurance/query");
|
|
29
|
+
const query_24 = require("../codec/leverage/query");
|
|
30
|
+
const query_25 = require("../codec/liquidation/query");
|
|
31
|
+
const query_26 = require("../codec/liquiditypool/query");
|
|
32
|
+
const query_27 = require("../codec/market/query");
|
|
33
|
+
const query_28 = require("../codec/marketstats/query");
|
|
34
|
+
const query_29 = require("../codec/misc/query");
|
|
35
|
+
const query_30 = require("../codec/oracle/query");
|
|
36
|
+
const query_31 = require("../codec/order/query");
|
|
37
|
+
const query_32 = require("../codec/position/query");
|
|
38
|
+
const query_33 = require("../codec/pricing/query");
|
|
39
|
+
const query_34 = require("../codec/profile/query");
|
|
40
|
+
const query_35 = require("../codec/subaccount/query");
|
|
40
41
|
const stargate_1 = require("@cosmjs/stargate");
|
|
41
42
|
const BlockchainClient_1 = __importDefault(require("./BlockchainClient"));
|
|
42
43
|
class CarbonQueryClient {
|
|
@@ -50,37 +51,41 @@ class CarbonQueryClient {
|
|
|
50
51
|
this.broker = new query_3.QueryClientImpl(rpcClient);
|
|
51
52
|
this.coin = new query_5.QueryClientImpl(rpcClient);
|
|
52
53
|
this.cdp = new query_4.QueryClientImpl(rpcClient);
|
|
53
|
-
this.fee = new
|
|
54
|
-
this.inflation = new
|
|
55
|
-
this.insurance = new
|
|
56
|
-
this.leverage = new
|
|
57
|
-
this.liquidation = new
|
|
58
|
-
this.liquiditypool = new
|
|
59
|
-
this.market = new
|
|
60
|
-
this.marketstats = new
|
|
61
|
-
this.misc = new
|
|
62
|
-
this.oracle = new
|
|
63
|
-
this.order = new
|
|
64
|
-
this.position = new
|
|
65
|
-
this.pricing = new
|
|
66
|
-
this.profile = new
|
|
67
|
-
this.subaccount = new
|
|
68
|
-
this.headersync = new
|
|
54
|
+
this.fee = new query_17.QueryClientImpl(rpcClient);
|
|
55
|
+
this.inflation = new query_22.QueryClientImpl(rpcClient);
|
|
56
|
+
this.insurance = new query_23.QueryClientImpl(rpcClient);
|
|
57
|
+
this.leverage = new query_24.QueryClientImpl(rpcClient);
|
|
58
|
+
this.liquidation = new query_25.QueryClientImpl(rpcClient);
|
|
59
|
+
this.liquiditypool = new query_26.QueryClientImpl(rpcClient);
|
|
60
|
+
this.market = new query_27.QueryClientImpl(rpcClient);
|
|
61
|
+
this.marketstats = new query_28.QueryClientImpl(rpcClient);
|
|
62
|
+
this.misc = new query_29.QueryClientImpl(rpcClient);
|
|
63
|
+
this.oracle = new query_30.QueryClientImpl(rpcClient);
|
|
64
|
+
this.order = new query_31.QueryClientImpl(rpcClient);
|
|
65
|
+
this.position = new query_32.QueryClientImpl(rpcClient);
|
|
66
|
+
this.pricing = new query_33.QueryClientImpl(rpcClient);
|
|
67
|
+
this.profile = new query_34.QueryClientImpl(rpcClient);
|
|
68
|
+
this.subaccount = new query_35.QueryClientImpl(rpcClient);
|
|
69
|
+
this.headersync = new query_18.QueryClientImpl(rpcClient);
|
|
69
70
|
this.auth = new query_6.QueryClientImpl(rpcClient);
|
|
70
71
|
this.bank = new query_7.QueryClientImpl(rpcClient);
|
|
71
|
-
this.distribution = new
|
|
72
|
-
this.evidence = new
|
|
73
|
-
this.gov = new
|
|
74
|
-
this.mint = new
|
|
75
|
-
this.params = new
|
|
76
|
-
this.slashing = new
|
|
77
|
-
this.staking = new
|
|
78
|
-
this.upgrade = new
|
|
72
|
+
this.distribution = new query_9.QueryClientImpl(rpcClient);
|
|
73
|
+
this.evidence = new query_10.QueryClientImpl(rpcClient);
|
|
74
|
+
this.gov = new query_11.QueryClientImpl(rpcClient);
|
|
75
|
+
this.mint = new query_12.QueryClientImpl(rpcClient);
|
|
76
|
+
this.params = new query_13.QueryClientImpl(rpcClient);
|
|
77
|
+
this.slashing = new query_14.QueryClientImpl(rpcClient);
|
|
78
|
+
this.staking = new query_15.QueryClientImpl(rpcClient);
|
|
79
|
+
this.upgrade = new query_16.QueryClientImpl(rpcClient);
|
|
80
|
+
this.cosmosTm = new query_8.ServiceClientImpl(rpcClient);
|
|
79
81
|
this.ibc = {
|
|
80
|
-
controller: new
|
|
81
|
-
host: new
|
|
82
|
-
transfer: new
|
|
82
|
+
controller: new query_19.QueryClientImpl(rpcClient),
|
|
83
|
+
host: new query_20.QueryClientImpl(rpcClient),
|
|
84
|
+
transfer: new query_21.QueryClientImpl(rpcClient),
|
|
83
85
|
};
|
|
84
86
|
}
|
|
87
|
+
getProtobufRpcClient() {
|
|
88
|
+
return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
91
|
exports.default = CarbonQueryClient;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -186,7 +186,7 @@ class ETHClient {
|
|
|
186
186
|
feeAmount = overrideFee;
|
|
187
187
|
}
|
|
188
188
|
const amount = ethers_1.ethers.BigNumber.from(tokenWithExternalBalances.externalBalance);
|
|
189
|
-
if (amount.lt(feeAmount
|
|
189
|
+
if (amount.lt(feeAmount)) {
|
|
190
190
|
return "insufficient balance";
|
|
191
191
|
}
|
|
192
192
|
const networkConfig = this.getNetworkConfig();
|
|
@@ -235,16 +235,16 @@ class ETHClient {
|
|
|
235
235
|
getDepositFeeAmount(token, depositAddress) {
|
|
236
236
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
237
|
const feeInfo = yield this.tokenClient.getFeeInfo(token.denom);
|
|
238
|
-
if (!feeInfo.
|
|
238
|
+
if (!feeInfo.deposit_fee) {
|
|
239
239
|
throw new Error("unsupported token");
|
|
240
240
|
}
|
|
241
241
|
if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) !== this.blockchain) {
|
|
242
242
|
throw new Error("unsupported token");
|
|
243
243
|
}
|
|
244
|
-
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.
|
|
244
|
+
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
245
245
|
const walletContractDeployed = yield this.isContract(depositAddress);
|
|
246
246
|
if (!walletContractDeployed) {
|
|
247
|
-
feeAmount = feeAmount.add(ethers_1.ethers.BigNumber.from(feeInfo.
|
|
247
|
+
feeAmount = feeAmount.add(ethers_1.ethers.BigNumber.from(feeInfo.create_wallet_fee));
|
|
248
248
|
}
|
|
249
249
|
return feeAmount;
|
|
250
250
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Token } from "../codec";
|
|
2
2
|
import { NetworkConfigProvider } from "../constant";
|
|
3
|
+
import { FeeQuote } from "../hydrogen/feeQuote";
|
|
3
4
|
import { BlockchainUtils, TypeUtils } from "../util";
|
|
4
5
|
import BigNumber from "bignumber.js";
|
|
5
6
|
import CarbonQueryClient from "./CarbonQueryClient";
|
|
@@ -28,7 +29,7 @@ declare class TokenClient {
|
|
|
28
29
|
toUnitless(denom: string, humanAmt: BigNumber): BigNumber;
|
|
29
30
|
tokenForId(id: string): Token | undefined;
|
|
30
31
|
tokenForDenom(denom: string): Token | undefined;
|
|
31
|
-
getFeeInfo(denom: string): Promise<
|
|
32
|
+
getFeeInfo(denom: string): Promise<FeeQuote>;
|
|
32
33
|
getTokenName(denom: string, overrideMap?: TypeUtils.SimpleMap<string>): string;
|
|
33
34
|
getTokenDesc(denom: string): string;
|
|
34
35
|
static isPoolTokenNew(denom: string): boolean;
|
|
@@ -117,7 +117,7 @@ class TokenClient {
|
|
|
117
117
|
getFeeInfo(denom) {
|
|
118
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
119
|
const config = this.configProvider.getConfig();
|
|
120
|
-
const url = `${config.
|
|
120
|
+
const url = `${config.hydrogenUrl}/fee_quote?token_denom=${denom}`;
|
|
121
121
|
const result = yield fetch(url).then(res => res.json());
|
|
122
122
|
return result;
|
|
123
123
|
});
|
|
@@ -12,6 +12,7 @@ const baseAssetParams = {
|
|
|
12
12
|
denom: "",
|
|
13
13
|
oracleId: "",
|
|
14
14
|
rateStrategyName: "",
|
|
15
|
+
repayStablecoinInterestDebt: false,
|
|
15
16
|
loanToValue: "",
|
|
16
17
|
liquidationThreshold: "",
|
|
17
18
|
liquidationBonus: "",
|
|
@@ -29,20 +30,23 @@ exports.AssetParams = {
|
|
|
29
30
|
if (message.rateStrategyName !== "") {
|
|
30
31
|
writer.uint32(26).string(message.rateStrategyName);
|
|
31
32
|
}
|
|
33
|
+
if (message.repayStablecoinInterestDebt === true) {
|
|
34
|
+
writer.uint32(32).bool(message.repayStablecoinInterestDebt);
|
|
35
|
+
}
|
|
32
36
|
if (message.loanToValue !== "") {
|
|
33
|
-
writer.uint32(
|
|
37
|
+
writer.uint32(42).string(message.loanToValue);
|
|
34
38
|
}
|
|
35
39
|
if (message.liquidationThreshold !== "") {
|
|
36
|
-
writer.uint32(
|
|
40
|
+
writer.uint32(50).string(message.liquidationThreshold);
|
|
37
41
|
}
|
|
38
42
|
if (message.liquidationBonus !== "") {
|
|
39
|
-
writer.uint32(
|
|
43
|
+
writer.uint32(58).string(message.liquidationBonus);
|
|
40
44
|
}
|
|
41
45
|
if (message.supplyCap !== "") {
|
|
42
|
-
writer.uint32(
|
|
46
|
+
writer.uint32(66).string(message.supplyCap);
|
|
43
47
|
}
|
|
44
48
|
if (message.borrowCap !== "") {
|
|
45
|
-
writer.uint32(
|
|
49
|
+
writer.uint32(74).string(message.borrowCap);
|
|
46
50
|
}
|
|
47
51
|
return writer;
|
|
48
52
|
},
|
|
@@ -63,18 +67,21 @@ exports.AssetParams = {
|
|
|
63
67
|
message.rateStrategyName = reader.string();
|
|
64
68
|
break;
|
|
65
69
|
case 4:
|
|
66
|
-
message.
|
|
70
|
+
message.repayStablecoinInterestDebt = reader.bool();
|
|
67
71
|
break;
|
|
68
72
|
case 5:
|
|
69
|
-
message.
|
|
73
|
+
message.loanToValue = reader.string();
|
|
70
74
|
break;
|
|
71
75
|
case 6:
|
|
72
|
-
message.
|
|
76
|
+
message.liquidationThreshold = reader.string();
|
|
73
77
|
break;
|
|
74
78
|
case 7:
|
|
75
|
-
message.
|
|
79
|
+
message.liquidationBonus = reader.string();
|
|
76
80
|
break;
|
|
77
81
|
case 8:
|
|
82
|
+
message.supplyCap = reader.string();
|
|
83
|
+
break;
|
|
84
|
+
case 9:
|
|
78
85
|
message.borrowCap = reader.string();
|
|
79
86
|
break;
|
|
80
87
|
default:
|
|
@@ -98,6 +105,11 @@ exports.AssetParams = {
|
|
|
98
105
|
object.rateStrategyName !== undefined && object.rateStrategyName !== null
|
|
99
106
|
? String(object.rateStrategyName)
|
|
100
107
|
: "";
|
|
108
|
+
message.repayStablecoinInterestDebt =
|
|
109
|
+
object.repayStablecoinInterestDebt !== undefined &&
|
|
110
|
+
object.repayStablecoinInterestDebt !== null
|
|
111
|
+
? Boolean(object.repayStablecoinInterestDebt)
|
|
112
|
+
: false;
|
|
101
113
|
message.loanToValue =
|
|
102
114
|
object.loanToValue !== undefined && object.loanToValue !== null
|
|
103
115
|
? String(object.loanToValue)
|
|
@@ -127,6 +139,8 @@ exports.AssetParams = {
|
|
|
127
139
|
message.oracleId !== undefined && (obj.oracleId = message.oracleId);
|
|
128
140
|
message.rateStrategyName !== undefined &&
|
|
129
141
|
(obj.rateStrategyName = message.rateStrategyName);
|
|
142
|
+
message.repayStablecoinInterestDebt !== undefined &&
|
|
143
|
+
(obj.repayStablecoinInterestDebt = message.repayStablecoinInterestDebt);
|
|
130
144
|
message.loanToValue !== undefined &&
|
|
131
145
|
(obj.loanToValue = message.loanToValue);
|
|
132
146
|
message.liquidationThreshold !== undefined &&
|
|
@@ -138,16 +152,18 @@ exports.AssetParams = {
|
|
|
138
152
|
return obj;
|
|
139
153
|
},
|
|
140
154
|
fromPartial(object) {
|
|
141
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
155
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
142
156
|
const message = Object.assign({}, baseAssetParams);
|
|
143
157
|
message.denom = (_a = object.denom) !== null && _a !== void 0 ? _a : "";
|
|
144
158
|
message.oracleId = (_b = object.oracleId) !== null && _b !== void 0 ? _b : "";
|
|
145
159
|
message.rateStrategyName = (_c = object.rateStrategyName) !== null && _c !== void 0 ? _c : "";
|
|
146
|
-
message.
|
|
147
|
-
|
|
148
|
-
message.
|
|
149
|
-
message.
|
|
150
|
-
message.
|
|
160
|
+
message.repayStablecoinInterestDebt =
|
|
161
|
+
(_d = object.repayStablecoinInterestDebt) !== null && _d !== void 0 ? _d : false;
|
|
162
|
+
message.loanToValue = (_e = object.loanToValue) !== null && _e !== void 0 ? _e : "";
|
|
163
|
+
message.liquidationThreshold = (_f = object.liquidationThreshold) !== null && _f !== void 0 ? _f : "";
|
|
164
|
+
message.liquidationBonus = (_g = object.liquidationBonus) !== null && _g !== void 0 ? _g : "";
|
|
165
|
+
message.supplyCap = (_h = object.supplyCap) !== null && _h !== void 0 ? _h : "";
|
|
166
|
+
message.borrowCap = (_j = object.borrowCap) !== null && _j !== void 0 ? _j : "";
|
|
151
167
|
return message;
|
|
152
168
|
},
|
|
153
169
|
};
|
|
@@ -4,10 +4,9 @@ export declare const protobufPackage = "Switcheo.carbon.cdp";
|
|
|
4
4
|
export interface DebtInfo {
|
|
5
5
|
denom: string;
|
|
6
6
|
lastUpdatedTime?: Date;
|
|
7
|
-
totalAccInterest: string;
|
|
8
7
|
totalPrincipal: string;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
cumulativeInterestMultiplier: string;
|
|
9
|
+
initialCumulativeInterestMultiplier: string;
|
|
11
10
|
utilizationRate: string;
|
|
12
11
|
}
|
|
13
12
|
export declare const DebtInfo: {
|
|
@@ -11,10 +11,9 @@ const timestamp_1 = require("../google/protobuf/timestamp");
|
|
|
11
11
|
exports.protobufPackage = "Switcheo.carbon.cdp";
|
|
12
12
|
const baseDebtInfo = {
|
|
13
13
|
denom: "",
|
|
14
|
-
totalAccInterest: "",
|
|
15
14
|
totalPrincipal: "",
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
cumulativeInterestMultiplier: "",
|
|
16
|
+
initialCumulativeInterestMultiplier: "",
|
|
18
17
|
utilizationRate: "",
|
|
19
18
|
};
|
|
20
19
|
exports.DebtInfo = {
|
|
@@ -25,20 +24,17 @@ exports.DebtInfo = {
|
|
|
25
24
|
if (message.lastUpdatedTime !== undefined) {
|
|
26
25
|
timestamp_1.Timestamp.encode(toTimestamp(message.lastUpdatedTime), writer.uint32(18).fork()).ldelim();
|
|
27
26
|
}
|
|
28
|
-
if (message.totalAccInterest !== "") {
|
|
29
|
-
writer.uint32(26).string(message.totalAccInterest);
|
|
30
|
-
}
|
|
31
27
|
if (message.totalPrincipal !== "") {
|
|
32
|
-
writer.uint32(
|
|
28
|
+
writer.uint32(26).string(message.totalPrincipal);
|
|
33
29
|
}
|
|
34
|
-
if (message.
|
|
35
|
-
writer.uint32(
|
|
30
|
+
if (message.cumulativeInterestMultiplier !== "") {
|
|
31
|
+
writer.uint32(34).string(message.cumulativeInterestMultiplier);
|
|
36
32
|
}
|
|
37
|
-
if (message.
|
|
38
|
-
writer.uint32(
|
|
33
|
+
if (message.initialCumulativeInterestMultiplier !== "") {
|
|
34
|
+
writer.uint32(42).string(message.initialCumulativeInterestMultiplier);
|
|
39
35
|
}
|
|
40
36
|
if (message.utilizationRate !== "") {
|
|
41
|
-
writer.uint32(
|
|
37
|
+
writer.uint32(50).string(message.utilizationRate);
|
|
42
38
|
}
|
|
43
39
|
return writer;
|
|
44
40
|
},
|
|
@@ -56,18 +52,15 @@ exports.DebtInfo = {
|
|
|
56
52
|
message.lastUpdatedTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
57
53
|
break;
|
|
58
54
|
case 3:
|
|
59
|
-
message.
|
|
55
|
+
message.totalPrincipal = reader.string();
|
|
60
56
|
break;
|
|
61
57
|
case 4:
|
|
62
|
-
message.
|
|
58
|
+
message.cumulativeInterestMultiplier = reader.string();
|
|
63
59
|
break;
|
|
64
60
|
case 5:
|
|
65
|
-
message.
|
|
61
|
+
message.initialCumulativeInterestMultiplier = reader.string();
|
|
66
62
|
break;
|
|
67
63
|
case 6:
|
|
68
|
-
message.totalPaidInterest = reader.string();
|
|
69
|
-
break;
|
|
70
|
-
case 7:
|
|
71
64
|
message.utilizationRate = reader.string();
|
|
72
65
|
break;
|
|
73
66
|
default:
|
|
@@ -87,23 +80,19 @@ exports.DebtInfo = {
|
|
|
87
80
|
object.lastUpdatedTime !== undefined && object.lastUpdatedTime !== null
|
|
88
81
|
? fromJsonTimestamp(object.lastUpdatedTime)
|
|
89
82
|
: undefined;
|
|
90
|
-
message.totalAccInterest =
|
|
91
|
-
object.totalAccInterest !== undefined && object.totalAccInterest !== null
|
|
92
|
-
? String(object.totalAccInterest)
|
|
93
|
-
: "";
|
|
94
83
|
message.totalPrincipal =
|
|
95
84
|
object.totalPrincipal !== undefined && object.totalPrincipal !== null
|
|
96
85
|
? String(object.totalPrincipal)
|
|
97
86
|
: "";
|
|
98
|
-
message.
|
|
99
|
-
object.
|
|
100
|
-
object.
|
|
101
|
-
? String(object.
|
|
87
|
+
message.cumulativeInterestMultiplier =
|
|
88
|
+
object.cumulativeInterestMultiplier !== undefined &&
|
|
89
|
+
object.cumulativeInterestMultiplier !== null
|
|
90
|
+
? String(object.cumulativeInterestMultiplier)
|
|
102
91
|
: "";
|
|
103
|
-
message.
|
|
104
|
-
object.
|
|
105
|
-
object.
|
|
106
|
-
? String(object.
|
|
92
|
+
message.initialCumulativeInterestMultiplier =
|
|
93
|
+
object.initialCumulativeInterestMultiplier !== undefined &&
|
|
94
|
+
object.initialCumulativeInterestMultiplier !== null
|
|
95
|
+
? String(object.initialCumulativeInterestMultiplier)
|
|
107
96
|
: "";
|
|
108
97
|
message.utilizationRate =
|
|
109
98
|
object.utilizationRate !== undefined && object.utilizationRate !== null
|
|
@@ -116,28 +105,28 @@ exports.DebtInfo = {
|
|
|
116
105
|
message.denom !== undefined && (obj.denom = message.denom);
|
|
117
106
|
message.lastUpdatedTime !== undefined &&
|
|
118
107
|
(obj.lastUpdatedTime = message.lastUpdatedTime.toISOString());
|
|
119
|
-
message.totalAccInterest !== undefined &&
|
|
120
|
-
(obj.totalAccInterest = message.totalAccInterest);
|
|
121
108
|
message.totalPrincipal !== undefined &&
|
|
122
109
|
(obj.totalPrincipal = message.totalPrincipal);
|
|
123
|
-
message.
|
|
124
|
-
(obj.
|
|
125
|
-
message.
|
|
126
|
-
(obj.
|
|
110
|
+
message.cumulativeInterestMultiplier !== undefined &&
|
|
111
|
+
(obj.cumulativeInterestMultiplier = message.cumulativeInterestMultiplier);
|
|
112
|
+
message.initialCumulativeInterestMultiplier !== undefined &&
|
|
113
|
+
(obj.initialCumulativeInterestMultiplier =
|
|
114
|
+
message.initialCumulativeInterestMultiplier);
|
|
127
115
|
message.utilizationRate !== undefined &&
|
|
128
116
|
(obj.utilizationRate = message.utilizationRate);
|
|
129
117
|
return obj;
|
|
130
118
|
},
|
|
131
119
|
fromPartial(object) {
|
|
132
|
-
var _a, _b, _c, _d, _e, _f
|
|
120
|
+
var _a, _b, _c, _d, _e, _f;
|
|
133
121
|
const message = Object.assign({}, baseDebtInfo);
|
|
134
122
|
message.denom = (_a = object.denom) !== null && _a !== void 0 ? _a : "";
|
|
135
123
|
message.lastUpdatedTime = (_b = object.lastUpdatedTime) !== null && _b !== void 0 ? _b : undefined;
|
|
136
|
-
message.
|
|
137
|
-
message.
|
|
138
|
-
|
|
139
|
-
message.
|
|
140
|
-
|
|
124
|
+
message.totalPrincipal = (_c = object.totalPrincipal) !== null && _c !== void 0 ? _c : "";
|
|
125
|
+
message.cumulativeInterestMultiplier =
|
|
126
|
+
(_d = object.cumulativeInterestMultiplier) !== null && _d !== void 0 ? _d : "";
|
|
127
|
+
message.initialCumulativeInterestMultiplier =
|
|
128
|
+
(_e = object.initialCumulativeInterestMultiplier) !== null && _e !== void 0 ? _e : "";
|
|
129
|
+
message.utilizationRate = (_f = object.utilizationRate) !== null && _f !== void 0 ? _f : "";
|
|
141
130
|
return message;
|
|
142
131
|
},
|
|
143
132
|
};
|
|
@@ -4,10 +4,9 @@ export declare const protobufPackage = "Switcheo.carbon.cdp";
|
|
|
4
4
|
export interface StablecoinDebtInfo {
|
|
5
5
|
denom: string;
|
|
6
6
|
lastUpdatedTime?: Date;
|
|
7
|
-
totalAccInterest: string;
|
|
8
7
|
totalPrincipal: string;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
cumulativeInterestMultiplier: string;
|
|
9
|
+
initialCumulativeInterestMultiplier: string;
|
|
11
10
|
}
|
|
12
11
|
export declare const StablecoinDebtInfo: {
|
|
13
12
|
encode(message: StablecoinDebtInfo, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -11,10 +11,9 @@ const timestamp_1 = require("../google/protobuf/timestamp");
|
|
|
11
11
|
exports.protobufPackage = "Switcheo.carbon.cdp";
|
|
12
12
|
const baseStablecoinDebtInfo = {
|
|
13
13
|
denom: "",
|
|
14
|
-
totalAccInterest: "",
|
|
15
14
|
totalPrincipal: "",
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
cumulativeInterestMultiplier: "",
|
|
16
|
+
initialCumulativeInterestMultiplier: "",
|
|
18
17
|
};
|
|
19
18
|
exports.StablecoinDebtInfo = {
|
|
20
19
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -24,17 +23,14 @@ exports.StablecoinDebtInfo = {
|
|
|
24
23
|
if (message.lastUpdatedTime !== undefined) {
|
|
25
24
|
timestamp_1.Timestamp.encode(toTimestamp(message.lastUpdatedTime), writer.uint32(18).fork()).ldelim();
|
|
26
25
|
}
|
|
27
|
-
if (message.totalAccInterest !== "") {
|
|
28
|
-
writer.uint32(26).string(message.totalAccInterest);
|
|
29
|
-
}
|
|
30
26
|
if (message.totalPrincipal !== "") {
|
|
31
|
-
writer.uint32(
|
|
27
|
+
writer.uint32(26).string(message.totalPrincipal);
|
|
32
28
|
}
|
|
33
|
-
if (message.
|
|
34
|
-
writer.uint32(
|
|
29
|
+
if (message.cumulativeInterestMultiplier !== "") {
|
|
30
|
+
writer.uint32(34).string(message.cumulativeInterestMultiplier);
|
|
35
31
|
}
|
|
36
|
-
if (message.
|
|
37
|
-
writer.uint32(
|
|
32
|
+
if (message.initialCumulativeInterestMultiplier !== "") {
|
|
33
|
+
writer.uint32(42).string(message.initialCumulativeInterestMultiplier);
|
|
38
34
|
}
|
|
39
35
|
return writer;
|
|
40
36
|
},
|
|
@@ -52,16 +48,13 @@ exports.StablecoinDebtInfo = {
|
|
|
52
48
|
message.lastUpdatedTime = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
53
49
|
break;
|
|
54
50
|
case 3:
|
|
55
|
-
message.
|
|
51
|
+
message.totalPrincipal = reader.string();
|
|
56
52
|
break;
|
|
57
53
|
case 4:
|
|
58
|
-
message.
|
|
54
|
+
message.cumulativeInterestMultiplier = reader.string();
|
|
59
55
|
break;
|
|
60
56
|
case 5:
|
|
61
|
-
message.
|
|
62
|
-
break;
|
|
63
|
-
case 6:
|
|
64
|
-
message.totalPaidInterest = reader.string();
|
|
57
|
+
message.initialCumulativeInterestMultiplier = reader.string();
|
|
65
58
|
break;
|
|
66
59
|
default:
|
|
67
60
|
reader.skipType(tag & 7);
|
|
@@ -80,23 +73,19 @@ exports.StablecoinDebtInfo = {
|
|
|
80
73
|
object.lastUpdatedTime !== undefined && object.lastUpdatedTime !== null
|
|
81
74
|
? fromJsonTimestamp(object.lastUpdatedTime)
|
|
82
75
|
: undefined;
|
|
83
|
-
message.totalAccInterest =
|
|
84
|
-
object.totalAccInterest !== undefined && object.totalAccInterest !== null
|
|
85
|
-
? String(object.totalAccInterest)
|
|
86
|
-
: "";
|
|
87
76
|
message.totalPrincipal =
|
|
88
77
|
object.totalPrincipal !== undefined && object.totalPrincipal !== null
|
|
89
78
|
? String(object.totalPrincipal)
|
|
90
79
|
: "";
|
|
91
|
-
message.
|
|
92
|
-
object.
|
|
93
|
-
object.
|
|
94
|
-
? String(object.
|
|
80
|
+
message.cumulativeInterestMultiplier =
|
|
81
|
+
object.cumulativeInterestMultiplier !== undefined &&
|
|
82
|
+
object.cumulativeInterestMultiplier !== null
|
|
83
|
+
? String(object.cumulativeInterestMultiplier)
|
|
95
84
|
: "";
|
|
96
|
-
message.
|
|
97
|
-
object.
|
|
98
|
-
object.
|
|
99
|
-
? String(object.
|
|
85
|
+
message.initialCumulativeInterestMultiplier =
|
|
86
|
+
object.initialCumulativeInterestMultiplier !== undefined &&
|
|
87
|
+
object.initialCumulativeInterestMultiplier !== null
|
|
88
|
+
? String(object.initialCumulativeInterestMultiplier)
|
|
100
89
|
: "";
|
|
101
90
|
return message;
|
|
102
91
|
},
|
|
@@ -105,25 +94,25 @@ exports.StablecoinDebtInfo = {
|
|
|
105
94
|
message.denom !== undefined && (obj.denom = message.denom);
|
|
106
95
|
message.lastUpdatedTime !== undefined &&
|
|
107
96
|
(obj.lastUpdatedTime = message.lastUpdatedTime.toISOString());
|
|
108
|
-
message.totalAccInterest !== undefined &&
|
|
109
|
-
(obj.totalAccInterest = message.totalAccInterest);
|
|
110
97
|
message.totalPrincipal !== undefined &&
|
|
111
98
|
(obj.totalPrincipal = message.totalPrincipal);
|
|
112
|
-
message.
|
|
113
|
-
(obj.
|
|
114
|
-
message.
|
|
115
|
-
(obj.
|
|
99
|
+
message.cumulativeInterestMultiplier !== undefined &&
|
|
100
|
+
(obj.cumulativeInterestMultiplier = message.cumulativeInterestMultiplier);
|
|
101
|
+
message.initialCumulativeInterestMultiplier !== undefined &&
|
|
102
|
+
(obj.initialCumulativeInterestMultiplier =
|
|
103
|
+
message.initialCumulativeInterestMultiplier);
|
|
116
104
|
return obj;
|
|
117
105
|
},
|
|
118
106
|
fromPartial(object) {
|
|
119
|
-
var _a, _b, _c, _d, _e
|
|
107
|
+
var _a, _b, _c, _d, _e;
|
|
120
108
|
const message = Object.assign({}, baseStablecoinDebtInfo);
|
|
121
109
|
message.denom = (_a = object.denom) !== null && _a !== void 0 ? _a : "";
|
|
122
110
|
message.lastUpdatedTime = (_b = object.lastUpdatedTime) !== null && _b !== void 0 ? _b : undefined;
|
|
123
|
-
message.
|
|
124
|
-
message.
|
|
125
|
-
|
|
126
|
-
message.
|
|
111
|
+
message.totalPrincipal = (_c = object.totalPrincipal) !== null && _c !== void 0 ? _c : "";
|
|
112
|
+
message.cumulativeInterestMultiplier =
|
|
113
|
+
(_d = object.cumulativeInterestMultiplier) !== null && _d !== void 0 ? _d : "";
|
|
114
|
+
message.initialCumulativeInterestMultiplier =
|
|
115
|
+
(_e = object.initialCumulativeInterestMultiplier) !== null && _e !== void 0 ? _e : "";
|
|
127
116
|
return message;
|
|
128
117
|
},
|
|
129
118
|
};
|
|
@@ -38,6 +38,9 @@ export interface NetworkConfig {
|
|
|
38
38
|
faucetUrl: string;
|
|
39
39
|
Bech32Prefix: string;
|
|
40
40
|
network: Network;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated on-chain fee service has been removed, please use the hydrogen fee_quote endpoint to query deposit/withdraw fees (please see HydrogenClient for the required query)
|
|
43
|
+
*/
|
|
41
44
|
feeURL: string;
|
|
42
45
|
feeAddress: string;
|
|
43
46
|
eth: EthNetworkConfig;
|
package/lib/constant/network.js
CHANGED
|
@@ -21,6 +21,9 @@ exports.NetworkConfigs = {
|
|
|
21
21
|
wsUrl: "wss://ws-api.carbon.network/ws",
|
|
22
22
|
faucetUrl: "",
|
|
23
23
|
Bech32Prefix: "swth",
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated on-chain fee service has been removed, please use the hydrogen fee_quote endpoint to query deposit/withdraw fees (please see HydrogenClient for the required query)
|
|
26
|
+
*/
|
|
24
27
|
feeURL: "https://fees.carbon.network",
|
|
25
28
|
feeAddress: "08d8f59e475830d9a1bb97d74285c4d34c6dac08",
|
|
26
29
|
eth: {
|
|
@@ -66,6 +69,9 @@ exports.NetworkConfigs = {
|
|
|
66
69
|
wsUrl: "wss://test-ws-api.carbon.network/ws",
|
|
67
70
|
faucetUrl: "https://test-faucet.carbon.network",
|
|
68
71
|
Bech32Prefix: "tswth",
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated on-chain fee service has been removed, please use the hydrogen fee_quote endpoint to query deposit/withdraw fees (please see HydrogenClient for the required query)
|
|
74
|
+
*/
|
|
69
75
|
feeURL: `http://54.255.42.175:9001`,
|
|
70
76
|
feeAddress: "989761fb0c0eb0c05605e849cae77d239f98ac7f",
|
|
71
77
|
eth: {
|
|
@@ -111,6 +117,9 @@ exports.NetworkConfigs = {
|
|
|
111
117
|
wsUrl: "wss://dev-ws-api.carbon.network/ws",
|
|
112
118
|
faucetUrl: "https://dev-faucet.carbon.network",
|
|
113
119
|
Bech32Prefix: "swth",
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated on-chain fee service has been removed, please use the hydrogen fee_quote endpoint to query deposit/withdraw fees (please see HydrogenClient for the required query)
|
|
122
|
+
*/
|
|
114
123
|
feeURL: `https://dev-fees.carbon.network`,
|
|
115
124
|
feeAddress: "989761fb0c0eb0c05605e849cae77d239f98ac7f",
|
|
116
125
|
eth: {
|
|
@@ -156,6 +165,9 @@ exports.NetworkConfigs = {
|
|
|
156
165
|
wsUrl: "ws://localhost:5000/ws",
|
|
157
166
|
faucetUrl: "http://localhost:4500",
|
|
158
167
|
Bech32Prefix: "tswth",
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated on-chain fee service has been removed, please use the hydrogen fee_quote endpoint to query deposit/withdraw fees (please see HydrogenClient for the required query)
|
|
170
|
+
*/
|
|
159
171
|
feeURL: `http://localhost:9001`,
|
|
160
172
|
feeAddress: "989761fb0c0eb0c05605e849cae77d239f98ac7f",
|
|
161
173
|
eth: {
|
package/lib/modules/fee.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetFeeQuoteResponse } from "../hydrogen/feeQuote";
|
|
2
2
|
import BaseModule from "./base";
|
|
3
3
|
export declare class FeeModule extends BaseModule {
|
|
4
|
-
getDepositWithdrawalFees(denom: string): Promise<
|
|
4
|
+
getDepositWithdrawalFees(denom: string): Promise<GetFeeQuoteResponse>;
|
|
5
5
|
}
|
package/lib/modules/fee.js
CHANGED
|
@@ -13,15 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.FeeModule = void 0;
|
|
16
|
-
const util_1 = require("../util");
|
|
17
16
|
const base_1 = __importDefault(require("./base"));
|
|
18
17
|
class FeeModule extends base_1.default {
|
|
19
18
|
getDepositWithdrawalFees(denom) {
|
|
20
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
20
|
+
const feeInfo = yield this.sdkProvider.hydrogen.getFeeQuote({
|
|
21
|
+
token_denom: denom,
|
|
22
|
+
});
|
|
23
|
+
return feeInfo;
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CarbonQueryClient, TokenClient } from "../../clients";
|
|
1
|
+
import { CarbonQueryClient, HydrogenClient, TokenClient } from "../../clients";
|
|
2
2
|
import { NetworkConfig } from "../../constant/network";
|
|
3
3
|
import { CarbonWallet } from "../../wallet/CarbonWallet";
|
|
4
4
|
interface SDKProvider {
|
|
5
|
+
hydrogen: HydrogenClient;
|
|
5
6
|
query: CarbonQueryClient;
|
|
6
7
|
getTokenClient(): TokenClient;
|
|
7
8
|
log: (...args: any[]) => void;
|