@metamask-previews/earn-controller 3.0.0-preview-91d59c3 → 3.0.0-preview-243e64f7

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,mDAc6B;AAC7B,6EAK0C;AAG1C,+CAAyD;AAS5C,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;Q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AA,IAAI,2BAAY,IAAI,MAAA,CAAC;QACrB,2DAA2D;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,iFAQkB,eAAwB;IACzC,MAAM,oBAAoB,GACxB,eAAe;QACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,4BAA4B,CAAC;aACpD,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
+ {"version":3,"file":"EarnController.cjs","sourceRoot":"","sources":["../src/EarnController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAwD;AAUxD,+DAA2D;AAC3D,iEAAwE;AAOxE,mDAgB6B;AAC7B,6EAI0C;AAU7B,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,EAA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,aAAa,CAAC,aAAa,CAAC;IAEhD,oDAAoD;IACpD,MAAM,MAAM,GAAkB;QAC5B,OAAO,EAAE,IAAA,sCAAmB,EAAC,OAAO,CAAC;QACrC,GAAG,EAAE,uBAAA,IAAI,2BAAK;KACf,CAAC;IAEF,IAAI;QACF,uBAAA,IAAI,2BAAY,MAAM,mBAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAA,CAAC;KACxD;IAAC,OAAO,KAAK,EAAE;QACd,uBAAA,IAAI,2BAAY,IAAI,MAAA,CAAC;QACrB,2DAA2D;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 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 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 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} 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 * 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 | NetworkControllerStateChangeEvent\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 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.#initializeSDK(\n networkControllerState.selectedNetworkClientId,\n ).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 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 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 chainId - The chain id to refresh pooled staking vault daily apys for (optional).\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 chainId: number = ChainId.ETHEREUM,\n days = 365,\n order: 'asc' | 'desc' = 'desc',\n ): 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,7 +1,7 @@
1
1
  import type { AccountsControllerGetSelectedAccountAction, AccountsControllerSelectedAccountChangeEvent } from "@metamask/accounts-controller";
2
- import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
2
+ import type { ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
3
3
  import { BaseController } from "@metamask/base-controller";
4
- import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction, NetworkControllerStateChangeEvent } from "@metamask/network-controller";
4
+ import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerNetworkDidChangeEvent, 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
7
  import type { RefreshEarnEligibilityOptions, RefreshLendingEligibilityOptions, RefreshLendingPositionsOptions, RefreshPooledStakesOptions, RefreshPooledStakingDataOptions } from "./types.cjs";
@@ -66,18 +66,10 @@ export declare const DEFAULT_POOLED_STAKING_CHAIN_STATE: {
66
66
  * @returns The default EarnController state.
67
67
  */
68
68
  export declare function getDefaultEarnControllerState(): EarnControllerState;
69
- /**
70
- * The action which can be used to retrieve the state of the EarnController.
71
- */
72
- export type EarnControllerGetStateAction = ControllerGetStateAction<typeof controllerName, EarnControllerState>;
73
- /**
74
- * All actions that EarnController registers, to be called externally.
75
- */
76
- export type EarnControllerActions = EarnControllerGetStateAction;
77
69
  /**
78
70
  * All actions that EarnController calls internally.
79
71
  */
80
- export type AllowedActions = NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetStateAction | AccountsControllerGetSelectedAccountAction;
72
+ export type AllowedActions = NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | AccountsControllerGetSelectedAccountAction;
81
73
  /**
82
74
  * The event that EarnController publishes when updating state.
83
75
  */
@@ -89,21 +81,22 @@ export type EarnControllerEvents = EarnControllerStateChangeEvent;
89
81
  /**
90
82
  * All events that EarnController subscribes to internally.
91
83
  */
92
- export type AllowedEvents = AccountsControllerSelectedAccountChangeEvent | NetworkControllerStateChangeEvent | TransactionControllerTransactionConfirmedEvent;
84
+ export type AllowedEvents = AccountsControllerSelectedAccountChangeEvent | NetworkControllerStateChangeEvent | TransactionControllerTransactionConfirmedEvent | NetworkControllerNetworkDidChangeEvent;
93
85
  /**
94
86
  * The messenger which is restricted to actions and events accessed by
95
87
  * EarnController.
96
88
  */
97
- export type EarnControllerMessenger = RestrictedMessenger<typeof controllerName, EarnControllerActions | AllowedActions, EarnControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
89
+ export type EarnControllerMessenger = RestrictedMessenger<typeof controllerName, AllowedActions, EarnControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
98
90
  /**
99
91
  * EarnController manages DeFi earning opportunities across different protocols and chains.
100
92
  */
101
93
  export declare class EarnController extends BaseController<typeof controllerName, EarnControllerState, EarnControllerMessenger> {
102
94
  #private;
103
- constructor({ messenger, state, addTransactionFn, env, }: {
95
+ constructor({ messenger, state, addTransactionFn, selectedNetworkClientId, env, }: {
104
96
  messenger: EarnControllerMessenger;
105
97
  state?: Partial<EarnControllerState>;
106
98
  addTransactionFn: typeof TransactionController.prototype.addTransaction;
99
+ selectedNetworkClientId: string;
107
100
  env?: EarnEnvironments;
108
101
  });
109
102
  /**
@@ -114,9 +107,10 @@ export declare class EarnController extends BaseController<typeof controllerName
114
107
  * @param options - Optional arguments
115
108
  * @param [options.resetCache] - Control whether the BE cache should be invalidated (optional).
116
109
  * @param [options.address] - The address to refresh pooled stakes for (optional).
110
+ * @param [options.chainId] - The chain id to refresh pooled stakes for (optional).
117
111
  * @returns A promise that resolves when the stakes data has been updated
118
112
  */
119
- refreshPooledStakes({ resetCache, address, }?: RefreshPooledStakesOptions): Promise<void>;
113
+ refreshPooledStakes({ resetCache, address, chainId, }?: RefreshPooledStakesOptions): Promise<void>;
120
114
  /**
121
115
  * Refreshes the earn eligibility status for the current account.
122
116
  * Updates the eligibility status in the controller state based on the location and address blocklist for compliance.
@@ -133,25 +127,28 @@ export declare class EarnController extends BaseController<typeof controllerName
133
127
  * Updates the vault metadata in the controller state including APY, capacity,
134
128
  * fee percentage, total assets, and vault address.
135
129
  *
130
+ * @param chainId - The chain id to refresh pooled staking vault metadata for (optional).
136
131
  * @returns A promise that resolves when the vault metadata has been updated
137
132
  */
138
- refreshPooledStakingVaultMetadata(): Promise<void>;
133
+ refreshPooledStakingVaultMetadata(chainId?: number): Promise<void>;
139
134
  /**
140
135
  * Refreshes pooled staking vault daily apys for the current chain.
141
136
  * Updates the pooled staking vault daily apys controller state.
142
137
  *
138
+ * @param chainId - The chain id to refresh pooled staking vault daily apys for (optional).
143
139
  * @param days - The number of days to fetch pooled staking vault daily apys for (defaults to 365).
144
140
  * @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').
145
141
  * @returns A promise that resolves when the pooled staking vault daily apys have been updated.
146
142
  */
147
- refreshPooledStakingVaultDailyApys(days?: number, order?: 'asc' | 'desc'): Promise<void>;
143
+ refreshPooledStakingVaultDailyApys(chainId?: number, days?: number, order?: 'asc' | 'desc'): Promise<void>;
148
144
  /**
149
145
  * Refreshes pooled staking vault apy averages for the current chain.
150
146
  * Updates the pooled staking vault apy averages controller state.
151
147
  *
148
+ * @param chainId - The chain id to refresh pooled staking vault apy averages for (optional).
152
149
  * @returns A promise that resolves when the pooled staking vault apy averages have been updated.
153
150
  */
154
- refreshPooledStakingVaultApyAverages(): Promise<void>;
151
+ refreshPooledStakingVaultApyAverages(chainId?: number): Promise<void>;
155
152
  /**
156
153
  * Refreshes all pooled staking related data including stakes, eligibility, and vault data.
157
154
  * This method allows partial success, meaning some data may update while other requests fail.
@@ -203,7 +200,7 @@ export declare class EarnController extends BaseController<typeof controllerName
203
200
  *
204
201
  * @param options - Optional arguments
205
202
  * @param [options.address] - The address to get lending position history for (optional).
206
- * @param [options.chainId] - The chain id to get lending position history for (optional).
203
+ * @param [options.chainId] - The chain id to get lending position history for.
207
204
  * @param [options.positionId] - The position id to get lending position history for.
208
205
  * @param [options.marketId] - The market id to get lending position history for.
209
206
  * @param [options.marketAddress] - The market address to get lending position history for.
@@ -213,7 +210,7 @@ export declare class EarnController extends BaseController<typeof controllerName
213
210
  */
214
211
  getLendingPositionHistory({ address, chainId, positionId, marketId, marketAddress, protocol, days, }: {
215
212
  address?: string;
216
- chainId?: number;
213
+ chainId: number;
217
214
  positionId: string;
218
215
  marketId: string;
219
216
  marketAddress: string;
@@ -224,14 +221,14 @@ export declare class EarnController extends BaseController<typeof controllerName
224
221
  * Gets the lending market daily apys and averages for the current chain.
225
222
  *
226
223
  * @param options - Optional arguments
227
- * @param [options.chainId] - The chain id to get lending market daily apys and averages for (optional).
224
+ * @param [options.chainId] - The chain id to get lending market daily apys and averages for.
228
225
  * @param [options.protocol] - The protocol to get lending market daily apys and averages for.
229
226
  * @param [options.marketId] - The market id to get lending market daily apys and averages for.
230
227
  * @param [options.days] - The number of days to get lending market daily apys and averages for (optional).
231
228
  * @returns A promise that resolves when the lending market daily apys and averages have been updated
232
229
  */
233
230
  getLendingMarketDailyApysAndAverages({ chainId, protocol, marketId, days, }: {
234
- chainId?: number;
231
+ chainId: number;
235
232
  protocol: string;
236
233
  marketId: string;
237
234
  days?: number;
@@ -241,6 +238,7 @@ export declare class EarnController extends BaseController<typeof controllerName
241
238
  *
242
239
  * @param options - The options for the lending deposit transaction.
243
240
  * @param options.amount - The amount to deposit.
241
+ * @param options.chainId - The chain ID for the lending deposit transaction.
244
242
  * @param options.protocol - The protocol of the lending market.
245
243
  * @param options.underlyingTokenAddress - The address of the underlying token.
246
244
  * @param options.gasOptions - The gas options for the transaction.
@@ -249,8 +247,9 @@ export declare class EarnController extends BaseController<typeof controllerName
249
247
  * @param options.txOptions - The transaction options for the transaction.
250
248
  * @returns A promise that resolves to the transaction hash.
251
249
  */
252
- executeLendingDeposit({ amount, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
250
+ executeLendingDeposit({ amount, chainId, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
253
251
  amount: string;
252
+ chainId: string;
254
253
  protocol: LendingMarket['protocol'];
255
254
  underlyingTokenAddress: string;
256
255
  gasOptions: {
@@ -264,6 +263,7 @@ export declare class EarnController extends BaseController<typeof controllerName
264
263
  *
265
264
  * @param options - The options for the lending withdraw transaction.
266
265
  * @param options.amount - The amount to withdraw.
266
+ * @param options.chainId - The chain ID for the lending withdraw transaction.
267
267
  * @param options.protocol - The protocol of the lending market.
268
268
  * @param options.underlyingTokenAddress - The address of the underlying token.
269
269
  * @param options.gasOptions - The gas options for the transaction.
@@ -272,8 +272,9 @@ export declare class EarnController extends BaseController<typeof controllerName
272
272
  * @param options.txOptions - The transaction options for the transaction.
273
273
  * @returns A promise that resolves to the transaction hash.
274
274
  */
275
- executeLendingWithdraw({ amount, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
275
+ executeLendingWithdraw({ amount, chainId, protocol, underlyingTokenAddress, gasOptions, txOptions, }: {
276
276
  amount: string;
277
+ chainId: string;
277
278
  protocol: LendingMarket['protocol'];
278
279
  underlyingTokenAddress: string;
279
280
  gasOptions: {
@@ -287,6 +288,7 @@ export declare class EarnController extends BaseController<typeof controllerName
287
288
  *
288
289
  * @param options - The options for the lending token approve transaction.
289
290
  * @param options.amount - The amount to approve.
291
+ * @param options.chainId - The chain ID for the lending token approve transaction.
290
292
  * @param options.protocol - The protocol of the lending market.
291
293
  * @param options.underlyingTokenAddress - The address of the underlying token.
292
294
  * @param options.gasOptions - The gas options for the transaction.
@@ -295,9 +297,10 @@ export declare class EarnController extends BaseController<typeof controllerName
295
297
  * @param options.txOptions - The transaction options for the transaction.
296
298
  * @returns A promise that resolves to the transaction hash.
297
299
  */
298
- executeLendingTokenApprove({ protocol, amount, underlyingTokenAddress, gasOptions, txOptions, }: {
300
+ executeLendingTokenApprove({ protocol, amount, chainId, underlyingTokenAddress, gasOptions, txOptions, }: {
299
301
  protocol: LendingMarket['protocol'];
300
302
  amount: string;
303
+ chainId: string;
301
304
  underlyingTokenAddress: string;
302
305
  gasOptions: {
303
306
  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,+BAA+B,EAC/B,iCAAiC,EAClC,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,EACjB,4BAA4B;AAC7B,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,8CAA8C,EAEpD,yCAAyC;AAI1C,OAAO,KAAK,EACV,6BAA6B,EAC7B,gCAAgC,EAChC,8BAA8B,EAC9B,0BAA0B,EAC1B,+BAA+B,EAChC,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,CAAC;QAChC,gBAAgB,EAAE,gBAAgB,CAAC;KACpC,CAAC;IACF,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,eAAe,GAAG;IACx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