@defisaver/positions-sdk 2.1.122-shifter-dev → 2.1.122-shifter-1-dev

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.
@@ -116,13 +116,11 @@ const _getCompoundV3AccountBalances = (provider, network, block, addressMapping,
116
116
  if (!address) {
117
117
  return balances;
118
118
  }
119
- const market = ({
120
- [(0, compound_1.COMPOUND_V3_ETH)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_ETH)(network),
121
- [(0, compound_1.COMPOUND_V3_USDC)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_USDC)(network),
122
- [(0, compound_1.COMPOUND_V3_USDBC)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_USDBC)(network),
123
- [(0, compound_1.COMPOUND_V3_USDT)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_USDT)(network),
124
- [(0, compound_1.COMPOUND_V3_USDCe)(network).baseMarketAddress.toLowerCase()]: (0, compound_1.COMPOUND_V3_USDCe)(network),
125
- })[marketAddress.toLowerCase()];
119
+ const market = Object.values((0, compound_1.CompoundMarkets)(network)).find((m) => (m.baseMarketAddress
120
+ && m.baseMarketAddress !== constants_1.ZERO_ADDRESS
121
+ && m.baseMarketAddress.toLowerCase() === marketAddress.toLowerCase()));
122
+ if (!market)
123
+ throw new Error(`Unsupported Compound V3 market address ${marketAddress} on network ${network}`);
126
124
  const loanInfoContract = (0, contracts_1.CompV3ViewContractViem)(provider, network, block);
127
125
  const loanInfo = yield loanInfoContract.read.getLoanData([market.baseMarketAddress, address], (0, viem_1.setViemBlockNumber)(block));
128
126
  const baseAssetInfo = (0, tokens_1.getAssetInfo)((0, utils_1.wethToEth)(market.baseAsset), network);
@@ -16,7 +16,7 @@ import { ethToWeth, wethToEth } from '../services/utils';
16
16
  import { ZERO_ADDRESS } from '../constants';
17
17
  import { calculateBorrowingAssetLimit } from '../moneymarket';
18
18
  import { formatBaseData, formatMarketData, getCompoundV3AggregatedData, getIncentiveApys, } from '../helpers/compoundHelpers';
19
- import { COMPOUND_V3_ETH, COMPOUND_V3_USDBC, COMPOUND_V3_USDC, COMPOUND_V3_USDCe, COMPOUND_V3_USDT, } from '../markets/compound';
19
+ import { CompoundMarkets } from '../markets/compound';
20
20
  import { getEthPrice, getCompPrice, getUSDCPrice, getWstETHPrice, } from '../services/priceService';
21
21
  import { getViemProvider, setViemBlockNumber } from '../services/viem';
22
22
  const getSupportedAssetsAddressesForMarket = (selectedMarket, network) => selectedMarket.collAssets.map(asset => getAssetInfo(ethToWeth(asset), network)).map(addr => addr.address.toLowerCase());
@@ -108,13 +108,11 @@ export const _getCompoundV3AccountBalances = (provider, network, block, addressM
108
108
  if (!address) {
109
109
  return balances;
110
110
  }
111
- const market = ({
112
- [COMPOUND_V3_ETH(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_ETH(network),
113
- [COMPOUND_V3_USDC(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDC(network),
114
- [COMPOUND_V3_USDBC(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDBC(network),
115
- [COMPOUND_V3_USDT(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDT(network),
116
- [COMPOUND_V3_USDCe(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDCe(network),
117
- })[marketAddress.toLowerCase()];
111
+ const market = Object.values(CompoundMarkets(network)).find((m) => (m.baseMarketAddress
112
+ && m.baseMarketAddress !== ZERO_ADDRESS
113
+ && m.baseMarketAddress.toLowerCase() === marketAddress.toLowerCase()));
114
+ if (!market)
115
+ throw new Error(`Unsupported Compound V3 market address ${marketAddress} on network ${network}`);
118
116
  const loanInfoContract = CompV3ViewContractViem(provider, network, block);
119
117
  const loanInfo = yield loanInfoContract.read.getLoanData([market.baseMarketAddress, address], setViemBlockNumber(block));
120
118
  const baseAssetInfo = getAssetInfo(wethToEth(market.baseAsset), network);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.122-shifter-dev",
3
+ "version": "2.1.122-shifter-1-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -19,9 +19,7 @@ import { calculateBorrowingAssetLimit } from '../moneymarket';
19
19
  import {
20
20
  formatBaseData, formatMarketData, getCompoundV3AggregatedData, getIncentiveApys,
21
21
  } from '../helpers/compoundHelpers';
22
- import {
23
- COMPOUND_V3_ETH, COMPOUND_V3_USDBC, COMPOUND_V3_USDC, COMPOUND_V3_USDCe, COMPOUND_V3_USDT,
24
- } from '../markets/compound';
22
+ import { CompoundMarkets } from '../markets/compound';
25
23
  import {
26
24
  getEthPrice, getCompPrice, getUSDCPrice, getWstETHPrice,
27
25
  } from '../services/priceService';
@@ -134,13 +132,13 @@ export const _getCompoundV3AccountBalances = async (provider: Client, network: N
134
132
  return balances;
135
133
  }
136
134
 
137
- const market = ({
138
- [COMPOUND_V3_ETH(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_ETH(network),
139
- [COMPOUND_V3_USDC(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDC(network),
140
- [COMPOUND_V3_USDBC(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDBC(network),
141
- [COMPOUND_V3_USDT(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDT(network),
142
- [COMPOUND_V3_USDCe(network).baseMarketAddress.toLowerCase()]: COMPOUND_V3_USDCe(network),
143
- })[marketAddress.toLowerCase()];
135
+ const market = Object.values(CompoundMarkets(network)).find((m) => (
136
+ m.baseMarketAddress
137
+ && m.baseMarketAddress !== ZERO_ADDRESS
138
+ && m.baseMarketAddress.toLowerCase() === marketAddress.toLowerCase()
139
+ ));
140
+
141
+ if (!market) throw new Error(`Unsupported Compound V3 market address ${marketAddress} on network ${network}`);
144
142
 
145
143
  const loanInfoContract = CompV3ViewContractViem(provider, network, block);
146
144
  const loanInfo = await loanInfoContract.read.getLoanData([market.baseMarketAddress, address], setViemBlockNumber(block));