@gearbox-protocol/sdk 1.17.1 → 1.17.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.
- package/lib/apy/convexAPY.js +9 -15
- package/lib/tokens/curveLP.d.ts +4 -1
- package/lib/tokens/curveLP.js +83 -70
- package/lib/utils/formatter.js +1 -1
- package/package.json +1 -1
package/lib/apy/convexAPY.js
CHANGED
|
@@ -56,7 +56,6 @@ function getConvexAPY(_a) {
|
|
|
56
56
|
var pool = _a.pool, provider = _a.provider, networkType = _a.networkType, getTokenPrice = _a.getTokenPrice, curveAPY = _a.curveAPY;
|
|
57
57
|
return __awaiter(this, void 0, void 0, function () {
|
|
58
58
|
var tokenList, contractsList, poolParams, stakedTokenParams, underlying, basePoolAddress, crvParams, swapPoolAddress, cvxAddress, extraPoolAddresses, _b, basePoolRate, basePoolSupply, vPrice, cvxSupply, extra, cvxPrice, crvPrice, crvPerSecond, virtualSupply, crvPerUnderlying, crvPerYear, cvxPerYear, crvAPY, cvxAPY, extraAPRs, extraAPYTotal, baseApyWAD;
|
|
59
|
-
var _this = this;
|
|
60
59
|
return __generator(this, function (_c) {
|
|
61
60
|
switch (_c.label) {
|
|
62
61
|
case 0:
|
|
@@ -88,20 +87,15 @@ function getConvexAPY(_a) {
|
|
|
88
87
|
cvxPerYear = getCVXMintAmount(crvPerYear, cvxSupply);
|
|
89
88
|
crvAPY = crvPerYear.mul(crvPrice).div(constants_1.PRICE_DECIMALS);
|
|
90
89
|
cvxAPY = cvxPerYear.mul(cvxPrice).div(constants_1.PRICE_DECIMALS);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return [2 /*return*/, extraAPY];
|
|
101
|
-
});
|
|
102
|
-
}); }))];
|
|
103
|
-
case 2:
|
|
104
|
-
extraAPRs = _c.sent();
|
|
90
|
+
extraAPRs = extraPoolAddresses.map(function (_, index) {
|
|
91
|
+
var extraRewardSymbol = poolParams.extraRewards[index].rewardToken;
|
|
92
|
+
var extraPoolRate = extra[index];
|
|
93
|
+
var perUnderlying = extraPoolRate.mul(constants_1.WAD).div(virtualSupply);
|
|
94
|
+
var perYear = perUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
95
|
+
var extraPrice = getTokenPrice(tokenList[extraRewardSymbol]);
|
|
96
|
+
var extraAPY = perYear.mul(extraPrice).div(constants_1.PRICE_DECIMALS);
|
|
97
|
+
return extraAPY;
|
|
98
|
+
});
|
|
105
99
|
extraAPYTotal = extraAPRs.reduce(function (acc, apy) { return acc.add(apy); }, ethers_1.BigNumber.from(0));
|
|
106
100
|
baseApyWAD = curveAPY[underlying];
|
|
107
101
|
return [2 /*return*/, baseApyWAD.add(crvAPY).add(cvxAPY).add(extraAPYTotal)];
|
package/lib/tokens/curveLP.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { TradeAction } from "../pathfinder/tradeTypes";
|
|
|
4
4
|
import { PartialRecord } from "../utils/types";
|
|
5
5
|
import type { SupportedToken, TokenBase } from "./token";
|
|
6
6
|
import { TokenType } from "./tokenType";
|
|
7
|
-
export declare type
|
|
7
|
+
export declare type CurveMetaTokens = "FRAX3CRV" | "LUSD3CRV" | "gusd3CRV";
|
|
8
|
+
export declare type CurveLPToken = "3Crv" | "steCRV" | "crvPlain3andSUSD" | "crvFRAX" | CurveMetaTokens;
|
|
8
9
|
export declare type CurveLPTokenData = {
|
|
9
10
|
symbol: CurveLPToken;
|
|
10
11
|
type: TokenType.CURVE_LP_TOKEN;
|
|
@@ -21,5 +22,7 @@ export declare type MetaCurveLPTokenData = {
|
|
|
21
22
|
wrapper?: CurvePoolContract;
|
|
22
23
|
} & TokenBase;
|
|
23
24
|
export declare const Curve3CrvUnderlyingTokenIndex: PartialRecord<SupportedToken, BigNumber>;
|
|
25
|
+
export declare const curveMetaTokens: Record<CurveMetaTokens, MetaCurveLPTokenData>;
|
|
24
26
|
export declare const curveTokens: Record<CurveLPToken, CurveLPTokenData | MetaCurveLPTokenData>;
|
|
25
27
|
export declare const isCurveLPToken: (t: unknown) => t is CurveLPToken;
|
|
28
|
+
export declare const isCurveMetaToken: (t: unknown) => t is CurveMetaTokens;
|
package/lib/tokens/curveLP.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCurveLPToken = exports.curveTokens = exports.Curve3CrvUnderlyingTokenIndex = void 0;
|
|
14
|
+
exports.isCurveMetaToken = exports.isCurveLPToken = exports.curveTokens = exports.curveMetaTokens = exports.Curve3CrvUnderlyingTokenIndex = void 0;
|
|
4
15
|
var ethers_1 = require("ethers");
|
|
5
16
|
var tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
6
17
|
var tokenType_1 = require("./tokenType");
|
|
@@ -9,7 +20,69 @@ exports.Curve3CrvUnderlyingTokenIndex = {
|
|
|
9
20
|
USDC: ethers_1.BigNumber.from(1),
|
|
10
21
|
USDT: ethers_1.BigNumber.from(2),
|
|
11
22
|
};
|
|
12
|
-
exports.
|
|
23
|
+
exports.curveMetaTokens = {
|
|
24
|
+
// META CURVE LP TOKENS
|
|
25
|
+
FRAX3CRV: {
|
|
26
|
+
name: "Curve FRAX3CRV-f",
|
|
27
|
+
symbol: "FRAX3CRV",
|
|
28
|
+
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
29
|
+
pool: "CURVE_FRAX_POOL",
|
|
30
|
+
lpActions: [
|
|
31
|
+
{
|
|
32
|
+
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
33
|
+
contract: "CURVE_FRAX_POOL",
|
|
34
|
+
tokenOut: ["FRAX", "3Crv"],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: tradeTypes_1.TradeType.ConvexDepositLP,
|
|
38
|
+
contract: "CONVEX_BOOSTER",
|
|
39
|
+
tokenOut: "cvxFRAX3CRV",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: tradeTypes_1.TradeType.ConvexDepositLPAndStake,
|
|
43
|
+
contract: "CONVEX_BOOSTER",
|
|
44
|
+
tokenOut: "stkcvxFRAX3CRV",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
LUSD3CRV: {
|
|
49
|
+
name: "Curve LUSD3CRV-f",
|
|
50
|
+
symbol: "LUSD3CRV",
|
|
51
|
+
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
52
|
+
pool: "CURVE_LUSD_POOL",
|
|
53
|
+
lpActions: [
|
|
54
|
+
{
|
|
55
|
+
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
56
|
+
contract: "CURVE_LUSD_POOL",
|
|
57
|
+
tokenOut: ["LUSD", "3Crv"],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
gusd3CRV: {
|
|
62
|
+
name: "Curve gusd3CRV",
|
|
63
|
+
symbol: "gusd3CRV",
|
|
64
|
+
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
65
|
+
pool: "CURVE_GUSD_POOL",
|
|
66
|
+
lpActions: [
|
|
67
|
+
{
|
|
68
|
+
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
69
|
+
contract: "CURVE_GUSD_POOL",
|
|
70
|
+
tokenOut: ["GUSD", "3Crv"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: tradeTypes_1.TradeType.ConvexDepositLP,
|
|
74
|
+
contract: "CONVEX_BOOSTER",
|
|
75
|
+
tokenOut: "cvxgusd3CRV",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: tradeTypes_1.TradeType.ConvexDepositLPAndStake,
|
|
79
|
+
contract: "CONVEX_BOOSTER",
|
|
80
|
+
tokenOut: "stkcvxgusd3CRV",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
exports.curveTokens = __assign({
|
|
13
86
|
// CURVE LP TOKENS
|
|
14
87
|
"3Crv": {
|
|
15
88
|
name: "Curve 3Crv",
|
|
@@ -33,8 +106,7 @@ exports.curveTokens = {
|
|
|
33
106
|
tokenOut: "stkcvx3Crv",
|
|
34
107
|
},
|
|
35
108
|
],
|
|
36
|
-
},
|
|
37
|
-
crvFRAX: {
|
|
109
|
+
}, crvFRAX: {
|
|
38
110
|
name: "Curve.fi FRAX/USDC",
|
|
39
111
|
symbol: "crvFRAX",
|
|
40
112
|
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
@@ -56,8 +128,7 @@ exports.curveTokens = {
|
|
|
56
128
|
tokenOut: "stkcvxcrvFRAX",
|
|
57
129
|
},
|
|
58
130
|
],
|
|
59
|
-
},
|
|
60
|
-
steCRV: {
|
|
131
|
+
}, steCRV: {
|
|
61
132
|
name: "Curve steCRV",
|
|
62
133
|
symbol: "steCRV",
|
|
63
134
|
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
@@ -79,8 +150,7 @@ exports.curveTokens = {
|
|
|
79
150
|
tokenOut: "stkcvxsteCRV",
|
|
80
151
|
},
|
|
81
152
|
],
|
|
82
|
-
},
|
|
83
|
-
crvPlain3andSUSD: {
|
|
153
|
+
}, crvPlain3andSUSD: {
|
|
84
154
|
name: "Curve crvPlain3andSUSD",
|
|
85
155
|
symbol: "crvPlain3andSUSD",
|
|
86
156
|
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
@@ -103,69 +173,12 @@ exports.curveTokens = {
|
|
|
103
173
|
tokenOut: "stkcvxcrvPlain3andSUSD",
|
|
104
174
|
},
|
|
105
175
|
],
|
|
106
|
-
},
|
|
107
|
-
// META CURVE LP TOKENS
|
|
108
|
-
FRAX3CRV: {
|
|
109
|
-
name: "Curve FRAX3CRV-f",
|
|
110
|
-
symbol: "FRAX3CRV",
|
|
111
|
-
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
112
|
-
pool: "CURVE_FRAX_POOL",
|
|
113
|
-
lpActions: [
|
|
114
|
-
{
|
|
115
|
-
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
116
|
-
contract: "CURVE_FRAX_POOL",
|
|
117
|
-
tokenOut: ["FRAX", "3Crv"],
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
type: tradeTypes_1.TradeType.ConvexDepositLP,
|
|
121
|
-
contract: "CONVEX_BOOSTER",
|
|
122
|
-
tokenOut: "cvxFRAX3CRV",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
type: tradeTypes_1.TradeType.ConvexDepositLPAndStake,
|
|
126
|
-
contract: "CONVEX_BOOSTER",
|
|
127
|
-
tokenOut: "stkcvxFRAX3CRV",
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
LUSD3CRV: {
|
|
132
|
-
name: "Curve LUSD3CRV-f",
|
|
133
|
-
symbol: "LUSD3CRV",
|
|
134
|
-
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
135
|
-
pool: "CURVE_LUSD_POOL",
|
|
136
|
-
lpActions: [
|
|
137
|
-
{
|
|
138
|
-
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
139
|
-
contract: "CURVE_LUSD_POOL",
|
|
140
|
-
tokenOut: ["LUSD", "3Crv"],
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
gusd3CRV: {
|
|
145
|
-
name: "Curve gusd3CRV",
|
|
146
|
-
symbol: "gusd3CRV",
|
|
147
|
-
type: tokenType_1.TokenType.CURVE_LP_TOKEN,
|
|
148
|
-
pool: "CURVE_GUSD_POOL",
|
|
149
|
-
lpActions: [
|
|
150
|
-
{
|
|
151
|
-
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
152
|
-
contract: "CURVE_GUSD_POOL",
|
|
153
|
-
tokenOut: ["GUSD", "3Crv"],
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
type: tradeTypes_1.TradeType.ConvexDepositLP,
|
|
157
|
-
contract: "CONVEX_BOOSTER",
|
|
158
|
-
tokenOut: "cvxgusd3CRV",
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
type: tradeTypes_1.TradeType.ConvexDepositLPAndStake,
|
|
162
|
-
contract: "CONVEX_BOOSTER",
|
|
163
|
-
tokenOut: "stkcvxgusd3CRV",
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
};
|
|
176
|
+
} }, exports.curveMetaTokens);
|
|
168
177
|
var isCurveLPToken = function (t) {
|
|
169
178
|
return typeof t === "string" && !!exports.curveTokens[t];
|
|
170
179
|
};
|
|
171
180
|
exports.isCurveLPToken = isCurveLPToken;
|
|
181
|
+
var isCurveMetaToken = function (t) {
|
|
182
|
+
return typeof t === "string" && !!exports.curveMetaTokens[t];
|
|
183
|
+
};
|
|
184
|
+
exports.isCurveMetaToken = isCurveMetaToken;
|
package/lib/utils/formatter.js
CHANGED
|
@@ -57,7 +57,7 @@ exports.formatBN = formatBN;
|
|
|
57
57
|
function formatBn4dig(num, precision) {
|
|
58
58
|
if (precision === void 0) { precision = 2; }
|
|
59
59
|
if (precision > 6) {
|
|
60
|
-
throw new Error("
|
|
60
|
+
throw new Error("Precision is too high, try <= 6");
|
|
61
61
|
}
|
|
62
62
|
var numStr = num.toString();
|
|
63
63
|
if (numStr.length < 6) {
|