export default class EulerProtocolEvm extends LendingProtocol { /** * Reuses the account's own ethers provider when it has one (WDK EVM accounts share one provider per wallet manager, * possibly a failover provider), otherwise builds one from the account's 'provider' configuration. * * @private */ private static _resolveProvider; /** * Creates a new read-only interface to the Euler v2 protocol for evm blockchains. * * @overload * @param {IWalletAccountReadOnly} account - The wallet account to use to interact with the protocol. * @param {EulerProtocolConfig} [config] - The protocol configuration. */ constructor(account: IWalletAccountReadOnly, config?: EulerProtocolConfig); /** * Creates a new interface to the Euler v2 protocol for evm blockchains. * * @overload * @param {IWalletAccount} account - The wallet account to use to interact with the protocol. * @param {EulerProtocolConfig} [config] - The protocol configuration. */ constructor(account: IWalletAccount, config?: EulerProtocolConfig); /** @private */ private _vaults; /** @private */ private _gasLimitBuffer; /** @private */ private _evcAddress; /** @private */ private _provider; /** * Deposits a specific token amount into an Euler vault. The account receives vault shares that earn the vault's supply rate. * * Users must first approve the necessary amount of tokens to the vault address using the account's `approve` method. * Use `getVaultAddress(token)` to read the vault address. To use the deposit as collateral, call `setUseVaultAsCollateral`. * * @param {EulerSupplyOptions} options - The supply's options. * @param {Object} [config] - If the protocol has been initialized with an erc-4337 wallet account, it can be used to override * its configuration options. Standard (non erc-4337) accounts silently ignore this config. * @returns {Promise} The supply's result. */ supply({ token, amount, onBehalfOf, vault }: EulerSupplyOptions, config?: any): Promise; /** * Quotes the costs of a supply operation. * * Users must first approve the necessary amount of tokens to the vault address using the account's `approve` method. * * @param {EulerSupplyOptions} options - The supply's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise>} The supply's costs. */ quoteSupply({ token, amount, onBehalfOf, vault }: EulerSupplyOptions, config?: any): Promise>; /** @private */ private _getSupplyTransaction; /** * Withdraws a specific token amount from an Euler vault. * * Pass `MaxUint256` as the amount to redeem every share the account holds in the vault (a full exit with no dust left). * * @param {EulerWithdrawOptions} options - The withdraw's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise} The withdraw's result. */ withdraw({ token, amount, to, vault }: EulerWithdrawOptions, config?: any): Promise; /** * Quotes the costs of a withdraw operation. * * @param {EulerWithdrawOptions} options - The withdraw's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise>} The withdraw's costs. */ quoteWithdraw({ token, amount, to, vault }: EulerWithdrawOptions, config?: any): Promise>; /** @private */ private _getWithdrawTransaction; /** * Borrows a specific token amount from an Euler vault. * * The account must have enabled at least one collateral vault accepted by the borrow vault (see `setUseVaultAsCollateral`). * If the borrow vault is not yet the account's controller, it is enabled in the same transaction through an EVC batch. * In Euler v2 debt always belongs to the borrowing account, so `onBehalfOf` (credit delegation) is not supported. * * @param {EulerBorrowOptions} options - The borrow's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise} The borrow's result. */ borrow({ token, amount, onBehalfOf, vault }: EulerBorrowOptions, config?: any): Promise; /** * Quotes the costs of a borrow operation. * * @param {EulerBorrowOptions} options - The borrow's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise>} The borrow's costs. */ quoteBorrow({ token, amount, onBehalfOf, vault }: EulerBorrowOptions, config?: any): Promise>; /** @private */ private _getBorrowTransaction; /** * Repays a specific token amount to an Euler vault. * * Users must first approve the necessary amount of tokens to the vault address using the account's `approve` method. * Pass `MaxUint256` as the amount to repay the whole debt, including interest accrued up to the block of inclusion * (approve a little more than `getAccountData().debt` to cover it). After a full repay, `disableController(vault)` * releases the account's collateral from the vault's control. * * @param {EulerRepayOptions} options - The repay's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise} The repay's result. */ repay({ token, amount, onBehalfOf, vault }: EulerRepayOptions, config?: any): Promise; /** * Quotes the costs of a repay operation. * * @param {EulerRepayOptions} options - The repay's options. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise>} The repay's costs. */ quoteRepay({ token, amount, onBehalfOf, vault }: EulerRepayOptions, config?: any): Promise>; /** @private */ private _getRepayTransaction; /** * Enables or disables a vault as collateral for the account's borrows. The equivalent of Aave's `setUseReserveAsCollateral`. * * @param {string} vault - The collateral vault's address. * @param {boolean} useAsCollateral - True to enable the vault as collateral, false to disable it. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise} The transaction's result. */ setUseVaultAsCollateral(vault: string, useAsCollateral: boolean, config?: any): Promise; /** * Releases the account from a vault's control. Only succeeds once the account has no debt in that vault. * * @param {string} vault - The controller vault's address. * @param {Object} [config] - Optional erc-4337 configuration override. * @returns {Promise} The transaction's result. */ disableController(vault: string, config?: any): Promise; /** * Returns the vault this module uses for a token: the 'vaults' map of the configuration, unless a vault is given. * This is the address to approve before a supply or a repay. * * @param {string} token - The token's address. * @param {string} [vault] - An explicit vault, validated against the token. * @returns {Promise} The vault's address. */ getVaultAddress(token: string, vault?: string): Promise; /** * Returns the token amount an account can currently withdraw from its deposit in a vault (shares converted to assets). * * @param {string} token - The token's address. * @param {Object} [options] - Options. * @param {string} [options.vault] - An explicit vault, validated against the token. * @param {string} [options.account] - If set, reads the position of this address instead of the wallet's. * @returns {Promise} The position's value in the token's base unit. */ getSupplied(token: string, { vault, account }?: { vault?: string; account?: string; }): Promise; /** * Returns this or another account's data: enabled controllers and collaterals, and, when the account borrows, its risk position * as computed by the controller vault. * * @param {string} [account] - If set, returns the account's data for the given address. * @returns {Promise} The account's data. */ getAccountData(account?: string): Promise; /** @private */ private _withGasLimit; /** @private */ private _send; /** @private */ private _quote; /** @private */ private _getProvider; /** @private */ private _assertNotReadOnly; /** @private */ private _validateCommon; /** @private */ private _validateOptionalAddress; /** @private */ private _assertNoDelegation; /** @private */ private _getVault; /** @private */ private _assertSameEvc; /** @private */ private _getEvcContract; /** @private */ private _assertTokenBalance; /** @private */ private _assertOperationEnabled; } export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult; export type BorrowOptions = import("@tetherto/wdk-wallet/protocols").BorrowOptions; export type BorrowResult = import("@tetherto/wdk-wallet/protocols").BorrowResult; export type SupplyOptions = import("@tetherto/wdk-wallet/protocols").SupplyOptions; export type SupplyResult = import("@tetherto/wdk-wallet/protocols").SupplyResult; export type WithdrawOptions = import("@tetherto/wdk-wallet/protocols").WithdrawOptions; export type WithdrawResult = import("@tetherto/wdk-wallet/protocols").WithdrawResult; export type RepayOptions = import("@tetherto/wdk-wallet/protocols").RepayOptions; export type RepayResult = import("@tetherto/wdk-wallet/protocols").RepayResult; export type IWalletAccount = import("@tetherto/wdk-wallet").IWalletAccount; export type IWalletAccountReadOnly = import("@tetherto/wdk-wallet").IWalletAccountReadOnly; export type EulerProtocolConfig = { /** * - Default vault per token address, used by supply, withdraw, borrow and repay when no * 'vault' option is passed. Euler v2 is vault based: every vault holds a single asset and the same asset can have many vaults * with different risk settings, so the integrator chooses which vault a token maps to. */ vaults?: Record; /** * - Extra gas, in percent of the estimate, set as an explicit gas limit on transactions sent by * standard (non erc-4337) accounts. Euler vaults accrue interest on their first touch in a block, so an estimate made in one block * can fall short when the transaction lands in the next one. Default: 20. Set to 0 to send the raw estimate. */ gasLimitBuffer?: number; }; export type EulerVaultOption = { /** * - The Euler vault (EVK) to use for this operation. Overrides the 'vaults' map of the configuration. */ vault?: string; }; export type EulerSupplyOptions = SupplyOptions & EulerVaultOption; export type EulerWithdrawOptions = WithdrawOptions & EulerVaultOption; export type EulerBorrowOptions = BorrowOptions & EulerVaultOption; export type EulerRepayOptions = RepayOptions & EulerVaultOption; export type AccountData = { /** * - The vaults enabled as controller (at most one; the vault the account borrows from). */ controllers: string[]; /** * - The vaults enabled as collateral. */ collaterals: string[]; /** * - The account's collateral value adjusted by the controller's liquidation LTVs, in the controller's unit of account. */ collateralValue: bigint; /** * - The account's collateral value adjusted by the controller's borrow LTVs (the limit for new borrows). */ borrowCollateralValue: bigint; /** * - The account's debt value, in the controller's unit of account. */ liabilityValue: bigint; /** * - The account's debt in the controller vault, in the vault asset's base unit. */ debt: bigint; /** * - collateralValue / liabilityValue scaled by 1e18, on liquidation LTVs like Aave's health factor: * below 1e18 the account can be liquidated. MaxUint256 when the account has no debt. */ healthFactor: bigint; }; import { LendingProtocol } from '@tetherto/wdk-wallet/protocols';