carbon-js-sdk 0.11.21 → 0.11.22

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.
@@ -270,6 +270,16 @@ exports.registry.register("/Switcheo.carbon.oracle.MsgDeployOracleContract", Car
270
270
  exports.registry.register("/Switcheo.carbon.oracle.MsgDeployOracleContractResponse", Carbon.Oracle.MsgDeployOracleContractResponse);
271
271
  exports.registry.register("/Switcheo.carbon.oracle.MsgCreateResult", Carbon.Oracle.MsgCreateResult);
272
272
  exports.registry.register("/Switcheo.carbon.oracle.MsgCreateResultResponse", Carbon.Oracle.MsgCreateResultResponse);
273
+ exports.registry.register("/Switcheo.carbon.otc.MsgCreateRfq", Carbon.Otc.MsgCreateRfq);
274
+ exports.registry.register("/Switcheo.carbon.otc.MsgCreateRfqResponse", Carbon.Otc.MsgCreateRfqResponse);
275
+ exports.registry.register("/Switcheo.carbon.otc.MsgCancelRfq", Carbon.Otc.MsgCancelRfq);
276
+ exports.registry.register("/Switcheo.carbon.otc.MsgCancelRfqResponse", Carbon.Otc.MsgCancelRfqResponse);
277
+ exports.registry.register("/Switcheo.carbon.otc.MsgCreateQuote", Carbon.Otc.MsgCreateQuote);
278
+ exports.registry.register("/Switcheo.carbon.otc.MsgCreateQuoteResponse", Carbon.Otc.MsgCreateQuoteResponse);
279
+ exports.registry.register("/Switcheo.carbon.otc.MsgAcceptQuote", Carbon.Otc.MsgAcceptQuote);
280
+ exports.registry.register("/Switcheo.carbon.otc.MsgAcceptQuoteResponse", Carbon.Otc.MsgAcceptQuoteResponse);
281
+ exports.registry.register("/Switcheo.carbon.otc.MsgUpdateParams", Carbon.Otc.MsgUpdateParams);
282
+ exports.registry.register("/Switcheo.carbon.otc.MsgUpdateParamsResponse", Carbon.Otc.MsgUpdateParamsResponse);
273
283
  exports.registry.register("/Switcheo.carbon.evmcontract.MsgDeactivateContract", Carbon.Evmcontract.MsgDeactivateContract);
274
284
  exports.registry.register("/Switcheo.carbon.evmcontract.MsgDeactivateContractResponse", Carbon.Evmcontract.MsgDeactivateContractResponse);
275
285
  exports.registry.register("/Switcheo.carbon.evmcontract.MsgActivateContract", Carbon.Evmcontract.MsgActivateContract);
@@ -299,8 +309,6 @@ exports.registry.register("/Switcheo.carbon.coin.MsgLinkToken", Carbon.Coin.MsgL
299
309
  exports.registry.register("/Switcheo.carbon.coin.MsgLinkTokenResponse", Carbon.Coin.MsgLinkTokenResponse);
300
310
  exports.registry.register("/Switcheo.carbon.coin.MsgWithdraw", Carbon.Coin.MsgWithdraw);
301
311
  exports.registry.register("/Switcheo.carbon.coin.MsgWithdrawResponse", Carbon.Coin.MsgWithdrawResponse);
302
- exports.registry.register("/Switcheo.carbon.coin.MsgAdminWithdraw", Carbon.Coin.MsgAdminWithdraw);
303
- exports.registry.register("/Switcheo.carbon.coin.MsgAdminWithdrawResponse", Carbon.Coin.MsgAdminWithdrawResponse);
304
312
  exports.registry.register("/Switcheo.carbon.coin.MsgAuthorizeBridge", Carbon.Coin.MsgAuthorizeBridge);
305
313
  exports.registry.register("/Switcheo.carbon.coin.MsgAuthorizeBridgeResponse", Carbon.Coin.MsgAuthorizeBridgeResponse);
306
314
  exports.registry.register("/Switcheo.carbon.coin.MsgDeauthorizeBridge", Carbon.Coin.MsgDeauthorizeBridge);
@@ -911,6 +919,16 @@ exports.TxTypes = {
911
919
  "MsgDeployOracleContractResponse": "/Switcheo.carbon.oracle.MsgDeployOracleContractResponse",
912
920
  "MsgCreateResult": "/Switcheo.carbon.oracle.MsgCreateResult",
913
921
  "MsgCreateResultResponse": "/Switcheo.carbon.oracle.MsgCreateResultResponse",
922
+ "MsgCreateRfq": "/Switcheo.carbon.otc.MsgCreateRfq",
923
+ "MsgCreateRfqResponse": "/Switcheo.carbon.otc.MsgCreateRfqResponse",
924
+ "MsgCancelRfq": "/Switcheo.carbon.otc.MsgCancelRfq",
925
+ "MsgCancelRfqResponse": "/Switcheo.carbon.otc.MsgCancelRfqResponse",
926
+ "MsgCreateQuote": "/Switcheo.carbon.otc.MsgCreateQuote",
927
+ "MsgCreateQuoteResponse": "/Switcheo.carbon.otc.MsgCreateQuoteResponse",
928
+ "MsgAcceptQuote": "/Switcheo.carbon.otc.MsgAcceptQuote",
929
+ "MsgAcceptQuoteResponse": "/Switcheo.carbon.otc.MsgAcceptQuoteResponse",
930
+ "MsgOtcUpdateParams": "/Switcheo.carbon.otc.MsgUpdateParams",
931
+ "MsgOtcUpdateParamsResponse": "/Switcheo.carbon.otc.MsgUpdateParamsResponse",
914
932
  "MsgDeactivateContract": "/Switcheo.carbon.evmcontract.MsgDeactivateContract",
915
933
  "MsgDeactivateContractResponse": "/Switcheo.carbon.evmcontract.MsgDeactivateContractResponse",
916
934
  "MsgActivateContract": "/Switcheo.carbon.evmcontract.MsgActivateContract",
@@ -940,8 +958,6 @@ exports.TxTypes = {
940
958
  "MsgLinkTokenResponse": "/Switcheo.carbon.coin.MsgLinkTokenResponse",
941
959
  "MsgWithdraw": "/Switcheo.carbon.coin.MsgWithdraw",
942
960
  "MsgWithdrawResponse": "/Switcheo.carbon.coin.MsgWithdrawResponse",
943
- "MsgAdminWithdraw": "/Switcheo.carbon.coin.MsgAdminWithdraw",
944
- "MsgAdminWithdrawResponse": "/Switcheo.carbon.coin.MsgAdminWithdrawResponse",
945
961
  "MsgAuthorizeBridge": "/Switcheo.carbon.coin.MsgAuthorizeBridge",
946
962
  "MsgAuthorizeBridgeResponse": "/Switcheo.carbon.coin.MsgAuthorizeBridgeResponse",
947
963
  "MsgDeauthorizeBridge": "/Switcheo.carbon.coin.MsgDeauthorizeBridge",
@@ -4920,6 +4936,17 @@ exports.EIP712Types = {
4920
4936
  "MsgUpdateParamsResponse": []
4921
4937
  },
4922
4938
  "/Switcheo.carbon.cdp": {
4939
+ "AssetParamsAPI": [
4940
+ {
4941
+ "name": "asset_params",
4942
+ "type": "AssetParams",
4943
+ "packageName": "/Switcheo.carbon.cdp"
4944
+ },
4945
+ {
4946
+ "name": "token_name",
4947
+ "type": "string"
4948
+ }
4949
+ ],
4923
4950
  "AssetParams": [
4924
4951
  {
4925
4952
  "name": "denom",
@@ -6195,7 +6222,7 @@ exports.EIP712Types = {
6195
6222
  "QueryAssetResponse": [
6196
6223
  {
6197
6224
  "name": "asset_params",
6198
- "type": "AssetParams",
6225
+ "type": "AssetParamsAPI",
6199
6226
  "packageName": "/Switcheo.carbon.cdp"
6200
6227
  }
6201
6228
  ],
@@ -6209,7 +6236,7 @@ exports.EIP712Types = {
6209
6236
  "QueryAssetAllResponse": [
6210
6237
  {
6211
6238
  "name": "asset_params_all",
6212
- "type": "AssetParams[]",
6239
+ "type": "AssetParamsAPI[]",
6213
6240
  "packageName": "/Switcheo.carbon.cdp"
6214
6241
  },
6215
6242
  {
@@ -7540,25 +7567,6 @@ exports.EIP712Types = {
7540
7567
  }
7541
7568
  ],
7542
7569
  "MsgWithdrawResponse": [],
7543
- "MsgAdminWithdraw": [
7544
- {
7545
- "name": "creator",
7546
- "type": "string"
7547
- },
7548
- {
7549
- "name": "to_address",
7550
- "type": "string"
7551
- },
7552
- {
7553
- "name": "denom",
7554
- "type": "string"
7555
- },
7556
- {
7557
- "name": "amount",
7558
- "type": "string"
7559
- }
7560
- ],
7561
- "MsgAdminWithdrawResponse": [],
7562
7570
  "MsgAuthorizeBridge": [
7563
7571
  {
7564
7572
  "name": "creator",
@@ -8115,13 +8123,6 @@ exports.EIP712Types = {
8115
8123
  "type": "PageResponse",
8116
8124
  "packageName": "/cosmos.base.query.v1beta1"
8117
8125
  }
8118
- ],
8119
- "QueryPolyBlacklistRequest": [],
8120
- "QueryPolyBlacklistResponse": [
8121
- {
8122
- "name": "blacklisted_tokens",
8123
- "type": "string[]"
8124
- }
8125
8126
  ]
8126
8127
  },
8127
8128
  "/Switcheo.carbon.erc20": {
@@ -13730,6 +13731,364 @@ exports.EIP712Types = {
13730
13731
  ],
13731
13732
  "MsgCreateResultResponse": []
13732
13733
  },
13734
+ "/Switcheo.carbon.otc": {
13735
+ "Rfq": [
13736
+ {
13737
+ "name": "id",
13738
+ "type": "string"
13739
+ },
13740
+ {
13741
+ "name": "requester",
13742
+ "type": "string"
13743
+ },
13744
+ {
13745
+ "name": "sell_coins",
13746
+ "type": "Coin[]",
13747
+ "packageName": "/cosmos.base.v1beta1"
13748
+ },
13749
+ {
13750
+ "name": "buy_denom",
13751
+ "type": "string"
13752
+ },
13753
+ {
13754
+ "name": "expiry_time",
13755
+ "type": "string"
13756
+ }
13757
+ ],
13758
+ "RfqWithStatus": [
13759
+ {
13760
+ "name": "rfq",
13761
+ "type": "Rfq",
13762
+ "packageName": "/Switcheo.carbon.otc"
13763
+ },
13764
+ {
13765
+ "name": "status",
13766
+ "type": "string"
13767
+ }
13768
+ ],
13769
+ "Quote": [
13770
+ {
13771
+ "name": "id",
13772
+ "type": "string"
13773
+ },
13774
+ {
13775
+ "name": "quoter",
13776
+ "type": "string"
13777
+ },
13778
+ {
13779
+ "name": "rfq_id",
13780
+ "type": "string"
13781
+ },
13782
+ {
13783
+ "name": "coin",
13784
+ "type": "Coin",
13785
+ "packageName": "/cosmos.base.v1beta1"
13786
+ },
13787
+ {
13788
+ "name": "expiry_time",
13789
+ "type": "string"
13790
+ }
13791
+ ],
13792
+ "QuoteWithStatus": [
13793
+ {
13794
+ "name": "quote",
13795
+ "type": "Quote",
13796
+ "packageName": "/Switcheo.carbon.otc"
13797
+ },
13798
+ {
13799
+ "name": "status",
13800
+ "type": "string"
13801
+ }
13802
+ ],
13803
+ "QuoteEvent": [
13804
+ {
13805
+ "name": "quote",
13806
+ "type": "Quote",
13807
+ "packageName": "/Switcheo.carbon.otc"
13808
+ },
13809
+ {
13810
+ "name": "status",
13811
+ "type": "string"
13812
+ },
13813
+ {
13814
+ "name": "updated_block_height",
13815
+ "type": "uint64"
13816
+ }
13817
+ ],
13818
+ "RfqEvent": [
13819
+ {
13820
+ "name": "rfq",
13821
+ "type": "Rfq",
13822
+ "packageName": "/Switcheo.carbon.otc"
13823
+ },
13824
+ {
13825
+ "name": "status",
13826
+ "type": "string"
13827
+ },
13828
+ {
13829
+ "name": "updated_block_height",
13830
+ "type": "uint64"
13831
+ }
13832
+ ],
13833
+ "Params": [
13834
+ {
13835
+ "name": "fee_collector_whitelisted_market_makers",
13836
+ "type": "string[]"
13837
+ },
13838
+ {
13839
+ "name": "fee_collector_blacklisted_denoms",
13840
+ "type": "string[]"
13841
+ },
13842
+ {
13843
+ "name": "fee_collector_rfq_block_interval",
13844
+ "type": "int64"
13845
+ },
13846
+ {
13847
+ "name": "fee_collector_rfq_expiry_duration",
13848
+ "type": "string"
13849
+ },
13850
+ {
13851
+ "name": "minimum_duration",
13852
+ "type": "string"
13853
+ },
13854
+ {
13855
+ "name": "maximum_duration",
13856
+ "type": "string"
13857
+ },
13858
+ {
13859
+ "name": "enable_fee_conversion",
13860
+ "type": "bool"
13861
+ }
13862
+ ],
13863
+ "ParamsToUpdate": [
13864
+ {
13865
+ "name": "fee_collector_whitelisted_market_makers",
13866
+ "type": "string[]"
13867
+ },
13868
+ {
13869
+ "name": "fee_collector_blacklisted_denoms",
13870
+ "type": "string[]"
13871
+ },
13872
+ {
13873
+ "name": "fee_collector_rfq_block_interval",
13874
+ "type": "int64"
13875
+ },
13876
+ {
13877
+ "name": "fee_collector_rfq_expiry_duration",
13878
+ "type": "string"
13879
+ },
13880
+ {
13881
+ "name": "minimum_duration",
13882
+ "type": "string"
13883
+ },
13884
+ {
13885
+ "name": "maximum_duration",
13886
+ "type": "string"
13887
+ },
13888
+ {
13889
+ "name": "enable_fee_conversion",
13890
+ "type": "bool"
13891
+ }
13892
+ ],
13893
+ "GenesisState": [
13894
+ {
13895
+ "name": "params",
13896
+ "type": "Params",
13897
+ "packageName": "/Switcheo.carbon.otc"
13898
+ },
13899
+ {
13900
+ "name": "rfqs",
13901
+ "type": "Rfq[]",
13902
+ "packageName": "/Switcheo.carbon.otc"
13903
+ },
13904
+ {
13905
+ "name": "quotes",
13906
+ "type": "Quote[]",
13907
+ "packageName": "/Switcheo.carbon.otc"
13908
+ }
13909
+ ],
13910
+ "QueryParamsRequest": [],
13911
+ "QueryParamsResponse": [
13912
+ {
13913
+ "name": "params",
13914
+ "type": "Params",
13915
+ "packageName": "/Switcheo.carbon.otc"
13916
+ }
13917
+ ],
13918
+ "QueryRfqRequest": [
13919
+ {
13920
+ "name": "id",
13921
+ "type": "string"
13922
+ }
13923
+ ],
13924
+ "QueryRfqResponse": [
13925
+ {
13926
+ "name": "rfq",
13927
+ "type": "RfqWithStatus",
13928
+ "packageName": "/Switcheo.carbon.otc"
13929
+ }
13930
+ ],
13931
+ "QueryAllRfqRequest": [
13932
+ {
13933
+ "name": "requester",
13934
+ "type": "string"
13935
+ },
13936
+ {
13937
+ "name": "buy_denom",
13938
+ "type": "string"
13939
+ },
13940
+ {
13941
+ "name": "status",
13942
+ "type": "string"
13943
+ },
13944
+ {
13945
+ "name": "pagination",
13946
+ "type": "PageRequest",
13947
+ "packageName": "/cosmos.base.query.v1beta1"
13948
+ }
13949
+ ],
13950
+ "QueryAllRfqResponse": [
13951
+ {
13952
+ "name": "rfqs",
13953
+ "type": "RfqWithStatus[]",
13954
+ "packageName": "/Switcheo.carbon.otc"
13955
+ },
13956
+ {
13957
+ "name": "pagination",
13958
+ "type": "PageResponse",
13959
+ "packageName": "/cosmos.base.query.v1beta1"
13960
+ }
13961
+ ],
13962
+ "QueryQuoteRequest": [
13963
+ {
13964
+ "name": "id",
13965
+ "type": "string"
13966
+ }
13967
+ ],
13968
+ "QueryQuoteResponse": [
13969
+ {
13970
+ "name": "quote",
13971
+ "type": "QuoteWithStatus",
13972
+ "packageName": "/Switcheo.carbon.otc"
13973
+ }
13974
+ ],
13975
+ "QueryAllQuoteRequest": [
13976
+ {
13977
+ "name": "quoter",
13978
+ "type": "string"
13979
+ },
13980
+ {
13981
+ "name": "rfq_id",
13982
+ "type": "string"
13983
+ },
13984
+ {
13985
+ "name": "denom",
13986
+ "type": "string"
13987
+ },
13988
+ {
13989
+ "name": "min_quantity",
13990
+ "type": "string"
13991
+ },
13992
+ {
13993
+ "name": "max_quantity",
13994
+ "type": "string"
13995
+ },
13996
+ {
13997
+ "name": "status",
13998
+ "type": "string"
13999
+ },
14000
+ {
14001
+ "name": "pagination",
14002
+ "type": "PageRequest",
14003
+ "packageName": "/cosmos.base.query.v1beta1"
14004
+ }
14005
+ ],
14006
+ "QueryAllQuoteResponse": [
14007
+ {
14008
+ "name": "quotes",
14009
+ "type": "QuoteWithStatus[]",
14010
+ "packageName": "/Switcheo.carbon.otc"
14011
+ },
14012
+ {
14013
+ "name": "pagination",
14014
+ "type": "PageResponse",
14015
+ "packageName": "/cosmos.base.query.v1beta1"
14016
+ }
14017
+ ],
14018
+ "MsgCreateRfq": [
14019
+ {
14020
+ "name": "requester",
14021
+ "type": "string"
14022
+ },
14023
+ {
14024
+ "name": "sell_coins",
14025
+ "type": "Coin[]",
14026
+ "packageName": "/cosmos.base.v1beta1"
14027
+ },
14028
+ {
14029
+ "name": "buy_denom",
14030
+ "type": "string"
14031
+ },
14032
+ {
14033
+ "name": "expiry_time",
14034
+ "type": "string"
14035
+ }
14036
+ ],
14037
+ "MsgCreateRfqResponse": [],
14038
+ "MsgCancelRfq": [
14039
+ {
14040
+ "name": "requester",
14041
+ "type": "string"
14042
+ },
14043
+ {
14044
+ "name": "id",
14045
+ "type": "string"
14046
+ }
14047
+ ],
14048
+ "MsgCancelRfqResponse": [],
14049
+ "MsgCreateQuote": [
14050
+ {
14051
+ "name": "quoter",
14052
+ "type": "string"
14053
+ },
14054
+ {
14055
+ "name": "rfq_id",
14056
+ "type": "string"
14057
+ },
14058
+ {
14059
+ "name": "quantity",
14060
+ "type": "string"
14061
+ },
14062
+ {
14063
+ "name": "expiry_time",
14064
+ "type": "string"
14065
+ }
14066
+ ],
14067
+ "MsgCreateQuoteResponse": [],
14068
+ "MsgAcceptQuote": [
14069
+ {
14070
+ "name": "requester",
14071
+ "type": "string"
14072
+ },
14073
+ {
14074
+ "name": "id",
14075
+ "type": "string"
14076
+ }
14077
+ ],
14078
+ "MsgAcceptQuoteResponse": [],
14079
+ "MsgUpdateParams": [
14080
+ {
14081
+ "name": "authority",
14082
+ "type": "string"
14083
+ },
14084
+ {
14085
+ "name": "params",
14086
+ "type": "ParamsToUpdate",
14087
+ "packageName": "/Switcheo.carbon.otc"
14088
+ }
14089
+ ],
14090
+ "MsgUpdateParamsResponse": []
14091
+ },
13733
14092
  "/Switcheo.carbon.perpspool": {
13734
14093
  "Quote": [
13735
14094
  {
@@ -15510,6 +15869,10 @@ exports.EIP712Types = {
15510
15869
  {
15511
15870
  "name": "main_address",
15512
15871
  "type": "string"
15872
+ },
15873
+ {
15874
+ "name": "role",
15875
+ "type": "string"
15513
15876
  }
15514
15877
  ],
15515
15878
  "QueryAllSubAccountResponse": [
@@ -370,7 +370,7 @@ class CDPModule extends base_1.default {
370
370
  }
371
371
  // start of cdp calculations
372
372
  getAccountData(account) {
373
- var _a;
373
+ var _a, _b, _c;
374
374
  return __awaiter(this, void 0, void 0, function* () {
375
375
  const sdk = this.sdkProvider;
376
376
  const debtInfoPromise = sdk.query.cdp.TokenDebtAll(CarbonSDK_1.Carbon.Cdp.QueryTokenDebtAllRequest.fromPartial({}));
@@ -382,7 +382,7 @@ class CDPModule extends base_1.default {
382
382
  const [debtInfoResponse, collateralsRsp, assetParamsRsp, debtsRsp, stablecoinDebtInfoRsp] = yield Promise.all([debtInfoPromise, collateralsPromise, assetParamsPromise, debtsPromise, stablecoinDebtInfoPromise]);
383
383
  const debtInfos = debtInfoResponse.debtInfosAll;
384
384
  const collaterals = collateralsRsp.collaterals;
385
- const assetParams = assetParamsRsp.assetParamsAll;
385
+ const assetParamsAPI = assetParamsRsp.assetParamsAll;
386
386
  let totalCollateralsUsd = number_1.BN_ZERO;
387
387
  let availableBorrowsUsd = number_1.BN_ZERO;
388
388
  let currLiquidationThreshold = number_1.BN_ZERO;
@@ -400,13 +400,13 @@ class CDPModule extends base_1.default {
400
400
  if (!collateralUsdVal) {
401
401
  continue;
402
402
  }
403
- const assetParam = assetParams.find((a) => a.denom === denom);
404
- if (!assetParam) {
403
+ const assetParamAPI = assetParamsAPI.find((a) => { var _a; return ((_a = a.assetParams) === null || _a === void 0 ? void 0 : _a.denom) === denom; });
404
+ if (!assetParamAPI) {
405
405
  continue;
406
406
  }
407
- const ltv = number_1.bnOrZero(assetParam.loanToValue).div(number_1.BN_10000);
407
+ const ltv = number_1.bnOrZero((_a = assetParamAPI.assetParams) === null || _a === void 0 ? void 0 : _a.loanToValue).div(number_1.BN_10000);
408
408
  const availableBorrowUsd = collateralUsdVal.times(ltv);
409
- const liquidationThreshold = number_1.bnOrZero(assetParam.liquidationThreshold).div(number_1.BN_10000);
409
+ const liquidationThreshold = number_1.bnOrZero((_b = assetParamAPI.assetParams) === null || _b === void 0 ? void 0 : _b.liquidationThreshold).div(number_1.BN_10000);
410
410
  const liquidationThresholdVal = collateralUsdVal.times(liquidationThreshold);
411
411
  totalCollateralsUsd = totalCollateralsUsd.plus(collateralUsdVal);
412
412
  availableBorrowsUsd = availableBorrowsUsd.plus(availableBorrowUsd);
@@ -439,7 +439,7 @@ class CDPModule extends base_1.default {
439
439
  let stablecoinDebtUsd = number_1.BN_ZERO;
440
440
  if (stablecoinDebtInfo) {
441
441
  const accountStablecoin = yield sdk.query.cdp.AccountStablecoin({ address: account });
442
- const stablecoinDecimals = (_a = (yield this.sdkProvider.getTokenClient().getDecimals(stablecoinDebtInfo.denom))) !== null && _a !== void 0 ? _a : number_1.BN_ZERO;
442
+ const stablecoinDecimals = (_c = (yield this.sdkProvider.getTokenClient().getDecimals(stablecoinDebtInfo.denom))) !== null && _c !== void 0 ? _c : number_1.BN_ZERO;
443
443
  const stablecoinDebtAmount = number_1.bnOrZero(accountStablecoin.principal).plus(number_1.bnOrZero(accountStablecoin.interest));
444
444
  stablecoinDebtUsd = stablecoinDebtAmount.shiftedBy(-stablecoinDecimals);
445
445
  totalDebtsUsd = totalDebtsUsd.plus(stablecoinDebtUsd);
@@ -568,8 +568,8 @@ class CDPModule extends base_1.default {
568
568
  const supply = (_a = totalSupply.supply.find((supply) => supply.denom === token.denom)) === null || _a === void 0 ? void 0 : _a.amount;
569
569
  const balance = (_b = moduleBalancesMap[underlyingDenom]) === null || _b === void 0 ? void 0 : _b.amount;
570
570
  const debtInfo = debtInfosAll.debtInfosAll.find((debtInfo) => debtInfo.denom === underlyingDenom);
571
- const assetParam = assetParamsAll.assetParamsAll.find((assetParam) => assetParam.denom === underlyingDenom);
572
- const rateStrategy = rateStrategies.rateStrategyParamsAll.find((rateStrategy) => rateStrategy.name === (assetParam === null || assetParam === void 0 ? void 0 : assetParam.rateStrategyName));
571
+ const assetParamAPI = assetParamsAll.assetParamsAll.find((assetParamAPI) => { var _a; return ((_a = assetParamAPI.assetParams) === null || _a === void 0 ? void 0 : _a.denom) === underlyingDenom; });
572
+ const rateStrategy = rateStrategies.rateStrategyParamsAll.find((rateStrategy) => { var _a; return rateStrategy.name === ((_a = assetParamAPI === null || assetParamAPI === void 0 ? void 0 : assetParamAPI.assetParams) === null || _a === void 0 ? void 0 : _a.rateStrategyName); });
573
573
  if (!debtInfo || !supply || !tokenPrice || !rateStrategy)
574
574
  throw new Error("unable to retrieve token info");
575
575
  const apy = CDPModule.calculateInterestAPY(debtInfo, rateStrategy);
@@ -686,6 +686,7 @@ class CDPModule extends base_1.default {
686
686
  });
687
687
  }
688
688
  calculateAPY(denom, debtInfo, assetParams, rateStrategyParams) {
689
+ var _a;
689
690
  return __awaiter(this, void 0, void 0, function* () {
690
691
  const sdk = this.sdkProvider;
691
692
  if (!debtInfo) {
@@ -697,7 +698,7 @@ class CDPModule extends base_1.default {
697
698
  if (!rateStrategyParams) {
698
699
  if (!assetParams) {
699
700
  const assetResponse = yield sdk.query.cdp.Asset(CarbonSDK_1.Carbon.Cdp.QueryAssetRequest.fromPartial({ denom }));
700
- assetParams = assetResponse.assetParams;
701
+ assetParams = (_a = assetResponse.assetParams) === null || _a === void 0 ? void 0 : _a.assetParams;
701
702
  if (!assetParams) {
702
703
  throw new Error("unable to retrieve asset param for " + denom);
703
704
  }
@@ -789,16 +790,18 @@ class CDPModule extends base_1.default {
789
790
  });
790
791
  }
791
792
  getMaxCollateralForUnlock(account, cibtDenom) {
792
- var _a, _b, _c, _d, _e;
793
+ var _a, _b, _c, _d, _e, _f;
793
794
  return __awaiter(this, void 0, void 0, function* () {
794
795
  const sdk = this.sdkProvider;
795
796
  const denom = this.getUnderlyingDenom(cibtDenom);
796
- const assetParams = yield sdk.query.cdp.Asset({ denom: denom });
797
- if (!assetParams.assetParams)
797
+ const assetResponse = yield sdk.query.cdp.Asset({ denom: denom });
798
+ if (!((_a = assetResponse.assetParams) === null || _a === void 0 ? void 0 : _a.assetParams))
798
799
  return;
799
- let unlockRatio = new bignumber_js_1.BigNumber(assetParams.assetParams.loanToValue);
800
+ const params = assetResponse.assetParams.assetParams;
801
+ const ltv = params.loanToValue;
802
+ let unlockRatio = new bignumber_js_1.BigNumber(ltv);
800
803
  if (sdk.getConfig().network === constant_1.Network.LocalHost || sdk.getConfig().network === constant_1.Network.DevNet) {
801
- unlockRatio = new bignumber_js_1.BigNumber(assetParams.assetParams.liquidationThreshold);
804
+ unlockRatio = new bignumber_js_1.BigNumber(params.liquidationThreshold);
802
805
  }
803
806
  const accountDataRequest = this.getAccountData(account);
804
807
  const tokenPriceRequest = sdk.query.pricing.TokenPrice({ denom });
@@ -808,16 +811,16 @@ class CDPModule extends base_1.default {
808
811
  cibtDenom: cibtDenom,
809
812
  });
810
813
  const [accountData, tokenPrice, accountCollateral] = yield Promise.all([accountDataRequest, tokenPriceRequest, accountCollateralRequest]);
811
- const tokenTwap = number_1.bnOrZero((_a = tokenPrice.tokenPrice) === null || _a === void 0 ? void 0 : _a.twap);
814
+ const tokenTwap = number_1.bnOrZero((_b = tokenPrice.tokenPrice) === null || _b === void 0 ? void 0 : _b.twap);
812
815
  if (tokenTwap.isZero())
813
816
  throw new Error("unable to retrieve token price for " + denom);
814
- const tokenDecimals = (_b = (yield sdk.getTokenClient().getDecimals(denom))) !== null && _b !== void 0 ? _b : 0;
817
+ const tokenDecimals = (_c = (yield sdk.getTokenClient().getDecimals(denom))) !== null && _c !== void 0 ? _c : 0;
815
818
  const availableBorrowsUsd = accountData.AvailableBorrowsUsd.minus(accountData.TotalDebtsUsd);
816
819
  const unlockableUsd = availableBorrowsUsd.multipliedBy(number_1.BN_10000).div(unlockRatio);
817
820
  const tokenAmt = unlockableUsd.div(tokenTwap.shiftedBy(-18)).shiftedBy(tokenDecimals);
818
- const cdpToActualRatio = (_c = (yield this.getCdpToActualRatio(cibtDenom))) !== null && _c !== void 0 ? _c : number_1.BN_ZERO;
821
+ const cdpToActualRatio = (_d = (yield this.getCdpToActualRatio(cibtDenom))) !== null && _d !== void 0 ? _d : number_1.BN_ZERO;
819
822
  const cdpTokenAmt = tokenAmt.multipliedBy(cdpToActualRatio);
820
- const lockedAmount = number_1.bnOrZero((_e = (_d = accountCollateral.collateral) === null || _d === void 0 ? void 0 : _d.collateralAmount) !== null && _e !== void 0 ? _e : "0");
823
+ const lockedAmount = number_1.bnOrZero((_f = (_e = accountCollateral.collateral) === null || _e === void 0 ? void 0 : _e.collateralAmount) !== null && _f !== void 0 ? _f : "0");
821
824
  return lockedAmount.lt(cdpTokenAmt) ? lockedAmount : cdpTokenAmt;
822
825
  });
823
826
  }
@@ -847,6 +850,7 @@ class CDPModule extends base_1.default {
847
850
  return denom;
848
851
  }
849
852
  getMaxCollateralForLiquidator(debtor, cibtDenom, debtDenom, debtRepaymentAmount) {
853
+ var _a;
850
854
  return __awaiter(this, void 0, void 0, function* () {
851
855
  const sdk = this.sdkProvider;
852
856
  // get the discounted price for the cdp token
@@ -863,12 +867,13 @@ class CDPModule extends base_1.default {
863
867
  if (!params.params) {
864
868
  throw new Error("unable to retrieve cdp params");
865
869
  }
866
- if (!asset.assetParams)
870
+ if (!((_a = asset.assetParams) === null || _a === void 0 ? void 0 : _a.assetParams))
867
871
  throw new Error("unable to retrieve asset param for " + cdpActualDenom);
868
872
  if (!debtorAccountCollateral.collateral) {
869
873
  throw Error("unable to retrieve debtor's collateral amount");
870
874
  }
871
- const bonus = number_1.bnOrZero(asset.assetParams.liquidationDiscount).div(number_1.BN_10000);
875
+ const assetParams = asset.assetParams.assetParams;
876
+ const bonus = number_1.bnOrZero(assetParams.liquidationDiscount).div(number_1.BN_10000);
872
877
  const cdpTokenPrice = yield this.getCdpTokenPrice(cibtDenom);
873
878
  const cdpTokenDiscountedPrice = cdpTokenPrice.multipliedBy(number_1.BN_ONE.minus(bonus));
874
879
  // get close factor
@@ -1,6 +1,7 @@
1
1
  import { Network, RequestArguments, SyncResult } from "../../constant";
2
2
  import { BlockchainV2, EVMChain } from "../../util/blockchain";
3
3
  import { ethers } from "ethers";
4
+ import { CarbonTx } from "../../util";
4
5
  import { CarbonSigner } from "../../wallet";
5
6
  import { CarbonSDK } from "../../index";
6
7
  import { StdFee } from "@cosmjs/stargate";
@@ -65,7 +66,10 @@ export declare class MetaMask extends Eip6963Provider {
65
66
  personalSign(address: string, message: string, metamaskAPI?: MetaMaskAPI): Promise<string>;
66
67
  getEncryptionPublicKey(address: string, metamaskAPI?: MetaMaskAPI): Promise<string>;
67
68
  getPublicKey(address: string, message?: string, metamaskAPI?: MetaMaskAPI): Promise<string>;
68
- signEip712(evmHexAddress: string, accountNumber: string, evmChainId: string, msgs: readonly AminoMsg[], fee: StdFee, memo: string, sequence: string, feePayer?: string): Promise<string>;
69
+ signEip712(evmHexAddress: string, accountNumber: string, evmChainId: string, msgs: readonly AminoMsg[], fee: StdFee, memo: string, sequence: string, feePayer?: string): Promise<{
70
+ sig: string;
71
+ signedDoc: CarbonTx.StdSignDoc;
72
+ }>;
69
73
  sendEvmTransaction(req: ethers.providers.TransactionRequest, metamaskAPI?: MetaMaskAPI): Promise<string>;
70
74
  storeMnemonic(encryptedMnemonic: string, blockchain?: EVMChain): Promise<string>;
71
75
  login(blockchain?: EVMChain): Promise<string | null>;