@gearbox-protocol/sdk 15.1.0-next.24 → 15.1.0-next.26
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/model/charts.js +20 -34
- package/dist/cjs/model/opportunities.schema.js +15 -13
- package/dist/cjs/sdk/OnchainSDK.js +16 -0
- package/dist/cjs/sdk/accounts/intents/guards.js +1 -7
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/sdk/accounts/intents/utils/pick-token.js +2 -2
- package/dist/cjs/sdk/base/TokensMeta.js +33 -1
- package/dist/cjs/sdk/base/index.js +1 -0
- package/dist/cjs/sdk/base/token-types.js +13 -0
- package/dist/cjs/sdk/chain/chains.js +9 -12
- package/dist/cjs/sdk/chain/index.js +0 -1
- package/dist/cjs/sdk/index.js +1 -2
- package/dist/cjs/sdk/market/MarketSuite.js +11 -5
- package/dist/cjs/sdk/market/credit/CreditSuite.js +14 -3
- package/dist/cjs/sdk/market/credit/collateralUtils.js +2 -14
- package/dist/cjs/sdk/market/credit/index.js +0 -1
- package/dist/cjs/sdk/market/index.js +0 -1
- package/dist/cjs/sdk/market/strategyName.js +4 -6
- package/dist/cjs/sdk/positions/PositionsService.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/charts.js +20 -34
- package/dist/esm/model/opportunities.schema.js +15 -13
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/OnchainSDK.js +16 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/intents/guards.js +1 -7
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/sdk/accounts/intents/utils/pick-token.js +1 -1
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +36 -4
- package/dist/esm/sdk/base/index.js +2 -2
- package/dist/esm/sdk/base/token-types.js +13 -1
- package/dist/esm/sdk/chain/chains.js +10 -12
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/chain/index.js +2 -2
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/index.js +4 -4
- package/dist/esm/sdk/market/MarketSuite.js +11 -5
- package/dist/esm/sdk/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/sdk/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditSuite.js +14 -3
- package/dist/esm/sdk/market/credit/collateralUtils.js +2 -13
- package/dist/esm/sdk/market/credit/index.js +2 -2
- package/dist/esm/sdk/market/index.js +2 -2
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/strategyName.js +4 -6
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/positions/PositionsService.js +1 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/charts.d.ts +16 -23
- package/dist/types/model/charts.schema.d.ts +24 -52
- package/dist/types/model/opportunities.d.ts +18 -4
- package/dist/types/model/opportunities.schema.d.ts +101 -38
- package/dist/types/model/primitives.d.ts +4 -0
- package/dist/types/new-sdk/opportunities/types.d.ts +1 -1
- package/dist/types/new-sdk/positions/types.d.ts +1 -1
- package/dist/types/sdk/base/TokensMeta.d.ts +31 -2
- package/dist/types/sdk/base/index.d.ts +3 -3
- package/dist/types/sdk/base/token-types.d.ts +14 -1
- package/dist/types/sdk/chain/chains.d.ts +3 -11
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +5 -5
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +7 -1
- package/dist/types/sdk/market/credit/collateralUtils.d.ts +1 -7
- package/dist/types/sdk/market/credit/index.d.ts +2 -2
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/strategyName.d.ts +3 -5
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
4
3
|
import "../../base/index.js";
|
|
4
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/sdk/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -178,11 +178,22 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
181
|
-
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
181
|
+
* see {@link isStrategyCollateral} for the per-token criteria. Tokens the
|
|
182
|
+
* facade has forbidden are excluded — they cannot be taken on — even when
|
|
183
|
+
* they still pass the shared eligibility rule used for target selection.
|
|
182
184
|
*/
|
|
183
185
|
get strategyCollaterals() {
|
|
184
186
|
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return [];
|
|
185
|
-
|
|
187
|
+
const forbidden = new Set(this.forbiddenTokens);
|
|
188
|
+
return this.creditManager.collateralTokens.filter((token) => !forbidden.has(token) && isStrategyCollateral(this.#strategyCollateralProps(token), true));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Tokens forbidden by the facade.
|
|
192
|
+
*/
|
|
193
|
+
get forbiddenTokens() {
|
|
194
|
+
const mask = this.creditFacade.forbiddenTokensMask;
|
|
195
|
+
if (mask === 0n) return [];
|
|
196
|
+
return this.creditManager.collateralTokens.filter((_, i) => (mask & 1n << BigInt(i)) !== 0n);
|
|
186
197
|
}
|
|
187
198
|
/**
|
|
188
199
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -220,7 +231,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
220
231
|
get strategyName() {
|
|
221
232
|
const collateral = this.strategyTargetCollateral;
|
|
222
233
|
if (!collateral) return;
|
|
223
|
-
return strategyName(this.tokensMeta.mustGetToken(collateral), this.market.underlyingToken
|
|
234
|
+
return strategyName(this.tokensMeta.mustGetToken(collateral), this.market.underlyingToken);
|
|
224
235
|
}
|
|
225
236
|
/**
|
|
226
237
|
* Describes this suite's leveraged strategy as the shared read model does,
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import "../../constants/math.js";
|
|
2
2
|
import "../../constants/index.js";
|
|
3
|
+
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES } from "../../base/token-types.js";
|
|
3
4
|
import { isAddressEqual } from "viem";
|
|
4
5
|
//#region src/sdk/market/credit/collateralUtils.ts
|
|
5
|
-
/**
|
|
6
|
-
* Withdrawal and redemption phantom tokens that can never be acquired as a
|
|
7
|
-
* strategy target. Other `PHANTOM_TOKEN::*` types (Convex, Infrared, staking
|
|
8
|
-
* rewards) can.
|
|
9
|
-
*/
|
|
10
|
-
const NON_STRATEGY_PHANTOM_TOKEN_TYPES = [
|
|
11
|
-
"PHANTOM_TOKEN::INFINIFI_UNWIND",
|
|
12
|
-
"PHANTOM_TOKEN::MELLOW_WITHDRAWAL",
|
|
13
|
-
"PHANTOM_TOKEN::MIDAS_REDEMPTION",
|
|
14
|
-
"PHANTOM_TOKEN::SECURITIZE_RD",
|
|
15
|
-
"PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
|
|
16
|
-
];
|
|
17
6
|
const NON_STRATEGY_PHANTOM_TOKEN_TYPE_SET = new Set(NON_STRATEGY_PHANTOM_TOKEN_TYPES);
|
|
18
7
|
const RWA_UNDERLYING_PREFIX = "RWA_UNDERLYING::";
|
|
19
8
|
/**
|
|
@@ -90,4 +79,4 @@ function dominantCollateral(account, market) {
|
|
|
90
79
|
return dominant;
|
|
91
80
|
}
|
|
92
81
|
//#endregion
|
|
93
|
-
export {
|
|
82
|
+
export { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral };
|
|
@@ -2,8 +2,8 @@ import { CreditConfiguratorV310Contract } from "./CreditConfiguratorV310Contract
|
|
|
2
2
|
import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./CreditFacadeV310BaseContract.js";
|
|
3
3
|
import { CreditFacadeV310Contract } from "./CreditFacadeV310Contract.js";
|
|
4
4
|
import { CreditManagerV310Contract } from "./CreditManagerV310Contract.js";
|
|
5
|
-
import {
|
|
5
|
+
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
6
6
|
import { CreditSuite } from "./CreditSuite.js";
|
|
7
7
|
import { expectedBalanceDeltas } from "./expectedBalanceDeltas.js";
|
|
8
8
|
import "./types.js";
|
|
9
|
-
export { CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite,
|
|
9
|
+
export { CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, abi as creditFacadeV310Abi, dominantCollateral, expectedBalanceDeltas, isStrategyCollateral, pickStrategyTargetCollateral };
|
|
@@ -90,7 +90,7 @@ import { CreditFacadeV310Contract } from "./credit/CreditFacadeV310Contract.js";
|
|
|
90
90
|
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./math.js";
|
|
91
91
|
import { CreditManagerV310Contract } from "./credit/CreditManagerV310Contract.js";
|
|
92
92
|
import { strategyName } from "./strategyName.js";
|
|
93
|
-
import {
|
|
93
|
+
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./credit/collateralUtils.js";
|
|
94
94
|
import { CreditSuite } from "./credit/CreditSuite.js";
|
|
95
95
|
import { expectedBalanceDeltas } from "./credit/expectedBalanceDeltas.js";
|
|
96
96
|
import "./credit/index.js";
|
|
@@ -144,4 +144,4 @@ import { RWARegistry } from "./rwa/RWARegistry.js";
|
|
|
144
144
|
import { RWA_FACTORY_TYPES, isRWAFactory } from "./rwa/types.js";
|
|
145
145
|
import "./rwa/index.js";
|
|
146
146
|
import "./types.js";
|
|
147
|
-
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract,
|
|
147
|
+
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, classifyCurveOperation, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, usdToNumber };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
4
3
|
import { RAY } from "../../constants/math.js";
|
|
@@ -7,6 +6,7 @@ import { formatBN, formatBNvalue, percentFmt } from "../../utils/formatter.js";
|
|
|
7
6
|
import "../../utils/index.js";
|
|
8
7
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
9
8
|
import "../../base/index.js";
|
|
9
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
10
10
|
import { calcUtilization } from "../math.js";
|
|
11
11
|
//#region src/sdk/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { getTokenPrettyName } from "../chain/chains.js";
|
|
2
1
|
//#region src/sdk/market/strategyName.ts
|
|
3
2
|
/**
|
|
4
3
|
* Display name of a leveraged strategy: the target collateral over the
|
|
5
4
|
* borrowed underlying, e.g. `"wstETH / WETH"`.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Uses each token's display {@link Token.symbol}, which may already be a
|
|
7
|
+
* curated pretty name or a `"source -> target"` redemption rewrite.
|
|
9
8
|
*
|
|
10
9
|
* @param target - Collateral the position is built around.
|
|
11
10
|
* @param underlying - Token the position borrows.
|
|
12
|
-
* @param network - Chain id or network type label of the market.
|
|
13
11
|
**/
|
|
14
|
-
function strategyName(target, underlying
|
|
15
|
-
return `${
|
|
12
|
+
function strategyName(target, underlying) {
|
|
13
|
+
return `${target.symbol} / ${underlying.symbol}`;
|
|
16
14
|
}
|
|
17
15
|
//#endregion
|
|
18
16
|
export { strategyName };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
1
|
import { ZapperContract } from "./ZapperContract.js";
|
|
2
|
+
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
3
3
|
//#region src/sdk/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
3
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/sdk/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
1
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
2
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
3
3
|
import "../constants/addresses.js";
|
|
4
4
|
import { PERCENTAGE_FACTOR, RAY } from "../constants/math.js";
|
|
5
5
|
import "../constants/index.js";
|
|
@@ -176,7 +176,7 @@ var PositionsService = class extends SDKConstruct {
|
|
|
176
176
|
chainId: this.sdk.chainId,
|
|
177
177
|
creditManager: ca.creditManager,
|
|
178
178
|
creditAccount: ca.creditAccount,
|
|
179
|
-
name: target ? strategyName(this.sdk.tokensMeta.mustGetToken(target), token
|
|
179
|
+
name: target ? strategyName(this.sdk.tokensMeta.mustGetToken(target), token) : token.symbol,
|
|
180
180
|
targetCollateral: target ? this.sdk.tokensMeta.mustGetToken(target) : null,
|
|
181
181
|
leverage: calcPositionLeverage(totalValue, totalDebtValue),
|
|
182
182
|
borrowApy: calcBorrowApy(pool.baseInterestRate, suite.creditManager.feeInterest),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
2
|
import { generateCastTraceCall } from "./cast.js";
|
|
3
|
+
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -22,7 +22,7 @@ type ChartRange = (typeof CHART_RANGES)[number];
|
|
|
22
22
|
/**
|
|
23
23
|
* Every metric a pool opportunity can chart.
|
|
24
24
|
**/
|
|
25
|
-
declare const POOL_OPPORTUNITY_CHART_METRICS: readonly ["depositApy", "
|
|
25
|
+
declare const POOL_OPPORTUNITY_CHART_METRICS: readonly ["depositApy", "depositApyAvg7d", "dieselRate", "supplied", "borrowed"];
|
|
26
26
|
/**
|
|
27
27
|
* Metric a pool opportunity can chart. Derived from the runtime list that also
|
|
28
28
|
* builds the backend's route enum, so the two cannot drift.
|
|
@@ -34,7 +34,7 @@ type PoolOpportunityChartMetric = (typeof POOL_OPPORTUNITY_CHART_METRICS)[number
|
|
|
34
34
|
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
35
35
|
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
36
36
|
**/
|
|
37
|
-
declare const STRATEGY_OPPORTUNITY_CHART_METRICS: readonly ["
|
|
37
|
+
declare const STRATEGY_OPPORTUNITY_CHART_METRICS: readonly ["borrowApy", "borrowApyAvg7d", "quotaRate", "liquidationThreshold", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
38
38
|
/**
|
|
39
39
|
* Metric a strategy opportunity can chart, derived from
|
|
40
40
|
* {@link STRATEGY_OPPORTUNITY_CHART_METRICS}.
|
|
@@ -44,13 +44,12 @@ type StrategyOpportunityChartMetric = (typeof STRATEGY_OPPORTUNITY_CHART_METRICS
|
|
|
44
44
|
* Every metric a pool position can chart.
|
|
45
45
|
*
|
|
46
46
|
* Nothing to do with {@link POOL_OPPORTUNITY_CHART_METRICS}: an opportunity charts what the
|
|
47
|
-
* pool did, a position charts what one wallet's deposit did in it. `mwr`
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* only zooms the visible slice and its first point is rarely zero.
|
|
47
|
+
* pool did, a position charts what one wallet's deposit did in it. `mwr` is the
|
|
48
|
+
* money-weighted return since the position opened, so it is sensitive to when
|
|
49
|
+
* deposits and withdrawals landed. It is anchored at inception, so a narrow
|
|
50
|
+
* `range` only zooms the visible slice and its first point is rarely zero.
|
|
52
51
|
**/
|
|
53
|
-
declare const POOL_POSITION_CHART_METRICS: readonly ["
|
|
52
|
+
declare const POOL_POSITION_CHART_METRICS: readonly ["apy", "pnl", "mwr"];
|
|
54
53
|
/**
|
|
55
54
|
* Metric a pool position can chart, derived from
|
|
56
55
|
* {@link POOL_POSITION_CHART_METRICS}.
|
|
@@ -59,12 +58,11 @@ type PoolPositionChartMetric = (typeof POOL_POSITION_CHART_METRICS)[number];
|
|
|
59
58
|
/**
|
|
60
59
|
* Every metric a strategy position can chart.
|
|
61
60
|
*
|
|
62
|
-
* `
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* different ages.
|
|
61
|
+
* `netApy7d` is the trailing seven-day net yield, so it tracks the position's
|
|
62
|
+
* recent pace rather than its lifetime return and is comparable across
|
|
63
|
+
* positions of different ages.
|
|
66
64
|
**/
|
|
67
|
-
declare const STRATEGY_POSITION_CHART_METRICS: readonly ["
|
|
65
|
+
declare const STRATEGY_POSITION_CHART_METRICS: readonly ["totalValueUnderlying", "debt", "healthFactor", "borrowApy", "borrowApyAvg7d", "pnl", "mwr", "netApy7d"];
|
|
68
66
|
/**
|
|
69
67
|
* Metric a strategy position can chart, derived from
|
|
70
68
|
* {@link STRATEGY_POSITION_CHART_METRICS}.
|
|
@@ -161,31 +159,26 @@ type ChartUnit =
|
|
|
161
159
|
**/
|
|
162
160
|
declare const CHART_METRIC_UNITS: {
|
|
163
161
|
readonly depositApy: "bps";
|
|
162
|
+
readonly depositApyAvg7d: "bps";
|
|
164
163
|
readonly borrowApy: "bps";
|
|
165
|
-
readonly
|
|
164
|
+
readonly borrowApyAvg7d: "bps";
|
|
165
|
+
readonly quotaRate: "bps";
|
|
166
|
+
readonly liquidationThreshold: "bps";
|
|
166
167
|
readonly collateralApy: "bps";
|
|
167
168
|
readonly supplied: "token";
|
|
168
169
|
readonly borrowed: "token";
|
|
169
|
-
readonly availableLiquidity: "token";
|
|
170
170
|
readonly tvl: "token";
|
|
171
171
|
readonly dieselRate: "ratio";
|
|
172
172
|
readonly collateralPrice: "ratio";
|
|
173
173
|
readonly collateralUsdPrice: "usd";
|
|
174
174
|
readonly underlyingUsdPrice: "usd";
|
|
175
|
-
readonly value: "token";
|
|
176
175
|
readonly apy: "bps";
|
|
177
176
|
readonly pnl: "token";
|
|
178
177
|
readonly mwr: "bps";
|
|
179
|
-
readonly twr: "bps";
|
|
180
|
-
readonly underlyingPrice: "usd";
|
|
181
|
-
readonly totalValueUsd: "usd";
|
|
182
178
|
readonly totalValueUnderlying: "token";
|
|
183
179
|
readonly debt: "token";
|
|
184
180
|
readonly healthFactor: "bps";
|
|
185
|
-
readonly
|
|
186
|
-
readonly twrApy: "bps";
|
|
187
|
-
readonly trailingApy7d: "bps";
|
|
188
|
-
readonly trailingApy30d: "bps";
|
|
181
|
+
readonly netApy7d: "bps";
|
|
189
182
|
};
|
|
190
183
|
/**
|
|
191
184
|
* A unit together with what it is denominated in.
|
|
@@ -24,10 +24,9 @@ declare const chartRangeSchema: z.ZodEnum<{
|
|
|
24
24
|
* {@link PoolOpportunityChartMetric}
|
|
25
25
|
**/
|
|
26
26
|
declare const poolOpportunityChartMetricSchema: z.ZodEnum<{
|
|
27
|
-
availableLiquidity: "availableLiquidity";
|
|
28
|
-
borrowApy: "borrowApy";
|
|
29
27
|
borrowed: "borrowed";
|
|
30
28
|
depositApy: "depositApy";
|
|
29
|
+
depositApyAvg7d: "depositApyAvg7d";
|
|
31
30
|
dieselRate: "dieselRate";
|
|
32
31
|
supplied: "supplied";
|
|
33
32
|
}>;
|
|
@@ -36,10 +35,12 @@ declare const poolOpportunityChartMetricSchema: z.ZodEnum<{
|
|
|
36
35
|
**/
|
|
37
36
|
declare const strategyOpportunityChartMetricSchema: z.ZodEnum<{
|
|
38
37
|
borrowApy: "borrowApy";
|
|
38
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
39
39
|
collateralApy: "collateralApy";
|
|
40
40
|
collateralPrice: "collateralPrice";
|
|
41
41
|
collateralUsdPrice: "collateralUsdPrice";
|
|
42
|
-
|
|
42
|
+
liquidationThreshold: "liquidationThreshold";
|
|
43
|
+
quotaRate: "quotaRate";
|
|
43
44
|
tvl: "tvl";
|
|
44
45
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
45
46
|
}>;
|
|
@@ -50,108 +51,86 @@ declare const poolPositionChartMetricSchema: z.ZodEnum<{
|
|
|
50
51
|
apy: "apy";
|
|
51
52
|
mwr: "mwr";
|
|
52
53
|
pnl: "pnl";
|
|
53
|
-
twr: "twr";
|
|
54
|
-
underlyingPrice: "underlyingPrice";
|
|
55
|
-
value: "value";
|
|
56
54
|
}>;
|
|
57
55
|
/**
|
|
58
56
|
* {@link StrategyPositionChartMetric}
|
|
59
57
|
**/
|
|
60
58
|
declare const strategyPositionChartMetricSchema: z.ZodEnum<{
|
|
61
59
|
borrowApy: "borrowApy";
|
|
60
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
62
61
|
debt: "debt";
|
|
63
62
|
healthFactor: "healthFactor";
|
|
64
|
-
leverage: "leverage";
|
|
65
63
|
mwr: "mwr";
|
|
64
|
+
netApy7d: "netApy7d";
|
|
66
65
|
pnl: "pnl";
|
|
67
66
|
totalValueUnderlying: "totalValueUnderlying";
|
|
68
|
-
totalValueUsd: "totalValueUsd";
|
|
69
|
-
trailingApy30d: "trailingApy30d";
|
|
70
|
-
trailingApy7d: "trailingApy7d";
|
|
71
|
-
twr: "twr";
|
|
72
|
-
twrApy: "twrApy";
|
|
73
|
-
underlyingPrice: "underlyingPrice";
|
|
74
67
|
}>;
|
|
75
68
|
/**
|
|
76
69
|
* {@link ChartMetric}, every metric either kind of subject can chart.
|
|
77
70
|
**/
|
|
78
71
|
declare const chartMetricSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
79
|
-
availableLiquidity: "availableLiquidity";
|
|
80
|
-
borrowApy: "borrowApy";
|
|
81
72
|
borrowed: "borrowed";
|
|
82
73
|
depositApy: "depositApy";
|
|
74
|
+
depositApyAvg7d: "depositApyAvg7d";
|
|
83
75
|
dieselRate: "dieselRate";
|
|
84
76
|
supplied: "supplied";
|
|
85
77
|
}>, z.ZodEnum<{
|
|
86
78
|
borrowApy: "borrowApy";
|
|
79
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
87
80
|
collateralApy: "collateralApy";
|
|
88
81
|
collateralPrice: "collateralPrice";
|
|
89
82
|
collateralUsdPrice: "collateralUsdPrice";
|
|
90
|
-
|
|
83
|
+
liquidationThreshold: "liquidationThreshold";
|
|
84
|
+
quotaRate: "quotaRate";
|
|
91
85
|
tvl: "tvl";
|
|
92
86
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
93
87
|
}>, z.ZodEnum<{
|
|
94
88
|
apy: "apy";
|
|
95
89
|
mwr: "mwr";
|
|
96
90
|
pnl: "pnl";
|
|
97
|
-
twr: "twr";
|
|
98
|
-
underlyingPrice: "underlyingPrice";
|
|
99
|
-
value: "value";
|
|
100
91
|
}>, z.ZodEnum<{
|
|
101
92
|
borrowApy: "borrowApy";
|
|
93
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
102
94
|
debt: "debt";
|
|
103
95
|
healthFactor: "healthFactor";
|
|
104
|
-
leverage: "leverage";
|
|
105
96
|
mwr: "mwr";
|
|
97
|
+
netApy7d: "netApy7d";
|
|
106
98
|
pnl: "pnl";
|
|
107
99
|
totalValueUnderlying: "totalValueUnderlying";
|
|
108
|
-
totalValueUsd: "totalValueUsd";
|
|
109
|
-
trailingApy30d: "trailingApy30d";
|
|
110
|
-
trailingApy7d: "trailingApy7d";
|
|
111
|
-
twr: "twr";
|
|
112
|
-
twrApy: "twrApy";
|
|
113
|
-
underlyingPrice: "underlyingPrice";
|
|
114
100
|
}>]>;
|
|
115
101
|
/**
|
|
116
102
|
* {@link ChartQuery}
|
|
117
103
|
**/
|
|
118
104
|
declare const chartQuerySchema: z.ZodObject<{
|
|
119
105
|
metrics: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
120
|
-
availableLiquidity: "availableLiquidity";
|
|
121
|
-
borrowApy: "borrowApy";
|
|
122
106
|
borrowed: "borrowed";
|
|
123
107
|
depositApy: "depositApy";
|
|
108
|
+
depositApyAvg7d: "depositApyAvg7d";
|
|
124
109
|
dieselRate: "dieselRate";
|
|
125
110
|
supplied: "supplied";
|
|
126
111
|
}>, z.ZodEnum<{
|
|
127
112
|
borrowApy: "borrowApy";
|
|
113
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
128
114
|
collateralApy: "collateralApy";
|
|
129
115
|
collateralPrice: "collateralPrice";
|
|
130
116
|
collateralUsdPrice: "collateralUsdPrice";
|
|
131
|
-
|
|
117
|
+
liquidationThreshold: "liquidationThreshold";
|
|
118
|
+
quotaRate: "quotaRate";
|
|
132
119
|
tvl: "tvl";
|
|
133
120
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
134
121
|
}>, z.ZodEnum<{
|
|
135
122
|
apy: "apy";
|
|
136
123
|
mwr: "mwr";
|
|
137
124
|
pnl: "pnl";
|
|
138
|
-
twr: "twr";
|
|
139
|
-
underlyingPrice: "underlyingPrice";
|
|
140
|
-
value: "value";
|
|
141
125
|
}>, z.ZodEnum<{
|
|
142
126
|
borrowApy: "borrowApy";
|
|
127
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
143
128
|
debt: "debt";
|
|
144
129
|
healthFactor: "healthFactor";
|
|
145
|
-
leverage: "leverage";
|
|
146
130
|
mwr: "mwr";
|
|
131
|
+
netApy7d: "netApy7d";
|
|
147
132
|
pnl: "pnl";
|
|
148
133
|
totalValueUnderlying: "totalValueUnderlying";
|
|
149
|
-
totalValueUsd: "totalValueUsd";
|
|
150
|
-
trailingApy30d: "trailingApy30d";
|
|
151
|
-
trailingApy7d: "trailingApy7d";
|
|
152
|
-
twr: "twr";
|
|
153
|
-
twrApy: "twrApy";
|
|
154
|
-
underlyingPrice: "underlyingPrice";
|
|
155
134
|
}>]>>>;
|
|
156
135
|
range: z.ZodEnum<{
|
|
157
136
|
"1d": "1d";
|
|
@@ -195,41 +174,34 @@ declare const chartQueryCodec: z.ZodCodec<z.ZodObject<{
|
|
|
195
174
|
}>;
|
|
196
175
|
}, z.core.$strip>, z.ZodObject<{
|
|
197
176
|
metrics: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
198
|
-
availableLiquidity: "availableLiquidity";
|
|
199
|
-
borrowApy: "borrowApy";
|
|
200
177
|
borrowed: "borrowed";
|
|
201
178
|
depositApy: "depositApy";
|
|
179
|
+
depositApyAvg7d: "depositApyAvg7d";
|
|
202
180
|
dieselRate: "dieselRate";
|
|
203
181
|
supplied: "supplied";
|
|
204
182
|
}>, z.ZodEnum<{
|
|
205
183
|
borrowApy: "borrowApy";
|
|
184
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
206
185
|
collateralApy: "collateralApy";
|
|
207
186
|
collateralPrice: "collateralPrice";
|
|
208
187
|
collateralUsdPrice: "collateralUsdPrice";
|
|
209
|
-
|
|
188
|
+
liquidationThreshold: "liquidationThreshold";
|
|
189
|
+
quotaRate: "quotaRate";
|
|
210
190
|
tvl: "tvl";
|
|
211
191
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
212
192
|
}>, z.ZodEnum<{
|
|
213
193
|
apy: "apy";
|
|
214
194
|
mwr: "mwr";
|
|
215
195
|
pnl: "pnl";
|
|
216
|
-
twr: "twr";
|
|
217
|
-
underlyingPrice: "underlyingPrice";
|
|
218
|
-
value: "value";
|
|
219
196
|
}>, z.ZodEnum<{
|
|
220
197
|
borrowApy: "borrowApy";
|
|
198
|
+
borrowApyAvg7d: "borrowApyAvg7d";
|
|
221
199
|
debt: "debt";
|
|
222
200
|
healthFactor: "healthFactor";
|
|
223
|
-
leverage: "leverage";
|
|
224
201
|
mwr: "mwr";
|
|
202
|
+
netApy7d: "netApy7d";
|
|
225
203
|
pnl: "pnl";
|
|
226
204
|
totalValueUnderlying: "totalValueUnderlying";
|
|
227
|
-
totalValueUsd: "totalValueUsd";
|
|
228
|
-
trailingApy30d: "trailingApy30d";
|
|
229
|
-
trailingApy7d: "trailingApy7d";
|
|
230
|
-
twr: "twr";
|
|
231
|
-
twrApy: "twrApy";
|
|
232
|
-
underlyingPrice: "underlyingPrice";
|
|
233
205
|
}>]>>>;
|
|
234
206
|
range: z.ZodEnum<{
|
|
235
207
|
"1d": "1d";
|
|
@@ -206,6 +206,10 @@ interface PoolOpportunity extends OpportunityBase {
|
|
|
206
206
|
* @mode offchain
|
|
207
207
|
**/
|
|
208
208
|
supplyApyAvg7D?: ApyBreakdown;
|
|
209
|
+
/**
|
|
210
|
+
* Quota configuration of every collateral token of the market.
|
|
211
|
+
**/
|
|
212
|
+
quotaAssets: QuotaAsset[];
|
|
209
213
|
}
|
|
210
214
|
/**
|
|
211
215
|
* A leveraged position: one credit manager plus the single target collateral
|
|
@@ -494,6 +498,20 @@ interface QuotaAsset {
|
|
|
494
498
|
* Amount currently quoted, denominated in the market's underlying.
|
|
495
499
|
**/
|
|
496
500
|
used: Amount;
|
|
501
|
+
/**
|
|
502
|
+
* This token's share of the pool's used quota, in basis points:
|
|
503
|
+
* `used / Σ used` over every quota asset of the pool. Zero when nothing is
|
|
504
|
+
* quoted.
|
|
505
|
+
*
|
|
506
|
+
* @example `2500` for 25% of the quoted amount
|
|
507
|
+
**/
|
|
508
|
+
allocationShare: Bps;
|
|
509
|
+
/**
|
|
510
|
+
* Estimate of how much of the pool's {@link OpportunityBase.totalBorrow}
|
|
511
|
+
* backs this collateral: {@link allocationShare} applied to the pool's
|
|
512
|
+
* total borrowed amount, denominated in the underlying.
|
|
513
|
+
**/
|
|
514
|
+
allocatedDebt: Amount;
|
|
497
515
|
}
|
|
498
516
|
/**
|
|
499
517
|
* A price feed and the feeds it is composed of.
|
|
@@ -560,10 +578,6 @@ interface PoolOpportunityDetail extends PoolOpportunity {
|
|
|
560
578
|
* Interest rate curve of the pool.
|
|
561
579
|
**/
|
|
562
580
|
rateCurve: RateCurve;
|
|
563
|
-
/**
|
|
564
|
-
* Quota configuration of every collateral token of the market.
|
|
565
|
-
**/
|
|
566
|
-
quotaAssets: QuotaAsset[];
|
|
567
581
|
}
|
|
568
582
|
/**
|
|
569
583
|
* A strategy opportunity plus the data only its detail screen needs.
|