@defisaver/positions-sdk 1.0.2-dev → 1.0.2

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.
@@ -79,11 +79,6 @@ const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaiter(void
79
79
  abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
80
80
  params: [selectedMarket.controllerAddress],
81
81
  },
82
- {
83
- target: selectedMarket.controllerAddress,
84
- abiItem: (0, utils_1.getAbiItem)((0, contracts_1.getConfigContractAbi)('crvUSDwstETHController'), 'loan_discount'),
85
- params: [],
86
- },
87
82
  ];
88
83
  const multiRes = yield (0, multicall_1.multicall)(multicallData, web3, network);
89
84
  const data = multiRes[2][0];
@@ -101,12 +96,10 @@ const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaiter(void
101
96
  .toString();
102
97
  const bandsData = yield getAndFormatBands(web3, network, selectedMarket, data.minBand, data.maxBand);
103
98
  const leftToBorrow = new decimal_js_1.default(debtCeiling).minus(totalDebt).toString();
104
- const loanDiscount = (0, tokens_1.assetAmountInEth)(multiRes[3][0], debtAsset);
105
99
  return Object.assign(Object.assign({}, data), { debtCeiling,
106
100
  totalDebt,
107
101
  ammPrice, oraclePrice: (0, tokens_1.assetAmountInEth)(data.oraclePrice, debtAsset), basePrice: (0, tokens_1.assetAmountInEth)(data.basePrice, debtAsset), minted: (0, tokens_1.assetAmountInEth)(data.minted, debtAsset), redeemed: (0, tokens_1.assetAmountInEth)(data.redeemed, debtAsset), borrowRate,
108
- futureBorrowRate, bands: bandsData, leftToBorrow,
109
- loanDiscount });
102
+ futureBorrowRate, bands: bandsData, leftToBorrow });
110
103
  });
111
104
  exports.getCurveUsdGlobalData = getCurveUsdGlobalData;
112
105
  const getStatusForUser = (bandRange, activeBand, crvUSDSupplied, collSupplied, healthPercent) => {
@@ -97,6 +97,10 @@ const parseMarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0,
97
97
  supplyRate: '0',
98
98
  borrowRate,
99
99
  };
100
+ if (staking_1.STAKING_ASSETS.includes(debtAssetData.symbol)) {
101
+ debtAssetData.incentiveBorrowApy = yield (0, staking_1.getStakingApy)(debtAsset.symbol, mainnetWeb3);
102
+ debtAssetData.incentiveBorrowToken = debtAsset.symbol;
103
+ }
100
104
  const assetsData = {
101
105
  [collAsset.symbol]: collAssetData,
102
106
  [debtAsset.symbol]: debtAssetData,
@@ -59,7 +59,6 @@ export interface CrvUSDGlobalMarketData {
59
59
  futureBorrowRate: string;
60
60
  leftToBorrow: string;
61
61
  bands: BandData[];
62
- loanDiscount: string;
63
62
  }
64
63
  export interface CrvUSDAggregatedPositionData {
65
64
  ratio: string;
@@ -159,6 +159,8 @@ export interface FluidAssetData {
159
159
  price: string;
160
160
  incentiveSupplyApy?: string;
161
161
  incentiveSupplyToken?: string;
162
+ incentiveBorrowApy?: string;
163
+ incentiveBorrowToken?: string;
162
164
  totalSupply: string;
163
165
  totalBorrow: string;
164
166
  canBeSupplied: boolean;
@@ -12,10 +12,10 @@ import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
12
12
  import { CrvUSDStatus, } from '../types';
13
13
  import { multicall } from '../multicall';
14
14
  import { NetworkNumber, } from '../types/common';
15
- import { CrvUSDFactoryContract, CrvUSDViewContract, getConfigContractAbi } from '../contracts';
15
+ import { CrvUSDFactoryContract, CrvUSDViewContract } from '../contracts';
16
16
  import { getCrvUsdAggregatedData } from '../helpers/curveUsdHelpers';
17
17
  import { CrvUsdMarkets } from '../markets';
18
- import { getAbiItem, wethToEth } from '../services/utils';
18
+ import { wethToEth } from '../services/utils';
19
19
  const getAndFormatBands = (web3, network, selectedMarket, _minBand, _maxBand) => __awaiter(void 0, void 0, void 0, function* () {
20
20
  const contract = CrvUSDViewContract(web3, network);
21
21
  const minBand = parseInt(_minBand, 10);
@@ -73,11 +73,6 @@ export const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaite
73
73
  abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
74
74
  params: [selectedMarket.controllerAddress],
75
75
  },
76
- {
77
- target: selectedMarket.controllerAddress,
78
- abiItem: getAbiItem(getConfigContractAbi('crvUSDwstETHController'), 'loan_discount'),
79
- params: [],
80
- },
81
76
  ];
82
77
  const multiRes = yield multicall(multicallData, web3, network);
83
78
  const data = multiRes[2][0];
@@ -95,12 +90,10 @@ export const getCurveUsdGlobalData = (web3, network, selectedMarket) => __awaite
95
90
  .toString();
96
91
  const bandsData = yield getAndFormatBands(web3, network, selectedMarket, data.minBand, data.maxBand);
97
92
  const leftToBorrow = new Dec(debtCeiling).minus(totalDebt).toString();
98
- const loanDiscount = assetAmountInEth(multiRes[3][0], debtAsset);
99
93
  return Object.assign(Object.assign({}, data), { debtCeiling,
100
94
  totalDebt,
101
95
  ammPrice, oraclePrice: assetAmountInEth(data.oraclePrice, debtAsset), basePrice: assetAmountInEth(data.basePrice, debtAsset), minted: assetAmountInEth(data.minted, debtAsset), redeemed: assetAmountInEth(data.redeemed, debtAsset), borrowRate,
102
- futureBorrowRate, bands: bandsData, leftToBorrow,
103
- loanDiscount });
96
+ futureBorrowRate, bands: bandsData, leftToBorrow });
104
97
  });
105
98
  const getStatusForUser = (bandRange, activeBand, crvUSDSupplied, collSupplied, healthPercent) => {
106
99
  // if bands are equal, that can only be [0,0] which means user doesn't have loan (min number of bands is 4)
@@ -91,6 +91,10 @@ const parseMarketData = (web3, data, network, mainnetWeb3) => __awaiter(void 0,
91
91
  supplyRate: '0',
92
92
  borrowRate,
93
93
  };
94
+ if (STAKING_ASSETS.includes(debtAssetData.symbol)) {
95
+ debtAssetData.incentiveBorrowApy = yield getStakingApy(debtAsset.symbol, mainnetWeb3);
96
+ debtAssetData.incentiveBorrowToken = debtAsset.symbol;
97
+ }
94
98
  const assetsData = {
95
99
  [collAsset.symbol]: collAssetData,
96
100
  [debtAsset.symbol]: debtAssetData,
@@ -59,7 +59,6 @@ export interface CrvUSDGlobalMarketData {
59
59
  futureBorrowRate: string;
60
60
  leftToBorrow: string;
61
61
  bands: BandData[];
62
- loanDiscount: string;
63
62
  }
64
63
  export interface CrvUSDAggregatedPositionData {
65
64
  ratio: string;
@@ -159,6 +159,8 @@ export interface FluidAssetData {
159
159
  price: string;
160
160
  incentiveSupplyApy?: string;
161
161
  incentiveSupplyToken?: string;
162
+ incentiveBorrowApy?: string;
163
+ incentiveBorrowToken?: string;
162
164
  totalSupply: string;
163
165
  totalBorrow: string;
164
166
  canBeSupplied: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "1.0.2-dev",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -8,10 +8,10 @@ import { multicall } from '../multicall';
8
8
  import {
9
9
  Blockish, EthAddress, NetworkNumber, PositionBalances,
10
10
  } from '../types/common';
11
- import { CrvUSDFactoryContract, CrvUSDViewContract, getConfigContractAbi } from '../contracts';
11
+ import { CrvUSDFactoryContract, CrvUSDViewContract } from '../contracts';
12
12
  import { getCrvUsdAggregatedData } from '../helpers/curveUsdHelpers';
13
13
  import { CrvUsdMarkets } from '../markets';
14
- import { getAbiItem, wethToEth } from '../services/utils';
14
+ import { wethToEth } from '../services/utils';
15
15
 
16
16
  const getAndFormatBands = async (web3: Web3, network: NetworkNumber, selectedMarket: CrvUSDMarketData, _minBand: string, _maxBand: string) => {
17
17
  const contract = CrvUSDViewContract(web3, network);
@@ -73,11 +73,6 @@ export const getCurveUsdGlobalData = async (web3: Web3, network: NetworkNumber,
73
73
  abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
74
74
  params: [selectedMarket.controllerAddress],
75
75
  },
76
- {
77
- target: selectedMarket.controllerAddress,
78
- abiItem: getAbiItem(getConfigContractAbi('crvUSDwstETHController'), 'loan_discount'),
79
- params: [],
80
- },
81
76
  ];
82
77
  const multiRes = await multicall(multicallData, web3, network);
83
78
  const data = multiRes[2][0];
@@ -100,9 +95,6 @@ export const getCurveUsdGlobalData = async (web3: Web3, network: NetworkNumber,
100
95
  const bandsData = await getAndFormatBands(web3, network, selectedMarket, data.minBand, data.maxBand);
101
96
 
102
97
  const leftToBorrow = new Dec(debtCeiling).minus(totalDebt).toString();
103
-
104
- const loanDiscount = assetAmountInEth(multiRes[3][0], debtAsset);
105
-
106
98
  return {
107
99
  ...data,
108
100
  debtCeiling,
@@ -116,7 +108,6 @@ export const getCurveUsdGlobalData = async (web3: Web3, network: NetworkNumber,
116
108
  futureBorrowRate,
117
109
  bands: bandsData,
118
110
  leftToBorrow,
119
- loanDiscount,
120
111
  };
121
112
  };
122
113
 
@@ -236,4 +227,4 @@ export const getCurveUsdFullPositionData = async (web3: Web3, network: NetworkNu
236
227
  const marketData = await getCurveUsdGlobalData(web3, network, selectedMarket);
237
228
  const positionData = await getCurveUsdUserData(web3, network, address, selectedMarket, marketData.activeBand);
238
229
  return positionData;
239
- };
230
+ };
@@ -103,6 +103,11 @@ const parseMarketData = async (web3: Web3, data: FluidView.VaultDataStructOutput
103
103
  borrowRate,
104
104
  };
105
105
 
106
+ if (STAKING_ASSETS.includes(debtAssetData.symbol)) {
107
+ debtAssetData.incentiveBorrowApy = await getStakingApy(debtAsset.symbol, mainnetWeb3);
108
+ debtAssetData.incentiveBorrowToken = debtAsset.symbol;
109
+ }
110
+
106
111
  const assetsData = {
107
112
  [collAsset.symbol]: collAssetData,
108
113
  [debtAsset.symbol]: debtAssetData,
@@ -65,7 +65,6 @@ export interface CrvUSDGlobalMarketData {
65
65
  futureBorrowRate: string,
66
66
  leftToBorrow: string,
67
67
  bands: BandData[],
68
- loanDiscount: string;
69
68
  }
70
69
 
71
70
  export interface CrvUSDAggregatedPositionData {
@@ -170,6 +170,8 @@ export interface FluidAssetData {
170
170
  price: string,
171
171
  incentiveSupplyApy?: string,
172
172
  incentiveSupplyToken?: string,
173
+ incentiveBorrowApy?: string,
174
+ incentiveBorrowToken?: string,
173
175
  totalSupply: string,
174
176
  totalBorrow: string,
175
177
  canBeSupplied: boolean,