@gearbox-protocol/sdk 14.10.2-next.2 → 14.10.2-next.4
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/common-utils/utils/creditAccount/quota-utils.js +1 -0
- package/dist/cjs/common-utils/utils/validation/index.js +4 -0
- package/dist/cjs/plugins/apy/strategy-data-source.js +21 -3
- package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -0
- package/dist/esm/common-utils/utils/validation/index.js +2 -0
- package/dist/esm/plugins/apy/strategy-data-source.js +21 -3
- package/dist/types/common-utils/utils/apy/calculate-borrow-rate-from-utilization.d.ts +1 -1
- package/dist/types/common-utils/utils/apy/calculate-earnings.d.ts +2 -2
- package/dist/types/common-utils/utils/apy/calculate-safe-borrow-rate.d.ts +3 -3
- package/dist/types/common-utils/utils/creditAccount/calc-health-factor.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/calc-overall-apy.d.ts +1 -1
- package/dist/types/common-utils/utils/creditAccount/quota-utils.d.ts +3 -2
- package/dist/types/common-utils/utils/strategies/credit-managers/get-cm-allowed-collaterals.d.ts +3 -4
- package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/leverage/get-recommended-debt.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-apy.d.ts +3 -4
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.d.ts +5 -5
- package/dist/types/common-utils/utils/strategies/strategy-info/get-strategy-you-can-earn.d.ts +6 -6
- package/dist/types/common-utils/utils/strategies/strategy-info/types.d.ts +25 -0
- package/dist/types/common-utils/utils/strategies/tokens/add-amount-in-target.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/tokens/is-collateral-token.d.ts +3 -4
- package/dist/types/common-utils/utils/strategies/tokens/is-forbidden-token.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/tokens/is-obtainable-token.d.ts +2 -8
- package/dist/types/common-utils/utils/strategies/tokens/is-valid-extra-collateral-token.d.ts +3 -6
- package/dist/types/common-utils/utils/strategies/types/index.d.ts +0 -2
- package/dist/types/common-utils/utils/strategies/types/strategy-data.d.ts +0 -48
- package/dist/types/common-utils/utils/strategies/types/strategy-earnings.d.ts +5 -5
- package/dist/types/common-utils/utils/strategies/types/targetable.d.ts +2 -2
- package/dist/types/common-utils/utils/validation/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -82,6 +82,7 @@ function calcQuotaUpdate(props) {
|
|
|
82
82
|
};
|
|
83
83
|
const desiredQuota = Object.values(quotas).reduce(
|
|
84
84
|
(acc, cmQuota) => {
|
|
85
|
+
if (!cmQuota) return acc;
|
|
85
86
|
const { token, isActive } = cmQuota;
|
|
86
87
|
const { quota: initialQuota = 0n } = initialQuotas[token] || {};
|
|
87
88
|
if (!isActive) {
|
|
@@ -21,6 +21,8 @@ __reExport(validation_exports, require("./validate-balances.js"), module.exports
|
|
|
21
21
|
__reExport(validation_exports, require("./validate-credit-manager.js"), module.exports);
|
|
22
22
|
__reExport(validation_exports, require("./validate-hf.js"), module.exports);
|
|
23
23
|
__reExport(validation_exports, require("./validate-open-account.js"), module.exports);
|
|
24
|
+
__reExport(validation_exports, require("./validate-open-account-pool-quota-status.js"), module.exports);
|
|
25
|
+
__reExport(validation_exports, require("./validate-open-account-pool-status.js"), module.exports);
|
|
24
26
|
__reExport(validation_exports, require("./validate-quota.js"), module.exports);
|
|
25
27
|
__reExport(validation_exports, require("./validate-token-to-obtain.js"), module.exports);
|
|
26
28
|
__reExport(validation_exports, require("./validation-types.js"), module.exports);
|
|
@@ -32,6 +34,8 @@ __reExport(validation_exports, require("./validation-types.js"), module.exports)
|
|
|
32
34
|
...require("./validate-credit-manager.js"),
|
|
33
35
|
...require("./validate-hf.js"),
|
|
34
36
|
...require("./validate-open-account.js"),
|
|
37
|
+
...require("./validate-open-account-pool-quota-status.js"),
|
|
38
|
+
...require("./validate-open-account-pool-status.js"),
|
|
35
39
|
...require("./validate-quota.js"),
|
|
36
40
|
...require("./validate-token-to-obtain.js"),
|
|
37
41
|
...require("./validation-types.js")
|
|
@@ -36,7 +36,7 @@ class OnchainSdkStrategyDataSource {
|
|
|
36
36
|
const meta = this.sdk.tokensMeta.get(token);
|
|
37
37
|
if (!meta) return void 0;
|
|
38
38
|
const address = lc(token);
|
|
39
|
-
return { address, decimals: meta.decimals };
|
|
39
|
+
return { address, decimals: meta.decimals, symbol: meta.symbol };
|
|
40
40
|
}
|
|
41
41
|
getPool(chainId, pool) {
|
|
42
42
|
if (chainId !== this.sdk.chainId) return void 0;
|
|
@@ -44,10 +44,24 @@ class OnchainSdkStrategyDataSource {
|
|
|
44
44
|
(m) => lc(m.pool.pool.address) === lc(pool)
|
|
45
45
|
);
|
|
46
46
|
if (!market) return void 0;
|
|
47
|
+
const linearModel = market.pool.linearModel;
|
|
47
48
|
return {
|
|
48
49
|
address: lc(market.pool.pool.address),
|
|
49
50
|
totalDebtLimit: market.pool.pool.totalDebtLimit,
|
|
50
|
-
totalBorrowed: market.pool.pool.totalBorrowed
|
|
51
|
+
totalBorrowed: market.pool.pool.totalBorrowed,
|
|
52
|
+
expectedLiquidity: market.pool.pool.expectedLiquidity,
|
|
53
|
+
availableLiquidity: market.pool.pool.availableLiquidity,
|
|
54
|
+
interestModel: {
|
|
55
|
+
interestModel: market.pool.interestRateModel.address,
|
|
56
|
+
U_1: BigInt(linearModel.U1),
|
|
57
|
+
U_2: BigInt(linearModel.U2),
|
|
58
|
+
R_base: BigInt(linearModel.Rbase),
|
|
59
|
+
R_slope1: BigInt(linearModel.Rslope1),
|
|
60
|
+
R_slope2: BigInt(linearModel.Rslope2),
|
|
61
|
+
R_slope3: BigInt(linearModel.Rslope3),
|
|
62
|
+
version: Number(linearModel.version),
|
|
63
|
+
isBorrowingMoreU2Forbidden: linearModel.isBorrowingMoreU2Forbidden
|
|
64
|
+
}
|
|
51
65
|
};
|
|
52
66
|
}
|
|
53
67
|
getCreditManager(chainId, creditManager) {
|
|
@@ -142,7 +156,11 @@ class OnchainSdkStrategyDataSource {
|
|
|
142
156
|
isBorrowingForbidden: facade.maxDebtPerBlockMultiplier === 0,
|
|
143
157
|
marketConfigurator: lc(cs.marketConfigurator),
|
|
144
158
|
supportedTokens,
|
|
145
|
-
forbiddenTokens
|
|
159
|
+
forbiddenTokens,
|
|
160
|
+
name: cs.name,
|
|
161
|
+
isPaused: facade.isPaused,
|
|
162
|
+
isQuoted: (token) => quotas[token] !== void 0,
|
|
163
|
+
isForbidden: (token) => forbiddenTokens[token] === true
|
|
146
164
|
};
|
|
147
165
|
}
|
|
148
166
|
findCreditManager(creditManager) {
|
|
@@ -59,6 +59,7 @@ function calcQuotaUpdate(props) {
|
|
|
59
59
|
};
|
|
60
60
|
const desiredQuota = Object.values(quotas).reduce(
|
|
61
61
|
(acc, cmQuota) => {
|
|
62
|
+
if (!cmQuota) return acc;
|
|
62
63
|
const { token, isActive } = cmQuota;
|
|
63
64
|
const { quota: initialQuota = 0n } = initialQuotas[token] || {};
|
|
64
65
|
if (!isActive) {
|
|
@@ -4,6 +4,8 @@ export * from "./validate-balances.js";
|
|
|
4
4
|
export * from "./validate-credit-manager.js";
|
|
5
5
|
export * from "./validate-hf.js";
|
|
6
6
|
export * from "./validate-open-account.js";
|
|
7
|
+
export * from "./validate-open-account-pool-quota-status.js";
|
|
8
|
+
export * from "./validate-open-account-pool-status.js";
|
|
7
9
|
export * from "./validate-quota.js";
|
|
8
10
|
export * from "./validate-token-to-obtain.js";
|
|
9
11
|
export * from "./validation-types.js";
|
|
@@ -20,7 +20,7 @@ class OnchainSdkStrategyDataSource {
|
|
|
20
20
|
const meta = this.sdk.tokensMeta.get(token);
|
|
21
21
|
if (!meta) return void 0;
|
|
22
22
|
const address = lc(token);
|
|
23
|
-
return { address, decimals: meta.decimals };
|
|
23
|
+
return { address, decimals: meta.decimals, symbol: meta.symbol };
|
|
24
24
|
}
|
|
25
25
|
getPool(chainId, pool) {
|
|
26
26
|
if (chainId !== this.sdk.chainId) return void 0;
|
|
@@ -28,10 +28,24 @@ class OnchainSdkStrategyDataSource {
|
|
|
28
28
|
(m) => lc(m.pool.pool.address) === lc(pool)
|
|
29
29
|
);
|
|
30
30
|
if (!market) return void 0;
|
|
31
|
+
const linearModel = market.pool.linearModel;
|
|
31
32
|
return {
|
|
32
33
|
address: lc(market.pool.pool.address),
|
|
33
34
|
totalDebtLimit: market.pool.pool.totalDebtLimit,
|
|
34
|
-
totalBorrowed: market.pool.pool.totalBorrowed
|
|
35
|
+
totalBorrowed: market.pool.pool.totalBorrowed,
|
|
36
|
+
expectedLiquidity: market.pool.pool.expectedLiquidity,
|
|
37
|
+
availableLiquidity: market.pool.pool.availableLiquidity,
|
|
38
|
+
interestModel: {
|
|
39
|
+
interestModel: market.pool.interestRateModel.address,
|
|
40
|
+
U_1: BigInt(linearModel.U1),
|
|
41
|
+
U_2: BigInt(linearModel.U2),
|
|
42
|
+
R_base: BigInt(linearModel.Rbase),
|
|
43
|
+
R_slope1: BigInt(linearModel.Rslope1),
|
|
44
|
+
R_slope2: BigInt(linearModel.Rslope2),
|
|
45
|
+
R_slope3: BigInt(linearModel.Rslope3),
|
|
46
|
+
version: Number(linearModel.version),
|
|
47
|
+
isBorrowingMoreU2Forbidden: linearModel.isBorrowingMoreU2Forbidden
|
|
48
|
+
}
|
|
35
49
|
};
|
|
36
50
|
}
|
|
37
51
|
getCreditManager(chainId, creditManager) {
|
|
@@ -126,7 +140,11 @@ class OnchainSdkStrategyDataSource {
|
|
|
126
140
|
isBorrowingForbidden: facade.maxDebtPerBlockMultiplier === 0,
|
|
127
141
|
marketConfigurator: lc(cs.marketConfigurator),
|
|
128
142
|
supportedTokens,
|
|
129
|
-
forbiddenTokens
|
|
143
|
+
forbiddenTokens,
|
|
144
|
+
name: cs.name,
|
|
145
|
+
isPaused: facade.isPaused,
|
|
146
|
+
isQuoted: (token) => quotas[token] !== void 0,
|
|
147
|
+
isForbidden: (token) => forbiddenTokens[token] === true
|
|
130
148
|
};
|
|
131
149
|
}
|
|
132
150
|
findCreditManager(creditManager) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LinearModel } from "../strategies/
|
|
1
|
+
import type { LinearModel } from "../strategies/strategy-info/types.js";
|
|
2
2
|
export declare function calculateBorrowRateFromUtilization(util: bigint, model: LinearModel, extraPrecision?: bigint): bigint;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TokenSlice } from "../strategies/strategy-info/types.js";
|
|
3
3
|
export interface CalculateEarningsProps {
|
|
4
4
|
overallAPYBigInt: bigint | undefined | null;
|
|
5
5
|
targetAmount: bigint | undefined;
|
|
6
6
|
targetToken: Address;
|
|
7
|
-
tokensList: Record<Address,
|
|
7
|
+
tokensList: Record<Address, TokenSlice>;
|
|
8
8
|
prices: Record<Address, bigint>;
|
|
9
9
|
}
|
|
10
10
|
export declare function calculateEarnings({ overallAPYBigInt, targetAmount, targetToken, tokensList, prices, }: CalculateEarningsProps): {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreditManagerSlice, PoolSlice } from "../strategies/strategy-info/types.js";
|
|
2
2
|
export interface CalculateBorrowRateSafelyProps {
|
|
3
|
-
pool:
|
|
4
|
-
creditManager:
|
|
3
|
+
pool: PoolSlice;
|
|
4
|
+
creditManager: CreditManagerSlice;
|
|
5
5
|
expectedLiquidityChange?: bigint;
|
|
6
6
|
availableLiquidityChange?: bigint;
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import type { QuotaInfoIsActiveSlice, TokenDataSlice } from "./types.js";
|
|
|
4
4
|
export interface CalcHealthFactorProps {
|
|
5
5
|
assets: Array<Asset>;
|
|
6
6
|
quotas: Record<Address, Asset>;
|
|
7
|
-
quotasInfo: Record<Address, QuotaInfoIsActiveSlice>;
|
|
7
|
+
quotasInfo: Record<Address, QuotaInfoIsActiveSlice | undefined>;
|
|
8
8
|
prices: Record<Address, bigint>;
|
|
9
9
|
liquidationThresholds: Record<Address, bigint>;
|
|
10
10
|
underlyingToken: Address;
|
|
@@ -5,7 +5,7 @@ export interface CalcOverallAPYProps {
|
|
|
5
5
|
caAssets: Array<Asset>;
|
|
6
6
|
lpAPY: Record<Address, number> | undefined;
|
|
7
7
|
quotas: Record<Address, Asset>;
|
|
8
|
-
quotaRates: Record<Address, QuotaInfoSlice>;
|
|
8
|
+
quotaRates: Record<Address, QuotaInfoSlice | undefined>;
|
|
9
9
|
feeInterest: number;
|
|
10
10
|
prices: Record<Address, bigint>;
|
|
11
11
|
totalValue: bigint | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { type Asset } from "../../../sdk/index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { QuotaSlice } from "../strategies/strategy-info/types.js";
|
|
4
|
+
import type { AssetWithAmountInTarget } from "./types.js";
|
|
4
5
|
export interface CalcDefaultQuotaProps {
|
|
5
6
|
amount: bigint;
|
|
6
7
|
lt: bigint;
|
|
@@ -13,7 +14,7 @@ export interface CalcRecommendedQuotaProps {
|
|
|
13
14
|
quotaReserve: bigint;
|
|
14
15
|
}
|
|
15
16
|
export interface CalcQuotaUpdateProps {
|
|
16
|
-
quotas: Record<Address,
|
|
17
|
+
quotas: Record<Address, QuotaSlice | undefined>;
|
|
17
18
|
initialQuotas: Record<Address, {
|
|
18
19
|
quota: bigint;
|
|
19
20
|
}>;
|
package/dist/types/common-utils/utils/strategies/credit-managers/get-cm-allowed-collaterals.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { TokenData } from "../../../charts/token-data.js";
|
|
3
2
|
import type { StrategyConfigPayload } from "../../../static/strategy.js";
|
|
4
|
-
import type {
|
|
3
|
+
import type { CreditManagerSlice, TokenSlice } from "../strategy-info/types.js";
|
|
5
4
|
type ExtraCollateralConfig = NonNullable<StrategyConfigPayload["additionalCollaterals"]>[number];
|
|
6
5
|
type ExtraCollaterals = Record<Address, Array<ExtraCollateralConfig>>;
|
|
7
6
|
export interface GetCMAllowedCollateralsProps {
|
|
8
|
-
creditManager:
|
|
9
|
-
tokensList: Record<Address,
|
|
7
|
+
creditManager: CreditManagerSlice | undefined;
|
|
8
|
+
tokensList: Record<Address, TokenSlice>;
|
|
10
9
|
zeroDebt?: boolean;
|
|
11
10
|
delayedPhantoms: Record<Address, boolean>;
|
|
12
11
|
extraCollaterals: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TokenSlice } from "../strategy-info/types.js";
|
|
4
4
|
export interface GetWalletBalancesAllowedOnCMProps {
|
|
5
5
|
walletBalances: Record<Address, bigint> | undefined;
|
|
6
6
|
collateralRecord: Record<Address, Address>;
|
|
7
|
-
tokensList: Record<Address,
|
|
7
|
+
tokensList: Record<Address, TokenSlice>;
|
|
8
8
|
prices: Record<Address, bigint>;
|
|
9
9
|
nativeTokenAddress: Address;
|
|
10
10
|
wrappedNativeTokenAddress: Address | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
3
3
|
export interface CalculateMaxDebtProps {
|
|
4
4
|
targetToken: Address;
|
|
5
5
|
amount: bigint;
|
|
6
|
-
creditManager:
|
|
6
|
+
creditManager: CreditManagerSlice;
|
|
7
7
|
slippage: number;
|
|
8
8
|
constantLoss?: bigint;
|
|
9
9
|
swapCollateral?: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
3
3
|
import type { LeverageFactor } from "./get-factor-from-leverage.js";
|
|
4
4
|
export interface GetRecommendedDebtProps {
|
|
5
5
|
targetToken: Address;
|
|
6
6
|
amount: bigint;
|
|
7
|
-
creditManager:
|
|
7
|
+
creditManager: CreditManagerSlice;
|
|
8
8
|
slippage: number;
|
|
9
9
|
maxLeverageConstantLoss?: bigint;
|
|
10
10
|
maxDebtConstantLoss?: bigint;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type { QuotaInfo } from "../types/strategy-data.js";
|
|
3
|
+
import type { QuotaSlice, TokenSlice } from "./types.js";
|
|
5
4
|
export interface TotalAPY {
|
|
6
5
|
overallAPY: number | undefined | null;
|
|
7
6
|
overallAPYBigInt: bigint | undefined | null;
|
|
@@ -19,10 +18,10 @@ export interface CalculateTotalAPYProps {
|
|
|
19
18
|
effectiveBorrowRate: number;
|
|
20
19
|
showAPY: boolean;
|
|
21
20
|
prices: Record<Address, bigint>;
|
|
22
|
-
quotaRates: Record<Address, Pick<
|
|
21
|
+
quotaRates: Record<Address, Pick<QuotaSlice, "isActive" | "rate"> | undefined>;
|
|
23
22
|
quotas: Record<Address, Asset>;
|
|
24
23
|
feeInterest: number;
|
|
25
24
|
underlyingToken: Address;
|
|
26
|
-
tokensList: Record<Address,
|
|
25
|
+
tokensList: Record<Address, TokenSlice>;
|
|
27
26
|
}
|
|
28
27
|
export declare function calculateTotalAPY({ caAssets, lpAPY, pointsInfo, isValueTo, debt, totalValue, effectiveBorrowRate, showAPY, prices, quotaRates, quotas, feeInterest, underlyingToken, tokensList, }: CalculateTotalAPYProps): Omit<TotalAPY, "extraAPY">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
-
import type { TokenData } from "../../../charts/token-data.js";
|
|
4
3
|
import type { LocalDebtReward, LocalPointsInfo, LocalPointsReward } from "../types/points-slices.js";
|
|
4
|
+
import type { TokenSlice } from "./types.js";
|
|
5
5
|
export interface PointsData {
|
|
6
6
|
rates: Array<LocalPointsReward["multiplier"]>;
|
|
7
7
|
debtRates: {
|
|
@@ -17,6 +17,6 @@ export declare function calculateTotalPoints({ pointsAsset, cmAddress, info, tot
|
|
|
17
17
|
totalValue: bigint | undefined;
|
|
18
18
|
assetValue: bigint | undefined;
|
|
19
19
|
prices: Record<Address, bigint>;
|
|
20
|
-
tokensList: Record<Address,
|
|
20
|
+
tokensList: Record<Address, TokenSlice>;
|
|
21
21
|
underlyingToken: Address;
|
|
22
22
|
}): PointsData | null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice, PoolSlice, TokenSlice } from "../strategy-info/types.js";
|
|
3
3
|
import type { Strategy } from "../types/strategy.js";
|
|
4
|
-
import type { APYList,
|
|
4
|
+
import type { APYList, PricesRecord } from "../types/strategy-data.js";
|
|
5
5
|
import type { StrategyCMEarningsInfo } from "../types/strategy-earnings.js";
|
|
6
|
-
export declare function getCMYouCanEarn<CM extends
|
|
6
|
+
export declare function getCMYouCanEarn<CM extends CreditManagerSlice>({ allPrices, creditManager, tokensList, delayedPhantoms, nativeTokenAddress, wrappedNativeTokenAddress, walletBalances, strategy, slippage, quotaReserve, apyList, pools, }: {
|
|
7
7
|
allPrices: PricesRecord | undefined;
|
|
8
8
|
creditManager: CM;
|
|
9
|
-
tokensList: Record<Address,
|
|
9
|
+
tokensList: Record<Address, TokenSlice>;
|
|
10
10
|
delayedPhantoms: Record<Address, boolean>;
|
|
11
11
|
nativeTokenAddress: Address;
|
|
12
12
|
wrappedNativeTokenAddress: Address | undefined;
|
|
@@ -15,5 +15,5 @@ export declare function getCMYouCanEarn<CM extends CreditManagerData>({ allPrice
|
|
|
15
15
|
slippage: number;
|
|
16
16
|
quotaReserve: number;
|
|
17
17
|
apyList: APYList | undefined;
|
|
18
|
-
pools: Record<`0x${string}`,
|
|
18
|
+
pools: Record<`0x${string}`, PoolSlice>;
|
|
19
19
|
}): StrategyCMEarningsInfo<CM>;
|
package/dist/types/common-utils/utils/strategies/strategy-info/get-strategy-you-can-earn.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice, PoolSlice, TokenSlice } from "../strategy-info/types.js";
|
|
3
3
|
import type { Strategy } from "../types/strategy.js";
|
|
4
|
-
import type { APYList,
|
|
4
|
+
import type { APYList, PricesRecord } from "../types/strategy-data.js";
|
|
5
5
|
import type { StrategyCMEarningsInfo } from "../types/strategy-earnings.js";
|
|
6
|
-
type EarningsList<CM extends
|
|
6
|
+
type EarningsList<CM extends CreditManagerSlice> = Array<StrategyCMEarningsInfo<CM>>;
|
|
7
7
|
interface GearboxSDKFullState {
|
|
8
|
-
pools: Record<Address,
|
|
8
|
+
pools: Record<Address, PoolSlice> | undefined;
|
|
9
9
|
tokens: {
|
|
10
|
-
tokenDataList: Record<Address,
|
|
10
|
+
tokenDataList: Record<Address, TokenSlice>;
|
|
11
11
|
} | undefined;
|
|
12
12
|
addressProvider: {
|
|
13
13
|
wrappedNativeToken: Address | undefined;
|
|
@@ -16,7 +16,7 @@ interface GearboxSDKFullState {
|
|
|
16
16
|
withdrawalPhantomToken: Address;
|
|
17
17
|
}>> | undefined;
|
|
18
18
|
}
|
|
19
|
-
export declare function getStrategyYouCanEarn<CM extends
|
|
19
|
+
export declare function getStrategyYouCanEarn<CM extends CreditManagerSlice>({ strategy, creditManagers, sdkState, apyList, quotaReserve, slippage, allPrices, walletBalances, }: {
|
|
20
20
|
strategy: Strategy;
|
|
21
21
|
creditManagers: Record<Address, CM> | undefined;
|
|
22
22
|
sdkState: GearboxSDKFullState | undefined;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { PartialRecord } from "../../../../sdk/index.js";
|
|
3
3
|
import type { StrategyPointsResult } from "../points/get-strategy-points.js";
|
|
4
|
+
export interface LinearModel {
|
|
5
|
+
U_1: bigint;
|
|
6
|
+
U_2: bigint;
|
|
7
|
+
R_base: bigint;
|
|
8
|
+
R_slope1: bigint;
|
|
9
|
+
R_slope2: bigint;
|
|
10
|
+
R_slope3: bigint;
|
|
11
|
+
interestModel: Address;
|
|
12
|
+
version: number;
|
|
13
|
+
isBorrowingMoreU2Forbidden: boolean;
|
|
14
|
+
}
|
|
4
15
|
export interface QuotaSlice {
|
|
5
16
|
token: Address;
|
|
6
17
|
rate: bigint;
|
|
@@ -27,16 +38,30 @@ export interface CreditManagerSlice {
|
|
|
27
38
|
quotas: Record<Address, QuotaSlice | undefined>;
|
|
28
39
|
collateralTokens: readonly Address[];
|
|
29
40
|
maxEnabledTokensLength: number;
|
|
41
|
+
name: string;
|
|
42
|
+
isPaused: boolean;
|
|
43
|
+
supportedTokens: Record<Address, true>;
|
|
44
|
+
forbiddenTokens: Record<Address, true>;
|
|
45
|
+
isQuoted(token: Address): boolean;
|
|
46
|
+
isForbidden(token: Address): boolean;
|
|
30
47
|
}
|
|
31
48
|
export interface PoolSlice {
|
|
32
49
|
address: Address;
|
|
33
50
|
totalDebtLimit: bigint;
|
|
34
51
|
totalBorrowed: bigint;
|
|
52
|
+
expectedLiquidity: bigint;
|
|
53
|
+
availableLiquidity: bigint;
|
|
54
|
+
interestModel: LinearModel;
|
|
55
|
+
underlyingToken?: Address;
|
|
56
|
+
isPaused?: boolean;
|
|
35
57
|
}
|
|
36
58
|
export interface TokenSlice {
|
|
37
59
|
address: Address;
|
|
38
60
|
decimals: number;
|
|
39
61
|
title?: string;
|
|
62
|
+
symbol: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
isPhantom?: boolean;
|
|
40
65
|
}
|
|
41
66
|
export interface StrategySlice<ID extends string | number = string> {
|
|
42
67
|
id: ID;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function addAmountInTarget<T extends Asset>(asset: T, tokensList: Record<Address,
|
|
3
|
+
import type { TokenSlice } from "../strategy-info/types.js";
|
|
4
|
+
export declare function addAmountInTarget<T extends Asset>(asset: T, tokensList: Record<Address, TokenSlice>, prices: Record<Address, bigint>, toPrice: bigint, toDecimals: number): T & {
|
|
5
5
|
amountInTarget: bigint;
|
|
6
6
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TokenSlice } from "../strategy-info/types.js";
|
|
4
4
|
export interface AddAmountInTargetProps<T> {
|
|
5
5
|
assets: Array<T>;
|
|
6
6
|
targetToken: Address;
|
|
7
7
|
prices: Record<Address, bigint>;
|
|
8
|
-
tokensList: Record<Address,
|
|
8
|
+
tokensList: Record<Address, TokenSlice>;
|
|
9
9
|
}
|
|
10
10
|
export declare function getListWithAmountInTarget<T extends Asset>({ assets, targetToken, prices, tokensList, }: AddAmountInTargetProps<T>): Array<T & {
|
|
11
11
|
amountInTarget: bigint;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { TokenData } from "../../../charts/token-data.js";
|
|
3
2
|
import type { StrategyConfigPayload } from "../../../static/strategy.js";
|
|
4
|
-
import type {
|
|
3
|
+
import type { CreditManagerSlice, TokenSlice } from "../strategy-info/types.js";
|
|
5
4
|
type ExtraCollateralConfig = NonNullable<StrategyConfigPayload["additionalCollaterals"]>[number];
|
|
6
5
|
export interface IsCollateralTokenProps {
|
|
7
6
|
address: Address;
|
|
8
|
-
tokensList: Record<Address,
|
|
9
|
-
creditManager:
|
|
7
|
+
tokensList: Record<Address, TokenSlice>;
|
|
8
|
+
creditManager: CreditManagerSlice;
|
|
10
9
|
delayedPhantoms: Record<Address, boolean>;
|
|
11
10
|
extraCollateralConfigs: ExtraCollateralConfig[] | undefined;
|
|
12
11
|
prices: Record<Address, bigint> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
3
3
|
export declare function isForbiddenToken({ address, creditManager, }: {
|
|
4
4
|
address: Address;
|
|
5
|
-
creditManager: Pick<
|
|
5
|
+
creditManager: Pick<CreditManagerSlice, "forbiddenTokens">;
|
|
6
6
|
}): boolean;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
3
3
|
export interface IsObtainableTokenProps {
|
|
4
4
|
address: Address;
|
|
5
|
-
creditManager:
|
|
6
|
-
quotas: Record<Address, QuotaInfo | undefined>;
|
|
7
|
-
isQuoted(token: Address): boolean;
|
|
8
|
-
forbiddenTokens: Record<Address, true>;
|
|
9
|
-
liquidationThresholds: Record<Address, bigint>;
|
|
10
|
-
supportedTokens: Record<Address, true>;
|
|
11
|
-
};
|
|
5
|
+
creditManager: Pick<CreditManagerSlice, "quotas" | "isQuoted" | "forbiddenTokens" | "liquidationThresholds" | "supportedTokens">;
|
|
12
6
|
delayedPhantoms: Record<Address, boolean>;
|
|
13
7
|
}
|
|
14
8
|
export declare function isObtainableToken({ address, creditManager, delayedPhantoms, }: IsObtainableTokenProps): boolean;
|
package/dist/types/common-utils/utils/strategies/tokens/is-valid-extra-collateral-token.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
2
3
|
export interface IsValidExtraCollateralTokenProps {
|
|
3
4
|
address: Address;
|
|
4
5
|
extraCollateralConfigs: Array<Address | {
|
|
@@ -6,13 +7,9 @@ export interface IsValidExtraCollateralTokenProps {
|
|
|
6
7
|
cm: Address;
|
|
7
8
|
}> | undefined;
|
|
8
9
|
prices: Record<Address, bigint> | undefined;
|
|
9
|
-
creditManager:
|
|
10
|
-
address: Address;
|
|
11
|
-
underlyingToken: Address;
|
|
12
|
-
forbiddenTokens: Record<Address, true>;
|
|
13
|
-
} | undefined;
|
|
10
|
+
creditManager: Pick<CreditManagerSlice, "address" | "underlyingToken" | "forbiddenTokens"> | undefined;
|
|
14
11
|
tokensList: Record<Address, {
|
|
15
|
-
isPhantom
|
|
12
|
+
isPhantom?: boolean;
|
|
16
13
|
}>;
|
|
17
14
|
delayedPhantoms: Record<Address, boolean>;
|
|
18
15
|
zeroDebt?: boolean;
|
|
@@ -1,53 +1,5 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type { QuotaSlice } from "../strategy-info/types.js";
|
|
3
2
|
import type { LocalPointsInfo } from "./points-slices.js";
|
|
4
|
-
export type QuotaInfo = QuotaSlice;
|
|
5
|
-
export interface LinearModel {
|
|
6
|
-
U_1: bigint;
|
|
7
|
-
U_2: bigint;
|
|
8
|
-
R_base: bigint;
|
|
9
|
-
R_slope1: bigint;
|
|
10
|
-
R_slope2: bigint;
|
|
11
|
-
R_slope3: bigint;
|
|
12
|
-
interestModel: Address;
|
|
13
|
-
version: number;
|
|
14
|
-
isBorrowingMoreU2Forbidden: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface PoolData {
|
|
17
|
-
address: Address;
|
|
18
|
-
expectedLiquidity: bigint;
|
|
19
|
-
availableLiquidity: bigint;
|
|
20
|
-
interestModel: LinearModel;
|
|
21
|
-
totalDebtLimit: bigint;
|
|
22
|
-
totalBorrowed: bigint;
|
|
23
|
-
underlyingToken?: Address;
|
|
24
|
-
isPaused?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface CreditManagerData {
|
|
27
|
-
address: Address;
|
|
28
|
-
name: string;
|
|
29
|
-
underlyingToken: Address;
|
|
30
|
-
pool: Address;
|
|
31
|
-
isPaused: boolean;
|
|
32
|
-
collateralTokens: Array<Address>;
|
|
33
|
-
forbiddenTokens: Record<Address, true>;
|
|
34
|
-
supportedTokens: Record<Address, true>;
|
|
35
|
-
quotas: Record<Address, QuotaInfo>;
|
|
36
|
-
liquidationThresholds: Record<Address, bigint>;
|
|
37
|
-
maxDebt: bigint;
|
|
38
|
-
minDebt: bigint;
|
|
39
|
-
availableToBorrow: bigint;
|
|
40
|
-
totalDebt: bigint;
|
|
41
|
-
totalDebtLimit: bigint;
|
|
42
|
-
feeInterest: number;
|
|
43
|
-
baseBorrowRate: number;
|
|
44
|
-
maxEnabledTokensLength: number;
|
|
45
|
-
chainId: number;
|
|
46
|
-
isDegenMode: boolean;
|
|
47
|
-
degenNFT: Address;
|
|
48
|
-
isQuoted(token: Address): boolean;
|
|
49
|
-
isForbidden(token: Address): boolean;
|
|
50
|
-
}
|
|
51
3
|
export interface PricesRecord {
|
|
52
4
|
[pool: Address]: {
|
|
53
5
|
[token: Address]: bigint;
|
|
@@ -3,9 +3,9 @@ import type { calculateEarnings } from "../../apy/calculate-earnings.js";
|
|
|
3
3
|
import type { Strategy } from "../../strategies/types/strategy.js";
|
|
4
4
|
import type { calculateTotalAPY } from "../strategy-info/calculate-total-apy.js";
|
|
5
5
|
import type { calculateTotalPoints } from "../strategy-info/calculate-total-points.js";
|
|
6
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
6
7
|
import type { getListWithAmountInTarget } from "../tokens/get-list-with-amount-in-target.js";
|
|
7
|
-
|
|
8
|
-
export type StrategyCMEarningsInfo<CM extends CreditManagerData> = {
|
|
8
|
+
export type StrategyCMEarningsInfo<CM extends CreditManagerSlice> = {
|
|
9
9
|
status: "ok";
|
|
10
10
|
description: string;
|
|
11
11
|
otherInfo?: object;
|
|
@@ -34,9 +34,9 @@ export type StrategyCMEarningsInfo<CM extends CreditManagerData> = {
|
|
|
34
34
|
otherInfo?: object;
|
|
35
35
|
data: undefined;
|
|
36
36
|
};
|
|
37
|
-
export type EarningsList<CM extends
|
|
38
|
-
export type StrategyEarningsListByChain<CM extends
|
|
39
|
-
export interface BestEarningsState<CM extends
|
|
37
|
+
export type EarningsList<CM extends CreditManagerSlice> = Array<StrategyCMEarningsInfo<CM>>;
|
|
38
|
+
export type StrategyEarningsListByChain<CM extends CreditManagerSlice> = Record<number, Record<string, EarningsList<CM>>>;
|
|
39
|
+
export interface BestEarningsState<CM extends CreditManagerSlice> {
|
|
40
40
|
best: StrategyCMEarningsInfo<CM> | undefined;
|
|
41
41
|
sorted: StrategyCMEarningsInfo<CM>[];
|
|
42
42
|
bestRecord: Record<number, Record<Strategy["id"], StrategyCMEarningsInfo<CM>>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
3
3
|
export type IsTargetableProps = {
|
|
4
4
|
address: Address;
|
|
5
|
-
creditManager: Pick<
|
|
5
|
+
creditManager: Pick<CreditManagerSlice, "forbiddenTokens" | "liquidationThresholds" | "quotas" | "supportedTokens">;
|
|
6
6
|
};
|
|
@@ -4,6 +4,8 @@ export * from "./validate-balances.js";
|
|
|
4
4
|
export * from "./validate-credit-manager.js";
|
|
5
5
|
export * from "./validate-hf.js";
|
|
6
6
|
export * from "./validate-open-account.js";
|
|
7
|
+
export * from "./validate-open-account-pool-quota-status.js";
|
|
8
|
+
export * from "./validate-open-account-pool-status.js";
|
|
7
9
|
export * from "./validate-quota.js";
|
|
8
10
|
export * from "./validate-token-to-obtain.js";
|
|
9
11
|
export * from "./validation-types.js";
|