import { Bps, ChainId } from "../../model/primitives.js"; import { CreditManagerPausedError, DebtOutOfRangeError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaAboveMaxError, QuotaInactiveError, QuotaUnchangedError } from "../../model/errors/operation-errors.js"; import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js"; import { Position, PositionCollateral, StrategyPosition } from "../../model/positions.js"; import { SDKReturn } from "../../model/result.js"; import "../../model/index.js"; import { Asset } from "../../onchain/base/types.js"; import { OnchainSDK } from "../../onchain/OnchainSDK.js"; import { MultichainSDK } from "../../onchain/MultichainSDK.js"; import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js"; import { OperationState, WithPartialState, WithdrawCeilings } from "../../onchain/accounts/intents/types.js"; import { BorrowState } from "../../onchain/accounts/intents/borrow.js"; import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js"; import { OpenStrategyState } from "../../onchain/accounts/intents/open-strategy.js"; import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js"; import "../../onchain/index.js"; import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowAndWithdrawParams, BorrowParams, BorrowResult, DepositStrategyParams, EmptyCreditAccountResult, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowAndWithdrawOptions, MaxBorrowParams, MaxWithdrawCollateralOptions, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, QuotaBufferState, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, UpdateQuotaParams, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js"; import { EnsureFreshChains } from "../types.js"; import { Address } from "viem"; //#region src/sdk/prepare/PrepareApi.d.ts /** * The chain's SDK, resolved on the spot. * * The LP methods need it synchronously, because they only do arithmetic on * loaded state and have nothing to await; the execute namespace resolves its * chain the same way. **/ export type ChainOf = (chainId: ChainId) => OnchainSDK; /** * {@inheritDoc IOpportunitiesPrepare} * * Holds no state of its own: it owns the mapping from the public, * read-model-shaped request to the engine's intent, and nothing else. All * protocol knowledge stays in `CreditAccountOperationsService` and * `PoolService`. * * A prepared operation names one chain and reads it directly: there is no * second source to fall back to, so a chain the SDK does not cover, or one * that fails the read, is a failure of the whole request rather than a thinner * answer. * * No refusable async method here throws. Every way such a preparation can * fail — the market's own refusals, the ones the namespace decides itself, and * anything the chain or the engine raises — comes back in the failure half of * its `SDKReturn`, under the codes that method's signature names. A caller * writes one branch, not a branch and a `try`. The synchronous LP methods and * the bare `max*` reads throw on bugs and lifecycle errors instead, see * {@link IOpportunitiesPrepare}. **/ export declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPrepare { #private; constructor(sdk: MultichainSDK, ensureFresh?: EnsureFreshChains); /** * {@inheritDoc IOpportunitiesPrepare.finalize} **/ finalize(position: PositionInput, params: FinalizeParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.deposit} **/ deposit(pool: PoolInput, params: LpParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.withdraw} **/ withdraw(pool: PoolInput, params: LpParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.redeem} **/ redeem(pool: PoolInput, params: LpRedeemParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.openEmptyCreditAccount} **/ openEmptyCreditAccount(strategy: StrategyInput): Promise>; /** * {@inheritDoc IOpportunitiesPrepare.openNewStrategy} **/ openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.borrow} **/ borrow(strategy: StrategyInput, params: BorrowParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.depositStrategy} **/ depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.withdrawStrategy} **/ withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.maxWithdraw} **/ maxWithdraw(position: PositionInput, sourceToken?: Address, targetHF?: bigint): Promise; /** * {@inheritDoc IOpportunitiesPrepare.repayStrategy} **/ repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.maxRepay} **/ maxRepay(position: PositionInput): Promise; /** * {@inheritDoc IOpportunitiesPrepare.adjustLeverage} **/ adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.addCollateral} **/ addCollateral(position: PositionInput, params: AddCollateralParams): Promise>>; /** {@inheritDoc IOpportunitiesPrepare.maxBorrowAndWithdraw} */ maxBorrowAndWithdraw(position: PositionInput, options?: MaxBorrowAndWithdrawOptions): Promise; /** * {@inheritDoc IOpportunitiesPrepare.borrowAndWithdraw} **/ borrowAndWithdraw(position: PositionInput, params: BorrowAndWithdrawParams): Promise>>; /** {@inheritDoc IOpportunitiesPrepare.withdrawCollateral} */ withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.updateQuota} **/ updateQuota(position: PositionInput, params: UpdateQuotaParams): Promise>>; /** * {@inheritDoc IOpportunitiesPrepare.leverageBand} **/ leverageBand(strategy: StrategyInput, collateral: readonly Asset[], targetHF?: Bps, position?: StrategyPosition): LeverageBand | undefined; /** * {@inheritDoc IOpportunitiesPrepare.withdrawableCollaterals} **/ withdrawableCollaterals(position: StrategyPosition): PositionCollateral[]; /** * {@inheritDoc IOpportunitiesPrepare.maxWithdrawCollateral} **/ maxWithdrawCollateral(position: PositionInput, token: Address, options?: MaxWithdrawCollateralOptions): Promise; /** * {@inheritDoc IOpportunitiesPrepare.maxBorrow} **/ maxBorrow(strategy: StrategyInput, params: MaxBorrowParams): bigint; /** {@inheritDoc IOpportunitiesPrepare.getQuotaBufferState} */ getQuotaBufferState(position: Position, extraQuotas?: readonly (Pick & { quota: bigint; })[]): QuotaBufferState | undefined; } //#endregion