@metamask-previews/earn-controller 4.0.0-preview-280e81c5 → 4.0.0-preview-4bc9f9d

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.
@@ -1 +1 @@
1
- {"version":3,"file":"EarnController.cjs","sourceRoot":"","sources":["../src/EarnController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAwD;AAWxD,+DAA2D;AAC3D,iEAAwE;AAMxE,mDAgB6B;AAC7B,6EAI0C;AAW7B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AA4C/C,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAA0B;IAC/D,wCAAe,CAAC,cAAc;IAC9B,wCAAe,CAAC,cAAc;IAC9B,wCAAe,CAAC,YAAY;CAC7B,CAAC,CAAC;AAMH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAA0B;IAC/D,wCAAe,CAAC,cAAc;IAC9B,wCAAe,CAAC,eAAe;CAChC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,sBAAsB,GAAuC;IACjE,cAAc,EAAE;QACd,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,IAAI;KAChB;CACF,CAAC;AASF,wBAAwB;AACX,QAAA,sBAAsB,GAAkB;IACnD,EAAE,EAAE,EAAE;IACN,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,EAA+B;IACzC,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,CAAC;IAClB,UAAU,EAAE;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IACD,WAAW,EAAE;QACX,OAAO,EAAE,EAAE;QACX,OAAO,EA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;QAC3D,IACE,CAAC,CACC,KAAK,YAAY,KAAK;YACtB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAC9C,EACD;YACA,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;SACzD;KACF;AACH,CAAC;IAQC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { Web3Provider } from '@ethersproject/providers';\nimport type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerSelectedAccountChangeEvent,\n} from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { convertHexToDecimal, toHex } from '@metamask/controller-utils';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetSelectedNetworkClientAction,\n NetworkControllerNetworkDidChangeEvent,\n} from '@metamask/network-controller';\nimport {\n EarnSdk,\n EarnApiService,\n isSupportedLendingChain,\n type LendingMarket,\n type PooledStake,\n type EarnSdkConfig,\n type VaultData,\n type VaultDailyApy,\n type VaultApyAverages,\n type LendingPosition,\n type GasLimitParams,\n type HistoricLendingMarketApys,\n EarnEnvironments,\n ChainId,\n isSupportedPooledStakingChain,\n} from '@metamask/stake-sdk';\nimport {\n type TransactionController,\n TransactionType,\n type TransactionControllerTransactionConfirmedEvent,\n} from '@metamask/transaction-controller';\n\nimport type {\n RefreshEarnEligibilityOptions,\n RefreshLendingEligibilityOptions,\n RefreshLendingPositionsOptions,\n RefreshPooledStakesOptions,\n RefreshPooledStakingDataOptions,\n RefreshPooledStakingVaultDailyApysOptions,\n} from './types';\n\nexport const controllerName = 'EarnController';\n\nexport type PooledStakingState = {\n [chainId: number]: {\n pooledStakes: PooledStake;\n exchangeRate: string;\n vaultMetadata: VaultData;\n vaultDailyApys: VaultDailyApy[];\n vaultApyAverages: VaultApyAverages;\n };\n isEligible: boolean;\n};\n\nexport type LendingPositionWithMarket = LendingPosition & {\n marketId: string;\n marketAddress: string;\n protocol: string;\n};\n\n// extends LendingPosition to include a marketId, marketAddress, and protocol reference\nexport type LendingPositionWithMarketReference = Omit<\n LendingPosition,\n 'market'\n> & {\n marketId: string;\n marketAddress: string;\n protocol: string;\n};\n\nexport type LendingMarketWithPosition = LendingMarket & {\n position: LendingPositionWithMarketReference;\n};\n\nexport type LendingState = {\n markets: LendingMarket[]; // list of markets\n positions: LendingPositionWithMarketReference[]; // list of positions\n isEligible: boolean;\n};\n\ntype StakingTransactionTypes =\n | TransactionType.stakingDeposit\n | TransactionType.stakingUnstake\n | TransactionType.stakingClaim;\n\nconst stakingTransactionTypes = new Set<StakingTransactionTypes>([\n TransactionType.stakingDeposit,\n TransactionType.stakingUnstake,\n TransactionType.stakingClaim,\n]);\n\ntype LendingTransactionTypes =\n | TransactionType.lendingDeposit\n | TransactionType.lendingWithdraw;\n\nconst lendingTransactionTypes = new Set<LendingTransactionTypes>([\n TransactionType.lendingDeposit,\n TransactionType.lendingWithdraw,\n]);\n\n/**\n * Metadata for the EarnController.\n */\nconst earnControllerMetadata: StateMetadata<EarnControllerState> = {\n pooled_staking: {\n persist: true,\n anonymous: false,\n },\n lending: {\n persist: true,\n anonymous: false,\n },\n lastUpdated: {\n persist: false,\n anonymous: true,\n },\n};\n\n// === State Types ===\nexport type EarnControllerState = {\n pooled_staking: PooledStakingState;\n lending: LendingState;\n lastUpdated: number;\n};\n\n// === Default State ===\nexport const DEFAULT_LENDING_MARKET: LendingMarket = {\n id: '',\n chainId: 0,\n protocol: '' as LendingMarket['protocol'],\n name: '',\n address: '',\n tvlUnderlying: '0',\n netSupplyRate: 0,\n totalSupplyRate: 0,\n underlying: {\n address: '',\n chainId: 0,\n },\n outputToken: {\n address: '',\n chainId: 0,\n },\n rewards: [\n {\n token: {\n address: '',\n chainId: 0,\n },\n rate: 0,\n },\n ],\n};\n\nexport const DEFAULT_LENDING_POSITION: LendingPositionWithMarketReference = {\n id: '',\n chainId: 0,\n assets: '0',\n marketId: '',\n marketAddress: '',\n protocol: '',\n};\n\nexport const DEFAULT_POOLED_STAKING_VAULT_APY_AVERAGES: VaultApyAverages = {\n oneDay: '0',\n oneWeek: '0',\n oneMonth: '0',\n threeMonths: '0',\n sixMonths: '0',\n oneYear: '0',\n};\n\nexport const DEFAULT_POOLED_STAKING_CHAIN_STATE = {\n pooledStakes: {\n account: '',\n lifetimeRewards: '0',\n assets: '0',\n exitRequests: [],\n },\n exchangeRate: '1',\n vaultMetadata: {\n apy: '0',\n capacity: '0',\n feePercent: 0,\n totalAssets: '0',\n vaultAddress: '0x0000000000000000000000000000000000000000',\n },\n vaultDailyApys: [],\n vaultApyAverages: DEFAULT_POOLED_STAKING_VAULT_APY_AVERAGES,\n};\n\n/**\n * Gets the default state for the EarnController.\n *\n * @returns The default EarnController state.\n */\nexport function getDefaultEarnControllerState(): EarnControllerState {\n return {\n pooled_staking: {\n isEligible: false,\n },\n lending: {\n markets: [DEFAULT_LENDING_MARKET],\n positions: [DEFAULT_LENDING_POSITION],\n isEligible: false,\n },\n lastUpdated: 0,\n };\n}\n\n// === MESSENGER ===\n\n/**\n * The action which can be used to retrieve the state of the EarnController.\n */\nexport type EarnControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n EarnControllerState\n>;\n\n/**\n * All actions that EarnController registers, to be called externally.\n */\nexport type EarnControllerActions = EarnControllerGetStateAction;\n\n/**\n * All actions that EarnController calls internally.\n */\nexport type AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetSelectedNetworkClientAction\n | AccountsControllerGetSelectedAccountAction;\n\n/**\n * The event that EarnController publishes when updating state.\n */\nexport type EarnControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n EarnControllerState\n>;\n\n/**\n * All events that EarnController publishes, to be subscribed to externally.\n */\nexport type EarnControllerEvents = EarnControllerStateChangeEvent;\n\n/**\n * All events that EarnController subscribes to internally.\n */\nexport type AllowedEvents =\n | AccountsControllerSelectedAccountChangeEvent\n | TransactionControllerTransactionConfirmedEvent\n | NetworkControllerNetworkDidChangeEvent;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * EarnController.\n */\nexport type EarnControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n EarnControllerActions | AllowedActions,\n EarnControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * EarnController manages DeFi earning opportunities across different protocols and chains.\n */\nexport class EarnController extends BaseController<\n typeof controllerName,\n EarnControllerState,\n EarnControllerMessenger\n> {\n #earnSDK: EarnSdk | null = null;\n\n #selectedNetworkClientId: string;\n\n readonly #earnApiService: EarnApiService;\n\n readonly #addTransactionFn: typeof TransactionController.prototype.addTransaction;\n\n readonly #supportedPooledStakingChains: number[];\n\n readonly #env: EarnEnvironments;\n\n constructor({\n messenger,\n state = {},\n addTransactionFn,\n selectedNetworkClientId,\n env = EarnEnvironments.PROD,\n }: {\n messenger: EarnControllerMessenger;\n state?: Partial<EarnControllerState>;\n addTransactionFn: typeof TransactionController.prototype.addTransaction;\n selectedNetworkClientId: string;\n env?: EarnEnvironments;\n }) {\n super({\n name: controllerName,\n metadata: earnControllerMetadata,\n messenger,\n state: {\n ...getDefaultEarnControllerState(),\n ...state,\n },\n });\n\n this.#env = env;\n\n this.#earnApiService = new EarnApiService(this.#env);\n\n // temporary array of supported chains\n // TODO: remove this once we export a supported chains list from the sdk\n // from sdk or api to get lending and pooled staking chains\n this.#supportedPooledStakingChains = [ChainId.ETHEREUM, ChainId.HOODI];\n\n this.#addTransactionFn = addTransactionFn;\n\n this.#selectedNetworkClientId = selectedNetworkClientId;\n\n this.#initializeSDK(selectedNetworkClientId).catch(console.error);\n this.refreshPooledStakingData().catch(console.error);\n this.refreshLendingData().catch(console.error);\n\n // Listen for network changes\n this.messagingSystem.subscribe(\n 'NetworkController:networkDidChange',\n (networkControllerState) => {\n this.#selectedNetworkClientId =\n networkControllerState.selectedNetworkClientId;\n\n this.#initializeSDK(this.#selectedNetworkClientId).catch(console.error);\n\n // refresh pooled staking data\n this.refreshPooledStakingVaultMetadata().catch(console.error);\n this.refreshPooledStakingVaultDailyApys().catch(console.error);\n this.refreshPooledStakingVaultApyAverages().catch(console.error);\n this.refreshPooledStakes().catch(console.error);\n\n // refresh lending data for all chains\n this.refreshLendingMarkets().catch(console.error);\n this.refreshLendingPositions().catch(console.error);\n },\n );\n\n // Listen for account changes\n this.messagingSystem.subscribe(\n 'AccountsController:selectedAccountChange',\n (account) => {\n const address = account?.address;\n /**\n * TEMP: There's a race condition where the account state isn't updated immediately.\n * Until this has been fixed, we rely on the event payload for the latest account instead of #getCurrentAccount().\n * Issue: https://github.com/MetaMask/accounts-planning/issues/887\n */\n\n // TODO: temp solution, this will refresh lending eligibility also\n // we could have a more general check, as what is happening is a compliance address check\n this.refreshEarnEligibility({ address }).catch(console.error);\n this.refreshPooledStakes({ address }).catch(console.error);\n this.refreshLendingPositions({ address }).catch(console.error);\n },\n );\n\n // Listen for confirmed staking transactions\n this.messagingSystem.subscribe(\n 'TransactionController:transactionConfirmed',\n (transactionMeta) => {\n /**\n * When we speed up a transaction, we set the type as Retry and we lose\n * information about type of transaction that is being set up, so we use\n * original type to track that information.\n */\n const { type, originalType } = transactionMeta;\n\n const isStakingTransaction =\n stakingTransactionTypes.has(type as StakingTransactionTypes) ||\n stakingTransactionTypes.has(originalType as StakingTransactionTypes);\n\n const isLendingTransaction =\n lendingTransactionTypes.has(type as LendingTransactionTypes) ||\n lendingTransactionTypes.has(originalType as LendingTransactionTypes);\n\n const sender = transactionMeta.txParams.from;\n\n if (isStakingTransaction) {\n this.refreshPooledStakes({ resetCache: true, address: sender }).catch(\n console.error,\n );\n }\n if (isLendingTransaction) {\n this.refreshLendingPositions({ address: sender }).catch(\n console.error,\n );\n }\n },\n );\n }\n\n /**\n * Initializes the Earn SDK.\n *\n * @param networkClientId - The network client id to initialize the Earn SDK for.\n */\n async #initializeSDK(networkClientId: string) {\n const networkClient = this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n\n if (!networkClient?.provider) {\n this.#earnSDK = null;\n return;\n }\n\n const provider = new Web3Provider(networkClient.provider);\n const { chainId } = networkClient.configuration;\n\n // Initialize appropriate contracts based on chainId\n const config: EarnSdkConfig = {\n chainId: convertHexToDecimal(chainId),\n env: this.#env,\n };\n\n try {\n this.#earnSDK = await EarnSdk.create(provider, config);\n } catch (error) {\n this.#earnSDK = null;\n // Only log unexpected errors, not unsupported chain errors\n if (\n !(\n error instanceof Error &&\n error.message.includes('Unsupported chainId')\n )\n ) {\n console.error('Earn SDK initialization failed:', error);\n }\n }\n }\n\n /**\n * Gets the current account.\n *\n * @returns The current account.\n */\n #getCurrentAccount() {\n return this.messagingSystem.call('AccountsController:getSelectedAccount');\n }\n\n /**\n * Refreshes the pooled stakes data for the current account.\n * Fetches updated stake information including lifetime rewards, assets, and exit requests\n * from the staking API service and updates the state.\n *\n * @param options - Optional arguments\n * @param [options.resetCache] - Control whether the BE cache should be invalidated (optional).\n * @param [options.address] - The address to refresh pooled stakes for (optional).\n * @param [options.chainId] - The chain id to refresh pooled stakes for (optional).\n * @returns A promise that resolves when the stakes data has been updated\n */\n async refreshPooledStakes({\n resetCache = false,\n address,\n chainId = ChainId.ETHEREUM,\n }: RefreshPooledStakesOptions = {}): Promise<void> {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToUse) {\n return;\n }\n\n const chainIdToUse = isSupportedPooledStakingChain(chainId)\n ? chainId\n : ChainId.ETHEREUM;\n\n const { accounts, exchangeRate } =\n await this.#earnApiService.pooledStaking.getPooledStakes(\n [addressToUse],\n chainIdToUse,\n resetCache,\n );\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainIdToUse] ??\n DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainIdToUse] = {\n ...chainState,\n pooledStakes: accounts[0],\n exchangeRate,\n };\n });\n }\n\n /**\n * Refreshes the earn eligibility status for the current account.\n * Updates the eligibility status in the controller state based on the location and address blocklist for compliance.\n *\n * Note: Pooled-staking and Lending used the same result since there isn't a need to split these up right now.\n *\n * @param options - Optional arguments\n * @param [options.address] - Address to refresh earn eligibility for (optional).\n * @returns A promise that resolves when the eligibility status has been updated\n */\n async refreshEarnEligibility({\n address,\n }: RefreshEarnEligibilityOptions = {}): Promise<void> {\n const addressToCheck = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToCheck) {\n return;\n }\n\n const { eligible: isEligible } =\n await this.#earnApiService.pooledStaking.getPooledStakingEligibility([\n addressToCheck,\n ]);\n\n this.update((state) => {\n state.pooled_staking.isEligible = isEligible;\n state.lending.isEligible = isEligible;\n });\n }\n\n /**\n * Refreshes pooled staking vault metadata for the current chain.\n * Updates the vault metadata in the controller state including APY, capacity,\n * fee percentage, total assets, and vault address.\n *\n * @param chainId - The chain id to refresh pooled staking vault metadata for (optional).\n * @returns A promise that resolves when the vault metadata has been updated\n */\n async refreshPooledStakingVaultMetadata(\n chainId: number = ChainId.ETHEREUM,\n ): Promise<void> {\n const chainIdToUse = isSupportedPooledStakingChain(chainId)\n ? chainId\n : ChainId.ETHEREUM;\n\n const vaultMetadata =\n await this.#earnApiService.pooledStaking.getVaultData(chainIdToUse);\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainIdToUse] ??\n DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainIdToUse] = {\n ...chainState,\n vaultMetadata,\n };\n });\n }\n\n /**\n * Refreshes pooled staking vault daily apys for the current chain.\n * Updates the pooled staking vault daily apys controller state.\n *\n * @param [options] - The options for refreshing pooled staking vault daily apys.\n * @param [options.chainId] - The chain id to refresh pooled staking vault daily apys for (defaults to Ethereum).\n * @param [options.days] - The number of days to fetch pooled staking vault daily apys for (defaults to 365).\n * @param [options.order] - The order in which to fetch pooled staking vault daily apys. Descending order fetches the latest N days (latest working backwards). Ascending order fetches the oldest N days (oldest working forwards) (defaults to 'desc').\n * @returns A promise that resolves when the pooled staking vault daily apys have been updated.\n */\n async refreshPooledStakingVaultDailyApys({\n chainId = ChainId.ETHEREUM,\n days = 365,\n order = 'desc',\n }: RefreshPooledStakingVaultDailyApysOptions = {}): Promise<void> {\n const chainIdToUse = isSupportedPooledStakingChain(chainId)\n ? chainId\n : ChainId.ETHEREUM;\n\n const vaultDailyApys =\n await this.#earnApiService.pooledStaking.getVaultDailyApys(\n chainIdToUse,\n days,\n order,\n );\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainIdToUse] ??\n DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainIdToUse] = {\n ...chainState,\n vaultDailyApys,\n };\n });\n }\n\n /**\n * Refreshes pooled staking vault apy averages for the current chain.\n * Updates the pooled staking vault apy averages controller state.\n *\n * @param chainId - The chain id to refresh pooled staking vault apy averages for (optional).\n * @returns A promise that resolves when the pooled staking vault apy averages have been updated.\n */\n async refreshPooledStakingVaultApyAverages(\n chainId: number = ChainId.ETHEREUM,\n ) {\n const chainIdToUse = isSupportedPooledStakingChain(chainId)\n ? chainId\n : ChainId.ETHEREUM;\n\n const vaultApyAverages =\n await this.#earnApiService.pooledStaking.getVaultApyAverages(\n chainIdToUse,\n );\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainIdToUse] ??\n DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainIdToUse] = {\n ...chainState,\n vaultApyAverages,\n };\n });\n }\n\n /**\n * Refreshes all pooled staking related data including stakes, eligibility, and vault data.\n * This method allows partial success, meaning some data may update while other requests fail.\n * All errors are collected and thrown as a single error message.\n *\n * @param options - Optional arguments\n * @param [options.resetCache] - Control whether the BE cache should be invalidated (optional).\n * @param [options.address] - The address to refresh pooled stakes for (optional).\n * @returns A promise that resolves when all possible data has been updated\n * @throws {Error} If any of the refresh operations fail, with concatenated error messages\n */\n async refreshPooledStakingData({\n resetCache,\n address,\n }: RefreshPooledStakingDataOptions = {}): Promise<void> {\n const errors: Error[] = [];\n\n for (const chainId of this.#supportedPooledStakingChains) {\n await Promise.all([\n this.refreshPooledStakes({ resetCache, address, chainId }).catch(\n (error) => {\n errors.push(error);\n },\n ),\n this.refreshEarnEligibility({ address }).catch((error) => {\n errors.push(error);\n }),\n this.refreshPooledStakingVaultMetadata(chainId).catch((error) => {\n errors.push(error);\n }),\n this.refreshPooledStakingVaultDailyApys({ chainId }).catch((error) => {\n errors.push(error);\n }),\n this.refreshPooledStakingVaultApyAverages(chainId).catch((error) => {\n errors.push(error);\n }),\n ]);\n }\n\n if (errors.length > 0) {\n throw new Error(\n `Failed to refresh some staking data: ${errors\n .map((e) => e.message)\n .join(', ')}`,\n );\n }\n }\n\n /**\n * Refreshes the lending markets data for all chains.\n * Updates the lending markets in the controller state.\n *\n * @returns A promise that resolves when the lending markets have been updated\n */\n async refreshLendingMarkets(): Promise<void> {\n const markets = await this.#earnApiService.lending.getMarkets();\n\n this.update((state) => {\n state.lending.markets = markets;\n });\n }\n\n /**\n * Refreshes the lending positions for the current account.\n * Updates the lending positions in the controller state.\n *\n * @param options - Optional arguments\n * @param [options.address] - The address to refresh lending positions for (optional).\n * @returns A promise that resolves when the lending positions have been updated\n */\n async refreshLendingPositions({\n address,\n }: RefreshLendingPositionsOptions = {}): Promise<void> {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToUse) {\n return;\n }\n\n // linter complaining about this not being a promise, but it is\n // TODO: figure out why this is not seen as a promise\n const positions = await Promise.resolve(\n this.#earnApiService.lending.getPositions(addressToUse),\n );\n\n this.update((state) => {\n state.lending.positions = positions.map((position) => ({\n ...position,\n marketId: position.market.id,\n marketAddress: position.market.address,\n protocol: position.market.protocol,\n }));\n });\n }\n\n /**\n * Refreshes the lending eligibility status for the current account.\n * Updates the eligibility status in the controller state based on the location and address blocklist for compliance.\n *\n * @param options - Optional arguments\n * @param [options.address] - The address to refresh lending eligibility for (optional).\n * @returns A promise that resolves when the eligibility status has been updated\n */\n async refreshLendingEligibility({\n address,\n }: RefreshLendingEligibilityOptions = {}): Promise<void> {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n // TODO: this is a temporary solution to refresh lending eligibility as\n // the eligibility check is not yet implemented for lending\n // this check will check the address against the same blocklist as the\n // staking eligibility check\n\n if (!addressToUse) {\n return;\n }\n\n const { eligible: isEligible } =\n await this.#earnApiService.pooledStaking.getPooledStakingEligibility([\n addressToUse,\n ]);\n\n this.update((state) => {\n state.lending.isEligible = isEligible;\n state.pooled_staking.isEligible = isEligible;\n });\n }\n\n /**\n * Refreshes all lending related data including markets, positions, and eligibility.\n * This method allows partial success, meaning some data may update while other requests fail.\n * All errors are collected and thrown as a single error message.\n *\n * @returns A promise that resolves when all possible data has been updated\n * @throws {Error} If any of the refresh operations fail, with concatenated error messages\n */\n async refreshLendingData(): Promise<void> {\n const errors: Error[] = [];\n\n await Promise.all([\n this.refreshLendingMarkets().catch((error) => {\n errors.push(error);\n }),\n this.refreshLendingPositions().catch((error) => {\n errors.push(error);\n }),\n this.refreshLendingEligibility().catch((error) => {\n errors.push(error);\n }),\n ]);\n\n if (errors.length > 0) {\n throw new Error(\n `Failed to refresh some lending data: ${errors\n .map((e) => e.message)\n .join(', ')}`,\n );\n }\n }\n\n /**\n * Gets the lending position history for the current account.\n *\n * @param options - Optional arguments\n * @param [options.address] - The address to get lending position history for (optional).\n * @param options.chainId - The chain id to get lending position history for.\n * @param [options.positionId] - The position id to get lending position history for.\n * @param [options.marketId] - The market id to get lending position history for.\n * @param [options.marketAddress] - The market address to get lending position history for.\n * @param [options.protocol] - The protocol to get lending position history for.\n * @param [options.days] - The number of days to get lending position history for (optional).\n * @returns A promise that resolves when the lending position history has been updated\n */\n getLendingPositionHistory({\n address,\n chainId,\n positionId,\n marketId,\n marketAddress,\n protocol,\n days = 730,\n }: {\n address?: string;\n chainId: number;\n positionId: string;\n marketId: string;\n marketAddress: string;\n protocol: string;\n days?: number;\n }) {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToUse || !isSupportedLendingChain(chainId)) {\n return [];\n }\n\n return this.#earnApiService.lending.getPositionHistory(\n addressToUse,\n chainId,\n protocol,\n marketId,\n marketAddress,\n positionId,\n days,\n );\n }\n\n /**\n * Gets the lending market daily apys and averages for the current chain.\n *\n * @param options - Optional arguments\n * @param options.chainId - The chain id to get lending market daily apys and averages for.\n * @param [options.protocol] - The protocol to get lending market daily apys and averages for.\n * @param [options.marketId] - The market id to get lending market daily apys and averages for.\n * @param [options.days] - The number of days to get lending market daily apys and averages for (optional).\n * @returns A promise that resolves when the lending market daily apys and averages have been updated\n */\n getLendingMarketDailyApysAndAverages({\n chainId,\n protocol,\n marketId,\n days = 365,\n }: {\n chainId: number;\n protocol: string;\n marketId: string;\n days?: number;\n }): Promise<HistoricLendingMarketApys> | undefined {\n if (!isSupportedLendingChain(chainId)) {\n return undefined;\n }\n\n return this.#earnApiService.lending.getHistoricMarketApys(\n chainId,\n protocol,\n marketId,\n days,\n );\n }\n\n /**\n * Executes a lending deposit transaction.\n *\n * @param options - The options for the lending deposit transaction.\n * @param options.amount - The amount to deposit.\n * @param options.chainId - The chain ID for the lending deposit transaction.\n * @param options.protocol - The protocol of the lending market.\n * @param options.underlyingTokenAddress - The address of the underlying token.\n * @param options.gasOptions - The gas options for the transaction.\n * @param options.gasOptions.gasLimit - The gas limit for the transaction.\n * @param options.gasOptions.gasBufferPct - The gas buffer percentage for the transaction.\n * @param options.txOptions - The transaction options for the transaction.\n * @returns A promise that resolves to the transaction hash.\n */\n async executeLendingDeposit({\n amount,\n chainId,\n protocol,\n underlyingTokenAddress,\n gasOptions,\n txOptions,\n }: {\n amount: string;\n chainId: string;\n protocol: LendingMarket['protocol'];\n underlyingTokenAddress: string;\n gasOptions: {\n gasLimit?: GasLimitParams;\n gasBufferPct?: number;\n };\n txOptions: Parameters<\n typeof TransactionController.prototype.addTransaction\n >[1];\n }) {\n const address = this.#getCurrentAccount()?.address;\n\n const transactionData = await this.#earnSDK?.contracts?.lending?.[\n protocol\n ]?.[underlyingTokenAddress]?.encodeDepositTransactionData(\n amount,\n address,\n gasOptions,\n );\n\n if (!transactionData) {\n throw new Error('Transaction data not found');\n }\n if (!this.#selectedNetworkClientId) {\n throw new Error('Selected network client id not found');\n }\n\n const gasLimit = !transactionData.gasLimit\n ? undefined\n : toHex(transactionData.gasLimit);\n\n const txHash = await this.#addTransactionFn(\n {\n ...transactionData,\n value: transactionData.value.toString(),\n chainId: toHex(chainId),\n gasLimit,\n },\n {\n ...txOptions,\n networkClientId: this.#selectedNetworkClientId,\n },\n );\n\n return txHash;\n }\n\n /**\n * Executes a lending withdraw transaction.\n *\n * @param options - The options for the lending withdraw transaction.\n * @param options.amount - The amount to withdraw.\n * @param options.chainId - The chain ID for the lending withdraw transaction.\n * @param options.protocol - The protocol of the lending market.\n * @param options.underlyingTokenAddress - The address of the underlying token.\n * @param options.gasOptions - The gas options for the transaction.\n * @param options.gasOptions.gasLimit - The gas limit for the transaction.\n * @param options.gasOptions.gasBufferPct - The gas buffer percentage for the transaction.\n * @param options.txOptions - The transaction options for the transaction.\n * @returns A promise that resolves to the transaction hash.\n */\n async executeLendingWithdraw({\n amount,\n chainId,\n protocol,\n underlyingTokenAddress,\n gasOptions,\n txOptions,\n }: {\n amount: string;\n chainId: string;\n protocol: LendingMarket['protocol'];\n underlyingTokenAddress: string;\n gasOptions: {\n gasLimit?: GasLimitParams;\n gasBufferPct?: number;\n };\n txOptions: Parameters<\n typeof TransactionController.prototype.addTransaction\n >[1];\n }) {\n const address = this.#getCurrentAccount()?.address;\n\n const transactionData = await this.#earnSDK?.contracts?.lending?.[\n protocol\n ]?.[underlyingTokenAddress]?.encodeWithdrawTransactionData(\n amount,\n address,\n gasOptions,\n );\n\n if (!transactionData) {\n throw new Error('Transaction data not found');\n }\n\n if (!this.#selectedNetworkClientId) {\n throw new Error('Selected network client id not found');\n }\n\n const gasLimit = !transactionData.gasLimit\n ? undefined\n : toHex(transactionData.gasLimit);\n\n const txHash = await this.#addTransactionFn(\n {\n ...transactionData,\n value: transactionData.value.toString(),\n chainId: toHex(chainId),\n gasLimit,\n },\n {\n ...txOptions,\n networkClientId: this.#selectedNetworkClientId,\n },\n );\n\n return txHash;\n }\n\n /**\n * Executes a lending token approve transaction.\n *\n * @param options - The options for the lending token approve transaction.\n * @param options.amount - The amount to approve.\n * @param options.chainId - The chain ID for the lending token approve transaction.\n * @param options.protocol - The protocol of the lending market.\n * @param options.underlyingTokenAddress - The address of the underlying token.\n * @param options.gasOptions - The gas options for the transaction.\n * @param options.gasOptions.gasLimit - The gas limit for the transaction.\n * @param options.gasOptions.gasBufferPct - The gas buffer percentage for the transaction.\n * @param options.txOptions - The transaction options for the transaction.\n * @returns A promise that resolves to the transaction hash.\n */\n async executeLendingTokenApprove({\n protocol,\n amount,\n chainId,\n underlyingTokenAddress,\n gasOptions,\n txOptions,\n }: {\n protocol: LendingMarket['protocol'];\n amount: string;\n chainId: string;\n underlyingTokenAddress: string;\n gasOptions: {\n gasLimit?: GasLimitParams;\n gasBufferPct?: number;\n };\n txOptions: Parameters<\n typeof TransactionController.prototype.addTransaction\n >[1];\n }) {\n const address = this.#getCurrentAccount()?.address;\n\n const transactionData = await this.#earnSDK?.contracts?.lending?.[\n protocol\n ]?.[underlyingTokenAddress]?.encodeUnderlyingTokenApproveTransactionData(\n amount,\n address,\n gasOptions,\n );\n\n if (!transactionData) {\n throw new Error('Transaction data not found');\n }\n\n if (!this.#selectedNetworkClientId) {\n throw new Error('Selected network client id not found');\n }\n\n const gasLimit = !transactionData.gasLimit\n ? undefined\n : toHex(transactionData.gasLimit);\n\n const txHash = await this.#addTransactionFn(\n {\n ...transactionData,\n value: transactionData.value.toString(),\n chainId: toHex(chainId),\n gasLimit,\n },\n {\n ...txOptions,\n networkClientId: this.#selectedNetworkClientId,\n },\n );\n\n return txHash;\n }\n\n /**\n * Gets the allowance for a lending token.\n *\n * @param protocol - The protocol of the lending market.\n * @param underlyingTokenAddress - The address of the underlying token.\n * @returns A promise that resolves to the allowance.\n */\n async getLendingTokenAllowance(\n protocol: LendingMarket['protocol'],\n underlyingTokenAddress: string,\n ) {\n const address = this.#getCurrentAccount()?.address;\n\n const allowance =\n await this.#earnSDK?.contracts?.lending?.[protocol]?.[\n underlyingTokenAddress\n ]?.underlyingTokenAllowance(address);\n\n return allowance;\n }\n\n /**\n * Gets the maximum withdraw amount for a lending token's output token or shares if no output token.\n *\n * @param protocol - The protocol of the lending market.\n * @param underlyingTokenAddress - The address of the underlying token.\n * @returns A promise that resolves to the maximum withdraw amount.\n */\n async getLendingTokenMaxWithdraw(\n protocol: LendingMarket['protocol'],\n underlyingTokenAddress: string,\n ) {\n const address = this.#getCurrentAccount()?.address;\n\n const maxWithdraw =\n await this.#earnSDK?.contracts?.lending?.[protocol]?.[\n underlyingTokenAddress\n ]?.maxWithdraw(address);\n\n return maxWithdraw;\n }\n\n /**\n * Gets the maximum deposit amount for a lending token.\n *\n * @param protocol - The protocol of the lending market.\n * @param underlyingTokenAddress - The address of the underlying token.\n * @returns A promise that resolves to the maximum deposit amount.\n */\n async getLendingTokenMaxDeposit(\n protocol: LendingMarket['protocol'],\n underlyingTokenAddress: string,\n ) {\n const address = this.#getCurrentAccount()?.address;\n\n const maxDeposit =\n await this.#earnSDK?.contracts?.lending?.[protocol]?.[\n underlyingTokenAddress\n ]?.maxDeposit(address);\n\n return maxDeposit;\n }\n}\n"]}
1
+ {"version":3,"file":"EarnController.cjs","sourceRoot":"","sources":["../src/EarnController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAwD;AAWxD,+DAA2D;AAC3D,iEAAwE;AAMxE,mDAc6B;AAC7B,6EAK0C;AAG1C,+CAAyD;AAS5C,QAAA,cAAc,GAAG,gBAAgB,CAAC;AA4C/C,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAA0B;IAC/D,wCAAe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,uBAAuB,CAAC;IAE7B,MAAM,EACJ,aAAa,EAAE,EAAE,OAAO,EAAE,GAC3B,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAC3B,wCAAwC,EACxC,oBAAoB,CACrB,CAAC;IACF,OAAO,IAAA,sCAAmB,EAAC,OAAO,CAAC,CAAC;AACtC,CAAC;IAQC,MAAM,aAAa,GAAG,uBAAA,IAAI,oEAAmB,MAAvB,IAAI,CAAqB,CAAC;IAEhD,IACE,CAAC,aAAa;QACd,CAAC,uBAAA,IAAI,oDAA8B,CAAC,QAAQ,CAAC,IAAA,wBAAK,EAAC,aAAa,CAAC,CAAC,EAClE;QACA,4DAA4D;QAC5D,OAAO,IAAA,sCAAmB,EAAC,kCAAS,CAAC,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { Web3Provider } from '@ethersproject/providers';\nimport type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerSelectedAccountChangeEvent,\n} from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { convertHexToDecimal, toHex } from '@metamask/controller-utils';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport {\n EarnSdk,\n EarnApiService,\n isSupportedLendingChain,\n type LendingMarket,\n type PooledStake,\n type EarnSdkConfig,\n type VaultData,\n type VaultDailyApy,\n type VaultApyAverages,\n type LendingPosition,\n type GasLimitParams,\n type HistoricLendingMarketApys,\n EarnEnvironments,\n} from '@metamask/stake-sdk';\nimport {\n type TransactionController,\n TransactionType,\n type TransactionControllerTransactionConfirmedEvent,\n CHAIN_IDS,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport { HOODI_TESTNET_CHAIN_ID_HEX } from './constants';\nimport type {\n RefreshEarnEligibilityOptions,\n RefreshLendingEligibilityOptions,\n RefreshLendingPositionsOptions,\n RefreshPooledStakesOptions,\n RefreshPooledStakingDataOptions,\n} from './types';\n\nexport const controllerName = 'EarnController';\n\nexport type PooledStakingState = {\n [chainId: number]: {\n pooledStakes: PooledStake;\n exchangeRate: string;\n vaultMetadata: VaultData;\n vaultDailyApys: VaultDailyApy[];\n vaultApyAverages: VaultApyAverages;\n };\n isEligible: boolean;\n};\n\nexport type LendingPositionWithMarket = LendingPosition & {\n marketId: string;\n marketAddress: string;\n protocol: string;\n};\n\n// extends LendingPosition to include a marketId, marketAddress, and protocol reference\nexport type LendingPositionWithMarketReference = Omit<\n LendingPosition,\n 'market'\n> & {\n marketId: string;\n marketAddress: string;\n protocol: string;\n};\n\nexport type LendingMarketWithPosition = LendingMarket & {\n position: LendingPositionWithMarketReference;\n};\n\nexport type LendingState = {\n markets: LendingMarket[]; // list of markets\n positions: LendingPositionWithMarketReference[]; // list of positions\n isEligible: boolean;\n};\n\ntype StakingTransactionTypes =\n | TransactionType.stakingDeposit\n | TransactionType.stakingUnstake\n | TransactionType.stakingClaim;\n\nconst stakingTransactionTypes = new Set<StakingTransactionTypes>([\n TransactionType.stakingDeposit,\n TransactionType.stakingUnstake,\n TransactionType.stakingClaim,\n]);\n\ntype LendingTransactionTypes =\n | TransactionType.lendingDeposit\n | TransactionType.lendingWithdraw;\n\nconst lendingTransactionTypes = new Set<LendingTransactionTypes>([\n TransactionType.lendingDeposit,\n TransactionType.lendingWithdraw,\n]);\n\n/**\n * Metadata for the EarnController.\n */\nconst earnControllerMetadata: StateMetadata<EarnControllerState> = {\n pooled_staking: {\n persist: true,\n anonymous: false,\n },\n lending: {\n persist: true,\n anonymous: false,\n },\n lastUpdated: {\n persist: false,\n anonymous: true,\n },\n};\n\n// === State Types ===\nexport type EarnControllerState = {\n pooled_staking: PooledStakingState;\n lending: LendingState;\n lastUpdated: number;\n};\n\n// === Default State ===\nexport const DEFAULT_LENDING_MARKET: LendingMarket = {\n id: '',\n chainId: 0,\n protocol: '' as LendingMarket['protocol'],\n name: '',\n address: '',\n tvlUnderlying: '0',\n netSupplyRate: 0,\n totalSupplyRate: 0,\n underlying: {\n address: '',\n chainId: 0,\n },\n outputToken: {\n address: '',\n chainId: 0,\n },\n rewards: [\n {\n token: {\n address: '',\n chainId: 0,\n },\n rate: 0,\n },\n ],\n};\n\nexport const DEFAULT_LENDING_POSITION: LendingPositionWithMarketReference = {\n id: '',\n chainId: 0,\n assets: '0',\n marketId: '',\n marketAddress: '',\n protocol: '',\n};\n\nexport const DEFAULT_POOLED_STAKING_VAULT_APY_AVERAGES: VaultApyAverages = {\n oneDay: '0',\n oneWeek: '0',\n oneMonth: '0',\n threeMonths: '0',\n sixMonths: '0',\n oneYear: '0',\n};\n\nexport const DEFAULT_POOLED_STAKING_CHAIN_STATE = {\n pooledStakes: {\n account: '',\n lifetimeRewards: '0',\n assets: '0',\n exitRequests: [],\n },\n exchangeRate: '1',\n vaultMetadata: {\n apy: '0',\n capacity: '0',\n feePercent: 0,\n totalAssets: '0',\n vaultAddress: '0x0000000000000000000000000000000000000000',\n },\n vaultDailyApys: [],\n vaultApyAverages: DEFAULT_POOLED_STAKING_VAULT_APY_AVERAGES,\n};\n\n/**\n * Gets the default state for the EarnController.\n *\n * @returns The default EarnController state.\n */\nexport function getDefaultEarnControllerState(): EarnControllerState {\n return {\n pooled_staking: {\n isEligible: false,\n },\n lending: {\n markets: [DEFAULT_LENDING_MARKET],\n positions: [DEFAULT_LENDING_POSITION],\n isEligible: false,\n },\n lastUpdated: 0,\n };\n}\n\n// === MESSENGER ===\n\n/**\n * The action which can be used to retrieve the state of the EarnController.\n */\nexport type EarnControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n EarnControllerState\n>;\n\n/**\n * All actions that EarnController registers, to be called externally.\n */\nexport type EarnControllerActions = EarnControllerGetStateAction;\n\n/**\n * All actions that EarnController calls internally.\n */\nexport type AllowedActions =\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetStateAction\n | AccountsControllerGetSelectedAccountAction;\n\n/**\n * The event that EarnController publishes when updating state.\n */\nexport type EarnControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n EarnControllerState\n>;\n\n/**\n * All events that EarnController publishes, to be subscribed to externally.\n */\nexport type EarnControllerEvents = EarnControllerStateChangeEvent;\n\n/**\n * All events that EarnController subscribes to internally.\n */\nexport type AllowedEvents =\n | AccountsControllerSelectedAccountChangeEvent\n | NetworkControllerStateChangeEvent\n | TransactionControllerTransactionConfirmedEvent;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * EarnController.\n */\nexport type EarnControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n EarnControllerActions | AllowedActions,\n EarnControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n// === CONTROLLER DEFINITION ===\n\n/**\n * EarnController manages DeFi earning opportunities across different protocols and chains.\n */\nexport class EarnController extends BaseController<\n typeof controllerName,\n EarnControllerState,\n EarnControllerMessenger\n> {\n #earnSDK: EarnSdk | null = null;\n\n #selectedNetworkClientId?: string;\n\n readonly #earnApiService: EarnApiService;\n\n readonly #addTransactionFn: typeof TransactionController.prototype.addTransaction;\n\n readonly #supportedPooledStakingChains: Hex[];\n\n readonly #env: EarnEnvironments;\n\n constructor({\n messenger,\n state = {},\n addTransactionFn,\n env = EarnEnvironments.PROD,\n }: {\n messenger: EarnControllerMessenger;\n state?: Partial<EarnControllerState>;\n addTransactionFn: typeof TransactionController.prototype.addTransaction;\n env?: EarnEnvironments;\n }) {\n super({\n name: controllerName,\n metadata: earnControllerMetadata,\n messenger,\n state: {\n ...getDefaultEarnControllerState(),\n ...state,\n },\n });\n\n this.#env = env;\n\n this.#earnApiService = new EarnApiService(this.#env);\n\n // temporary array of supported chains\n // TODO: remove this once we export a supported chains list from the sdk\n // from sdk or api to get lending and pooled staking chains\n this.#supportedPooledStakingChains = [\n CHAIN_IDS.MAINNET,\n HOODI_TESTNET_CHAIN_ID_HEX,\n ];\n\n this.#addTransactionFn = addTransactionFn;\n\n this.#initializeSDK().catch(console.error);\n this.refreshPooledStakingData().catch(console.error);\n this.refreshLendingData().catch(console.error);\n\n const { selectedNetworkClientId } = this.messagingSystem.call(\n 'NetworkController:getState',\n );\n this.#selectedNetworkClientId = selectedNetworkClientId;\n\n // Listen for network changes\n this.messagingSystem.subscribe(\n 'NetworkController:stateChange',\n (networkControllerState) => {\n if (\n networkControllerState.selectedNetworkClientId !==\n this.#selectedNetworkClientId\n ) {\n this.#initializeSDK(\n networkControllerState.selectedNetworkClientId,\n ).catch(console.error);\n\n this.refreshPooledStakingVaultMetadata().catch(console.error);\n this.refreshPooledStakingVaultDailyApys().catch(console.error);\n this.refreshPooledStakingVaultApyAverages().catch(console.error);\n this.refreshPooledStakes().catch(console.error);\n\n // refresh lending data for all chains\n this.refreshLendingMarkets().catch(console.error);\n this.refreshLendingPositions().catch(console.error);\n }\n this.#selectedNetworkClientId =\n networkControllerState.selectedNetworkClientId;\n },\n );\n\n // Listen for account changes\n this.messagingSystem.subscribe(\n 'AccountsController:selectedAccountChange',\n (account) => {\n const address = account?.address;\n /**\n * TEMP: There's a race condition where the account state isn't updated immediately.\n * Until this has been fixed, we rely on the event payload for the latest account instead of #getCurrentAccount().\n * Issue: https://github.com/MetaMask/accounts-planning/issues/887\n */\n\n // TODO: temp solution, this will refresh lending eligibility also\n // we could have a more general check, as what is happening is a compliance address check\n this.refreshEarnEligibility({ address }).catch(console.error);\n\n this.refreshPooledStakes({ address }).catch(console.error);\n this.refreshLendingPositions({ address }).catch(console.error);\n },\n );\n\n // Listen for confirmed staking transactions\n this.messagingSystem.subscribe(\n 'TransactionController:transactionConfirmed',\n (transactionMeta) => {\n /**\n * When we speed up a transaction, we set the type as Retry and we lose\n * information about type of transaction that is being set up, so we use\n * original type to track that information.\n */\n const { type, originalType } = transactionMeta;\n\n const isStakingTransaction =\n stakingTransactionTypes.has(type as StakingTransactionTypes) ||\n stakingTransactionTypes.has(originalType as StakingTransactionTypes);\n\n const isLendingTransaction =\n lendingTransactionTypes.has(type as LendingTransactionTypes) ||\n lendingTransactionTypes.has(originalType as LendingTransactionTypes);\n\n const sender = transactionMeta.txParams.from;\n\n if (isStakingTransaction) {\n this.refreshPooledStakes({ resetCache: true, address: sender }).catch(\n console.error,\n );\n }\n if (isLendingTransaction) {\n this.refreshLendingPositions({ address: sender }).catch(\n console.error,\n );\n }\n },\n );\n }\n\n /**\n * Initializes the Earn SDK.\n *\n * @param networkClientId - The network client id to initialize the Earn SDK for (optional).\n */\n async #initializeSDK(networkClientId?: string) {\n const { selectedNetworkClientId } = networkClientId\n ? { selectedNetworkClientId: networkClientId }\n : this.messagingSystem.call('NetworkController:getState');\n\n const networkClient = this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n selectedNetworkClientId,\n );\n\n if (!networkClient?.provider) {\n this.#earnSDK = null;\n return;\n }\n\n const provider = new Web3Provider(networkClient.provider);\n const { chainId } = networkClient.configuration;\n\n // Initialize appropriate contracts based on chainId\n const config: EarnSdkConfig = {\n chainId: convertHexToDecimal(chainId),\n env: this.#env,\n };\n\n try {\n this.#earnSDK = await EarnSdk.create(provider, config);\n } catch (error) {\n this.#earnSDK = null;\n // Only log unexpected errors, not unsupported chain errors\n if (\n !(\n error instanceof Error &&\n error.message.includes('Unsupported chainId')\n )\n ) {\n console.error('Earn SDK initialization failed:', error);\n }\n }\n }\n\n /**\n * Gets the current account.\n *\n * @returns The current account.\n */\n #getCurrentAccount() {\n return this.messagingSystem.call('AccountsController:getSelectedAccount');\n }\n\n /**\n * Gets the current chain id.\n *\n * @param networkClientId - The network client id to get the chain id for (optional).\n * @returns The current chain id in decimal.\n */\n #getCurrentChainId(networkClientId?: string): number {\n const networkClientIdToUse =\n networkClientId ??\n this.messagingSystem.call('NetworkController:getState')\n .selectedNetworkClientId;\n\n const {\n configuration: { chainId },\n } = this.messagingSystem.call(\n 'NetworkController:getNetworkClientById',\n networkClientIdToUse,\n );\n return convertHexToDecimal(chainId);\n }\n\n /**\n * Ensures chainId is compatible with pooled-staking. Falls back to Ethereum Mainnet if chainId is not supported.\n *\n * @returns The current chain id in decimal. Ethereum Mainnet if it's not an ethereum chain.\n */\n #getActivePooledStakingChainId(): number {\n const activeChainId = this.#getCurrentChainId();\n\n if (\n !activeChainId ||\n !this.#supportedPooledStakingChains.includes(toHex(activeChainId))\n ) {\n // Fallback to Ethereum Mainnet if chainId is not supported.\n return convertHexToDecimal(CHAIN_IDS.MAINNET);\n }\n\n return activeChainId;\n }\n\n /**\n * Refreshes the pooled stakes data for the current account.\n * Fetches updated stake information including lifetime rewards, assets, and exit requests\n * from the staking API service and updates the state.\n *\n * @param options - Optional arguments\n * @param [options.resetCache] - Control whether the BE cache should be invalidated (optional).\n * @param [options.address] - The address to refresh pooled stakes for (optional).\n * @returns A promise that resolves when the stakes data has been updated\n */\n async refreshPooledStakes({\n resetCache = false,\n address,\n }: RefreshPooledStakesOptions = {}): Promise<void> {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToUse) {\n return;\n }\n\n const chainId = this.#getActivePooledStakingChainId();\n\n const { accounts, exchangeRate } =\n await this.#earnApiService.pooledStaking.getPooledStakes(\n [addressToUse],\n chainId,\n resetCache,\n );\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainId] ?? DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainId] = {\n ...chainState,\n pooledStakes: accounts[0],\n exchangeRate,\n };\n });\n }\n\n /**\n * Refreshes the earn eligibility status for the current account.\n * Updates the eligibility status in the controller state based on the location and address blocklist for compliance.\n *\n * Note: Pooled-staking and Lending used the same result since there isn't a need to split these up right now.\n *\n * @param options - Optional arguments\n * @param [options.address] - Address to refresh earn eligibility for (optional).\n * @returns A promise that resolves when the eligibility status has been updated\n */\n async refreshEarnEligibility({\n address,\n }: RefreshEarnEligibilityOptions = {}): Promise<void> {\n const addressToCheck = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToCheck) {\n return;\n }\n\n const { eligible: isEligible } =\n await this.#earnApiService.pooledStaking.getPooledStakingEligibility([\n addressToCheck,\n ]);\n\n this.update((state) => {\n state.pooled_staking.isEligible = isEligible;\n state.lending.isEligible = isEligible;\n });\n }\n\n /**\n * Refreshes pooled staking vault metadata for the current chain.\n * Updates the vault metadata in the controller state including APY, capacity,\n * fee percentage, total assets, and vault address.\n *\n * @returns A promise that resolves when the vault metadata has been updated\n */\n async refreshPooledStakingVaultMetadata(): Promise<void> {\n const chainId = this.#getActivePooledStakingChainId();\n\n const vaultMetadata =\n await this.#earnApiService.pooledStaking.getVaultData(chainId);\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainId] ?? DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainId] = {\n ...chainState,\n vaultMetadata,\n };\n });\n }\n\n /**\n * Refreshes pooled staking vault daily apys for the current chain.\n * Updates the pooled staking vault daily apys controller state.\n *\n * @param days - The number of days to fetch pooled staking vault daily apys for (defaults to 365).\n * @param order - The order in which to fetch pooled staking vault daily apys. Descending order fetches the latest N days (latest working backwards). Ascending order fetches the oldest N days (oldest working forwards) (defaults to 'desc').\n * @returns A promise that resolves when the pooled staking vault daily apys have been updated.\n */\n async refreshPooledStakingVaultDailyApys(\n days = 365,\n order: 'asc' | 'desc' = 'desc',\n ): Promise<void> {\n const chainId = this.#getActivePooledStakingChainId();\n\n const vaultDailyApys =\n await this.#earnApiService.pooledStaking.getVaultDailyApys(\n chainId,\n days,\n order,\n );\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainId] ?? DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainId] = {\n ...chainState,\n vaultDailyApys,\n };\n });\n }\n\n /**\n * Refreshes pooled staking vault apy averages for the current chain.\n * Updates the pooled staking vault apy averages controller state.\n *\n * @returns A promise that resolves when the pooled staking vault apy averages have been updated.\n */\n async refreshPooledStakingVaultApyAverages() {\n const chainId = this.#getActivePooledStakingChainId();\n\n const vaultApyAverages =\n await this.#earnApiService.pooledStaking.getVaultApyAverages(chainId);\n\n this.update((state) => {\n const chainState =\n state.pooled_staking[chainId] ?? DEFAULT_POOLED_STAKING_CHAIN_STATE;\n state.pooled_staking[chainId] = {\n ...chainState,\n vaultApyAverages,\n };\n });\n }\n\n /**\n * Refreshes all pooled staking related data including stakes, eligibility, and vault data.\n * This method allows partial success, meaning some data may update while other requests fail.\n * All errors are collected and thrown as a single error message.\n *\n * @param options - Optional arguments\n * @param [options.resetCache] - Control whether the BE cache should be invalidated (optional).\n * @param [options.address] - The address to refresh pooled stakes for (optional).\n * @returns A promise that resolves when all possible data has been updated\n * @throws {Error} If any of the refresh operations fail, with concatenated error messages\n */\n async refreshPooledStakingData({\n resetCache,\n address,\n }: RefreshPooledStakingDataOptions = {}): Promise<void> {\n const errors: Error[] = [];\n await Promise.all([\n this.refreshPooledStakes({ resetCache, address }).catch((error) => {\n errors.push(error);\n }),\n this.refreshEarnEligibility({ address }).catch((error) => {\n errors.push(error);\n }),\n this.refreshPooledStakingVaultMetadata().catch((error) => {\n errors.push(error);\n }),\n this.refreshPooledStakingVaultDailyApys().catch((error) => {\n errors.push(error);\n }),\n this.refreshPooledStakingVaultApyAverages().catch((error) => {\n errors.push(error);\n }),\n ]);\n\n if (errors.length > 0) {\n throw new Error(\n `Failed to refresh some staking data: ${errors\n .map((e) => e.message)\n .join(', ')}`,\n );\n }\n }\n\n /**\n * Refreshes the lending markets data for all chains.\n * Updates the lending markets in the controller state.\n *\n * @returns A promise that resolves when the lending markets have been updated\n */\n async refreshLendingMarkets(): Promise<void> {\n const markets = await this.#earnApiService.lending.getMarkets();\n\n this.update((state) => {\n state.lending.markets = markets;\n });\n }\n\n /**\n * Refreshes the lending positions for the current account.\n * Updates the lending positions in the controller state.\n *\n * @param options - Optional arguments\n * @param [options.address] - The address to refresh lending positions for (optional).\n * @returns A promise that resolves when the lending positions have been updated\n */\n async refreshLendingPositions({\n address,\n }: RefreshLendingPositionsOptions = {}): Promise<void> {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n\n if (!addressToUse) {\n return;\n }\n\n // linter complaining about this not being a promise, but it is\n // TODO: figure out why this is not seen as a promise\n const positions = await Promise.resolve(\n this.#earnApiService.lending.getPositions(addressToUse),\n );\n\n this.update((state) => {\n state.lending.positions = positions.map((position) => ({\n ...position,\n marketId: position.market.id,\n marketAddress: position.market.address,\n protocol: position.market.protocol,\n }));\n });\n }\n\n /**\n * Refreshes the lending eligibility status for the current account.\n * Updates the eligibility status in the controller state based on the location and address blocklist for compliance.\n *\n * @param options - Optional arguments\n * @param [options.address] - The address to refresh lending eligibility for (optional).\n * @returns A promise that resolves when the eligibility status has been updated\n */\n async refreshLendingEligibility({\n address,\n }: RefreshLendingEligibilityOptions = {}): Promise<void> {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n // TODO: this is a temporary solution to refresh lending eligibility as\n // the eligibility check is not yet implemented for lending\n // this check will check the address against the same blocklist as the\n // staking eligibility check\n\n if (!addressToUse) {\n return;\n }\n\n const { eligible: isEligible } =\n await this.#earnApiService.pooledStaking.getPooledStakingEligibility([\n addressToUse,\n ]);\n\n this.update((state) => {\n state.lending.isEligible = isEligible;\n state.pooled_staking.isEligible = isEligible;\n });\n }\n\n /**\n * Refreshes all lending related data including markets, positions, and eligibility.\n * This method allows partial success, meaning some data may update while other requests fail.\n * All errors are collected and thrown as a single error message.\n *\n * @returns A promise that resolves when all possible data has been updated\n * @throws {Error} If any of the refresh operations fail, with concatenated error messages\n */\n async refreshLendingData(): Promise<void> {\n const errors: Error[] = [];\n\n await Promise.all([\n this.refreshLendingMarkets().catch((error) => {\n errors.push(error);\n }),\n this.refreshLendingPositions().catch((error) => {\n errors.push(error);\n }),\n this.refreshLendingEligibility().catch((error) => {\n errors.push(error);\n }),\n ]);\n\n if (errors.length > 0) {\n throw new Error(\n `Failed to refresh some lending data: ${errors\n .map((e) => e.message)\n .join(', ')}`,\n );\n }\n }\n\n /**\n * Gets the lending position history for the current account.\n *\n * @param options - Optional arguments\n * @param [options.address] - The address to get lending position history for (optional).\n * @param [options.chainId] - The chain id to get lending position history for (optional).\n * @param [options.positionId] - The position id to get lending position history for.\n * @param [options.marketId] - The market id to get lending position history for.\n * @param [options.marketAddress] - The market address to get lending position history for.\n * @param [options.protocol] - The protocol to get lending position history for.\n * @param [options.days] - The number of days to get lending position history for (optional).\n * @returns A promise that resolves when the lending position history has been updated\n */\n getLendingPositionHistory({\n address,\n chainId,\n positionId,\n marketId,\n marketAddress,\n protocol,\n days = 730,\n }: {\n address?: string;\n chainId?: number;\n positionId: string;\n marketId: string;\n marketAddress: string;\n protocol: string;\n days?: number;\n }) {\n const addressToUse = address ?? this.#getCurrentAccount()?.address;\n const chainIdToUse = chainId ?? this.#getCurrentChainId();\n\n if (!addressToUse || !isSupportedLendingChain(chainIdToUse)) {\n return [];\n }\n\n return this.#earnApiService.lending.getPositionHistory(\n addressToUse,\n chainIdToUse,\n protocol,\n marketId,\n marketAddress,\n positionId,\n days,\n );\n }\n\n /**\n * Gets the lending market daily apys and averages for the current chain.\n *\n * @param options - Optional arguments\n * @param [options.chainId] - The chain id to get lending market daily apys and averages for (optional).\n * @param [options.protocol] - The protocol to get lending market daily apys and averages for.\n * @param [options.marketId] - The market id to get lending market daily apys and averages for.\n * @param [options.days] - The number of days to get lending market daily apys and averages for (optional).\n * @returns A promise that resolves when the lending market daily apys and averages have been updated\n */\n getLendingMarketDailyApysAndAverages({\n chainId,\n protocol,\n marketId,\n days = 365,\n }: {\n chainId?: number;\n protocol: string;\n marketId: string;\n days?: number;\n }): Promise<HistoricLendingMarketApys> | undefined {\n const chainIdToUse = chainId ?? this.#getCurrentChainId();\n\n if (!isSupportedLendingChain(chainIdToUse)) {\n return undefined;\n }\n\n return this.#earnApiService.lending.getHistoricMarketApys(\n chainIdToUse,\n protocol,\n marketId,\n days,\n );\n }\n\n /**\n * Executes a lending deposit transaction.\n *\n * @param options - The options for the lending deposit transaction.\n * @param options.amount - The amount to deposit.\n * @param options.protocol - The protocol of the lending market.\n * @param options.underlyingTokenAddress - The address of the underlying token.\n * @param options.gasOptions - The gas options for the transaction.\n * @param options.gasOptions.gasLimit - The gas limit for the transaction.\n * @param options.gasOptions.gasBufferPct - The gas buffer percentage for the transaction.\n * @param options.txOptions - The transaction options for the transaction.\n * @returns A promise that resolves to the transaction hash.\n */\n async executeLendingDeposit({\n amount,\n protocol,\n underlyingTokenAddress,\n gasOptions,\n txOptions,\n }: {\n amount: string;\n protocol: LendingMarket['protocol'];\n underlyingTokenAddress: string;\n gasOptions: {\n gasLimit?: GasLimitParams;\n gasBufferPct?: number;\n };\n txOptions: Parameters<\n typeof TransactionController.prototype.addTransaction\n >[1];\n }) {\n const address = this.#getCurrentAccount()?.address;\n\n const transactionData = await this.#earnSDK?.contracts?.lending?.[\n protocol\n ]?.[underlyingTokenAddress]?.encodeDepositTransactionData(\n amount,\n address,\n gasOptions,\n );\n\n if (!transactionData) {\n throw new Error('Transaction data not found');\n }\n if (!this.#selectedNetworkClientId) {\n throw new Error('Selected network client id not found');\n }\n\n const gasLimit = !transactionData.gasLimit\n ? undefined\n : toHex(transactionData.gasLimit);\n\n const txHash = await this.#addTransactionFn(\n {\n ...transactionData,\n value: transactionData.value.toString(),\n chainId: toHex(this.#getCurrentChainId()),\n gasLimit,\n },\n {\n ...txOptions,\n networkClientId: this.#selectedNetworkClientId,\n },\n );\n\n return txHash;\n }\n\n /**\n * Executes a lending withdraw transaction.\n *\n * @param options - The options for the lending withdraw transaction.\n * @param options.amount - The amount to withdraw.\n * @param options.protocol - The protocol of the lending market.\n * @param options.underlyingTokenAddress - The address of the underlying token.\n * @param options.gasOptions - The gas options for the transaction.\n * @param options.gasOptions.gasLimit - The gas limit for the transaction.\n * @param options.gasOptions.gasBufferPct - The gas buffer percentage for the transaction.\n * @param options.txOptions - The transaction options for the transaction.\n * @returns A promise that resolves to the transaction hash.\n */\n async executeLendingWithdraw({\n amount,\n protocol,\n underlyingTokenAddress,\n gasOptions,\n txOptions,\n }: {\n amount: string;\n protocol: LendingMarket['protocol'];\n underlyingTokenAddress: string;\n gasOptions: {\n gasLimit?: GasLimitParams;\n gasBufferPct?: number;\n };\n txOptions: Parameters<\n typeof TransactionController.prototype.addTransaction\n >[1];\n }) {\n const address = this.#getCurrentAccount()?.address;\n\n const transactionData = await this.#earnSDK?.contracts?.lending?.[\n protocol\n ]?.[underlyingTokenAddress]?.encodeWithdrawTransactionData(\n amount,\n address,\n gasOptions,\n );\n\n if (!transactionData) {\n throw new Error('Transaction data not found');\n }\n\n if (!this.#selectedNetworkClientId) {\n throw new Error('Selected network client id not found');\n }\n\n const gasLimit = !transactionData.gasLimit\n ? undefined\n : toHex(transactionData.gasLimit);\n\n const txHash = await this.#addTransactionFn(\n {\n ...transactionData,\n value: transactionData.value.toString(),\n chainId: toHex(this.#getCurrentChainId()),\n gasLimit,\n },\n {\n ...txOptions,\n networkClientId: this.#selectedNetworkClientId,\n },\n );\n\n return txHash;\n }\n\n /**\n * Executes a lending token approve transaction.\n *\n * @param options - The options for the lending token approve transaction.\n * @param options.amount - The amount to approve.\n * @param options.protocol - The protocol of the lending market.\n * @param options.underlyingTokenAddress - The address of the underlying token.\n * @param options.gasOptions - The gas options for the transaction.\n * @param options.gasOptions.gasLimit - The gas limit for the transaction.\n * @param options.gasOptions.gasBufferPct - The gas buffer percentage for the transaction.\n * @param options.txOptions - The transaction options for the transaction.\n * @returns A promise that resolves to the transaction hash.\n */\n async executeLendingTokenApprove({\n protocol,\n amount,\n underlyingTokenAddress,\n gasOptions,\n txOptions,\n }: {\n protocol: LendingMarket['protocol'];\n amount: string;\n underlyingTokenAddress: string;\n gasOptions: {\n gasLimit?: GasLimitParams;\n gasBufferPct?: number;\n };\n txOptions: Parameters<\n typeof TransactionController.prototype.addTransaction\n >[1];\n }) {\n const address = this.#getCurrentAccount()?.address;\n\n const transactionData = await this.#earnSDK?.contracts?.lending?.[\n protocol\n ]?.[underlyingTokenAddress]?.encodeUnderlyingTokenApproveTransactionData(\n amount,\n address,\n gasOptions,\n );\n\n if (!transactionData) {\n throw new Error('Transaction data not found');\n }\n\n if (!this.#selectedNetworkClientId) {\n throw new Error('Selected network client id not found');\n }\n\n const gasLimit = !transactionData.gasLimit\n ? undefined\n : toHex(transactionData.gasLimit);\n\n const txHash = await this.#addTransactionFn(\n {\n ...transactionData,\n value: transactionData.value.toString(),\n chainId: toHex(this.#getCurrentChainId()),\n gasLimit,\n },\n {\n ...txOptions,\n networkClientId: this.#selectedNetworkClientId,\n },\n );\n\n return txHash;\n }\n\n /**\n * Gets the allowance for a lending token.\n *\n * @param protocol - The protocol of the lending market.\n * @param underlyingTokenAddress - The address of the underlying token.\n * @returns A promise that resolves to the allowance.\n */\n async getLendingTokenAllowance(\n protocol: LendingMarket['protocol'],\n underlyingTokenAddress: string,\n ) {\n const address = this.#getCurrentAccount()?.address;\n\n const allowance =\n await this.#earnSDK?.contracts?.lending?.[protocol]?.[\n underlyingTokenAddress\n ]?.underlyingTokenAllowance(address);\n\n return allowance;\n }\n\n /**\n * Gets the maximum withdraw amount for a lending token's output token or shares if no output token.\n *\n * @param protocol - The protocol of the lending market.\n * @param underlyingTokenAddress - The address of the underlying token.\n * @returns A promise that resolves to the maximum withdraw amount.\n */\n async getLendingTokenMaxWithdraw(\n protocol: LendingMarket['protocol'],\n underlyingTokenAddress: string,\n ) {\n const address = this.#getCurrentAccount()?.address;\n\n const maxWithdraw =\n await this.#earnSDK?.contracts?.lending?.[protocol]?.[\n underlyingTokenAddress\n ]?.maxWithdraw(address);\n\n return maxWithdraw;\n }\n\n /**\n * Gets the maximum deposit amount for a lending token.\n *\n * @param protocol - The protocol of the lending market.\n * @param underlyingTokenAddress - The address of the underlying token.\n * @returns A promise that resolves to the maximum deposit amount.\n */\n async getLendingTokenMaxDeposit(\n protocol: LendingMarket['protocol'],\n underlyingTokenAddress: string,\n ) {\n const address = this.#getCurrentAccount()?.address;\n\n const maxDeposit =\n await this.#earnSDK?.contracts?.lending?.[protocol]?.[\n underlyingTokenAddress\n ]?.maxDeposit(address);\n\n return maxDeposit;\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import type { AccountsControllerGetSelectedAccountAction, AccountsControllerSelectedAccountChangeEvent } from "@metamask/accounts-controller";
2
2
  import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
3
3
  import { BaseController } from "@metamask/base-controller";
4
- import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerNetworkDidChangeEvent } from "@metamask/network-controller";
4
+ import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction, NetworkControllerStateChangeEvent } from "@metamask/network-controller";
5
5
  import { type LendingMarket, type PooledStake, type VaultData, type VaultDailyApy, type VaultApyAverages, type LendingPosition, type GasLimitParams, type HistoricLendingMarketApys, EarnEnvironments } from "@metamask/stake-sdk";
6
6
  import { type TransactionController, type TransactionControllerTransactionConfirmedEvent } from "@metamask/transaction-controller";
7
- import type { RefreshEarnEligibilityOptions, RefreshLendingEligibilityOptions, RefreshLendingPositionsOptions, RefreshPooledStakesOptions, RefreshPooledStakingDataOptions, RefreshPooledStakingVaultDailyApysOptions } from "./types.cjs";
7
+ import type { RefreshEarnEligibilityOptions, RefreshLendingEligibilityOptions, RefreshLendingPositionsOptions, RefreshPooledStakesOptions, RefreshPooledStakingDataOptions } from "./types.cjs";
8
8
  export declare const controllerName = "EarnController";
9
9
  export type PooledStakingState = {
10
10
  [chainId: number]: {
@@ -77,7 +77,7 @@ export type EarnControllerActions = EarnControllerGetStateAction;
77
77
  /**
78
78
  * All actions that EarnController calls internally.
79
79
  */
80
- export type AllowedActions = NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | AccountsControllerGetSelectedAccountAction;
80
+ export type AllowedActions = NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetStateAction | AccountsControllerGetSelectedAccountAction;
81
81
  /**
82
82
  * The event that EarnController publishes when updating state.
83
83
  */
@@ -89,7 +89,7 @@ export type EarnControllerEvents = EarnControllerStateChangeEvent;
89
89
  /**
90
90
  * All events that EarnController subscribes to internally.
91
91
  */
92
- export type AllowedEvents = AccountsControllerSelectedAccountChangeEvent | TransactionControllerTransactionConfirmedEvent | NetworkControllerNetworkDidChangeEvent;
92
+ export type AllowedEvents = AccountsControllerSelectedAccountChangeEvent | NetworkControllerStateChangeEvent | TransactionControllerTransactionConfirmedEvent;
93
93
  /**
94
94
  * The messenger which is restricted to actions and events accessed by
95
95
  * EarnController.
@@ -100,11 +100,10 @@ export type EarnControllerMessenger = RestrictedMessenger<typeof controllerName,
100
100
  */
101
101
  export declare class EarnController extends BaseController<typeof controllerName, EarnControllerState, EarnControllerMessenger> {
102
102
  #private;
103
- constructor({ messenger, state, addTransactionFn, selectedNetworkClientId, env, }: {
103
+ constructor({ messenger, state, addTransactionFn, env, }: {
104
104
  messenger: EarnControllerMessenger;
105
105
  state?: Partial<EarnControllerState>;
106
106
  addTransactionFn: typeof TransactionController.prototype.addTransaction;
107
- selectedNetworkClientId: string;
108
107
  env?: EarnEnvironments;
109
108
  });
110
109
  /**
@@ -115,10 +114,9 @@ export declare class EarnController extends BaseController<typeof controllerName
115
114
  * @param options - Optional arguments
116
115
  * @param [options.resetCache] - Control whether the BE cache should be invalidated (optional).
117
116
  * @param [options.address] - The address to refresh pooled stakes for (optional).
118
- * @param [options.chainId] - The chain id to refresh pooled stakes for (optional).
119
117
  * @returns A promise that resolves when the stakes data has been updated
120
118
  */
121
- refreshPooledStakes({ resetCache, address, chainId, }?: RefreshPooledStakesOptions): Promise<void>;
119
+ refreshPooledStakes({ resetCache, address, }?: RefreshPooledStakesOptions): Promise<void>;
122
120
  /**
123
121
  * Refreshes the earn eligibility status for the current account.
124
122
  * Updates the eligibility status in the controller state based on the location and address blocklist for compliance.
@@ -135,29 +133,25 @@ export declare class EarnController extends BaseController<typeof controllerName
135
133
  * Updates the vault metadata in the controller state including APY, capacity,
136
134
  * fee percentage, total assets, and vault address.
137
135
  *
138
- * @param chainId - The chain id to refresh pooled staking vault metadata for (optional).
139
136
  * @returns A promise that resolves when the vault metadata has been updated
140
137
  */
141
- refreshPooledStakingVaultMetadata(chainId?: number): Promise<void>;
138
+ refreshPooledStakingVaultMetadata(): Promise<void>;
142
139
  /**
143
140
  * Refreshes pooled staking vault daily apys for the current chain.
144
141
  * Updates the pooled staking vault daily apys controller state.
145
142
  *
146
- * @param [options] - The options for refreshing pooled staking vault daily apys.
147
- * @param [options.chainId] - The chain id to refresh pooled staking vault daily apys for (defaults to Ethereum).
148
- * @param [options.days] - The number of days to fetch pooled staking vault daily apys for (defaults to 365).
149
- * @param [options.order] - The order in which to fetch pooled staking vault daily apys. Descending order fetches the latest N days (latest working backwards). Ascending order fetches the oldest N days (oldest working forwards) (defaults to 'desc').
143
+ * @param days - The number of days to fetch pooled staking vault daily apys for (defaults to 365).
144
+ * @param order - The order in which to fetch pooled staking vault daily apys. Descending order fetches the latest N days (latest working backwards). Ascending order fetches the oldest N days (oldest working forwards) (defaults to 'desc').
150
145
  * @returns A promise that resolves when the pooled staking vault daily apys have been updated.
151
146
  */
152
- refreshPooledStakingVaultDailyApys({ chainId, days, order, }?: RefreshPooledStakingVaultDailyApysOptions): Promise<void>;
147
+ refreshPooledStakingVaultDailyApys(days?: number, order?: 'asc' | 'desc'): Promise<void>;
153
148
  /**
154
149
  * Refreshes pooled staking vault apy averages for the current chain.
155
150
  * Updates the pooled staking vault apy averages controller state.
156
151
  *
157
- * @param chainId - The chain id to refresh pooled staking vault apy averages for (optional).
158
152
  * @returns A promise that resolves when the pooled staking vault apy averages have been updated.
159
153
  */
160
- refreshPooledStakingVaultApyAverages(chainId?: number): Promise<void>;
154
+ refreshPooledStakingVaultApyAverages(): Promise<void>;
161
155
  /**
162
156
  * Refreshes all pooled staking related data including stakes, eligibility, and vault data.
163
157
  * This method allows partial success, meaning some data may update while other requests fail.
@@ -209,7 +203,7 @@ export declare class EarnController extends BaseController<typeof controllerName
209
203
  *
210
204
  * @param options - Optional arguments
211
205
  * @param [options.address] - The address to get lending position history for (optional).
212
- * @param options.chainId - The chain id to get lending position history for.
206
+ * @param [options.chainId] - The chain id to get lending position history for (optional).
213
207
  * @param [options.positionId] - The position id to get lending position history for.
214
208
  * @param [options.marketId] - The market id to get lending position history for.
215
209
  * @param [options.marketAddress] - The market address to get lending position history for.
@@ -219,7 +213,7 @@ export declare class EarnController extends BaseController<typeof controllerName
219
213
  */
220
214
  getLendingPositionHistory({ address, chainId, positionId, marketId, marketAddress, protocol, days, }: {
221
215
  address?: string;
222
- chainId: number;
216
+ chainId?: number;
223
217
  positionId: string;
224
218
  marketId: string;
225
219
  marketAddress: string;
@@ -230,14 +224,14 @@ export declare class EarnController extends BaseController<typeof controllerName
230
224
  * Gets the lending market daily apys and averages for the current chain.
231
225
  *
232
226
  * @param options - Optional arguments
233
- * @param options.chainId - The chain id to get lending market daily apys and averages for.
227
+ * @param [options.chainId] - The chain id to get lending market daily apys and averages for (optional).
234
228
  * @param [options.protocol] - The protocol to get lending market daily apys and averages for.
235
229
  * @param [options.marketId] - The market id to get lending market daily apys and averages for.
236
230
  * @param [options.days] - The number of days to get lending market daily apys and averages for (optional).
237
231
  * @returns A promise that resolves when the lending market daily apys and averages have been updated
238
232
  */
239
233
  getLendingMarketDailyApysAndAverages({ chainId, protocol, marketId, days, }: {
240
- chainId: number;
234
+ chainId?: number;
241
235
  protocol: string;
242
236
  marketId: string;
243
237
  days?: number;
@@ -247,7 +241,6 @@ export declare class EarnController extends BaseController<typeof controllerName
247
241
  *
248
242
  * @param options - The options for the lending deposit transaction.
249
243
  * @param options.amount - The amount to deposit.
250
- * @param options.chainId - The chain ID for the lending deposit transaction.
251
244
  * @param options.protocol - The protocol of the lending market.
252
245
  * @param options.underlyingTokenAddress - The address of the underlying token.
253
246
  * @param options.gasOptions - The gas options for the transaction.
@@ -256,9 +249,8 @@ export declare class EarnController extends BaseController<typeof controllerName
256
249
  * @param options.txOptions - The transaction options for the transaction.
257
250
  * @returns A promise that resolves to the transaction hash.
258
251
  */
259
- executeLendingDeposit({ amount, chainId, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
252
+ executeLendingDeposit({ amount, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
260
253
  amount: string;
261
- chainId: string;
262
254
  protocol: LendingMarket['protocol'];
263
255
  underlyingTokenAddress: string;
264
256
  gasOptions: {
@@ -272,7 +264,6 @@ export declare class EarnController extends BaseController<typeof controllerName
272
264
  *
273
265
  * @param options - The options for the lending withdraw transaction.
274
266
  * @param options.amount - The amount to withdraw.
275
- * @param options.chainId - The chain ID for the lending withdraw transaction.
276
267
  * @param options.protocol - The protocol of the lending market.
277
268
  * @param options.underlyingTokenAddress - The address of the underlying token.
278
269
  * @param options.gasOptions - The gas options for the transaction.
@@ -281,9 +272,8 @@ export declare class EarnController extends BaseController<typeof controllerName
281
272
  * @param options.txOptions - The transaction options for the transaction.
282
273
  * @returns A promise that resolves to the transaction hash.
283
274
  */
284
- executeLendingWithdraw({ amount, chainId, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
275
+ executeLendingWithdraw({ amount, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
285
276
  amount: string;
286
- chainId: string;
287
277
  protocol: LendingMarket['protocol'];
288
278
  underlyingTokenAddress: string;
289
279
  gasOptions: {
@@ -297,7 +287,6 @@ export declare class EarnController extends BaseController<typeof controllerName
297
287
  *
298
288
  * @param options - The options for the lending token approve transaction.
299
289
  * @param options.amount - The amount to approve.
300
- * @param options.chainId - The chain ID for the lending token approve transaction.
301
290
  * @param options.protocol - The protocol of the lending market.
302
291
  * @param options.underlyingTokenAddress - The address of the underlying token.
303
292
  * @param options.gasOptions - The gas options for the transaction.
@@ -306,10 +295,9 @@ export declare class EarnController extends BaseController<typeof controllerName
306
295
  * @param options.txOptions - The transaction options for the transaction.
307
296
  * @returns A promise that resolves to the transaction hash.
308
297
  */
309
- executeLendingTokenApprove({ protocol, amount, chainId, underlyingTokenAddress, gasOptions, txOptions, }: {
298
+ executeLendingTokenApprove({ protocol, amount, underlyingTokenAddress, gasOptions, txOptions, }: {
310
299
  protocol: LendingMarket['protocol'];
311
300
  amount: string;
312
- chainId: string;
313
301
  underlyingTokenAddress: string;
314
302
  gasOptions: {
315
303
  gasLimit?: GasLimitParams;
@@ -1 +1 @@
1
- {"version":3,"file":"EarnController.d.cts","sourceRoot":"","sources":["../src/EarnController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,0CAA0C,EAC1C,4CAA4C,EAC7C,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EACV,2CAA2C,EAC3C,+CAA+C,EAC/C,sCAAsC,EACvC,qCAAqC;AACtC,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,WAAW,EAEhB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,gBAAgB,EAGjB,4BAA4B;AAC7B,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,8CAA8C,EACpD,yCAAyC;AAE1C,OAAO,KAAK,EACV,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,EAC9B,0BAA0B,EAC1B,+BAA+B,EAC/B,yCAAyC,EAC1C,oBAAgB;AAEjB,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,OAAO,EAAE,MAAM,GAAG;QACjB,YAAY,EAAE,WAAW,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,SAAS,CAAC;QACzB,cAAc,EAAE,aAAa,EAAE,CAA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