import { Address, Hex } from 'viem'; import { GondiPublicClient, Wallet } from '../../clients/contracts'; import { BaseContract } from '../../clients/contracts/BaseContract'; import { MslV6 } from '../../clients/contracts/MslV6'; import { positionMigratorAbi } from '../../generated/blockchain/positionMigrator'; import { EmitLoanArgs } from '../../gondi'; import { LoanToMslLoanType } from '../../utils/loan'; /** Borrower-authorized replacement of an Ethereum v3.1/v3.2 USDC or WETH loan. */ export interface CrossCurrencyRenegotiationInput { /** Complete current on-chain loan, normalized with loanToMslLoan by the SDK. */ loan: LoanToMslLoanType; /** Current on-chain loan ID, rather than the API's logical string ID. */ loanId: bigint; /** Signed offers for the same collateral, with homogeneous contract and currency. */ executionData: EmitLoanArgs; /** Maximum price movement in basis points; defaults to 100 (1%). */ slippageBps?: bigint; } /** A short-lived quote; repayment and old-currency approval use oldCurrency units. */ export type CrossCurrencyRenegotiationQuote = Readonly<{ borrower: Address; previousContract: Address; replacementContract: Address; purchaseBundler: Address; positionMigrator: Address; loanId: bigint; loanHash: Hex; executionHash: Hex; oldCurrency: Address; newCurrency: Address; repaymentAmount: bigint; /** Stable repayment ceiling through maturity; prepare this approval before the final quote. */ oldCurrencyApprovalAmount: bigint; quotedInput: bigint; maximumInput: bigint; premiumBps: bigint; premium: bigint; maximumFlashRepayment: bigint; newPrincipal: bigint; originationFee: bigint; /** Live target-contract fee on lender earnings, fixed for this confirmation. */ replacementProtocolFeeBps: bigint; netNewPrincipal: bigint; maximumTopUp: bigint; minimumSurplus: bigint; slippageBps: bigint; deadline: bigint; blockNumber: bigint; }>; /** Builds the fixed swap/repay/originate composition using deployed contracts. */ export declare class CrossCurrencyRenegotiation extends BaseContract { readonly previousMsl: MslV6; readonly msl: MslV6; constructor({ previousMsl, msl, walletClient, publicClient, }: { previousMsl: MslV6; msl: MslV6; walletClient: Wallet; publicClient: GondiPublicClient; }); /** * Quotes deadline-bounded repayment, conversion, flash fees and borrower spending. * * IMPLEMENTATION NOTE: QuoterV2's non-view quoteExactOutput is simulated with eth_call; * its first result is the new currency required for an exact old-currency output. * Aave's fee is read from FLASHLOAN_PREMIUM_TOTAL. Reserve configuration flags and the * legacy reserve tuple follow Aave V3's ReserveConfiguration and DataTypes libraries. * https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2 * https://aave.com/docs/aave-v3/guides/flash-loans */ quote(input: CrossCurrencyRenegotiationInput): Promise; /** Checks the bound quote and capped approvals, then simulates and broadcasts atomically. */ execute({ quote, ...input }: CrossCurrencyRenegotiationInput & { quote: CrossCurrencyRenegotiationQuote; }): Promise<{ txHash: `0x${string}`; waitTxInBlock: () => Promise<{ previousLoanId: bigint; loanId: bigint; loan: { id: string; contractAddress: `0x${string}`; borrower: `0x${string}`; nftCollateralTokenId: bigint; nftCollateralAddress: `0x${string}`; principalAddress: `0x${string}`; principalAmount: bigint; startTime: bigint; duration: bigint; tranche: readonly { loanId: bigint; floor: bigint; principalAmount: bigint; lender: `0x${string}`; accruedInterest: bigint; startTime: bigint; aprBps: bigint; }[]; protocolFee: bigint; } | { id: string; contractAddress: `0x${string}`; borrower: `0x${string}`; nftCollateralTokenId: bigint; nftCollateralAddress: `0x${string}`; principalAddress: `0x${string}`; principalAmount: bigint; startTime: bigint; duration: bigint; tranche: readonly { loanId: bigint; floor: bigint; principalAmount: bigint; lender: `0x${string}`; accruedInterest: bigint; startTime: bigint; aprBps: bigint; }[]; protocolFee: bigint; } | { id: string; contractAddress: `0x${string}`; borrower: `0x${string}`; nftCollateralTokenId: bigint; nftCollateralAddress: `0x${string}`; principalAddress: `0x${string}`; principalAmount: bigint; startTime: bigint; duration: bigint; tranche: readonly { loanId: bigint; floor: bigint; principalAmount: bigint; lender: `0x${string}`; accruedInterest: bigint; startTime: bigint; aprBps: bigint; }[]; protocolFee: bigint; lenderRefinanceDisabled: boolean; }; blobGasPrice?: bigint | undefined; blobGasUsed?: bigint | undefined; blockHash: import("viem").Hash; blockNumber: bigint; blockTimestamp?: bigint | undefined; contractAddress: Address | null | undefined; cumulativeGasUsed: bigint; effectiveGasPrice: bigint; from: Address; gasUsed: bigint; logs: import("viem").Log[]; logsBloom: Hex; root?: import("viem").Hash | undefined; status: "success" | "reverted"; to: Address | null; transactionHash: import("viem").Hash; transactionIndex: number; type: import("viem").TransactionType; }>; }>; private _parseInput; private _executionData; private _checkRoute; private _checkLenders; private _originationFee; }