import { type ethers } from "ethers"; import { type ContractProvider } from "../../../utils"; /** * Alchemix MYT strategies — VaultV2 adapters from Alchemix's MYT design. * Every strategy inherits `MYTStrategy` (the generic surface below) and * adds a protocol-specific leg: `AaveStrategy`, `ERC4626Strategy`, … * * Unlike the Byzantine adapter types there is NO factory: strategies are * deployed directly via their constructor, so type detection works by * probing the MYTStrategy surface (see `isAlchemixStrategy`) instead of * matching `factory()` against known addresses. */ /** Protocol-specific flavour of a deployed MYT strategy. */ export type AlchemixStrategyKind = "aave" | "erc4626" | "unknown"; /** Decoded `params()` struct (IMYTStrategy.StrategyParams). */ export interface AlchemixStrategyParams { owner: string; name: string; protocol: string; /** 0 = LOW, 1 = MEDIUM, 2 = HIGH. */ riskClass: number; cap: bigint; globalCap: bigint; /** Curator-snapshotted estimate, NOT a live on-chain rate. */ estimatedYield: bigint; additionalIncentives: boolean; slippageBPS: bigint; } /** * Live snapshot of a strategy and its underlying protocol position. * Kind-specific fields are undefined when they don't apply (or when the * flavour is unknown — only `realAssets` is guaranteed by `IAdapter`). */ export interface AlchemixStrategyState { kind: AlchemixStrategyKind; /** aToken (aave) or wrapped ERC-4626 vault (erc4626). */ underlyingAddress?: string; /** Total assets in the underlying market/vault, in asset units. */ underlyingTotalAssets?: bigint; /** Assets withdrawable from the underlying right now. */ underlyingLiquidity?: bigint; /** 1e18-scaled utilization (aave only). */ utilization?: bigint; /** Per-second supply rate in WAD (aave only). */ supplyRatePerSec?: bigint; /** Live value of the strategy's position (`realAssets()`), idle included. */ strategyPosition: bigint; } /** * MYT strategies decode the vault's `allocate`/`deallocate` `data` argument * as `abi.encode(VaultAdapterParams)` — NOT the empty bytes used by the * Byzantine adapter types. */ export type AlchemixActionType = "direct" | "swap" | "unwrapAndSwap"; /** * Build the `data` argument for `vault.allocate(strategy, data, assets)` / * `deallocate`. Defaults to a `direct` action (no swap), the only action * allowed on `forceDeallocate`. */ export declare function encodeAlchemixAdapterData(action?: AlchemixActionType, swapParams?: { txData: string; minIntermediateOut?: bigint; }): string; /** * Probe whether `account` is a MYT strategy: every flavour exposes `MYT()` * (its parent vault) and `adapterId()`. Both must answer for a positive — * a lone `adapterId()` would also match the Byzantine adapter types. */ export declare function isAlchemixStrategy(cp: ContractProvider, account: string): Promise; /** * Detect the protocol-specific flavour of a deployed strategy by probing * its child-class getters: `aToken()` → aave, `vault()` → erc4626. */ export declare function detectStrategyKind(contract: ethers.Contract): Promise; /** * Re-ABI the generic strategy contract with a child-class surface. Same * address, richer interface — the alchemix counterpart of the underlying * contracts the other adapter modules build inline. */ export declare function withAaveSurface(contract: ethers.Contract): ethers.Contract; export declare function withERC4626Surface(contract: ethers.Contract): ethers.Contract; export declare function getIds(contract: ethers.Contract): Promise; /** `keccak256(abi.encode("this", strategy))` — same scheme as the other types. */ export declare function getAdapterId(contract: ethers.Contract): Promise; /** Parent VaultV2 (the strategy calls it "MYT"). */ export declare function getMYT(contract: ethers.Contract): Promise; export declare function getKillSwitch(contract: ethers.Contract): Promise; export declare function getStrategyParams(contract: ethers.Contract): Promise; /** * Vault-side tracked allocation for this strategy's id. Lazy: only resynced * to the real position on (de)allocate, so it excludes interest/losses * accrued since the last interaction. Use the type-agnostic * `GlobalAdapters.getRealAssets` for the live value. */ export declare function getAllocation(contract: ethers.Contract): Promise; /** Expected net proceeds of a withdrawal after slippage/fees/rounding. */ export declare function previewAdjustedWithdraw(contract: ethers.Contract, amount: bigint): Promise; /** * Asset the strategy invests (the parent vault's asset). Every known * flavour exposes `mytAsset()` on the child class (not the base), so the * Aave surface works as the probe ABI for both. */ export declare function getMytAsset(contract: ethers.Contract): Promise; /** Underlying protocol position of the strategy (aToken / wrapped vault). */ export declare function getUnderlying(contract: ethers.Contract): Promise; /** Live state of the strategy, dispatched on the detected flavour. */ export declare function getStrategyState(contract: ethers.Contract): Promise; export declare function setKillSwitch(contract: ethers.Contract, value: boolean): Promise; export declare function setRiskClass(contract: ethers.Contract, newClass: number): Promise; export declare function setSlippageBPS(contract: ethers.Contract, newSlippageBPS: bigint): Promise; export declare function setAdditionalIncentives(contract: ethers.Contract, enabled: boolean): Promise; /** Claim protocol rewards and swap them to the vault asset via a 0x quote. */ export declare function claimRewards(contract: ethers.Contract, token: string, quote: string, minAmountOut: bigint): Promise; /** Sweep idle asset balance from the strategy back to the parent vault. */ export declare function withdrawToVault(contract: ethers.Contract): Promise; /** Rescue a non-protected ERC20 sent to the strategy by mistake. */ export declare function rescueTokens(contract: ethers.Contract, token: string, to: string, amount: bigint): Promise;