@gearbox-protocol/sdk 3.0.0-next.124 → 3.0.0-next.126
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/index.d.ts +1 -1
- package/lib/apy/index.js +1 -0
- package/lib/core/creditManager.d.ts +4 -3
- package/lib/core/creditManager.js +14 -4
- package/lib/pathfinder/balancerVault.d.ts +33 -0
- package/lib/pathfinder/balancerVault.js +59 -0
- package/lib/pathfinder/utils.d.ts +3 -2
- package/lib/pathfinder/utils.js +4 -5
- package/package.json +1 -1
package/lib/apy/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LPTokens, PartialRecord, SupportedToken } from "@gearbox-protocol/sdk-gov";
|
|
2
|
-
export type AdditionalTokenWithAPY = Extract<SupportedToken, "STETH" | "weETH" | "osETH" | "rETH" | "wstETH">;
|
|
2
|
+
export type AdditionalTokenWithAPY = Extract<SupportedToken, "STETH" | "weETH" | "osETH" | "rETH" | "wstETH" | "ezETH">;
|
|
3
3
|
export declare const additionalTokensWIthAPY: Record<AdditionalTokenWithAPY, true>;
|
|
4
4
|
export type TokensWithAPY = LPTokens | AdditionalTokenWithAPY;
|
|
5
5
|
export type LpTokensAPY = PartialRecord<TokensWithAPY, number>;
|
package/lib/apy/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { MultiCall } from "../pathfinder/core";
|
|
|
2
2
|
import { ChartsCreditManagerPayload, CreditManagerDataPayload, QuotaInfo } from "../payload/creditManager";
|
|
3
3
|
import { LinearModel } from "../payload/pool";
|
|
4
4
|
import { Asset } from "./assets";
|
|
5
|
-
|
|
5
|
+
export type CreditManagerType = "universal" | "trade" | "farm" | "restaking";
|
|
6
6
|
export declare class CreditManagerData {
|
|
7
7
|
readonly address: string;
|
|
8
|
-
readonly type:
|
|
8
|
+
readonly type: CreditManagerType;
|
|
9
9
|
readonly underlyingToken: string;
|
|
10
10
|
readonly pool: string;
|
|
11
11
|
readonly creditFacade: string;
|
|
@@ -55,7 +55,8 @@ export declare class CreditManagerData {
|
|
|
55
55
|
encodeWithdrawCollateralV3(token: string, amount: bigint, to: string): MultiCall;
|
|
56
56
|
static withdrawAllAndUnwrap_Convex(address: string, claim: boolean): MultiCall;
|
|
57
57
|
encodeOnDemandPriceUpdateV3(token: string, reserve: boolean, data: string): MultiCall;
|
|
58
|
-
static
|
|
58
|
+
static getTier(name: string): number;
|
|
59
|
+
static getType(name: string): CreditManagerType;
|
|
59
60
|
}
|
|
60
61
|
export declare class ChartsCreditManagerData {
|
|
61
62
|
readonly address: string;
|
|
@@ -4,7 +4,6 @@ exports.ChartsCreditManagerData = exports.CreditManagerData = void 0;
|
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
5
|
const txParser_1 = require("../parsers/txParser");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
-
const pool_1 = require("./pool");
|
|
8
7
|
class CreditManagerData {
|
|
9
8
|
address;
|
|
10
9
|
type;
|
|
@@ -41,10 +40,10 @@ class CreditManagerData {
|
|
|
41
40
|
constructor(payload) {
|
|
42
41
|
this.address = payload.addr.toLowerCase();
|
|
43
42
|
this.underlyingToken = payload.underlying.toLowerCase();
|
|
44
|
-
this.type =
|
|
43
|
+
this.type = CreditManagerData.getType(payload.name || "");
|
|
45
44
|
this.name = payload.name;
|
|
46
45
|
this.pool = payload.pool.toLowerCase();
|
|
47
|
-
this.tier = CreditManagerData.
|
|
46
|
+
this.tier = CreditManagerData.getTier(payload.name);
|
|
48
47
|
this.creditFacade = payload.creditFacade.toLowerCase();
|
|
49
48
|
this.creditConfigurator = payload.creditConfigurator.toLowerCase();
|
|
50
49
|
this.degenNFT = payload.degenNFT.toLowerCase();
|
|
@@ -219,7 +218,7 @@ class CreditManagerData {
|
|
|
219
218
|
callData: types_1.ICreditFacadeV3Multicall__factory.createInterface().encodeFunctionData("onDemandPriceUpdate", [token, reserve, data]),
|
|
220
219
|
};
|
|
221
220
|
}
|
|
222
|
-
static
|
|
221
|
+
static getTier(name) {
|
|
223
222
|
const DEFAULT_TIER = 99;
|
|
224
223
|
const l = name.split(" ") || [];
|
|
225
224
|
const [word, number] = l.slice(-2);
|
|
@@ -229,6 +228,17 @@ class CreditManagerData {
|
|
|
229
228
|
}
|
|
230
229
|
return DEFAULT_TIER;
|
|
231
230
|
}
|
|
231
|
+
static getType(name) {
|
|
232
|
+
const [identity = ""] = name.split(" ") || [];
|
|
233
|
+
const lc = identity.toLowerCase();
|
|
234
|
+
if (lc === "farm")
|
|
235
|
+
return "farm";
|
|
236
|
+
if (lc === "trade")
|
|
237
|
+
return "trade";
|
|
238
|
+
if (lc === "restaking")
|
|
239
|
+
return "restaking";
|
|
240
|
+
return "universal";
|
|
241
|
+
}
|
|
232
242
|
}
|
|
233
243
|
exports.CreditManagerData = CreditManagerData;
|
|
234
244
|
class ChartsCreditManagerData {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare enum PoolSpecialization {
|
|
2
|
+
GeneralPool = 0,
|
|
3
|
+
MinimalSwapInfoPool = 1,
|
|
4
|
+
TwoTokenPool = 2
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Splits a poolId into its components, i.e. pool address, pool specialization and its nonce
|
|
8
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
9
|
+
* @returns an object with the decomposed poolId
|
|
10
|
+
*/
|
|
11
|
+
export declare const splitPoolId: (poolId: string) => {
|
|
12
|
+
address: string;
|
|
13
|
+
specialization: PoolSpecialization;
|
|
14
|
+
nonce: bigint;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Extracts a pool's address from its poolId
|
|
18
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
19
|
+
* @returns the pool's address
|
|
20
|
+
*/
|
|
21
|
+
export declare const getPoolAddress: (poolId: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts a pool's specialization from its poolId
|
|
24
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
25
|
+
* @returns the pool's specialization
|
|
26
|
+
*/
|
|
27
|
+
export declare const getPoolSpecialization: (poolId: string) => PoolSpecialization;
|
|
28
|
+
/**
|
|
29
|
+
* Extracts a pool's nonce from its poolId
|
|
30
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
31
|
+
* @returns the pool's nonce
|
|
32
|
+
*/
|
|
33
|
+
export declare const getPoolNonce: (poolId: string) => bigint;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPoolNonce = exports.getPoolSpecialization = exports.getPoolAddress = exports.splitPoolId = exports.PoolSpecialization = void 0;
|
|
4
|
+
var PoolSpecialization;
|
|
5
|
+
(function (PoolSpecialization) {
|
|
6
|
+
PoolSpecialization[PoolSpecialization["GeneralPool"] = 0] = "GeneralPool";
|
|
7
|
+
PoolSpecialization[PoolSpecialization["MinimalSwapInfoPool"] = 1] = "MinimalSwapInfoPool";
|
|
8
|
+
PoolSpecialization[PoolSpecialization["TwoTokenPool"] = 2] = "TwoTokenPool";
|
|
9
|
+
})(PoolSpecialization = exports.PoolSpecialization || (exports.PoolSpecialization = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Splits a poolId into its components, i.e. pool address, pool specialization and its nonce
|
|
12
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
13
|
+
* @returns an object with the decomposed poolId
|
|
14
|
+
*/
|
|
15
|
+
const splitPoolId = (poolId) => {
|
|
16
|
+
return {
|
|
17
|
+
address: (0, exports.getPoolAddress)(poolId),
|
|
18
|
+
specialization: (0, exports.getPoolSpecialization)(poolId),
|
|
19
|
+
nonce: (0, exports.getPoolNonce)(poolId),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.splitPoolId = splitPoolId;
|
|
23
|
+
/**
|
|
24
|
+
* Extracts a pool's address from its poolId
|
|
25
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
26
|
+
* @returns the pool's address
|
|
27
|
+
*/
|
|
28
|
+
const getPoolAddress = (poolId) => {
|
|
29
|
+
if (poolId.length !== 66)
|
|
30
|
+
throw new Error("Invalid poolId length");
|
|
31
|
+
return poolId.slice(0, 42);
|
|
32
|
+
};
|
|
33
|
+
exports.getPoolAddress = getPoolAddress;
|
|
34
|
+
/**
|
|
35
|
+
* Extracts a pool's specialization from its poolId
|
|
36
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
37
|
+
* @returns the pool's specialization
|
|
38
|
+
*/
|
|
39
|
+
const getPoolSpecialization = (poolId) => {
|
|
40
|
+
if (poolId.length !== 66)
|
|
41
|
+
throw new Error("Invalid poolId length");
|
|
42
|
+
// Only have 3 pool specializations so we can just pull the relevant character
|
|
43
|
+
const specializationCode = parseInt(poolId[45], 10);
|
|
44
|
+
if (specializationCode >= 3)
|
|
45
|
+
throw new Error("Invalid pool specialization");
|
|
46
|
+
return specializationCode;
|
|
47
|
+
};
|
|
48
|
+
exports.getPoolSpecialization = getPoolSpecialization;
|
|
49
|
+
/**
|
|
50
|
+
* Extracts a pool's nonce from its poolId
|
|
51
|
+
* @param poolId - a bytes32 string of the pool's ID
|
|
52
|
+
* @returns the pool's nonce
|
|
53
|
+
*/
|
|
54
|
+
const getPoolNonce = (poolId) => {
|
|
55
|
+
if (poolId.length !== 66)
|
|
56
|
+
throw new Error("Invalid poolId length");
|
|
57
|
+
return BigInt(`0x${poolId.slice(46)}`);
|
|
58
|
+
};
|
|
59
|
+
exports.getPoolNonce = getPoolNonce;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { providers
|
|
1
|
+
import { providers } from "ethers";
|
|
2
|
+
import { Interface } from "ethers/lib/utils";
|
|
2
3
|
import { MultiCall } from "./core";
|
|
3
4
|
export interface FeeInfo {
|
|
4
5
|
type: KnownFeeTypes;
|
|
@@ -16,7 +17,7 @@ export declare const BALANCER_VAULT_ABI: {
|
|
|
16
17
|
stateMutability: string;
|
|
17
18
|
type: string;
|
|
18
19
|
}[];
|
|
19
|
-
export declare const BALANCER_VAULT_INTERFACE:
|
|
20
|
+
export declare const BALANCER_VAULT_INTERFACE: Interface;
|
|
20
21
|
interface FindPathFeesProps {
|
|
21
22
|
calls: Array<MultiCall>;
|
|
22
23
|
provider: providers.Provider;
|
package/lib/pathfinder/utils.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathFinderUtils = exports.BALANCER_VAULT_INTERFACE = exports.BALANCER_VAULT_ABI = void 0;
|
|
4
4
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
5
|
-
const ethers_1 = require("ethers");
|
|
6
5
|
const utils_1 = require("ethers/lib/utils");
|
|
7
6
|
const balancerV2VaultParser_1 = require("../parsers/balancerV2VaultParser");
|
|
8
7
|
const curveAdapterParser_1 = require("../parsers/curveAdapterParser");
|
|
@@ -11,6 +10,7 @@ const txParser_1 = require("../parsers/txParser");
|
|
|
11
10
|
const uniV2AdapterParser_1 = require("../parsers/uniV2AdapterParser");
|
|
12
11
|
const uniV3AdapterParser_1 = require("../parsers/uniV3AdapterParser");
|
|
13
12
|
const types_1 = require("../types");
|
|
13
|
+
const balancerVault_1 = require("./balancerVault");
|
|
14
14
|
const CURVE_FEE_DECIMALS = 100000000n;
|
|
15
15
|
const BALANCER_FEE_DECIMALS = 10000000000000000n;
|
|
16
16
|
exports.BALANCER_VAULT_ABI = [
|
|
@@ -151,11 +151,10 @@ class PathFinderUtils {
|
|
|
151
151
|
case "swapDiff":
|
|
152
152
|
case "swap": {
|
|
153
153
|
const { poolId = "" } = callObject.args?.[0] || {};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return contract
|
|
154
|
+
const { address } = (0, balancerVault_1.splitPoolId)(poolId);
|
|
155
|
+
return address
|
|
157
156
|
? {
|
|
158
|
-
address
|
|
157
|
+
address,
|
|
159
158
|
interface: exports.BALANCER_VAULT_INTERFACE,
|
|
160
159
|
method: "getSwapFeePercentage()",
|
|
161
160
|
}
|