carbon-js-sdk 0.2.16 → 0.2.18

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.
Files changed (58) hide show
  1. package/lib/clients/CarbonQueryClient.js +2 -2
  2. package/lib/clients/ETHClient.js +15 -15
  3. package/lib/clients/HydrogenClient.js +1 -1
  4. package/lib/clients/NEOClient.js +6 -6
  5. package/lib/clients/ZILClient.js +16 -16
  6. package/lib/codec/cdp/asset_params.d.ts +1 -1
  7. package/lib/codec/cdp/asset_params.js +11 -10
  8. package/lib/codec/cdp/params.d.ts +8 -0
  9. package/lib/codec/cdp/params.js +52 -9
  10. package/lib/codec/cdp/reward_scheme.d.ts +1 -13
  11. package/lib/codec/cdp/reward_scheme.js +15 -92
  12. package/lib/codec/cosmos/gov/v1beta1/query.js +2 -2
  13. package/lib/codec/cosmos/gov/v1beta1/tx.js +2 -2
  14. package/lib/codec/cosmos/tx/v1beta1/tx.js +2 -2
  15. package/lib/codec/pricing/legacy.d.ts +22 -0
  16. package/lib/codec/pricing/legacy.js +93 -0
  17. package/lib/constant/generic.js +1 -1
  18. package/lib/modules/gov.js +14 -14
  19. package/lib/modules/liquiditypool.js +1 -1
  20. package/lib/provider/account/EthLedgerAccount/EthLedgerAccount.js +1 -1
  21. package/lib/provider/account/NeoLedgerAccount/N3Ledger/ErrorCode.js +1 -1
  22. package/lib/provider/account/NeoLedgerAccount/N3Ledger/main.js +8 -8
  23. package/lib/provider/account/NeoLedgerAccount/NeoLedgerAccount.js +3 -3
  24. package/lib/provider/account/NeoLedgerAccount/NeonLedger.js +1 -1
  25. package/lib/provider/amino/types/admin.js +20 -20
  26. package/lib/provider/amino/types/bank.js +1 -1
  27. package/lib/provider/amino/types/broker.js +1 -1
  28. package/lib/provider/amino/types/cdp.js +4 -4
  29. package/lib/provider/amino/types/coin.js +2 -2
  30. package/lib/provider/amino/types/gov.js +4 -4
  31. package/lib/provider/amino/types/ibc.js +1 -1
  32. package/lib/provider/amino/types/leverage.js +1 -1
  33. package/lib/provider/amino/types/liquidityPool.js +7 -7
  34. package/lib/provider/amino/types/market.js +1 -1
  35. package/lib/provider/amino/types/oracle.js +1 -1
  36. package/lib/provider/amino/types/order.js +4 -4
  37. package/lib/provider/amino/types/position.js +1 -1
  38. package/lib/provider/amino/types/profile.js +1 -1
  39. package/lib/provider/amino/types/staking.js +4 -4
  40. package/lib/provider/amino/types/subaccount.js +3 -3
  41. package/lib/provider/amino/utils.js +11 -11
  42. package/lib/provider/keplr/KeplrAccount.js +5 -0
  43. package/lib/provider/keplr/KeplrStore.js +1 -1
  44. package/lib/provider/ledger/ledger.js +2 -2
  45. package/lib/provider/metamask/MetaMask.js +1 -1
  46. package/lib/provider/o3/O3Wallet.js +2 -2
  47. package/lib/util/address.js +13 -13
  48. package/lib/util/api.js +4 -4
  49. package/lib/util/fetch.js +1 -1
  50. package/lib/util/generic.js +3 -3
  51. package/lib/util/number.js +5 -5
  52. package/lib/util/tx.d.ts +1 -0
  53. package/lib/wallet/CarbonSigner.d.ts +5 -2
  54. package/lib/wallet/CarbonSigner.js +15 -2
  55. package/lib/wallet/CarbonSigningClient.js +8 -8
  56. package/lib/wallet/CarbonWallet.js +6 -6
  57. package/lib/websocket/connector.js +3 -3
  58. package/package.json +1 -1
@@ -44,7 +44,7 @@ class CarbonQueryClient {
44
44
  constructor(tmClient) {
45
45
  this.tmClient = tmClient;
46
46
  this.baseClient = new stargate_1.QueryClient(this.tmClient);
47
- const rpcClient = (0, stargate_1.createProtobufRpcClient)(this.baseClient);
47
+ const rpcClient = stargate_1.createProtobufRpcClient(this.baseClient);
48
48
  this.chain = BlockchainClient_1.default.connectWithTm(this.tmClient);
49
49
  this.adl = new query_1.QueryClientImpl(rpcClient);
50
50
  this.book = new query_2.QueryClientImpl(rpcClient);
@@ -85,7 +85,7 @@ class CarbonQueryClient {
85
85
  };
86
86
  }
87
87
  getProtobufRpcClient() {
88
- return (0, stargate_1.createProtobufRpcClient)(this.baseClient);
88
+ return stargate_1.createProtobufRpcClient(this.baseClient);
89
89
  }
90
90
  }
91
91
  exports.default = CarbonQueryClient;
@@ -40,13 +40,13 @@ class ETHClient {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  const tokenQueryResults = yield api.token.getAllTokens();
42
42
  const lockProxyAddress = this.getLockProxyAddress().toLowerCase();
43
- const tokens = tokenQueryResults.filter((token) => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
43
+ const tokens = tokenQueryResults.filter((token) => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
44
44
  token.tokenAddress.length == 40 &&
45
- token.bridgeAddress.toLowerCase() == (0, generic_1.stripHexPrefix)(lockProxyAddress) &&
45
+ token.bridgeAddress.toLowerCase() == generic_1.stripHexPrefix(lockProxyAddress) &&
46
46
  (!whitelistDenoms || whitelistDenoms.includes(token.denom)) &&
47
- this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress)));
47
+ this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress)));
48
48
  const assetIds = tokens.map((token) => {
49
- return this.verifyChecksum((0, generic_1.appendHexPrefix)(token.tokenAddress));
49
+ return this.verifyChecksum(generic_1.appendHexPrefix(token.tokenAddress));
50
50
  });
51
51
  const provider = this.getProvider();
52
52
  const contractAddress = this.getBalanceReaderAddress();
@@ -95,14 +95,14 @@ class ETHClient {
95
95
  throw new Error("Invalid recovery address");
96
96
  }
97
97
  const fromTokenId = fromToken.id;
98
- const fromTokenAddress = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
98
+ const fromTokenAddress = generic_1.appendHexPrefix(fromToken.tokenAddress);
99
99
  const toTokenDenom = toToken.denom;
100
100
  const recoveryAddressHex = ethers_1.ethers.utils.hexlify(util_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
101
101
  const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
102
102
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
103
103
  const nonce = yield rpcProvider.getTransactionCount(fromAddress);
104
104
  const contract = new ethers_1.ethers.Contract(this.getBridgeEntranceAddr(), eth_1.ABIs.bridgeEntrance, rpcProvider);
105
- const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
105
+ const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
106
106
  const tokenCreator = fromToken.creator;
107
107
  const targetAddressBytes = util_1.AddressUtils.SWTHAddress.getAddressBytes(tokenCreator, CarbonSDK_1.default.Network.MainNet);
108
108
  const targetProxyHash = ethers_1.ethers.utils.hexlify(targetAddressBytes);
@@ -137,9 +137,9 @@ class ETHClient {
137
137
  throw new Error("Minimum gas required: 150,000");
138
138
  }
139
139
  const networkConfig = this.getNetworkConfig();
140
- const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
141
- const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
142
- const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
140
+ const assetId = generic_1.appendHexPrefix(token.tokenAddress);
141
+ const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
142
+ const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
143
143
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
144
144
  const swthAddress = ethers_1.ethers.utils.hexlify(address);
145
145
  const contractAddress = this.getLockProxyAddress();
@@ -190,16 +190,16 @@ class ETHClient {
190
190
  return "insufficient balance";
191
191
  }
192
192
  const networkConfig = this.getNetworkConfig();
193
- const assetId = (0, generic_1.appendHexPrefix)(tokenWithExternalBalances.tokenAddress);
194
- const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(tokenWithExternalBalances));
195
- const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
193
+ const assetId = generic_1.appendHexPrefix(tokenWithExternalBalances.tokenAddress);
194
+ const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(tokenWithExternalBalances));
195
+ const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
196
196
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(tokenWithExternalBalances.id));
197
197
  const nonce = Math.floor(Math.random() * 1000000000); // random nonce to prevent replay attacks
198
198
  const message = ethers_1.ethers.utils.solidityKeccak256(["string", "address", "bytes", "bytes", "bytes", "uint256", "uint256", "uint256"], ["sendTokens", assetId, targetProxyHash, toAssetHash, feeAddress, amount, feeAmount, nonce]);
199
199
  // logger("sendDeposit message", message)
200
200
  let signatureResult;
201
201
  const { address, signature } = yield getSignatureCallback(message);
202
- const signatureBytes = ethers_1.ethers.utils.arrayify((0, generic_1.appendHexPrefix)(signature));
202
+ const signatureBytes = ethers_1.ethers.utils.arrayify(generic_1.appendHexPrefix(signature));
203
203
  const rsv = ethers_1.ethers.utils.splitSignature(signatureBytes);
204
204
  // logger("sign result", address, signature)
205
205
  signatureResult = {
@@ -238,7 +238,7 @@ class ETHClient {
238
238
  if (!feeInfo.deposit_fee) {
239
239
  throw new Error("unsupported token");
240
240
  }
241
- if ((0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) !== this.blockchain) {
241
+ if (blockchain_1.blockchainForChainId(token.chainId.toNumber()) !== this.blockchain) {
242
242
  throw new Error("unsupported token");
243
243
  }
244
244
  let feeAmount = ethers_1.ethers.BigNumber.from(feeInfo.deposit_fee);
@@ -304,7 +304,7 @@ class ETHClient {
304
304
  getTargetProxyHash(token) {
305
305
  const networkConfig = this.getNetworkConfig();
306
306
  const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
307
- const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
307
+ const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
308
308
  return addressHex;
309
309
  }
310
310
  getProvider() {
@@ -29,7 +29,7 @@ exports.HydrogenEndpoints = {
29
29
  const formatDateField = (value) => {
30
30
  if (typeof value !== "string")
31
31
  return null;
32
- return (0, dayjs_1.default)(value);
32
+ return dayjs_1.default(value);
33
33
  };
34
34
  const formatCrossChainTransfer = (value) => {
35
35
  var _a, _b;
@@ -63,13 +63,13 @@ class NEOClient {
63
63
  return __awaiter(this, void 0, void 0, function* () {
64
64
  const tokenQueryResults = yield sdk.token.getAllTokens();
65
65
  const account = new Neon.wallet.Account(address);
66
- const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
66
+ const tokens = tokenQueryResults.filter(token => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
67
67
  token.tokenAddress.length == 40 &&
68
68
  token.bridgeAddress.length == 40);
69
69
  const client = new Neon.rpc.RPCClient(url, "2.5.2"); // TODO: should we change the RPC version??
70
70
  // NOTE: fetching of tokens is chunked in sets of 15 as we may hit
71
71
  // the gas limit on the RPC node and error out otherwise
72
- const promises = (0, lodash_1.chunk)(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
72
+ const promises = lodash_1.chunk(tokens, 75).map((partition) => __awaiter(this, void 0, void 0, function* () {
73
73
  var _a, _b, _c;
74
74
  let acc = {};
75
75
  for (const token of partition) {
@@ -110,7 +110,7 @@ class NEOClient {
110
110
  const targetProxyHash = this.getTargetProxyHash(token);
111
111
  const toAssetHash = Neon.u.str2hexstring(token.id);
112
112
  const addressBytes = address_1.SWTHAddress.getAddressBytes(swthAddress, networkConfig.network);
113
- const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
113
+ const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
114
114
  const amount = ethers_1.ethers.BigNumber.from(token.externalBalance);
115
115
  const feeAmount = ethers_1.ethers.BigNumber.from(feeAmountInput !== null && feeAmountInput !== void 0 ? feeAmountInput : "100000000");
116
116
  const feeAddress = networkConfig.feeAddress;
@@ -157,7 +157,7 @@ class NEOClient {
157
157
  const fromAddress = util_1.AddressUtils.NEOAddress.publicKeyToAddress(publicKeyOutput.publicKey);
158
158
  const targetProxyHash = this.getTargetProxyHash(token);
159
159
  const toAssetHash = Neon.u.str2hexstring(token.id);
160
- const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
160
+ const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
161
161
  const nonce = Math.floor(Math.random() * 1000000);
162
162
  if (amount.lt(feeAmount)) {
163
163
  throw new Error("Invalid amount");
@@ -193,7 +193,7 @@ class NEOClient {
193
193
  const fromAddress = ledger.scriptHash;
194
194
  const targetProxyHash = this.getTargetProxyHash(token);
195
195
  const toAssetHash = Neon.u.str2hexstring(token.id);
196
- const toAddress = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(address));
196
+ const toAddress = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(address));
197
197
  const feeAddress = networkConfig.feeAddress;
198
198
  const nonce = Math.floor(Math.random() * 1000000);
199
199
  if (amount.lt(feeAmount)) {
@@ -313,7 +313,7 @@ class NEOClient {
313
313
  getTargetProxyHash(token) {
314
314
  const networkConfig = this.getNetworkConfig();
315
315
  const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
316
- const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
316
+ const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
317
317
  return addressHex;
318
318
  }
319
319
  getNetworkConfig() {
@@ -74,10 +74,10 @@ class ZILClient {
74
74
  getExternalBalances(sdk, address, whitelistDenoms) {
75
75
  return __awaiter(this, void 0, void 0, function* () {
76
76
  const tokenQueryResults = yield sdk.token.getAllTokens();
77
- const tokens = tokenQueryResults.filter(token => (0, blockchain_1.blockchainForChainId)(token.chainId.toNumber()) == this.blockchain &&
77
+ const tokens = tokenQueryResults.filter(token => blockchain_1.blockchainForChainId(token.chainId.toNumber()) == this.blockchain &&
78
78
  token.tokenAddress.length == 40 &&
79
79
  (!whitelistDenoms || whitelistDenoms.includes(token.denom)));
80
- const requests = tokens.map(token => token.tokenAddress === zeroAddress ? (0, exports.balanceBatchRequest)(address.replace(/^0x/i, "")) : (0, exports.tokenBalanceBatchRequest)(token.tokenAddress, address));
80
+ const requests = tokens.map(token => token.tokenAddress === zeroAddress ? exports.balanceBatchRequest(address.replace(/^0x/i, "")) : 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 (0, zilliqa_1.fromBech32Address)(bech32Address).toLowerCase().substr(2);
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((0, generic_1.stripHexPrefix)(zilAddress));
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 : (0, generic_1.appendHexPrefix)(token.bridgeAddress),
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 = (0, generic_1.appendHexPrefix)(token.tokenAddress);
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) {
@@ -204,13 +204,13 @@ class ZILClient {
204
204
  throw new Error("Invalid recovery address");
205
205
  }
206
206
  const fromTokenId = fromToken.id;
207
- const fromTokenAddr = (0, generic_1.appendHexPrefix)(fromToken.tokenAddress);
207
+ const fromTokenAddr = generic_1.appendHexPrefix(fromToken.tokenAddress);
208
208
  const toTokenDenom = toToken.denom;
209
- const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(fromToken));
209
+ const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(fromToken));
210
210
  const recoveryAddressHex = ethers_1.ethers.utils.hexlify(index_1.AddressUtils.SWTHAddress.getAddressBytes(recoveryAddress, CarbonSDK_1.default.Network.MainNet));
211
211
  const fromAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(fromTokenId));
212
212
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(toTokenDenom));
213
- const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
213
+ const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
214
214
  const contractAddress = this.getBridgeEntranceAddr();
215
215
  let zilliqa;
216
216
  if (typeof signer === 'string') {
@@ -225,7 +225,7 @@ class ZILClient {
225
225
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
226
226
  }
227
227
  const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
228
- const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(fromAddress));
228
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(fromAddress));
229
229
  if (balanceAndNonceResp.error !== undefined) {
230
230
  throw new Error(balanceAndNonceResp.error.message);
231
231
  }
@@ -302,13 +302,13 @@ class ZILClient {
302
302
  return __awaiter(this, void 0, void 0, function* () {
303
303
  const { address, amount, token, gasPrice, gasLimit, zilAddress, signer } = params;
304
304
  const networkConfig = this.getNetworkConfig();
305
- const assetId = (0, generic_1.appendHexPrefix)(token.tokenAddress);
306
- const targetProxyHash = (0, generic_1.appendHexPrefix)(this.getTargetProxyHash(token));
307
- const feeAddress = (0, generic_1.appendHexPrefix)(networkConfig.feeAddress);
305
+ const assetId = generic_1.appendHexPrefix(token.tokenAddress);
306
+ const targetProxyHash = generic_1.appendHexPrefix(this.getTargetProxyHash(token));
307
+ const feeAddress = generic_1.appendHexPrefix(networkConfig.feeAddress);
308
308
  const toAssetHash = ethers_1.ethers.utils.hexlify(ethers_1.ethers.utils.toUtf8Bytes(token.id));
309
309
  const swthAddress = ethers_1.ethers.utils.hexlify(address);
310
310
  // TODO: Check if bridgeAddress corresponds to carbon token lock_proxy_hash
311
- const contractAddress = (0, generic_1.appendHexPrefix)(token.bridgeAddress);
311
+ const contractAddress = generic_1.appendHexPrefix(token.bridgeAddress);
312
312
  let zilliqa;
313
313
  if (typeof signer === 'string') {
314
314
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
@@ -322,7 +322,7 @@ class ZILClient {
322
322
  zilliqa = new zilliqa_1.Zilliqa(this.getProviderUrl());
323
323
  }
324
324
  const deployedContract = (this.walletProvider || zilliqa).contracts.at(contractAddress);
325
- const balanceAndNonceResp = yield zilliqa.blockchain.getBalance((0, generic_1.stripHexPrefix)(zilAddress));
325
+ const balanceAndNonceResp = yield zilliqa.blockchain.getBalance(generic_1.stripHexPrefix(zilAddress));
326
326
  if (balanceAndNonceResp.error !== undefined) {
327
327
  throw new Error(balanceAndNonceResp.error.message);
328
328
  }
@@ -407,7 +407,7 @@ class ZILClient {
407
407
  getTargetProxyHash(token) {
408
408
  const networkConfig = this.getNetworkConfig();
409
409
  const addressBytes = address_1.SWTHAddress.getAddressBytes(token.creator, networkConfig.network);
410
- const addressHex = (0, generic_1.stripHexPrefix)(ethers_1.ethers.utils.hexlify(addressBytes));
410
+ const addressHex = generic_1.stripHexPrefix(ethers_1.ethers.utils.hexlify(addressBytes));
411
411
  return addressHex;
412
412
  }
413
413
  getNetworkConfig() {
@@ -8,7 +8,7 @@ export interface AssetParams {
8
8
  allowRepayStablecoinInterestDebt: boolean;
9
9
  loanToValue: string;
10
10
  liquidationThreshold: string;
11
- liquidationBonus: string;
11
+ liquidationDiscount: string;
12
12
  supplyCap: string;
13
13
  borrowCap: string;
14
14
  }
@@ -15,7 +15,7 @@ const baseAssetParams = {
15
15
  allowRepayStablecoinInterestDebt: false,
16
16
  loanToValue: "",
17
17
  liquidationThreshold: "",
18
- liquidationBonus: "",
18
+ liquidationDiscount: "",
19
19
  supplyCap: "",
20
20
  borrowCap: "",
21
21
  };
@@ -39,8 +39,8 @@ exports.AssetParams = {
39
39
  if (message.liquidationThreshold !== "") {
40
40
  writer.uint32(50).string(message.liquidationThreshold);
41
41
  }
42
- if (message.liquidationBonus !== "") {
43
- writer.uint32(58).string(message.liquidationBonus);
42
+ if (message.liquidationDiscount !== "") {
43
+ writer.uint32(58).string(message.liquidationDiscount);
44
44
  }
45
45
  if (message.supplyCap !== "") {
46
46
  writer.uint32(66).string(message.supplyCap);
@@ -76,7 +76,7 @@ exports.AssetParams = {
76
76
  message.liquidationThreshold = reader.string();
77
77
  break;
78
78
  case 7:
79
- message.liquidationBonus = reader.string();
79
+ message.liquidationDiscount = reader.string();
80
80
  break;
81
81
  case 8:
82
82
  message.supplyCap = reader.string();
@@ -119,9 +119,10 @@ exports.AssetParams = {
119
119
  object.liquidationThreshold !== null
120
120
  ? String(object.liquidationThreshold)
121
121
  : "";
122
- message.liquidationBonus =
123
- object.liquidationBonus !== undefined && object.liquidationBonus !== null
124
- ? String(object.liquidationBonus)
122
+ message.liquidationDiscount =
123
+ object.liquidationDiscount !== undefined &&
124
+ object.liquidationDiscount !== null
125
+ ? String(object.liquidationDiscount)
125
126
  : "";
126
127
  message.supplyCap =
127
128
  object.supplyCap !== undefined && object.supplyCap !== null
@@ -146,8 +147,8 @@ exports.AssetParams = {
146
147
  (obj.loanToValue = message.loanToValue);
147
148
  message.liquidationThreshold !== undefined &&
148
149
  (obj.liquidationThreshold = message.liquidationThreshold);
149
- message.liquidationBonus !== undefined &&
150
- (obj.liquidationBonus = message.liquidationBonus);
150
+ message.liquidationDiscount !== undefined &&
151
+ (obj.liquidationDiscount = message.liquidationDiscount);
151
152
  message.supplyCap !== undefined && (obj.supplyCap = message.supplyCap);
152
153
  message.borrowCap !== undefined && (obj.borrowCap = message.borrowCap);
153
154
  return obj;
@@ -162,7 +163,7 @@ exports.AssetParams = {
162
163
  (_d = object.allowRepayStablecoinInterestDebt) !== null && _d !== void 0 ? _d : false;
163
164
  message.loanToValue = (_e = object.loanToValue) !== null && _e !== void 0 ? _e : "";
164
165
  message.liquidationThreshold = (_f = object.liquidationThreshold) !== null && _f !== void 0 ? _f : "";
165
- message.liquidationBonus = (_g = object.liquidationBonus) !== null && _g !== void 0 ? _g : "";
166
+ message.liquidationDiscount = (_g = object.liquidationDiscount) !== null && _g !== void 0 ? _g : "";
166
167
  message.supplyCap = (_h = object.supplyCap) !== null && _h !== void 0 ? _h : "";
167
168
  message.borrowCap = (_j = object.borrowCap) !== null && _j !== void 0 ? _j : "";
168
169
  return message;
@@ -6,6 +6,7 @@ export interface Params {
6
6
  interestFee: string;
7
7
  liquidationFee: string;
8
8
  stablecoinInterestRate: string;
9
+ stablecoinMintCap: string;
9
10
  /**
10
11
  * Complete Liquidation Threshold determines how far between
11
12
  * liquidation_threshold (LT) and collateral_value (CV) a borrower's
@@ -41,6 +42,13 @@ export interface Params {
41
42
  * dynamic close factor.
42
43
  */
43
44
  smallLiquidationSize: string;
45
+ /**
46
+ * stale_price_grace_period determines the grace period in seconds before an oracle price is regarded as stale.
47
+ * This would cause certain actions like borrowing to be paused
48
+ */
49
+ stalePriceGracePeriod: string;
50
+ /** cdp_paused if true, causes all supply, locking, lending, borrowing and liquidations to be paused */
51
+ cdpPaused: boolean;
44
52
  }
45
53
  export declare const Params: {
46
54
  encode(message: Params, writer?: _m0.Writer): _m0.Writer;
@@ -12,9 +12,12 @@ const baseParams = {
12
12
  interestFee: "",
13
13
  liquidationFee: "",
14
14
  stablecoinInterestRate: "",
15
+ stablecoinMintCap: "",
15
16
  completeLiquidationThreshold: "",
16
17
  minimumCloseFactor: "",
17
18
  smallLiquidationSize: "",
19
+ stalePriceGracePeriod: "",
20
+ cdpPaused: false,
18
21
  };
19
22
  exports.Params = {
20
23
  encode(message, writer = minimal_1.default.Writer.create()) {
@@ -27,14 +30,23 @@ exports.Params = {
27
30
  if (message.stablecoinInterestRate !== "") {
28
31
  writer.uint32(26).string(message.stablecoinInterestRate);
29
32
  }
33
+ if (message.stablecoinMintCap !== "") {
34
+ writer.uint32(34).string(message.stablecoinMintCap);
35
+ }
30
36
  if (message.completeLiquidationThreshold !== "") {
31
- writer.uint32(34).string(message.completeLiquidationThreshold);
37
+ writer.uint32(42).string(message.completeLiquidationThreshold);
32
38
  }
33
39
  if (message.minimumCloseFactor !== "") {
34
- writer.uint32(42).string(message.minimumCloseFactor);
40
+ writer.uint32(50).string(message.minimumCloseFactor);
35
41
  }
36
42
  if (message.smallLiquidationSize !== "") {
37
- writer.uint32(50).string(message.smallLiquidationSize);
43
+ writer.uint32(58).string(message.smallLiquidationSize);
44
+ }
45
+ if (message.stalePriceGracePeriod !== "") {
46
+ writer.uint32(66).string(message.stalePriceGracePeriod);
47
+ }
48
+ if (message.cdpPaused === true) {
49
+ writer.uint32(72).bool(message.cdpPaused);
38
50
  }
39
51
  return writer;
40
52
  },
@@ -55,14 +67,23 @@ exports.Params = {
55
67
  message.stablecoinInterestRate = reader.string();
56
68
  break;
57
69
  case 4:
58
- message.completeLiquidationThreshold = reader.string();
70
+ message.stablecoinMintCap = reader.string();
59
71
  break;
60
72
  case 5:
61
- message.minimumCloseFactor = reader.string();
73
+ message.completeLiquidationThreshold = reader.string();
62
74
  break;
63
75
  case 6:
76
+ message.minimumCloseFactor = reader.string();
77
+ break;
78
+ case 7:
64
79
  message.smallLiquidationSize = reader.string();
65
80
  break;
81
+ case 8:
82
+ message.stalePriceGracePeriod = reader.string();
83
+ break;
84
+ case 9:
85
+ message.cdpPaused = reader.bool();
86
+ break;
66
87
  default:
67
88
  reader.skipType(tag & 7);
68
89
  break;
@@ -85,6 +106,11 @@ exports.Params = {
85
106
  object.stablecoinInterestRate !== null
86
107
  ? String(object.stablecoinInterestRate)
87
108
  : "";
109
+ message.stablecoinMintCap =
110
+ object.stablecoinMintCap !== undefined &&
111
+ object.stablecoinMintCap !== null
112
+ ? String(object.stablecoinMintCap)
113
+ : "";
88
114
  message.completeLiquidationThreshold =
89
115
  object.completeLiquidationThreshold !== undefined &&
90
116
  object.completeLiquidationThreshold !== null
@@ -100,6 +126,15 @@ exports.Params = {
100
126
  object.smallLiquidationSize !== null
101
127
  ? String(object.smallLiquidationSize)
102
128
  : "";
129
+ message.stalePriceGracePeriod =
130
+ object.stalePriceGracePeriod !== undefined &&
131
+ object.stalePriceGracePeriod !== null
132
+ ? String(object.stalePriceGracePeriod)
133
+ : "";
134
+ message.cdpPaused =
135
+ object.cdpPaused !== undefined && object.cdpPaused !== null
136
+ ? Boolean(object.cdpPaused)
137
+ : false;
103
138
  return message;
104
139
  },
105
140
  toJSON(message) {
@@ -110,24 +145,32 @@ exports.Params = {
110
145
  (obj.liquidationFee = message.liquidationFee);
111
146
  message.stablecoinInterestRate !== undefined &&
112
147
  (obj.stablecoinInterestRate = message.stablecoinInterestRate);
148
+ message.stablecoinMintCap !== undefined &&
149
+ (obj.stablecoinMintCap = message.stablecoinMintCap);
113
150
  message.completeLiquidationThreshold !== undefined &&
114
151
  (obj.completeLiquidationThreshold = message.completeLiquidationThreshold);
115
152
  message.minimumCloseFactor !== undefined &&
116
153
  (obj.minimumCloseFactor = message.minimumCloseFactor);
117
154
  message.smallLiquidationSize !== undefined &&
118
155
  (obj.smallLiquidationSize = message.smallLiquidationSize);
156
+ message.stalePriceGracePeriod !== undefined &&
157
+ (obj.stalePriceGracePeriod = message.stalePriceGracePeriod);
158
+ message.cdpPaused !== undefined && (obj.cdpPaused = message.cdpPaused);
119
159
  return obj;
120
160
  },
121
161
  fromPartial(object) {
122
- var _a, _b, _c, _d, _e, _f;
162
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
123
163
  const message = Object.assign({}, baseParams);
124
164
  message.interestFee = (_a = object.interestFee) !== null && _a !== void 0 ? _a : "";
125
165
  message.liquidationFee = (_b = object.liquidationFee) !== null && _b !== void 0 ? _b : "";
126
166
  message.stablecoinInterestRate = (_c = object.stablecoinInterestRate) !== null && _c !== void 0 ? _c : "";
167
+ message.stablecoinMintCap = (_d = object.stablecoinMintCap) !== null && _d !== void 0 ? _d : "";
127
168
  message.completeLiquidationThreshold =
128
- (_d = object.completeLiquidationThreshold) !== null && _d !== void 0 ? _d : "";
129
- message.minimumCloseFactor = (_e = object.minimumCloseFactor) !== null && _e !== void 0 ? _e : "";
130
- message.smallLiquidationSize = (_f = object.smallLiquidationSize) !== null && _f !== void 0 ? _f : "";
169
+ (_e = object.completeLiquidationThreshold) !== null && _e !== void 0 ? _e : "";
170
+ message.minimumCloseFactor = (_f = object.minimumCloseFactor) !== null && _f !== void 0 ? _f : "";
171
+ message.smallLiquidationSize = (_g = object.smallLiquidationSize) !== null && _g !== void 0 ? _g : "";
172
+ message.stalePriceGracePeriod = (_h = object.stalePriceGracePeriod) !== null && _h !== void 0 ? _h : "";
173
+ message.cdpPaused = (_j = object.cdpPaused) !== null && _j !== void 0 ? _j : false;
131
174
  return message;
132
175
  },
133
176
  };
@@ -30,16 +30,11 @@ export interface UpdateRewardSchemeParams {
30
30
  startTime?: Date;
31
31
  endTime?: Date;
32
32
  }
33
- export interface AddReservesParams {
34
- creator: string;
35
- rewardSchemeId: Long;
36
- amount: string;
37
- denom: string;
38
- }
39
33
  export interface RewardDebt {
40
34
  userAddress: string;
41
35
  rewardSchemeId: Long;
42
36
  rewardDebt: string;
37
+ lastUpdatedAt?: Date;
43
38
  }
44
39
  export declare const RewardScheme: {
45
40
  encode(message: RewardScheme, writer?: _m0.Writer): _m0.Writer;
@@ -62,13 +57,6 @@ export declare const UpdateRewardSchemeParams: {
62
57
  toJSON(message: UpdateRewardSchemeParams): unknown;
63
58
  fromPartial(object: DeepPartial<UpdateRewardSchemeParams>): UpdateRewardSchemeParams;
64
59
  };
65
- export declare const AddReservesParams: {
66
- encode(message: AddReservesParams, writer?: _m0.Writer): _m0.Writer;
67
- decode(input: _m0.Reader | Uint8Array, length?: number | undefined): AddReservesParams;
68
- fromJSON(object: any): AddReservesParams;
69
- toJSON(message: AddReservesParams): unknown;
70
- fromPartial(object: DeepPartial<AddReservesParams>): AddReservesParams;
71
- };
72
60
  export declare const RewardDebt: {
73
61
  encode(message: RewardDebt, writer?: _m0.Writer): _m0.Writer;
74
62
  decode(input: _m0.Reader | Uint8Array, length?: number | undefined): RewardDebt;