@gearbox-protocol/sdk 3.0.0-next.104 → 3.0.0-next.106
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 +2 -2
- package/lib/apy/convexAPY.js +2 -0
- package/lib/apy/curveAPY.js +1 -0
- package/lib/apy/maker.d.ts +2 -2
- package/lib/apy/maker.js +3 -0
- package/lib/apy/yearnAPY.js +1 -1
- package/lib/contracts/contractsRegister.d.ts +4 -2
- package/lib/contracts/contractsRegister.js +3 -0
- package/lib/core/creditAccount.js +3 -0
- package/lib/core/creditAccount.spec.js +1 -1
- package/lib/pathfinder/utils.js +1 -1
- package/package.json +2 -2
package/lib/apy/convexAPY.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ConvexPoolContract, ConvexPoolParams, CurveGEARPoolParams, CurveParams, CurveSteCRVPoolParams, MCall, NetworkType } from "@gearbox-protocol/sdk-gov";
|
|
2
2
|
import { CurveLPToken } from "@gearbox-protocol/sdk-gov/lib/tokens/curveLP";
|
|
3
3
|
import { SupportedToken } from "@gearbox-protocol/sdk-gov/lib/tokens/token";
|
|
4
|
-
import {
|
|
4
|
+
import { BigNumberish } from "ethers";
|
|
5
5
|
import { CurveAPYResult } from "./curveAPY";
|
|
6
6
|
type GetTokenPriceCallback = (tokenAddress: string, currency?: string) => bigint;
|
|
7
7
|
export interface GetConvexAPYBulkProps {
|
|
8
8
|
getTokenPrice: GetTokenPriceCallback;
|
|
9
9
|
curveAPY: CurveAPYResult;
|
|
10
10
|
generated: GetConvexAPYBulkCallsReturns;
|
|
11
|
-
response: Array<
|
|
11
|
+
response: Array<BigNumberish>;
|
|
12
12
|
}
|
|
13
13
|
export declare function getConvexAPYBulk(props: GetConvexAPYBulkProps): bigint[];
|
|
14
14
|
interface PoolInfo {
|
package/lib/apy/convexAPY.js
CHANGED
|
@@ -142,6 +142,8 @@ function calculateConvexAPY(props) {
|
|
|
142
142
|
const crvPerSecond = props.cvxPoolRate;
|
|
143
143
|
const vPrice = getVirtualPrice(props);
|
|
144
144
|
const virtualSupply = (props.cvxPoolSupply * vPrice) / sdk_gov_1.WAD;
|
|
145
|
+
if (!virtualSupply)
|
|
146
|
+
return 0n;
|
|
145
147
|
const crvPerUnderlying = (crvPerSecond * sdk_gov_1.WAD) / virtualSupply;
|
|
146
148
|
const crvPerYear = crvPerUnderlying * BigInt(sdk_gov_1.SECONDS_PER_YEAR);
|
|
147
149
|
const cvxPerYear = getCVXMintAmount(crvPerYear, props.cvxTokenSupply);
|
package/lib/apy/curveAPY.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getCurveAPY = void 0;
|
|
|
7
7
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const formatter_1 = require("../utils/formatter");
|
|
10
|
+
// !& wstETHCRV
|
|
10
11
|
const APY_DICTIONARY = {
|
|
11
12
|
"3Crv": "0",
|
|
12
13
|
FRAX3CRV: "34",
|
package/lib/apy/maker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ERC4626Params, ERC4626VaultContract, NetworkType } from "@gearbox-protocol/sdk-gov";
|
|
2
|
-
import {
|
|
2
|
+
import { BigNumberish } from "ethers";
|
|
3
3
|
import { Interface } from "ethers/lib/utils";
|
|
4
4
|
export declare const MAKER_VAULT_ABI: {
|
|
5
5
|
inputs: never[];
|
|
@@ -33,7 +33,7 @@ export declare function getMakerAPYBulkCalls({ pools, networkType, }: GetMakerAP
|
|
|
33
33
|
type GetMakerAPYBulkCallsReturns = ReturnType<typeof getMakerAPYBulkCalls>;
|
|
34
34
|
export interface GetMakerAPYBulkProps {
|
|
35
35
|
generated: GetMakerAPYBulkCallsReturns;
|
|
36
|
-
response: Array<
|
|
36
|
+
response: Array<BigNumberish>;
|
|
37
37
|
}
|
|
38
38
|
export declare function getMakerAPYBulk(props: GetMakerAPYBulkProps): bigint[];
|
|
39
39
|
export {};
|
package/lib/apy/maker.js
CHANGED
package/lib/apy/yearnAPY.js
CHANGED
|
@@ -19,7 +19,7 @@ async function getYearnAPY() {
|
|
|
19
19
|
}, {});
|
|
20
20
|
const yearnAPY = sdk_gov_1.TypedObjectUtils.entries(sdk_gov_1.yearnTokens).reduce((acc, [yearnSymbol]) => {
|
|
21
21
|
const { apy } = dataBySymbol[transformSymbol(yearnSymbol)] || {};
|
|
22
|
-
const { net_apy: netApy } = apy || {};
|
|
22
|
+
const { net_apy: netApy = 0 } = apy || {};
|
|
23
23
|
acc[yearnSymbol] = (0, formatter_1.toBN)((netApy / RESPONSE_DECIMALS).toString(), sdk_gov_1.WAD_DECIMALS_POW);
|
|
24
24
|
return acc;
|
|
25
25
|
}, {});
|
|
@@ -6,8 +6,9 @@ type MainnetCreditManagersV2_1 = "WETH_V2_1";
|
|
|
6
6
|
type MainnetCreditManagersV3 = "USDC_V3_TRADE_TIER_1" | "USDC_V3_TRADE_TIER_2" | "USDC_V3_TRADE_TIER_3" | "WBTC_V3_TRADE_TIER_1" | "WBTC_V3_TRADE_TIER_2" | "WBTC_V3_TRADE_TIER_3" | "WETH_V3_TRADE_TIER_1" | "WETH_V3_TRADE_TIER_2" | "WETH_V3_TRADE_TIER_3";
|
|
7
7
|
export type MainnetCreditManagers = MainnetCreditManagersV1 | MainnetCreditManagersV2 | MainnetCreditManagersV2_1 | MainnetCreditManagersV3;
|
|
8
8
|
export type ArbitrumCreditManagers = never;
|
|
9
|
+
export type OptimismCreditManagers = never;
|
|
9
10
|
type CreditManagersListType = {
|
|
10
|
-
[key in NetworkType]: key extends "Mainnet" ? Record<MainnetCreditManagers, string> : key extends "Arbitrum" ? Record<ArbitrumCreditManagers, string> : never;
|
|
11
|
+
[key in NetworkType]: key extends "Mainnet" ? Record<MainnetCreditManagers, string> : key extends "Arbitrum" ? Record<ArbitrumCreditManagers, string> : key extends "Optimism" ? Record<OptimismCreditManagers, string> : never;
|
|
11
12
|
};
|
|
12
13
|
export declare const creditManagerByNetwork: CreditManagersListType;
|
|
13
14
|
export type SupportedCreditManagers = MainnetCreditManagers | ArbitrumCreditManagers;
|
|
@@ -16,8 +17,9 @@ export type MainnetPoolsV1 = "DAI_V1" | "USDC_V1" | "WETH_V1" | "WBTC_V1" | "WST
|
|
|
16
17
|
export type MainnetPoolsV3 = "USDC_V3_TRADE" | "WETH_V3_TRADE" | "WBTC_V3_TRADE";
|
|
17
18
|
export type MainnetPools = MainnetPoolsV1 | MainnetPoolsV3;
|
|
18
19
|
export type ArbitrumPools = never;
|
|
20
|
+
export type OptimismPools = never;
|
|
19
21
|
type PoolsListType = {
|
|
20
|
-
[key in NetworkType]: key extends "Mainnet" ? Record<MainnetPools, string> : key extends "Arbitrum" ? Record<ArbitrumPools, string> : never;
|
|
22
|
+
[key in NetworkType]: key extends "Mainnet" ? Record<MainnetPools, string> : key extends "Arbitrum" ? Record<ArbitrumPools, string> : key extends "Optimism" ? Record<OptimismPools, string> : never;
|
|
21
23
|
};
|
|
22
24
|
export declare const poolByNetwork: PoolsListType;
|
|
23
25
|
export type SupportedPools = MainnetPools | ArbitrumPools;
|
|
@@ -5,6 +5,7 @@ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
|
5
5
|
exports.stEthPoolWrapper = {
|
|
6
6
|
Mainnet: "0x5a97e3E43dCBFe620ccF7865739075f92E93F5E4",
|
|
7
7
|
Arbitrum: "0x3fe62a62C022A069952069b32C9d56718D30B7ec",
|
|
8
|
+
Optimism: "",
|
|
8
9
|
};
|
|
9
10
|
exports.creditManagerByNetwork = {
|
|
10
11
|
Mainnet: {
|
|
@@ -30,6 +31,7 @@ exports.creditManagerByNetwork = {
|
|
|
30
31
|
WETH_V3_TRADE_TIER_3: "0x0b2486355e987586c32fc0feefe2943e396c484e".toLowerCase(),
|
|
31
32
|
},
|
|
32
33
|
Arbitrum: {},
|
|
34
|
+
Optimism: {},
|
|
33
35
|
};
|
|
34
36
|
exports.creditManagerByAddress = sdk_gov_1.TypedObjectUtils.entries(exports.creditManagerByNetwork).reduce((acc, [, cms]) => ({
|
|
35
37
|
...acc,
|
|
@@ -50,6 +52,7 @@ exports.poolByNetwork = {
|
|
|
50
52
|
WETH_V3_TRADE: "0xda0002859b2d05f66a753d8241fcde8623f26f4f".toLowerCase(),
|
|
51
53
|
},
|
|
52
54
|
Arbitrum: {},
|
|
55
|
+
Optimism: {},
|
|
53
56
|
};
|
|
54
57
|
const deployedContractNames = {
|
|
55
58
|
// MAINNET V1 CM
|
|
@@ -5,6 +5,7 @@ const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
|
5
5
|
const formatter_1 = require("../utils/formatter");
|
|
6
6
|
const math_1 = require("../utils/math");
|
|
7
7
|
const price_1 = require("../utils/price");
|
|
8
|
+
const MAX_UINT16 = 65535;
|
|
8
9
|
class CreditAccountData {
|
|
9
10
|
isSuccessful;
|
|
10
11
|
addr;
|
|
@@ -180,6 +181,8 @@ class CreditAccountData {
|
|
|
180
181
|
return `${creditManager.toLowerCase()}:${borrower.toLowerCase()}`;
|
|
181
182
|
}
|
|
182
183
|
static calcHealthFactor({ assets, quotas, quotasInfo, liquidationThresholds, underlyingToken, debt, prices, }) {
|
|
184
|
+
if (debt === 0n)
|
|
185
|
+
return MAX_UINT16;
|
|
183
186
|
const [, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(underlyingToken);
|
|
184
187
|
const underlyingPrice = prices[underlyingToken] || 0n;
|
|
185
188
|
const assetMoney = assets.reduce((acc, { token: tokenAddress, balance: amount }) => {
|
|
@@ -264,7 +264,7 @@ describe("CreditAccount calcHealthFactor test", () => {
|
|
|
264
264
|
underlyingToken: "",
|
|
265
265
|
debt: 0n,
|
|
266
266
|
});
|
|
267
|
-
(0, chai_1.expect)(result).to.be.eq(
|
|
267
|
+
(0, chai_1.expect)(result).to.be.eq(65535);
|
|
268
268
|
});
|
|
269
269
|
it("health factor after add collateral is calculated correctly", () => {
|
|
270
270
|
const collateral = {
|
package/lib/pathfinder/utils.js
CHANGED
|
@@ -151,7 +151,7 @@ class PathFinderUtils {
|
|
|
151
151
|
case "swapDiff":
|
|
152
152
|
case "swap": {
|
|
153
153
|
const { poolId = "" } = callObject.args?.[0] || {};
|
|
154
|
-
// !&
|
|
154
|
+
// !& implement address getting
|
|
155
155
|
const [contract] = ethers_1.utils.defaultAbiCoder.decode(["address", "unit16"], poolId);
|
|
156
156
|
return contract
|
|
157
157
|
? {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.106",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "npx mocha -r ts-node/register -r dotenv/config 'src/**/*.spec.ts'"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@gearbox-protocol/sdk-gov": "^1.
|
|
33
|
+
"@gearbox-protocol/sdk-gov": "^1.24.1",
|
|
34
34
|
"axios": "^1.2.6",
|
|
35
35
|
"decimal.js-light": "^2.5.1",
|
|
36
36
|
"deep-eql": "^4.1.0",
|