carbon-js-sdk 0.3.59 → 0.4.0
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 +1 -1
- package/lib/clients/ZILClient.js +17 -17
- package/lib/codec/bank/query.d.ts +1 -1
- package/lib/codec/bank/query.js +1 -1
- package/lib/codec/broker/query.d.ts +1 -4
- package/lib/codec/broker/query.js +4 -47
- package/lib/codec/cdp/event.d.ts +2 -0
- package/lib/codec/cdp/event.js +16 -1
- package/lib/codec/cdp/genesis.d.ts +3 -1
- package/lib/codec/cdp/genesis.js +21 -0
- package/lib/codec/cdp/params.d.ts +6 -0
- package/lib/codec/cdp/params.js +41 -1
- package/lib/codec/cdp/query.d.ts +23 -0
- package/lib/codec/cdp/query.js +92 -1
- package/lib/codec/{crisis/genesis.d.ts → cdp/stablecoin_interest_info.d.ts} +10 -9
- package/lib/codec/cdp/stablecoin_interest_info.js +99 -0
- package/lib/codec/cdp/tx.d.ts +20 -20
- package/lib/codec/cdp/tx.js +43 -43
- package/lib/codec/cosmos/auth/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/auth/v1beta1/export.js +13 -1
- package/lib/codec/cosmos/auth/v1beta1/query.d.ts +213 -0
- package/lib/codec/cosmos/auth/v1beta1/query.js +602 -1
- package/lib/codec/cosmos/authz/v1beta1/authz.d.ts +17 -2
- package/lib/codec/cosmos/authz/v1beta1/authz.js +50 -1
- package/lib/codec/cosmos/authz/v1beta1/query.d.ts +2 -2
- package/lib/codec/cosmos/bank/v1beta1/bank.d.ts +14 -1
- package/lib/codec/cosmos/bank/v1beta1/bank.js +25 -1
- package/lib/codec/cosmos/bank/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/bank/v1beta1/export.js +4 -1
- package/lib/codec/cosmos/bank/v1beta1/query.d.ts +73 -1
- package/lib/codec/cosmos/bank/v1beta1/query.js +200 -1
- package/lib/codec/cosmos/base/abci/v1beta1/abci.d.ts +24 -1
- package/lib/codec/cosmos/base/abci/v1beta1/abci.js +34 -4
- package/lib/codec/cosmos/base/query/v1beta1/pagination.d.ts +2 -1
- package/lib/codec/cosmos/base/snapshots/v1beta1/snapshot.d.ts +58 -5
- package/lib/codec/cosmos/base/snapshots/v1beta1/snapshot.js +145 -1
- package/lib/codec/cosmos/base/store/v1beta1/listening.d.ts +32 -0
- package/lib/codec/cosmos/base/store/v1beta1/listening.js +213 -1
- package/lib/codec/cosmos/base/store/v1beta1/snapshot.d.ts +45 -0
- package/lib/codec/cosmos/base/store/v1beta1/snapshot.js +246 -0
- package/lib/codec/cosmos/base/tendermint/v1beta1/query.d.ts +129 -9
- package/lib/codec/cosmos/base/tendermint/v1beta1/query.js +457 -7
- package/lib/codec/cosmos/distribution/v1beta1/tx.d.ts +12 -8
- package/lib/codec/cosmos/distribution/v1beta1/tx.js +42 -8
- package/lib/codec/cosmos/feegrant/v1beta1/feegrant.d.ts +5 -5
- package/lib/codec/cosmos/feegrant/v1beta1/query.d.ts +12 -3
- package/lib/codec/cosmos/feegrant/v1beta1/tx.d.ts +1 -1
- package/lib/codec/cosmos/gov/v1beta1/gov.d.ts +6 -1
- package/lib/codec/cosmos/gov/v1beta1/gov.js +1 -1
- package/lib/codec/cosmos/gov/v1beta1/query.d.ts +1 -1
- package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
- package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
- package/lib/codec/cosmos/params/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/params/v1beta1/export.js +4 -1
- package/lib/codec/cosmos/params/v1beta1/query.d.ts +55 -0
- package/lib/codec/cosmos/params/v1beta1/query.js +149 -1
- package/lib/codec/cosmos/staking/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/staking/v1beta1/export.js +3 -1
- package/lib/codec/cosmos/staking/v1beta1/query.d.ts +3 -3
- package/lib/codec/cosmos/staking/v1beta1/staking.d.ts +7 -1
- package/lib/codec/cosmos/staking/v1beta1/staking.js +16 -1
- package/lib/codec/cosmos/staking/v1beta1/tx.d.ts +42 -0
- package/lib/codec/cosmos/staking/v1beta1/tx.js +134 -1
- package/lib/codec/cosmos/tx/signing/v1beta1/signing.d.ts +23 -5
- package/lib/codec/cosmos/tx/signing/v1beta1/signing.js +28 -5
- package/lib/codec/cosmos/tx/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/tx/v1beta1/export.js +4 -1
- package/lib/codec/cosmos/tx/v1beta1/service.d.ts +21 -2
- package/lib/codec/cosmos/tx/v1beta1/service.js +55 -2
- package/lib/codec/cosmos/tx/v1beta1/tx.d.ts +101 -0
- package/lib/codec/cosmos/tx/v1beta1/tx.js +298 -3
- package/lib/codec/cosmos/upgrade/v1beta1/query.d.ts +36 -0
- package/lib/codec/cosmos/upgrade/v1beta1/query.js +84 -1
- package/lib/codec/cosmos/upgrade/v1beta1/upgrade.d.ts +8 -0
- package/lib/codec/cosmos/vesting/v1beta1/export.d.ts +1 -1
- package/lib/codec/cosmos/vesting/v1beta1/export.js +5 -1
- package/lib/codec/cosmos/vesting/v1beta1/tx.d.ts +83 -0
- package/lib/codec/cosmos/vesting/v1beta1/tx.js +251 -1
- package/lib/codec/google/protobuf/any.d.ts +8 -5
- package/lib/codec/ibc/applications/interchain_accounts/controller/export.d.ts +1 -0
- package/lib/codec/ibc/applications/interchain_accounts/controller/export.js +6 -1
- package/lib/codec/ibc/applications/interchain_accounts/v1/export.d.ts +0 -1
- package/lib/codec/ibc/applications/interchain_accounts/v1/export.js +1 -6
- package/lib/codec/ibc/core/channel/v1/channel.d.ts +20 -0
- package/lib/codec/ibc/core/channel/v1/channel.js +78 -1
- package/lib/codec/ibc/core/channel/v1/export.d.ts +1 -1
- package/lib/codec/ibc/core/channel/v1/export.js +3 -2
- package/lib/codec/ibc/core/channel/v1/tx.d.ts +3 -2
- package/lib/codec/ibc/core/client/v1/query.d.ts +1 -1
- package/lib/codec/ibc/core/connection/v1/export.d.ts +1 -1
- package/lib/codec/ibc/core/connection/v1/export.js +3 -1
- package/lib/codec/ibc/core/connection/v1/query.d.ts +26 -1
- package/lib/codec/ibc/core/connection/v1/query.js +87 -1
- package/lib/codec/ibc/core/connection/v1/tx.d.ts +3 -2
- package/lib/codec/index.d.ts +88 -15
- package/lib/codec/index.js +858 -701
- package/lib/codec/liquidation/query.d.ts +3 -2
- package/lib/codec/liquidation/query.js +39 -32
- package/lib/codec/misc/query.d.ts +1 -1
- package/lib/codec/misc/query.js +1 -1
- package/lib/codec/oracle/event.d.ts +1 -0
- package/lib/codec/oracle/event.js +15 -1
- package/lib/codec/order/query.d.ts +1 -1
- package/lib/codec/order/query.js +1 -1
- package/lib/codec/position/query.d.ts +1 -2
- package/lib/codec/position/query.js +3 -16
- package/lib/codec/proofs.d.ts +1 -0
- package/lib/codec/proofs.js +6 -0
- package/lib/codec/tendermint/abci/types.d.ts +8 -0
- package/lib/codec/tendermint/abci/types.js +45 -1
- package/lib/constant/generic.js +1 -1
- package/lib/modules/admin.d.ts +0 -1
- package/lib/modules/admin.js +0 -13
- package/lib/modules/cdp.js +43 -43
- package/lib/modules/cosmwasm.js +1 -1
- package/lib/modules/gov.js +12 -12
- package/lib/modules/liquiditypool.d.ts +0 -2
- package/lib/modules/liquiditypool.js +1 -34
- 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 -28
- 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/fetch.js +1 -1
- package/lib/util/generic.js +3 -3
- package/lib/util/number.js +5 -5
- package/lib/util/tx.d.ts +80 -10
- 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/codec/cosmos/app/v1alpha1/export.d.ts +0 -3
- package/lib/codec/cosmos/app/v1alpha1/export.js +0 -13
- package/lib/codec/cosmos/authz/v1beta1/export.d.ts +0 -4
- package/lib/codec/cosmos/authz/v1beta1/export.js +0 -25
- package/lib/codec/cosmos/capability/v1beta1/export.d.ts +0 -2
- package/lib/codec/cosmos/capability/v1beta1/export.js +0 -9
- package/lib/codec/cosmos/crisis/v1beta1/export.d.ts +0 -1
- package/lib/codec/cosmos/crisis/v1beta1/export.js +0 -6
- package/lib/codec/cosmos/evidence/v1beta1/export.d.ts +0 -3
- package/lib/codec/cosmos/evidence/v1beta1/export.js +0 -13
- package/lib/codec/cosmos/feegrant/v1beta1/export.d.ts +0 -3
- package/lib/codec/cosmos/feegrant/v1beta1/export.js +0 -20
- package/lib/codec/cosmos/gov/v1/export.d.ts +0 -3
- package/lib/codec/cosmos/gov/v1/export.js +0 -46
- package/lib/codec/cosmos/group/v1/export.d.ts +0 -4
- package/lib/codec/cosmos/group/v1/export.js +0 -94
- package/lib/codec/cosmos/nft/v1beta1/export.d.ts +0 -5
- package/lib/codec/cosmos/nft/v1beta1/export.js +0 -30
- package/lib/codec/cosmos/orm/v1/export.d.ts +0 -1
- package/lib/codec/cosmos/orm/v1/export.js +0 -8
- package/lib/codec/cosmos/orm/v1alpha1/export.d.ts +0 -1
- package/lib/codec/cosmos/orm/v1alpha1/export.js +0 -9
- package/lib/codec/cosmos/upgrade/v1beta1/export.d.ts +0 -3
- package/lib/codec/cosmos/upgrade/v1beta1/export.js +0 -24
- package/lib/codec/crisis/genesis.js +0 -46
- package/lib/codec/crisis/query.d.ts +0 -43
- package/lib/codec/crisis/query.js +0 -103
- package/lib/codec/crisis/tx.d.ts +0 -12
- package/lib/codec/crisis/tx.js +0 -20
- package/lib/codec/ibc/applications/fee/v1/export.d.ts +0 -6
- package/lib/codec/ibc/applications/fee/v1/export.js +0 -47
- package/lib/codec/liquiditypool/legacy.d.ts +0 -18
- package/lib/codec/liquiditypool/legacy.js +0 -64
|
@@ -47,7 +47,7 @@ class CarbonQueryClient {
|
|
|
47
47
|
constructor(tmClient) {
|
|
48
48
|
this.tmClient = tmClient;
|
|
49
49
|
this.baseClient = new stargate_1.QueryClient(this.tmClient);
|
|
50
|
-
const rpcClient =
|
|
50
|
+
const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
|
|
51
51
|
this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
|
|
52
52
|
this.adl = new query_1.QueryClientImpl(rpcClient);
|
|
53
53
|
this.book = new query_2.QueryClientImpl(rpcClient);
|
|
@@ -91,7 +91,7 @@ class CarbonQueryClient {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
getProtobufRpcClient() {
|
|
94
|
-
return
|
|
94
|
+
return stargate_1.createProtobufRpcClient(this.baseClient);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
exports.default = CarbonQueryClient;
|
package/lib/clients/ETHClient.js
CHANGED
|
@@ -39,13 +39,13 @@ class ETHClient {
|
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const tokenQueryResults = yield api.token.getAllTokens();
|
|
41
41
|
const lockProxyAddress = this.getLockProxyAddress().toLowerCase();
|
|
42
|
-
const tokens = tokenQueryResults.filter((token) =>
|
|
42
|
+
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber(), api.network) == this.blockchain &&
|
|
43
43
|
token.tokenAddress.length == 40 &&
|
|
44
|
-
token.bridgeAddress.toLowerCase() ==
|
|
44
|
+
token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
|
|
45
45
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
|
|
46
|
-
this.verifyChecksum(
|
|
46
|
+
this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress)));
|
|
47
47
|
const assetIds = tokens.map((token) => {
|
|
48
|
-
return this.verifyChecksum(
|
|
48
|
+
return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
|
|
49
49
|
});
|
|
50
50
|
const provider = this.getProvider();
|
|
51
51
|
const contractAddress = this.getBalanceReaderAddress();
|
|
@@ -96,14 +96,14 @@ class ETHClient {
|
|
|
96
96
|
}
|
|
97
97
|
const carbonNetwork = networkConfig.network;
|
|
98
98
|
const fromTokenId = fromToken.id;
|
|
99
|
-
const fromTokenAddress =
|
|
99
|
+
const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
100
100
|
const toTokenDenom = toToken.denom;
|
|
101
101
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
102
102
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
103
103
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
104
104
|
const nonce = yield rpcProvider.getTransactionCount(fromAddress);
|
|
105
105
|
const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
|
|
106
|
-
const feeAddress =
|
|
106
|
+
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
107
107
|
const tokenCreator = fromToken.creator;
|
|
108
108
|
const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, carbonNetwork);
|
|
109
109
|
const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
|
|
@@ -138,9 +138,9 @@ class ETHClient {
|
|
|
138
138
|
throw new Error("Minimum gas required: 150,000");
|
|
139
139
|
}
|
|
140
140
|
const networkConfig = this.getNetworkConfig();
|
|
141
|
-
const assetId =
|
|
142
|
-
const targetProxyHash =
|
|
143
|
-
const feeAddress =
|
|
141
|
+
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
142
|
+
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
143
|
+
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
144
144
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
145
145
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
146
146
|
const contractAddress = this.getLockProxyAddress();
|
|
@@ -191,16 +191,16 @@ class ETHClient {
|
|
|
191
191
|
return "insufficient balance";
|
|
192
192
|
}
|
|
193
193
|
const networkConfig = this.getNetworkConfig();
|
|
194
|
-
const assetId =
|
|
195
|
-
const targetProxyHash =
|
|
196
|
-
const feeAddress =
|
|
194
|
+
const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
|
|
195
|
+
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
|
|
196
|
+
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
197
197
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
|
|
198
198
|
const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
|
|
199
199
|
const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
|
|
200
200
|
// logger("sendDeposit message", message)
|
|
201
201
|
let signatureResult;
|
|
202
202
|
const { address, signature } = yield getSignatureCallback(message);
|
|
203
|
-
const signatureBytes = ethers_1.ethers.utils.arrayify(
|
|
203
|
+
const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
|
|
204
204
|
const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
|
|
205
205
|
// logger("sign result", address, signature)
|
|
206
206
|
signatureResult = {
|
|
@@ -239,7 +239,7 @@ class ETHClient {
|
|
|
239
239
|
if (!feeInfo.deposit_fee) {
|
|
240
240
|
throw new Error("unsupported token");
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
242
|
+
if (blockchain_1.blockchainForChainId(token.chainId.toNumber(), this.configProvider.getConfig().network) !== this.blockchain) {
|
|
243
243
|
throw new Error("unsupported token");
|
|
244
244
|
}
|
|
245
245
|
let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
|
|
@@ -305,7 +305,7 @@ class ETHClient {
|
|
|
305
305
|
getTargetProxyHash(token) {
|
|
306
306
|
const networkConfig = this.getNetworkConfig();
|
|
307
307
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
308
|
-
const addressHex =
|
|
308
|
+
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
309
309
|
return addressHex;
|
|
310
310
|
}
|
|
311
311
|
getProvider() {
|
|
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
|
|
|
29
29
|
const formatDateField = (value) => {
|
|
30
30
|
if (typeof value !== "string")
|
|
31
31
|
return null;
|
|
32
|
-
return
|
|
32
|
+
return dayjs_1.default(value);
|
|
33
33
|
};
|
|
34
34
|
// temporary function to parse okt/okc blockchain
|
|
35
35
|
// to remove when automatic deposit/withdraw feature is deployed
|
package/lib/clients/NEOClient.js
CHANGED
|
@@ -64,13 +64,13 @@ class NEOClient {
|
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
66
66
|
const account = new Neon.wallet.Account(address);
|
|
67
|
-
const tokens = tokenQueryResults.filter((token) =>
|
|
67
|
+
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber(), sdk.network) == this.blockchain &&
|
|
68
68
|
token.tokenAddress.length == 40 &&
|
|
69
69
|
token.bridgeAddress.length == 40);
|
|
70
70
|
const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
|
|
71
71
|
// NOTE: fetching of tokens is chunked in sets of 15 as we may hit
|
|
72
72
|
// the gas limit on the RPC node and error out otherwise
|
|
73
|
-
const promises =
|
|
73
|
+
const promises = lodash_1.chunk(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
var _a, _b, _c;
|
|
75
75
|
let acc = {};
|
|
76
76
|
for (const token of partition) {
|
|
@@ -112,8 +112,8 @@ class NEOClient {
|
|
|
112
112
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
113
113
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
114
114
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
|
|
115
|
-
const toAddress =
|
|
116
|
-
const zeroAddressHex =
|
|
115
|
+
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
116
|
+
const zeroAddressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(constant_1.ZeroAddress));
|
|
117
117
|
const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
|
|
118
118
|
const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
|
|
119
119
|
const feeAddress = feeAmount.isZero() ? zeroAddressHex : networkConfig.feeAddress;
|
|
@@ -160,7 +160,7 @@ class NEOClient {
|
|
|
160
160
|
const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
|
|
161
161
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
162
162
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
163
|
-
const toAddress =
|
|
163
|
+
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
164
164
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
165
165
|
if (amount.lt(feeAmount)) {
|
|
166
166
|
throw new Error("Invalid amount");
|
|
@@ -196,7 +196,7 @@ class NEOClient {
|
|
|
196
196
|
const fromAddress = ledger.scriptHash;
|
|
197
197
|
const targetProxyHash = this.getTargetProxyHash(token);
|
|
198
198
|
const toAssetHash = Neon.u.str2hexstring(token.id);
|
|
199
|
-
const toAddress =
|
|
199
|
+
const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
|
|
200
200
|
const feeAddress = networkConfig.feeAddress;
|
|
201
201
|
const nonce = Math.floor(Math.random() * 1000000);
|
|
202
202
|
if (amount.lt(feeAmount)) {
|
|
@@ -316,7 +316,7 @@ class NEOClient {
|
|
|
316
316
|
getTargetProxyHash(token) {
|
|
317
317
|
const networkConfig = this.getNetworkConfig();
|
|
318
318
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
319
|
-
const addressHex =
|
|
319
|
+
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
320
320
|
return addressHex;
|
|
321
321
|
}
|
|
322
322
|
getNetworkConfig() {
|
|
@@ -459,7 +459,7 @@ class TokenClient {
|
|
|
459
459
|
processTokenPrices(tokenPrices) {
|
|
460
460
|
return tokenPrices.reduce((prevPrices, price) => {
|
|
461
461
|
const newPrev = prevPrices;
|
|
462
|
-
newPrev[price.denom] =
|
|
462
|
+
newPrev[price.denom] = number_1.bnOrZero(price.twap).shiftedBy(-constant_1.decTypeDecimals);
|
|
463
463
|
return newPrev;
|
|
464
464
|
}, {});
|
|
465
465
|
}
|
package/lib/clients/ZILClient.js
CHANGED
|
@@ -72,12 +72,12 @@ class ZILClient {
|
|
|
72
72
|
getExternalBalances(sdk, address, whitelistDenoms) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
const tokenQueryResults = yield sdk.token.getAllTokens();
|
|
75
|
-
const tokens = tokenQueryResults.filter((token) =>
|
|
75
|
+
const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber(), sdk.network) == this.blockchain &&
|
|
76
76
|
token.tokenAddress.length == 40 &&
|
|
77
77
|
(!whitelistDenoms || whitelistDenoms.includes(token.denom)));
|
|
78
78
|
const requests = tokens.map((token) => token.tokenAddress === zeroAddress
|
|
79
|
-
?
|
|
80
|
-
:
|
|
79
|
+
? exports.balanceBatchRequest(address.replace(/^0x/i, ""))
|
|
80
|
+
: exports.tokenBalanceBatchRequest(token.tokenAddress, address));
|
|
81
81
|
const response = yield fetch(this.getProviderUrl(), {
|
|
82
82
|
method: "post",
|
|
83
83
|
headers: { "content-type": "application/json" },
|
|
@@ -102,7 +102,7 @@ class ZILClient {
|
|
|
102
102
|
// if (!isValidAddress) {
|
|
103
103
|
// throw new Error("invalid address")
|
|
104
104
|
// }
|
|
105
|
-
return
|
|
105
|
+
return zilliqa_1.fromBech32Address(bech32Address).toLowerCase().substr(2);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
// see examplesV2/zil_client.ts on how to confirm the transactions
|
|
@@ -148,7 +148,7 @@ class ZILClient {
|
|
|
148
148
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
149
149
|
}
|
|
150
150
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
151
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(
|
|
151
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
152
152
|
if (balanceAndNonceResp.error !== undefined) {
|
|
153
153
|
throw new Error(balanceAndNonceResp.error.message);
|
|
154
154
|
}
|
|
@@ -166,7 +166,7 @@ class ZILClient {
|
|
|
166
166
|
vname: "spender",
|
|
167
167
|
type: "ByStr20",
|
|
168
168
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
169
|
-
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress :
|
|
169
|
+
value: spenderAddress !== null && spenderAddress !== void 0 ? spenderAddress : generic_1.appendHexPrefix(token.bridgeAddress),
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
vname: "amount",
|
|
@@ -184,7 +184,7 @@ class ZILClient {
|
|
|
184
184
|
}
|
|
185
185
|
checkAllowanceZRC2(token, owner, spender) {
|
|
186
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const contractAddress =
|
|
187
|
+
const contractAddress = generic_1.appendHexPrefix(token.tokenAddress);
|
|
188
188
|
const zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
189
189
|
const resp = yield zilliqa.blockchain.getSmartContractSubState(contractAddress, "allowances", [owner, spender]);
|
|
190
190
|
if (resp.error !== undefined) {
|
|
@@ -206,13 +206,13 @@ class ZILClient {
|
|
|
206
206
|
}
|
|
207
207
|
const carbonNetwork = networkConfig.network;
|
|
208
208
|
const fromTokenId = fromToken.id;
|
|
209
|
-
const fromTokenAddr =
|
|
209
|
+
const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
|
|
210
210
|
const toTokenDenom = toToken.denom;
|
|
211
|
-
const targetProxyHash =
|
|
211
|
+
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(fromToken));
|
|
212
212
|
const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, carbonNetwork));
|
|
213
213
|
const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
|
|
214
214
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
|
|
215
|
-
const feeAddress =
|
|
215
|
+
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
216
216
|
const contractAddress = this.getBridgeEntranceAddr();
|
|
217
217
|
let zilliqa;
|
|
218
218
|
if (typeof signer === "string") {
|
|
@@ -227,7 +227,7 @@ class ZILClient {
|
|
|
227
227
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
228
228
|
}
|
|
229
229
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
230
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(
|
|
230
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(fromAddress));
|
|
231
231
|
if (balanceAndNonceResp.error !== undefined) {
|
|
232
232
|
throw new Error(balanceAndNonceResp.error.message);
|
|
233
233
|
}
|
|
@@ -304,13 +304,13 @@ class ZILClient {
|
|
|
304
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
305
305
|
const { address, amount, token, gasPrice, gasLimit, zilAddress, signer } = params;
|
|
306
306
|
const networkConfig = this.getNetworkConfig();
|
|
307
|
-
const assetId =
|
|
308
|
-
const targetProxyHash =
|
|
309
|
-
const feeAddress =
|
|
307
|
+
const assetId = generic_1.appendHexPrefix(token.tokenAddress);
|
|
308
|
+
const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
|
|
309
|
+
const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
|
|
310
310
|
const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
|
|
311
311
|
const swthAddress = ethers_1.ethers.utils.hexlify(address);
|
|
312
312
|
// TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
|
|
313
|
-
const contractAddress =
|
|
313
|
+
const contractAddress = generic_1.appendHexPrefix(token.bridgeAddress);
|
|
314
314
|
let zilliqa;
|
|
315
315
|
if (typeof signer === "string") {
|
|
316
316
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
@@ -324,7 +324,7 @@ class ZILClient {
|
|
|
324
324
|
zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
|
|
325
325
|
}
|
|
326
326
|
const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
|
|
327
|
-
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(
|
|
327
|
+
const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
|
|
328
328
|
if (balanceAndNonceResp.error !== undefined) {
|
|
329
329
|
throw new Error(balanceAndNonceResp.error.message);
|
|
330
330
|
}
|
|
@@ -409,7 +409,7 @@ class ZILClient {
|
|
|
409
409
|
getTargetProxyHash(token) {
|
|
410
410
|
const networkConfig = this.getNetworkConfig();
|
|
411
411
|
const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
|
|
412
|
-
const addressHex =
|
|
412
|
+
const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
|
|
413
413
|
return addressHex;
|
|
414
414
|
}
|
|
415
415
|
getNetworkConfig() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Long from "long";
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
|
-
import { PageRequest, PageResponse } from "../query/pagination";
|
|
3
|
+
import { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination";
|
|
4
4
|
export declare const protobufPackage = "Switcheo.carbon.bank";
|
|
5
5
|
export interface InternalTransfer {
|
|
6
6
|
sender: string;
|
package/lib/codec/bank/query.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.QueryClientImpl = exports.QueryInternalTransfersResponse = exports.Query
|
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
-
const pagination_1 = require("../query/pagination");
|
|
10
|
+
const pagination_1 = require("../cosmos/base/query/v1beta1/pagination");
|
|
11
11
|
exports.protobufPackage = "Switcheo.carbon.bank";
|
|
12
12
|
const baseInternalTransfer = {
|
|
13
13
|
sender: "",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Long from "long";
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
|
-
import { PageRequest, PageResponse } from "../query/pagination";
|
|
3
|
+
import { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination";
|
|
4
4
|
import { MinMaxBoundary } from "./pagination";
|
|
5
5
|
import { Candlestick } from "./candlestick";
|
|
6
6
|
import { TradeEvent } from "./event";
|
|
@@ -17,10 +17,8 @@ export interface QueryCandlesticksResponse {
|
|
|
17
17
|
export interface QueryTradesRequest {
|
|
18
18
|
address: string;
|
|
19
19
|
market: string;
|
|
20
|
-
limit: Long;
|
|
21
20
|
beforeId: Long;
|
|
22
21
|
afterId: Long;
|
|
23
|
-
orderBy: string;
|
|
24
22
|
orderId: string;
|
|
25
23
|
afterBlock: Long;
|
|
26
24
|
beforeBlock: Long;
|
|
@@ -35,7 +33,6 @@ export interface QueryTradesForPositionRequest {
|
|
|
35
33
|
address: string;
|
|
36
34
|
market: string;
|
|
37
35
|
openedBlockHeight: Long;
|
|
38
|
-
orderBy: string;
|
|
39
36
|
pagination?: PageRequest;
|
|
40
37
|
}
|
|
41
38
|
export interface QueryTradesForPositionResponse {
|
|
@@ -7,7 +7,7 @@ exports.QueryClientImpl = exports.QueryTradesForPositionResponse = exports.Query
|
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
-
const pagination_1 = require("../query/pagination");
|
|
10
|
+
const pagination_1 = require("../cosmos/base/query/v1beta1/pagination");
|
|
11
11
|
const pagination_2 = require("./pagination");
|
|
12
12
|
const candlestick_1 = require("./candlestick");
|
|
13
13
|
const event_1 = require("./event");
|
|
@@ -162,10 +162,8 @@ exports.QueryCandlesticksResponse = {
|
|
|
162
162
|
const baseQueryTradesRequest = {
|
|
163
163
|
address: "",
|
|
164
164
|
market: "",
|
|
165
|
-
limit: long_1.default.UZERO,
|
|
166
165
|
beforeId: long_1.default.UZERO,
|
|
167
166
|
afterId: long_1.default.UZERO,
|
|
168
|
-
orderBy: "",
|
|
169
167
|
orderId: "",
|
|
170
168
|
afterBlock: long_1.default.UZERO,
|
|
171
169
|
beforeBlock: long_1.default.UZERO,
|
|
@@ -178,18 +176,12 @@ exports.QueryTradesRequest = {
|
|
|
178
176
|
if (message.market !== "") {
|
|
179
177
|
writer.uint32(18).string(message.market);
|
|
180
178
|
}
|
|
181
|
-
if (!message.limit.isZero()) {
|
|
182
|
-
writer.uint32(24).uint64(message.limit);
|
|
183
|
-
}
|
|
184
179
|
if (!message.beforeId.isZero()) {
|
|
185
180
|
writer.uint32(32).uint64(message.beforeId);
|
|
186
181
|
}
|
|
187
182
|
if (!message.afterId.isZero()) {
|
|
188
183
|
writer.uint32(40).uint64(message.afterId);
|
|
189
184
|
}
|
|
190
|
-
if (message.orderBy !== "") {
|
|
191
|
-
writer.uint32(50).string(message.orderBy);
|
|
192
|
-
}
|
|
193
185
|
if (message.orderId !== "") {
|
|
194
186
|
writer.uint32(58).string(message.orderId);
|
|
195
187
|
}
|
|
@@ -217,18 +209,12 @@ exports.QueryTradesRequest = {
|
|
|
217
209
|
case 2:
|
|
218
210
|
message.market = reader.string();
|
|
219
211
|
break;
|
|
220
|
-
case 3:
|
|
221
|
-
message.limit = reader.uint64();
|
|
222
|
-
break;
|
|
223
212
|
case 4:
|
|
224
213
|
message.beforeId = reader.uint64();
|
|
225
214
|
break;
|
|
226
215
|
case 5:
|
|
227
216
|
message.afterId = reader.uint64();
|
|
228
217
|
break;
|
|
229
|
-
case 6:
|
|
230
|
-
message.orderBy = reader.string();
|
|
231
|
-
break;
|
|
232
218
|
case 7:
|
|
233
219
|
message.orderId = reader.string();
|
|
234
220
|
break;
|
|
@@ -258,10 +244,6 @@ exports.QueryTradesRequest = {
|
|
|
258
244
|
object.market !== undefined && object.market !== null
|
|
259
245
|
? String(object.market)
|
|
260
246
|
: "";
|
|
261
|
-
message.limit =
|
|
262
|
-
object.limit !== undefined && object.limit !== null
|
|
263
|
-
? long_1.default.fromString(object.limit)
|
|
264
|
-
: long_1.default.UZERO;
|
|
265
247
|
message.beforeId =
|
|
266
248
|
object.beforeId !== undefined && object.beforeId !== null
|
|
267
249
|
? long_1.default.fromString(object.beforeId)
|
|
@@ -270,10 +252,6 @@ exports.QueryTradesRequest = {
|
|
|
270
252
|
object.afterId !== undefined && object.afterId !== null
|
|
271
253
|
? long_1.default.fromString(object.afterId)
|
|
272
254
|
: long_1.default.UZERO;
|
|
273
|
-
message.orderBy =
|
|
274
|
-
object.orderBy !== undefined && object.orderBy !== null
|
|
275
|
-
? String(object.orderBy)
|
|
276
|
-
: "";
|
|
277
255
|
message.orderId =
|
|
278
256
|
object.orderId !== undefined && object.orderId !== null
|
|
279
257
|
? String(object.orderId)
|
|
@@ -296,13 +274,10 @@ exports.QueryTradesRequest = {
|
|
|
296
274
|
const obj = {};
|
|
297
275
|
message.address !== undefined && (obj.address = message.address);
|
|
298
276
|
message.market !== undefined && (obj.market = message.market);
|
|
299
|
-
message.limit !== undefined &&
|
|
300
|
-
(obj.limit = (message.limit || long_1.default.UZERO).toString());
|
|
301
277
|
message.beforeId !== undefined &&
|
|
302
278
|
(obj.beforeId = (message.beforeId || long_1.default.UZERO).toString());
|
|
303
279
|
message.afterId !== undefined &&
|
|
304
280
|
(obj.afterId = (message.afterId || long_1.default.UZERO).toString());
|
|
305
|
-
message.orderBy !== undefined && (obj.orderBy = message.orderBy);
|
|
306
281
|
message.orderId !== undefined && (obj.orderId = message.orderId);
|
|
307
282
|
message.afterBlock !== undefined &&
|
|
308
283
|
(obj.afterBlock = (message.afterBlock || long_1.default.UZERO).toString());
|
|
@@ -315,14 +290,10 @@ exports.QueryTradesRequest = {
|
|
|
315
290
|
return obj;
|
|
316
291
|
},
|
|
317
292
|
fromPartial(object) {
|
|
318
|
-
var _a, _b, _c
|
|
293
|
+
var _a, _b, _c;
|
|
319
294
|
const message = Object.assign({}, baseQueryTradesRequest);
|
|
320
295
|
message.address = (_a = object.address) !== null && _a !== void 0 ? _a : "";
|
|
321
296
|
message.market = (_b = object.market) !== null && _b !== void 0 ? _b : "";
|
|
322
|
-
message.limit =
|
|
323
|
-
object.limit !== undefined && object.limit !== null
|
|
324
|
-
? long_1.default.fromValue(object.limit)
|
|
325
|
-
: long_1.default.UZERO;
|
|
326
297
|
message.beforeId =
|
|
327
298
|
object.beforeId !== undefined && object.beforeId !== null
|
|
328
299
|
? long_1.default.fromValue(object.beforeId)
|
|
@@ -331,8 +302,7 @@ exports.QueryTradesRequest = {
|
|
|
331
302
|
object.afterId !== undefined && object.afterId !== null
|
|
332
303
|
? long_1.default.fromValue(object.afterId)
|
|
333
304
|
: long_1.default.UZERO;
|
|
334
|
-
message.
|
|
335
|
-
message.orderId = (_d = object.orderId) !== null && _d !== void 0 ? _d : "";
|
|
305
|
+
message.orderId = (_c = object.orderId) !== null && _c !== void 0 ? _c : "";
|
|
336
306
|
message.afterBlock =
|
|
337
307
|
object.afterBlock !== undefined && object.afterBlock !== null
|
|
338
308
|
? long_1.default.fromValue(object.afterBlock)
|
|
@@ -437,7 +407,6 @@ const baseQueryTradesForPositionRequest = {
|
|
|
437
407
|
address: "",
|
|
438
408
|
market: "",
|
|
439
409
|
openedBlockHeight: long_1.default.UZERO,
|
|
440
|
-
orderBy: "",
|
|
441
410
|
};
|
|
442
411
|
exports.QueryTradesForPositionRequest = {
|
|
443
412
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -450,9 +419,6 @@ exports.QueryTradesForPositionRequest = {
|
|
|
450
419
|
if (!message.openedBlockHeight.isZero()) {
|
|
451
420
|
writer.uint32(24).uint64(message.openedBlockHeight);
|
|
452
421
|
}
|
|
453
|
-
if (message.orderBy !== "") {
|
|
454
|
-
writer.uint32(34).string(message.orderBy);
|
|
455
|
-
}
|
|
456
422
|
if (message.pagination !== undefined) {
|
|
457
423
|
pagination_1.PageRequest.encode(message.pagination, writer.uint32(42).fork()).ldelim();
|
|
458
424
|
}
|
|
@@ -474,9 +440,6 @@ exports.QueryTradesForPositionRequest = {
|
|
|
474
440
|
case 3:
|
|
475
441
|
message.openedBlockHeight = reader.uint64();
|
|
476
442
|
break;
|
|
477
|
-
case 4:
|
|
478
|
-
message.orderBy = reader.string();
|
|
479
|
-
break;
|
|
480
443
|
case 5:
|
|
481
444
|
message.pagination = pagination_1.PageRequest.decode(reader, reader.uint32());
|
|
482
445
|
break;
|
|
@@ -502,10 +465,6 @@ exports.QueryTradesForPositionRequest = {
|
|
|
502
465
|
object.openedBlockHeight !== null
|
|
503
466
|
? long_1.default.fromString(object.openedBlockHeight)
|
|
504
467
|
: long_1.default.UZERO;
|
|
505
|
-
message.orderBy =
|
|
506
|
-
object.orderBy !== undefined && object.orderBy !== null
|
|
507
|
-
? String(object.orderBy)
|
|
508
|
-
: "";
|
|
509
468
|
message.pagination =
|
|
510
469
|
object.pagination !== undefined && object.pagination !== null
|
|
511
470
|
? pagination_1.PageRequest.fromJSON(object.pagination)
|
|
@@ -518,7 +477,6 @@ exports.QueryTradesForPositionRequest = {
|
|
|
518
477
|
message.market !== undefined && (obj.market = message.market);
|
|
519
478
|
message.openedBlockHeight !== undefined &&
|
|
520
479
|
(obj.openedBlockHeight = (message.openedBlockHeight || long_1.default.UZERO).toString());
|
|
521
|
-
message.orderBy !== undefined && (obj.orderBy = message.orderBy);
|
|
522
480
|
message.pagination !== undefined &&
|
|
523
481
|
(obj.pagination = message.pagination
|
|
524
482
|
? pagination_1.PageRequest.toJSON(message.pagination)
|
|
@@ -526,7 +484,7 @@ exports.QueryTradesForPositionRequest = {
|
|
|
526
484
|
return obj;
|
|
527
485
|
},
|
|
528
486
|
fromPartial(object) {
|
|
529
|
-
var _a, _b
|
|
487
|
+
var _a, _b;
|
|
530
488
|
const message = Object.assign({}, baseQueryTradesForPositionRequest);
|
|
531
489
|
message.address = (_a = object.address) !== null && _a !== void 0 ? _a : "";
|
|
532
490
|
message.market = (_b = object.market) !== null && _b !== void 0 ? _b : "";
|
|
@@ -535,7 +493,6 @@ exports.QueryTradesForPositionRequest = {
|
|
|
535
493
|
object.openedBlockHeight !== null
|
|
536
494
|
? long_1.default.fromValue(object.openedBlockHeight)
|
|
537
495
|
: long_1.default.UZERO;
|
|
538
|
-
message.orderBy = (_c = object.orderBy) !== null && _c !== void 0 ? _c : "";
|
|
539
496
|
message.pagination =
|
|
540
497
|
object.pagination !== undefined && object.pagination !== null
|
|
541
498
|
? pagination_1.PageRequest.fromPartial(object.pagination)
|
package/lib/codec/cdp/event.d.ts
CHANGED
|
@@ -35,8 +35,10 @@ export interface SetLiquidationFeeEvent {
|
|
|
35
35
|
type: string;
|
|
36
36
|
}
|
|
37
37
|
export interface SetStablecoinInterestRateEvent {
|
|
38
|
+
/** Deprecated for stablecoin_interest_rate_dec */
|
|
38
39
|
stablecoinInterestRate: string;
|
|
39
40
|
type: string;
|
|
41
|
+
stablecoinInterestRateDec: string;
|
|
40
42
|
}
|
|
41
43
|
export interface SetStablecoinMintCapEvent {
|
|
42
44
|
stablecoinMintCap: string;
|
package/lib/codec/cdp/event.js
CHANGED
|
@@ -453,6 +453,7 @@ exports.SetLiquidationFeeEvent = {
|
|
|
453
453
|
const baseSetStablecoinInterestRateEvent = {
|
|
454
454
|
stablecoinInterestRate: "",
|
|
455
455
|
type: "",
|
|
456
|
+
stablecoinInterestRateDec: "",
|
|
456
457
|
};
|
|
457
458
|
exports.SetStablecoinInterestRateEvent = {
|
|
458
459
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -462,6 +463,9 @@ exports.SetStablecoinInterestRateEvent = {
|
|
|
462
463
|
if (message.type !== "") {
|
|
463
464
|
writer.uint32(18).string(message.type);
|
|
464
465
|
}
|
|
466
|
+
if (message.stablecoinInterestRateDec !== "") {
|
|
467
|
+
writer.uint32(26).string(message.stablecoinInterestRateDec);
|
|
468
|
+
}
|
|
465
469
|
return writer;
|
|
466
470
|
},
|
|
467
471
|
decode(input, length) {
|
|
@@ -477,6 +481,9 @@ exports.SetStablecoinInterestRateEvent = {
|
|
|
477
481
|
case 2:
|
|
478
482
|
message.type = reader.string();
|
|
479
483
|
break;
|
|
484
|
+
case 3:
|
|
485
|
+
message.stablecoinInterestRateDec = reader.string();
|
|
486
|
+
break;
|
|
480
487
|
default:
|
|
481
488
|
reader.skipType(tag & 7);
|
|
482
489
|
break;
|
|
@@ -495,6 +502,11 @@ exports.SetStablecoinInterestRateEvent = {
|
|
|
495
502
|
object.type !== undefined && object.type !== null
|
|
496
503
|
? String(object.type)
|
|
497
504
|
: "";
|
|
505
|
+
message.stablecoinInterestRateDec =
|
|
506
|
+
object.stablecoinInterestRateDec !== undefined &&
|
|
507
|
+
object.stablecoinInterestRateDec !== null
|
|
508
|
+
? String(object.stablecoinInterestRateDec)
|
|
509
|
+
: "";
|
|
498
510
|
return message;
|
|
499
511
|
},
|
|
500
512
|
toJSON(message) {
|
|
@@ -502,13 +514,16 @@ exports.SetStablecoinInterestRateEvent = {
|
|
|
502
514
|
message.stablecoinInterestRate !== undefined &&
|
|
503
515
|
(obj.stablecoinInterestRate = message.stablecoinInterestRate);
|
|
504
516
|
message.type !== undefined && (obj.type = message.type);
|
|
517
|
+
message.stablecoinInterestRateDec !== undefined &&
|
|
518
|
+
(obj.stablecoinInterestRateDec = message.stablecoinInterestRateDec);
|
|
505
519
|
return obj;
|
|
506
520
|
},
|
|
507
521
|
fromPartial(object) {
|
|
508
|
-
var _a, _b;
|
|
522
|
+
var _a, _b, _c;
|
|
509
523
|
const message = Object.assign({}, baseSetStablecoinInterestRateEvent);
|
|
510
524
|
message.stablecoinInterestRate = (_a = object.stablecoinInterestRate) !== null && _a !== void 0 ? _a : "";
|
|
511
525
|
message.type = (_b = object.type) !== null && _b !== void 0 ? _b : "";
|
|
526
|
+
message.stablecoinInterestRateDec = (_c = object.stablecoinInterestRateDec) !== null && _c !== void 0 ? _c : "";
|
|
512
527
|
return message;
|
|
513
528
|
},
|
|
514
529
|
};
|
|
@@ -2,6 +2,7 @@ import Long from "long";
|
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
3
|
import { Params } from "./params";
|
|
4
4
|
import { StablecoinDebtInfo } from "./stablecoin_debt_info";
|
|
5
|
+
import { StablecoinInterestInfo } from "./stablecoin_interest_info";
|
|
5
6
|
import { RateStrategyParams } from "./rate_strategy_params";
|
|
6
7
|
import { AssetParams } from "./asset_params";
|
|
7
8
|
import { DebtInfo } from "./debt_info";
|
|
@@ -31,10 +32,11 @@ export interface GenesisState {
|
|
|
31
32
|
accountToStablecoinInitialCumulativeInterestMultiplier: {
|
|
32
33
|
[key: string]: Uint8Array;
|
|
33
34
|
};
|
|
34
|
-
/** this line is used by starport scaffolding # genesis/proto/state */
|
|
35
35
|
accountToRewardDebt: {
|
|
36
36
|
[key: string]: Uint8Array;
|
|
37
37
|
};
|
|
38
|
+
/** this line is used by starport scaffolding # genesis/proto/state */
|
|
39
|
+
stablecoinInterestInfo?: StablecoinInterestInfo;
|
|
38
40
|
}
|
|
39
41
|
export interface GenesisState_AccountToCollateralizedEntry {
|
|
40
42
|
key: string;
|