@gearbox-protocol/sdk 8.24.7 → 8.25.0
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/dist/cjs/plugins/zappers/extraZappers.js +84 -0
- package/dist/cjs/sdk/sdk-legacy/gearboxRewards/extraAPY.js +27 -8
- package/dist/esm/plugins/zappers/extraZappers.js +84 -0
- package/dist/esm/sdk/sdk-legacy/gearboxRewards/extraAPY.js +25 -7
- package/dist/types/sdk/sdk-legacy/gearboxRewards/extraAPY.d.ts +8 -2
- package/package.json +1 -1
|
@@ -64,6 +64,90 @@ const extraZappers = {
|
|
|
64
64
|
decimals: 18
|
|
65
65
|
},
|
|
66
66
|
pool: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
baseParams: {
|
|
70
|
+
addr: "0x17897d188bb49fea7bfac56e29b07036e16b3537",
|
|
71
|
+
version: 310n,
|
|
72
|
+
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
73
|
+
serializedParams: "0x0000000000000000000000009ef444a6d7f4a5adcd68fd5329aa5240c90e14d2000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
74
|
+
},
|
|
75
|
+
tokenIn: {
|
|
76
|
+
addr: "0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2",
|
|
77
|
+
symbol: "farmdUSDCV3",
|
|
78
|
+
name: "Farming of Trade USDC v3",
|
|
79
|
+
decimals: 6
|
|
80
|
+
},
|
|
81
|
+
tokenOut: {
|
|
82
|
+
addr: "0xC155444481854c60e7a29f4150373f479988F32D",
|
|
83
|
+
symbol: "USDC",
|
|
84
|
+
name: "USDC",
|
|
85
|
+
decimals: 6
|
|
86
|
+
},
|
|
87
|
+
pool: "0xC155444481854c60e7a29f4150373f479988F32D"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
baseParams: {
|
|
91
|
+
addr: "0x70383bac778f0285ddb5f35afbd631e5a4675c58",
|
|
92
|
+
version: 310n,
|
|
93
|
+
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
94
|
+
serializedParams: "0x0000000000000000000000009ef444a6d7f4a5adcd68fd5329aa5240c90e14d2000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
95
|
+
},
|
|
96
|
+
tokenIn: {
|
|
97
|
+
addr: "0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2",
|
|
98
|
+
symbol: "farmdUSDCV3",
|
|
99
|
+
name: "Farming of Trade USDC v3",
|
|
100
|
+
decimals: 6
|
|
101
|
+
},
|
|
102
|
+
tokenOut: {
|
|
103
|
+
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
104
|
+
symbol: "rUSDC",
|
|
105
|
+
name: "Resolv USDC",
|
|
106
|
+
decimals: 6
|
|
107
|
+
},
|
|
108
|
+
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
baseParams: {
|
|
112
|
+
addr: "0x2bC0231a1FC6a9b2E0C44AC1089F47a122a7a8c1",
|
|
113
|
+
version: 310n,
|
|
114
|
+
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
115
|
+
serializedParams: "0x000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
|
|
116
|
+
},
|
|
117
|
+
tokenIn: {
|
|
118
|
+
addr: "0xda0002859B2d05F66a753d8241fCDE8623f26F4f",
|
|
119
|
+
symbol: "dWETHV3",
|
|
120
|
+
name: "Trade WETH v3",
|
|
121
|
+
decimals: 18
|
|
122
|
+
},
|
|
123
|
+
tokenOut: {
|
|
124
|
+
addr: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A",
|
|
125
|
+
symbol: "dWETHV3-cp0x",
|
|
126
|
+
name: "Gearbox WETH v3",
|
|
127
|
+
decimals: 18
|
|
128
|
+
},
|
|
129
|
+
pool: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
baseParams: {
|
|
133
|
+
addr: "0x62af1fc6e54e66aba5322a3491b5ce1808a6fe89",
|
|
134
|
+
version: 310n,
|
|
135
|
+
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
136
|
+
serializedParams: "0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
137
|
+
},
|
|
138
|
+
tokenIn: {
|
|
139
|
+
addr: "0xda00000035fef4082F78dEF6A8903bee419FbF8E",
|
|
140
|
+
symbol: "dUSDCV3",
|
|
141
|
+
name: "Trade USDC v3",
|
|
142
|
+
decimals: 6
|
|
143
|
+
},
|
|
144
|
+
tokenOut: {
|
|
145
|
+
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
146
|
+
symbol: "rUSDC",
|
|
147
|
+
name: "Resolv USDC",
|
|
148
|
+
decimals: 6
|
|
149
|
+
},
|
|
150
|
+
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
67
151
|
}
|
|
68
152
|
]
|
|
69
153
|
};
|
|
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var extraAPY_exports = {};
|
|
30
30
|
__export(extraAPY_exports, {
|
|
31
|
-
GearboxRewardsExtraApy: () => GearboxRewardsExtraApy
|
|
31
|
+
GearboxRewardsExtraApy: () => GearboxRewardsExtraApy,
|
|
32
|
+
getKeyForPoolPointsInfo: () => getKeyForPoolPointsInfo
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(extraAPY_exports);
|
|
34
35
|
var import_axios = __toESM(require("axios"));
|
|
@@ -37,6 +38,18 @@ var import_constants = require("../../constants/index.js");
|
|
|
37
38
|
var import_endpoint = require("../core/endpoint.js");
|
|
38
39
|
var import_formatter = require("../utils/formatter.js");
|
|
39
40
|
var import_math = require("../utils/math.js");
|
|
41
|
+
function getKeyForPoolPointsInfo(i) {
|
|
42
|
+
return [
|
|
43
|
+
i.pool,
|
|
44
|
+
i.token,
|
|
45
|
+
i.symbol,
|
|
46
|
+
i.duration,
|
|
47
|
+
i.name,
|
|
48
|
+
i.type,
|
|
49
|
+
i.estimation,
|
|
50
|
+
i.condition
|
|
51
|
+
].join("-");
|
|
52
|
+
}
|
|
40
53
|
class GearboxRewardsExtraApy {
|
|
41
54
|
static async getTotalTokensOnProtocol({
|
|
42
55
|
tokensToCheck,
|
|
@@ -76,7 +89,7 @@ class GearboxRewardsExtraApy {
|
|
|
76
89
|
tokensList
|
|
77
90
|
}) {
|
|
78
91
|
const r = pools.reduce((acc, p) => {
|
|
79
|
-
const pointsInfo =
|
|
92
|
+
const pointsInfo = poolRewards[p.address] || [];
|
|
80
93
|
const poolPointsList = pointsInfo.reduce(
|
|
81
94
|
(acc2, pointsInfo2) => {
|
|
82
95
|
const { address: tokenAddress } = tokensList[pointsInfo2.token];
|
|
@@ -88,7 +101,11 @@ class GearboxRewardsExtraApy {
|
|
|
88
101
|
pointsInfo2
|
|
89
102
|
);
|
|
90
103
|
if (points !== null) {
|
|
91
|
-
acc2.push({
|
|
104
|
+
acc2.push({
|
|
105
|
+
key: getKeyForPoolPointsInfo(pointsInfo2),
|
|
106
|
+
info: pointsInfo2,
|
|
107
|
+
points
|
|
108
|
+
});
|
|
92
109
|
}
|
|
93
110
|
return acc2;
|
|
94
111
|
},
|
|
@@ -100,19 +117,21 @@ class GearboxRewardsExtraApy {
|
|
|
100
117
|
return r;
|
|
101
118
|
}
|
|
102
119
|
static getPoolTokenPoints(tokenBalanceInPool, pool, tokensList, pointsInfo) {
|
|
103
|
-
if (!tokenBalanceInPool && pointsInfo.estimation === "relative")
|
|
104
|
-
return null;
|
|
105
120
|
if (pool.expectedLiquidity <= 0) return 0n;
|
|
121
|
+
if (pointsInfo.estimation === "relative" && !tokenBalanceInPool)
|
|
122
|
+
return null;
|
|
106
123
|
const { decimals = 18 } = tokensList[pointsInfo.token] || {};
|
|
107
124
|
const targetFactor = 10n ** BigInt(decimals);
|
|
125
|
+
const defaultPoints = pointsInfo.amount * targetFactor / import_constants.PERCENTAGE_FACTOR;
|
|
126
|
+
if (pointsInfo.estimation === "absolute") return defaultPoints;
|
|
108
127
|
const { decimals: underlyingDecimals = 18 } = tokensList[pool.underlyingToken] || {};
|
|
109
128
|
const underlyingFactor = 10n ** BigInt(underlyingDecimals);
|
|
110
|
-
const
|
|
111
|
-
const points = pointsInfo.estimation === "absolute" ? defaultPoints : (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
129
|
+
const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
112
130
|
return import_math.BigIntMath.min(points, defaultPoints);
|
|
113
131
|
}
|
|
114
132
|
}
|
|
115
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
116
134
|
0 && (module.exports = {
|
|
117
|
-
GearboxRewardsExtraApy
|
|
135
|
+
GearboxRewardsExtraApy,
|
|
136
|
+
getKeyForPoolPointsInfo
|
|
118
137
|
});
|
|
@@ -41,6 +41,90 @@ const extraZappers = {
|
|
|
41
41
|
decimals: 18
|
|
42
42
|
},
|
|
43
43
|
pool: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
baseParams: {
|
|
47
|
+
addr: "0x17897d188bb49fea7bfac56e29b07036e16b3537",
|
|
48
|
+
version: 310n,
|
|
49
|
+
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
50
|
+
serializedParams: "0x0000000000000000000000009ef444a6d7f4a5adcd68fd5329aa5240c90e14d2000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
51
|
+
},
|
|
52
|
+
tokenIn: {
|
|
53
|
+
addr: "0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2",
|
|
54
|
+
symbol: "farmdUSDCV3",
|
|
55
|
+
name: "Farming of Trade USDC v3",
|
|
56
|
+
decimals: 6
|
|
57
|
+
},
|
|
58
|
+
tokenOut: {
|
|
59
|
+
addr: "0xC155444481854c60e7a29f4150373f479988F32D",
|
|
60
|
+
symbol: "USDC",
|
|
61
|
+
name: "USDC",
|
|
62
|
+
decimals: 6
|
|
63
|
+
},
|
|
64
|
+
pool: "0xC155444481854c60e7a29f4150373f479988F32D"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
baseParams: {
|
|
68
|
+
addr: "0x70383bac778f0285ddb5f35afbd631e5a4675c58",
|
|
69
|
+
version: 310n,
|
|
70
|
+
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
71
|
+
serializedParams: "0x0000000000000000000000009ef444a6d7f4a5adcd68fd5329aa5240c90e14d2000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
72
|
+
},
|
|
73
|
+
tokenIn: {
|
|
74
|
+
addr: "0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2",
|
|
75
|
+
symbol: "farmdUSDCV3",
|
|
76
|
+
name: "Farming of Trade USDC v3",
|
|
77
|
+
decimals: 6
|
|
78
|
+
},
|
|
79
|
+
tokenOut: {
|
|
80
|
+
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
81
|
+
symbol: "rUSDC",
|
|
82
|
+
name: "Resolv USDC",
|
|
83
|
+
decimals: 6
|
|
84
|
+
},
|
|
85
|
+
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
baseParams: {
|
|
89
|
+
addr: "0x2bC0231a1FC6a9b2E0C44AC1089F47a122a7a8c1",
|
|
90
|
+
version: 310n,
|
|
91
|
+
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
92
|
+
serializedParams: "0x000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
|
|
93
|
+
},
|
|
94
|
+
tokenIn: {
|
|
95
|
+
addr: "0xda0002859B2d05F66a753d8241fCDE8623f26F4f",
|
|
96
|
+
symbol: "dWETHV3",
|
|
97
|
+
name: "Trade WETH v3",
|
|
98
|
+
decimals: 18
|
|
99
|
+
},
|
|
100
|
+
tokenOut: {
|
|
101
|
+
addr: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A",
|
|
102
|
+
symbol: "dWETHV3-cp0x",
|
|
103
|
+
name: "Gearbox WETH v3",
|
|
104
|
+
decimals: 18
|
|
105
|
+
},
|
|
106
|
+
pool: "0xf00B548f1b69cB5EE559d891E03A196FB5101d4A"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
baseParams: {
|
|
110
|
+
addr: "0x62af1fc6e54e66aba5322a3491b5ce1808a6fe89",
|
|
111
|
+
version: 310n,
|
|
112
|
+
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
113
|
+
serializedParams: "0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
114
|
+
},
|
|
115
|
+
tokenIn: {
|
|
116
|
+
addr: "0xda00000035fef4082F78dEF6A8903bee419FbF8E",
|
|
117
|
+
symbol: "dUSDCV3",
|
|
118
|
+
name: "Trade USDC v3",
|
|
119
|
+
decimals: 6
|
|
120
|
+
},
|
|
121
|
+
tokenOut: {
|
|
122
|
+
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
123
|
+
symbol: "rUSDC",
|
|
124
|
+
name: "Resolv USDC",
|
|
125
|
+
decimals: 6
|
|
126
|
+
},
|
|
127
|
+
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
44
128
|
}
|
|
45
129
|
]
|
|
46
130
|
};
|
|
@@ -4,6 +4,18 @@ import { PERCENTAGE_FACTOR } from "../../constants/index.js";
|
|
|
4
4
|
import { GearboxBackendApi } from "../core/endpoint.js";
|
|
5
5
|
import { toBN } from "../utils/formatter.js";
|
|
6
6
|
import { BigIntMath } from "../utils/math.js";
|
|
7
|
+
function getKeyForPoolPointsInfo(i) {
|
|
8
|
+
return [
|
|
9
|
+
i.pool,
|
|
10
|
+
i.token,
|
|
11
|
+
i.symbol,
|
|
12
|
+
i.duration,
|
|
13
|
+
i.name,
|
|
14
|
+
i.type,
|
|
15
|
+
i.estimation,
|
|
16
|
+
i.condition
|
|
17
|
+
].join("-");
|
|
18
|
+
}
|
|
7
19
|
class GearboxRewardsExtraApy {
|
|
8
20
|
static async getTotalTokensOnProtocol({
|
|
9
21
|
tokensToCheck,
|
|
@@ -43,7 +55,7 @@ class GearboxRewardsExtraApy {
|
|
|
43
55
|
tokensList
|
|
44
56
|
}) {
|
|
45
57
|
const r = pools.reduce((acc, p) => {
|
|
46
|
-
const pointsInfo =
|
|
58
|
+
const pointsInfo = poolRewards[p.address] || [];
|
|
47
59
|
const poolPointsList = pointsInfo.reduce(
|
|
48
60
|
(acc2, pointsInfo2) => {
|
|
49
61
|
const { address: tokenAddress } = tokensList[pointsInfo2.token];
|
|
@@ -55,7 +67,11 @@ class GearboxRewardsExtraApy {
|
|
|
55
67
|
pointsInfo2
|
|
56
68
|
);
|
|
57
69
|
if (points !== null) {
|
|
58
|
-
acc2.push({
|
|
70
|
+
acc2.push({
|
|
71
|
+
key: getKeyForPoolPointsInfo(pointsInfo2),
|
|
72
|
+
info: pointsInfo2,
|
|
73
|
+
points
|
|
74
|
+
});
|
|
59
75
|
}
|
|
60
76
|
return acc2;
|
|
61
77
|
},
|
|
@@ -67,18 +83,20 @@ class GearboxRewardsExtraApy {
|
|
|
67
83
|
return r;
|
|
68
84
|
}
|
|
69
85
|
static getPoolTokenPoints(tokenBalanceInPool, pool, tokensList, pointsInfo) {
|
|
70
|
-
if (!tokenBalanceInPool && pointsInfo.estimation === "relative")
|
|
71
|
-
return null;
|
|
72
86
|
if (pool.expectedLiquidity <= 0) return 0n;
|
|
87
|
+
if (pointsInfo.estimation === "relative" && !tokenBalanceInPool)
|
|
88
|
+
return null;
|
|
73
89
|
const { decimals = 18 } = tokensList[pointsInfo.token] || {};
|
|
74
90
|
const targetFactor = 10n ** BigInt(decimals);
|
|
91
|
+
const defaultPoints = pointsInfo.amount * targetFactor / PERCENTAGE_FACTOR;
|
|
92
|
+
if (pointsInfo.estimation === "absolute") return defaultPoints;
|
|
75
93
|
const { decimals: underlyingDecimals = 18 } = tokensList[pool.underlyingToken] || {};
|
|
76
94
|
const underlyingFactor = 10n ** BigInt(underlyingDecimals);
|
|
77
|
-
const
|
|
78
|
-
const points = pointsInfo.estimation === "absolute" ? defaultPoints : (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
95
|
+
const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
|
|
79
96
|
return BigIntMath.min(points, defaultPoints);
|
|
80
97
|
}
|
|
81
98
|
}
|
|
82
99
|
export {
|
|
83
|
-
GearboxRewardsExtraApy
|
|
100
|
+
GearboxRewardsExtraApy,
|
|
101
|
+
getKeyForPoolPointsInfo
|
|
84
102
|
};
|
|
@@ -16,7 +16,7 @@ export interface PoolPointsInfo {
|
|
|
16
16
|
}
|
|
17
17
|
type PartialPool = Pick<PoolData_Legacy, "expectedLiquidity" | "underlyingToken" | "address">;
|
|
18
18
|
export interface GetPointsByPoolProps {
|
|
19
|
-
poolRewards: Record<Address,
|
|
19
|
+
poolRewards: Record<Address, Array<PoolPointsInfo>>;
|
|
20
20
|
totalTokenBalances: Record<Address, Asset>;
|
|
21
21
|
pools: Array<PartialPool>;
|
|
22
22
|
tokensList: Record<Address, TokenData>;
|
|
@@ -26,10 +26,16 @@ export interface GetTotalTokensOnProtocolProps {
|
|
|
26
26
|
tokensList: Record<Address, TokenData>;
|
|
27
27
|
network: NetworkType;
|
|
28
28
|
}
|
|
29
|
+
export type PoolPointsBase = Record<Address, Array<{
|
|
30
|
+
key: string;
|
|
31
|
+
info: PoolPointsInfo;
|
|
32
|
+
points: bigint;
|
|
33
|
+
}>>;
|
|
34
|
+
export declare function getKeyForPoolPointsInfo(i: PoolPointsInfo): string;
|
|
29
35
|
export declare class GearboxRewardsExtraApy {
|
|
30
36
|
static getTotalTokensOnProtocol({ tokensToCheck, tokensList, network, }: GetTotalTokensOnProtocolProps): Promise<[`0x${string}`, PromiseSettledResult<Asset>][]>;
|
|
31
37
|
private static getTokenTotal;
|
|
32
|
-
static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList, }: GetPointsByPoolProps):
|
|
38
|
+
static getPointsByPool({ poolRewards, totalTokenBalances, pools, tokensList, }: GetPointsByPoolProps): PoolPointsBase;
|
|
33
39
|
private static getPoolTokenPoints;
|
|
34
40
|
}
|
|
35
41
|
export {};
|