@gearbox-protocol/sdk 1.18.0 → 1.18.1
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/apy/convexAPY.d.ts +4 -2
- package/lib/apy/convexAPY.js +8 -3
- package/package.json +1 -1
package/lib/apy/convexAPY.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import { NetworkType } from "../core/constants";
|
|
|
4
4
|
import { CurveLPToken } from "../tokens/curveLP";
|
|
5
5
|
import { SupportedToken } from "../tokens/token";
|
|
6
6
|
import { CurveAPYResult } from "./curveAPY";
|
|
7
|
+
declare type GetTokenPriceCallback = (tokenAddress: string, currency?: string) => BigNumber;
|
|
7
8
|
export interface GetConvexAPYBaseProps {
|
|
8
9
|
provider: providers.Provider;
|
|
9
10
|
networkType: NetworkType;
|
|
10
|
-
getTokenPrice:
|
|
11
|
+
getTokenPrice: GetTokenPriceCallback;
|
|
11
12
|
curveAPY: CurveAPYResult;
|
|
12
13
|
}
|
|
13
14
|
export interface GetConvexAPYBulkProps extends GetConvexAPYBaseProps {
|
|
@@ -28,7 +29,8 @@ export interface CalculateConvexAPYProps {
|
|
|
28
29
|
extraPoolAddresses: string[];
|
|
29
30
|
poolParams: ConvexPoolParams;
|
|
30
31
|
underlying: CurveLPToken;
|
|
31
|
-
getTokenPrice:
|
|
32
|
+
getTokenPrice: GetTokenPriceCallback;
|
|
32
33
|
curveAPY: CurveAPYResult;
|
|
33
34
|
tokenList: Record<SupportedToken, string>;
|
|
34
35
|
}
|
|
36
|
+
export {};
|
package/lib/apy/convexAPY.js
CHANGED
|
@@ -203,10 +203,15 @@ function getCVXMintAmount(crvAmount, cvxSupply) {
|
|
|
203
203
|
return ethers_1.BigNumber.from(0);
|
|
204
204
|
}
|
|
205
205
|
exports.getCVXMintAmount = getCVXMintAmount;
|
|
206
|
+
var CURRENCY_LIST = {
|
|
207
|
+
stkcvxsteCRV: "WETH",
|
|
208
|
+
};
|
|
206
209
|
function calculateConvexAPY(_a) {
|
|
207
210
|
var basePoolRate = _a.basePoolRate, basePoolSupply = _a.basePoolSupply, vPrice = _a.vPrice, cvxSupply = _a.cvxSupply, extra = _a.extra, extraPoolAddresses = _a.extraPoolAddresses, poolParams = _a.poolParams, underlying = _a.underlying, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY, tokenList = _a.tokenList;
|
|
208
|
-
var
|
|
209
|
-
var
|
|
211
|
+
var currencySymbol = CURRENCY_LIST[poolParams.stakedToken];
|
|
212
|
+
var currency = currencySymbol && tokenList[currencySymbol || ""];
|
|
213
|
+
var cvxPrice = getTokenPrice(tokenList.CVX, currency);
|
|
214
|
+
var crvPrice = getTokenPrice(tokenList.CRV, currency);
|
|
210
215
|
var crvPerSecond = basePoolRate;
|
|
211
216
|
var virtualSupply = basePoolSupply.mul(vPrice).div(constants_1.WAD);
|
|
212
217
|
var crvPerUnderlying = crvPerSecond.mul(constants_1.WAD).div(virtualSupply);
|
|
@@ -219,7 +224,7 @@ function calculateConvexAPY(_a) {
|
|
|
219
224
|
var extraPoolRate = extra[index];
|
|
220
225
|
var perUnderlying = extraPoolRate.mul(constants_1.WAD).div(virtualSupply);
|
|
221
226
|
var perYear = perUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
222
|
-
var extraPrice = getTokenPrice(tokenList[extraRewardSymbol]);
|
|
227
|
+
var extraPrice = getTokenPrice(tokenList[extraRewardSymbol], currency);
|
|
223
228
|
var extraAPY = perYear.mul(extraPrice).div(constants_1.PRICE_DECIMALS);
|
|
224
229
|
return extraAPY;
|
|
225
230
|
});
|