@eth-optimism/actions-sdk 0.1.0 → 0.3.0
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.
- package/LICENSE +1 -1
- package/dist/__mocks__/MockAssets.d.ts.map +1 -0
- package/dist/{test → __mocks__}/MockAssets.js +2 -0
- package/dist/__mocks__/MockAssets.js.map +1 -0
- package/dist/__mocks__/MockPrivyClient.d.ts.map +1 -0
- package/dist/__mocks__/MockPrivyClient.js.map +1 -0
- package/dist/__mocks__/utils.d.ts.map +1 -0
- package/dist/__mocks__/utils.js.map +1 -0
- package/dist/__tests__/actions.test.d.ts.map +1 -0
- package/dist/{actions.test.js → __tests__/actions.test.js} +5 -9
- package/dist/__tests__/actions.test.js.map +1 -0
- package/dist/actions.d.ts +20 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +37 -13
- package/dist/actions.js.map +1 -1
- package/dist/constants/assets.d.ts +23 -0
- package/dist/constants/assets.d.ts.map +1 -1
- package/dist/constants/assets.js +99 -6
- package/dist/constants/assets.js.map +1 -1
- package/dist/constants/contracts.d.ts +4 -0
- package/dist/constants/contracts.d.ts.map +1 -0
- package/dist/constants/contracts.js +3 -0
- package/dist/constants/contracts.js.map +1 -0
- package/dist/constants/supportedChains.d.ts +1 -1
- package/dist/constants/supportedChains.d.ts.map +1 -1
- package/dist/constants/supportedChains.js +7 -3
- package/dist/constants/supportedChains.js.map +1 -1
- package/dist/core/asset/__mocks__/mockAsset.js +1 -1
- package/dist/core/asset/__mocks__/mockAsset.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/{test → lend/__mocks__}/MockLendProvider.d.ts +7 -6
- package/dist/lend/__mocks__/MockLendProvider.d.ts.map +1 -0
- package/dist/{test → lend/__mocks__}/MockLendProvider.js +20 -21
- package/dist/lend/__mocks__/MockLendProvider.js.map +1 -0
- package/dist/{test → lend/__mocks__}/MockMarkets.d.ts +1 -1
- package/dist/lend/__mocks__/MockMarkets.d.ts.map +1 -0
- package/dist/{test → lend/__mocks__}/MockMarkets.js +1 -1
- package/dist/lend/__mocks__/MockMarkets.js.map +1 -0
- package/dist/lend/__mocks__/mockLendTransaction.d.ts +3 -12
- package/dist/lend/__mocks__/mockLendTransaction.d.ts.map +1 -1
- package/dist/lend/__mocks__/mockLendTransaction.js +3 -19
- package/dist/lend/__mocks__/mockLendTransaction.js.map +1 -1
- package/dist/lend/core/LendProvider.d.ts +14 -8
- package/dist/lend/core/LendProvider.d.ts.map +1 -1
- package/dist/lend/core/LendProvider.js +29 -17
- package/dist/lend/core/LendProvider.js.map +1 -1
- package/dist/lend/core/__tests__/LendProvider.test.js +4 -6
- package/dist/lend/core/__tests__/LendProvider.test.js.map +1 -1
- package/dist/lend/namespaces/ActionsLendNamespace.d.ts +2 -36
- package/dist/lend/namespaces/ActionsLendNamespace.d.ts.map +1 -1
- package/dist/lend/namespaces/ActionsLendNamespace.js +2 -48
- package/dist/lend/namespaces/ActionsLendNamespace.js.map +1 -1
- package/dist/lend/namespaces/BaseLendNamespace.d.ts +47 -0
- package/dist/lend/namespaces/BaseLendNamespace.d.ts.map +1 -0
- package/dist/lend/namespaces/BaseLendNamespace.js +58 -0
- package/dist/lend/namespaces/BaseLendNamespace.js.map +1 -0
- package/dist/lend/namespaces/WalletLendNamespace.d.ts +8 -36
- package/dist/lend/namespaces/WalletLendNamespace.d.ts.map +1 -1
- package/dist/lend/namespaces/WalletLendNamespace.js +14 -69
- package/dist/lend/namespaces/WalletLendNamespace.js.map +1 -1
- package/dist/lend/namespaces/__tests__/ActionsLendNamespace.spec.js +2 -2
- package/dist/lend/namespaces/__tests__/ActionsLendNamespace.spec.js.map +1 -1
- package/dist/lend/namespaces/__tests__/BaseLendNamespace.spec.d.ts +2 -0
- package/dist/lend/namespaces/__tests__/BaseLendNamespace.spec.d.ts.map +1 -0
- package/dist/lend/namespaces/__tests__/BaseLendNamespace.spec.js +110 -0
- package/dist/lend/namespaces/__tests__/BaseLendNamespace.spec.js.map +1 -0
- package/dist/lend/namespaces/__tests__/WalletLendNamespace.spec.js +8 -10
- package/dist/lend/namespaces/__tests__/WalletLendNamespace.spec.js.map +1 -1
- package/dist/lend/providers/aave/AaveLendProvider.d.ts +19 -27
- package/dist/lend/providers/aave/AaveLendProvider.d.ts.map +1 -1
- package/dist/lend/providers/aave/AaveLendProvider.js +124 -180
- package/dist/lend/providers/aave/AaveLendProvider.js.map +1 -1
- package/dist/lend/providers/aave/__mocks__/mockReserve.d.ts +11 -0
- package/dist/lend/providers/aave/__mocks__/mockReserve.d.ts.map +1 -0
- package/dist/lend/providers/aave/__mocks__/mockReserve.js +80 -0
- package/dist/lend/providers/aave/__mocks__/mockReserve.js.map +1 -0
- package/dist/lend/providers/aave/__tests__/AaveLendProvider.test.d.ts +2 -0
- package/dist/lend/providers/aave/__tests__/AaveLendProvider.test.d.ts.map +1 -0
- package/dist/lend/providers/aave/__tests__/AaveLendProvider.test.js +315 -0
- package/dist/lend/providers/aave/__tests__/AaveLendProvider.test.js.map +1 -0
- package/dist/lend/providers/aave/abis/pool.d.ts +153 -0
- package/dist/lend/providers/aave/abis/pool.d.ts.map +1 -0
- package/dist/lend/providers/aave/abis/pool.js +79 -0
- package/dist/lend/providers/aave/abis/pool.js.map +1 -0
- package/dist/lend/providers/aave/sdk.d.ts.map +1 -1
- package/dist/lend/providers/aave/sdk.js +6 -65
- package/dist/lend/providers/aave/sdk.js.map +1 -1
- package/dist/lend/providers/morpho/MorphoLendProvider.d.ts +0 -1
- package/dist/lend/providers/morpho/MorphoLendProvider.d.ts.map +1 -1
- package/dist/lend/providers/morpho/MorphoLendProvider.js +13 -28
- package/dist/lend/providers/morpho/MorphoLendProvider.js.map +1 -1
- package/dist/lend/providers/morpho/__tests__/MorphoLendProvider.test.js +5 -24
- package/dist/lend/providers/morpho/__tests__/MorphoLendProvider.test.js.map +1 -1
- package/dist/lend/providers/morpho/__tests__/api.test.js +248 -54
- package/dist/lend/providers/morpho/__tests__/api.test.js.map +1 -1
- package/dist/lend/providers/morpho/__tests__/sdk.test.js +3 -2
- package/dist/lend/providers/morpho/__tests__/sdk.test.js.map +1 -1
- package/dist/lend/providers/morpho/api.d.ts +4 -0
- package/dist/lend/providers/morpho/api.d.ts.map +1 -1
- package/dist/lend/providers/morpho/api.js.map +1 -1
- package/dist/lend/providers/morpho/contracts.d.ts +19 -0
- package/dist/lend/providers/morpho/contracts.d.ts.map +1 -0
- package/dist/lend/providers/morpho/contracts.js +32 -0
- package/dist/lend/providers/morpho/contracts.js.map +1 -0
- package/dist/lend/providers/morpho/sdk.d.ts.map +1 -1
- package/dist/lend/providers/morpho/sdk.js +177 -71
- package/dist/lend/providers/morpho/sdk.js.map +1 -1
- package/dist/services/ChainManager.d.ts +1 -1
- package/dist/{test → services/__mocks__}/MockChainManager.d.ts +1 -1
- package/dist/services/__mocks__/MockChainManager.d.ts.map +1 -0
- package/dist/services/__mocks__/MockChainManager.js.map +1 -0
- package/dist/services/tokenBalance.d.ts.map +1 -1
- package/dist/services/tokenBalance.js +4 -5
- package/dist/services/tokenBalance.js.map +1 -1
- package/dist/services/tokenBalance.spec.js +2 -2
- package/dist/services/tokenBalance.spec.js.map +1 -1
- package/dist/supported/tokens.d.ts +4 -4
- package/dist/supported/tokens.d.ts.map +1 -1
- package/dist/supported/tokens.js +10 -70
- package/dist/supported/tokens.js.map +1 -1
- package/dist/swap/__mocks__/MockSwapProvider.d.ts +38 -0
- package/dist/swap/__mocks__/MockSwapProvider.d.ts.map +1 -0
- package/dist/swap/__mocks__/MockSwapProvider.js +138 -0
- package/dist/swap/__mocks__/MockSwapProvider.js.map +1 -0
- package/dist/swap/core/SwapProvider.d.ts +56 -0
- package/dist/swap/core/SwapProvider.d.ts.map +1 -0
- package/dist/swap/core/SwapProvider.js +177 -0
- package/dist/swap/core/SwapProvider.js.map +1 -0
- package/dist/swap/core/__tests__/SwapProvider.test.d.ts +2 -0
- package/dist/swap/core/__tests__/SwapProvider.test.d.ts.map +1 -0
- package/dist/swap/core/__tests__/SwapProvider.test.js +329 -0
- package/dist/swap/core/__tests__/SwapProvider.test.js.map +1 -0
- package/dist/swap/index.d.ts +7 -0
- package/dist/swap/index.d.ts.map +1 -0
- package/dist/swap/index.js +8 -0
- package/dist/swap/index.js.map +1 -0
- package/dist/swap/namespaces/ActionsSwapNamespace.d.ts +8 -0
- package/dist/swap/namespaces/ActionsSwapNamespace.d.ts.map +1 -0
- package/dist/swap/namespaces/ActionsSwapNamespace.js +8 -0
- package/dist/swap/namespaces/ActionsSwapNamespace.js.map +1 -0
- package/dist/swap/namespaces/BaseSwapNamespace.d.ts +33 -0
- package/dist/swap/namespaces/BaseSwapNamespace.d.ts.map +1 -0
- package/dist/swap/namespaces/BaseSwapNamespace.js +58 -0
- package/dist/swap/namespaces/BaseSwapNamespace.js.map +1 -0
- package/dist/swap/namespaces/WalletSwapNamespace.d.ts +22 -0
- package/dist/swap/namespaces/WalletSwapNamespace.d.ts.map +1 -0
- package/dist/swap/namespaces/WalletSwapNamespace.js +60 -0
- package/dist/swap/namespaces/WalletSwapNamespace.js.map +1 -0
- package/dist/swap/namespaces/__tests__/BaseSwapNamespace.spec.d.ts +2 -0
- package/dist/swap/namespaces/__tests__/BaseSwapNamespace.spec.d.ts.map +1 -0
- package/dist/swap/namespaces/__tests__/BaseSwapNamespace.spec.js +106 -0
- package/dist/swap/namespaces/__tests__/BaseSwapNamespace.spec.js.map +1 -0
- package/dist/swap/namespaces/__tests__/WalletSwapNamespace.spec.d.ts +2 -0
- package/dist/swap/namespaces/__tests__/WalletSwapNamespace.spec.d.ts.map +1 -0
- package/dist/swap/namespaces/__tests__/WalletSwapNamespace.spec.js +132 -0
- package/dist/swap/namespaces/__tests__/WalletSwapNamespace.spec.js.map +1 -0
- package/dist/swap/providers/uniswap/UniswapSwapProvider.d.ts +68 -0
- package/dist/swap/providers/uniswap/UniswapSwapProvider.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/UniswapSwapProvider.js +206 -0
- package/dist/swap/providers/uniswap/UniswapSwapProvider.js.map +1 -0
- package/dist/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.d.ts +2 -0
- package/dist/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.js +257 -0
- package/dist/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.js.map +1 -0
- package/dist/swap/providers/uniswap/__tests__/sdk.test.d.ts +2 -0
- package/dist/swap/providers/uniswap/__tests__/sdk.test.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/__tests__/sdk.test.js +312 -0
- package/dist/swap/providers/uniswap/__tests__/sdk.test.js.map +1 -0
- package/dist/swap/providers/uniswap/abis.d.ts +227 -0
- package/dist/swap/providers/uniswap/abis.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/abis.js +138 -0
- package/dist/swap/providers/uniswap/abis.js.map +1 -0
- package/dist/swap/providers/uniswap/addresses.d.ts +21 -0
- package/dist/swap/providers/uniswap/addresses.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/addresses.js +81 -0
- package/dist/swap/providers/uniswap/addresses.js.map +1 -0
- package/dist/swap/providers/uniswap/encoding.d.ts +77 -0
- package/dist/swap/providers/uniswap/encoding.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/encoding.js +233 -0
- package/dist/swap/providers/uniswap/encoding.js.map +1 -0
- package/dist/swap/providers/uniswap/types.d.ts +20 -0
- package/dist/swap/providers/uniswap/types.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/types.js +2 -0
- package/dist/swap/providers/uniswap/types.js.map +1 -0
- package/dist/types/actions.d.ts +19 -5
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/asset.d.ts +3 -3
- package/dist/types/asset.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/lend/base.d.ts +7 -22
- package/dist/types/lend/base.d.ts.map +1 -1
- package/dist/types/lend/base.js.map +1 -1
- package/dist/types/lend/contracts.d.ts +17 -0
- package/dist/types/lend/contracts.d.ts.map +1 -0
- package/dist/types/lend/contracts.js +2 -0
- package/dist/types/lend/contracts.js.map +1 -0
- package/dist/types/lend/index.d.ts +1 -0
- package/dist/types/lend/index.d.ts.map +1 -1
- package/dist/types/lend/index.js +1 -0
- package/dist/types/lend/index.js.map +1 -1
- package/dist/types/swap/base.d.ts +238 -0
- package/dist/types/swap/base.d.ts.map +1 -0
- package/dist/types/swap/base.js +4 -0
- package/dist/types/swap/base.js.map +1 -0
- package/dist/types/swap/index.d.ts +2 -0
- package/dist/types/swap/index.d.ts.map +1 -0
- package/dist/types/swap/index.js +2 -0
- package/dist/types/swap/index.js.map +1 -0
- package/dist/types/transaction.d.ts +14 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/dist/types/transaction.js +2 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/utils/assets.d.ts +11 -6
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/assets.js +16 -12
- package/dist/utils/assets.js.map +1 -1
- package/dist/utils/assets.test.js +14 -2
- package/dist/utils/assets.test.js.map +1 -1
- package/dist/utils/constants.d.ts +5 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/permit2.d.ts +46 -0
- package/dist/utils/permit2.d.ts.map +1 -0
- package/dist/utils/permit2.js +100 -0
- package/dist/utils/permit2.js.map +1 -0
- package/dist/utils/permit2.test.d.ts +2 -0
- package/dist/utils/permit2.test.d.ts.map +1 -0
- package/dist/utils/permit2.test.js +110 -0
- package/dist/utils/permit2.test.js.map +1 -0
- package/dist/utils/validation.d.ts +12 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +44 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/wallet/core/namespace/WalletNamespace.d.ts.map +1 -1
- package/dist/wallet/core/namespace/WalletNamespace.js.map +1 -1
- package/dist/wallet/core/namespace/__tests__/WalletNamespace.spec.js +4 -4
- package/dist/wallet/core/namespace/__tests__/WalletNamespace.spec.js.map +1 -1
- package/dist/wallet/core/providers/__tests__/WalletProvider.spec.js +4 -4
- package/dist/wallet/core/providers/__tests__/WalletProvider.spec.js.map +1 -1
- package/dist/wallet/core/providers/hosted/abstract/HostedWalletProvider.d.ts +7 -1
- package/dist/wallet/core/providers/hosted/abstract/HostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/core/providers/hosted/abstract/HostedWalletProvider.js +2 -1
- package/dist/wallet/core/providers/hosted/abstract/HostedWalletProvider.js.map +1 -1
- package/dist/wallet/core/providers/hosted/registry/__tests__/HostedWalletProviderRegistry.spec.js +2 -2
- package/dist/wallet/core/providers/hosted/registry/__tests__/HostedWalletProviderRegistry.spec.js.map +1 -1
- package/dist/wallet/core/providers/hosted/types/index.d.ts +5 -1
- package/dist/wallet/core/providers/hosted/types/index.d.ts.map +1 -1
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.d.ts +7 -1
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.d.ts.map +1 -1
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.js +5 -1
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.js.map +1 -1
- package/dist/wallet/core/providers/smart/default/__tests__/DefaultSmartWalletProvider.spec.js +5 -5
- package/dist/wallet/core/providers/smart/default/__tests__/DefaultSmartWalletProvider.spec.js.map +1 -1
- package/dist/wallet/core/wallets/abstract/Wallet.d.ts +13 -2
- package/dist/wallet/core/wallets/abstract/Wallet.d.ts.map +1 -1
- package/dist/wallet/core/wallets/abstract/Wallet.js +7 -1
- package/dist/wallet/core/wallets/abstract/Wallet.js.map +1 -1
- package/dist/wallet/core/wallets/abstract/__tests__/Wallet.spec.js +2 -2
- package/dist/wallet/core/wallets/abstract/__tests__/Wallet.spec.js.map +1 -1
- package/dist/wallet/core/wallets/eoa/__tests__/EOAWallet.spec.js +2 -2
- package/dist/wallet/core/wallets/eoa/__tests__/EOAWallet.spec.js.map +1 -1
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.d.ts +7 -2
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.d.ts.map +1 -1
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.js +6 -5
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.js.map +1 -1
- package/dist/wallet/core/wallets/smart/default/__tests__/DefaultSmartWallet.spec.js +3 -3
- package/dist/wallet/core/wallets/smart/default/__tests__/DefaultSmartWallet.spec.js.map +1 -1
- package/dist/wallet/core/wallets/smart/default/utils/__tests__/findSignerInArray.spec.js +1 -1
- package/dist/wallet/core/wallets/smart/default/utils/__tests__/findSignerInArray.spec.js.map +1 -1
- package/dist/wallet/core/wallets/smart/default/utils/__tests__/getSignerPublicKey.spec.js +1 -1
- package/dist/wallet/core/wallets/smart/default/utils/__tests__/getSignerPublicKey.spec.js.map +1 -1
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.d.ts +6 -1
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.js +3 -1
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/node/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.js +4 -4
- package/dist/wallet/node/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.js.map +1 -1
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.d.ts.map +1 -1
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.js +4 -3
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.js.map +1 -1
- package/dist/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.js +2 -2
- package/dist/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.js.map +1 -1
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts +5 -1
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js +4 -2
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/node/providers/hosted/turnkey/__tests__/TurnkeyHostedWalletProvider.spec.js +2 -2
- package/dist/wallet/node/providers/hosted/turnkey/__tests__/TurnkeyHostedWalletProvider.spec.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.d.ts +6 -1
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.d.ts.map +1 -1
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.js +4 -3
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/privy/__tests__/PrivyWallet.spec.js +3 -3
- package/dist/wallet/node/wallets/hosted/privy/__tests__/PrivyWallet.spec.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/privy/utils/__tests__/createSigner.spec.js +2 -2
- package/dist/wallet/node/wallets/hosted/privy/utils/__tests__/createSigner.spec.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.d.ts +5 -1
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.d.ts.map +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.js +2 -2
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/__tests__/TurnkeyWallet.spec.js +2 -2
- package/dist/wallet/node/wallets/hosted/turnkey/__tests__/TurnkeyWallet.spec.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/utils/__tests__/createSigner.spec.js +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/utils/__tests__/createSigner.spec.js.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.d.ts +7 -1
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.js +6 -2
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.js.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/__mocks__/DynamicHostedWalletProviderMock.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/__mocks__/DynamicHostedWalletProviderMock.js +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/__mocks__/DynamicHostedWalletProviderMock.js.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/__tests__/DynamicHostedWalletProvider.spec.js +6 -2
- package/dist/wallet/react/providers/hosted/dynamic/__tests__/DynamicHostedWalletProvider.spec.js.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.d.ts +6 -1
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.js +5 -2
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/__mocks__/PrivyHostedWalletProviderMock.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/__mocks__/PrivyHostedWalletProviderMock.js +1 -1
- package/dist/wallet/react/providers/hosted/privy/__mocks__/PrivyHostedWalletProviderMock.js.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.js +3 -2
- package/dist/wallet/react/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.js.map +1 -1
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts +6 -3
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js +5 -4
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/react/providers/hosted/turnkey/__tests__/TurnkeyHostedWalletProvider.spec.js +2 -2
- package/dist/wallet/react/providers/hosted/turnkey/__tests__/TurnkeyHostedWalletProvider.spec.js.map +1 -1
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.d.ts.map +1 -1
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.js +6 -6
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.js.map +1 -1
- package/dist/wallet/react/providers/registry/__tests__/ReactHostedWalletProviderRegistry.spec.js +1 -1
- package/dist/wallet/react/providers/registry/__tests__/ReactHostedWalletProviderRegistry.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.d.ts +7 -1
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.d.ts.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.js +5 -3
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/__tests__/DynamicWallet.spec.js +2 -2
- package/dist/wallet/react/wallets/hosted/dynamic/__tests__/DynamicWallet.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/utils/__tests__/createSigner.spec.js +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/utils/__tests__/createSigner.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/privy/PrivyWallet.d.ts +5 -1
- package/dist/wallet/react/wallets/hosted/privy/PrivyWallet.d.ts.map +1 -1
- package/dist/wallet/react/wallets/hosted/privy/PrivyWallet.js +3 -3
- package/dist/wallet/react/wallets/hosted/privy/PrivyWallet.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/privy/__tests__/PrivyWallet.spec.js +2 -2
- package/dist/wallet/react/wallets/hosted/privy/__tests__/PrivyWallet.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/privy/utils/__tests__/createSigner.spec.js +1 -1
- package/dist/wallet/react/wallets/hosted/privy/utils/__tests__/createSigner.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/turnkey/TurnkeyWallet.d.ts +5 -1
- package/dist/wallet/react/wallets/hosted/turnkey/TurnkeyWallet.d.ts.map +1 -1
- package/dist/wallet/react/wallets/hosted/turnkey/TurnkeyWallet.js +2 -2
- package/dist/wallet/react/wallets/hosted/turnkey/TurnkeyWallet.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/turnkey/__tests__/TurnkeyWallet.spec.js +2 -2
- package/dist/wallet/react/wallets/hosted/turnkey/__tests__/TurnkeyWallet.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/turnkey/utils/__tests__/createSigner.spec.js +1 -1
- package/dist/wallet/react/wallets/hosted/turnkey/utils/__tests__/createSigner.spec.js.map +1 -1
- package/package.json +2 -2
- package/src/{test → __mocks__}/MockAssets.ts +2 -0
- package/src/{test → __mocks__}/MockPrivyClient.ts +1 -1
- package/src/{actions.test.ts → __tests__/actions.test.ts} +2 -6
- package/src/actions.ts +57 -19
- package/src/constants/assets.ts +108 -8
- package/src/constants/contracts.ts +5 -0
- package/src/constants/supportedChains.ts +10 -2
- package/src/core/asset/__mocks__/mockAsset.ts +1 -1
- package/src/index.ts +30 -2
- package/src/{test → lend/__mocks__}/MockLendProvider.ts +20 -23
- package/src/{test → lend/__mocks__}/MockMarkets.ts +1 -1
- package/src/lend/__mocks__/mockLendTransaction.ts +4 -26
- package/src/lend/core/LendProvider.ts +40 -20
- package/src/lend/core/__tests__/LendProvider.test.ts +4 -7
- package/src/lend/namespaces/ActionsLendNamespace.ts +2 -85
- package/src/lend/namespaces/BaseLendNamespace.ts +89 -0
- package/src/lend/namespaces/WalletLendNamespace.ts +25 -121
- package/src/lend/namespaces/__tests__/ActionsLendNamespace.spec.ts +10 -9
- package/src/lend/namespaces/__tests__/BaseLendNamespace.spec.ts +137 -0
- package/src/lend/namespaces/__tests__/WalletLendNamespace.spec.ts +19 -22
- package/src/lend/providers/aave/AaveLendProvider.ts +163 -231
- package/src/lend/providers/aave/__mocks__/mockReserve.ts +84 -0
- package/src/lend/providers/aave/__tests__/AaveLendProvider.test.ts +419 -0
- package/src/lend/providers/aave/abis/pool.ts +81 -0
- package/src/lend/providers/aave/sdk.ts +7 -69
- package/src/lend/providers/morpho/MorphoLendProvider.ts +20 -41
- package/src/lend/providers/morpho/__tests__/MorphoLendProvider.test.ts +8 -32
- package/src/lend/providers/morpho/__tests__/api.test.ts +277 -51
- package/src/lend/providers/morpho/__tests__/sdk.test.ts +3 -2
- package/src/lend/providers/morpho/api.ts +4 -0
- package/src/lend/providers/morpho/contracts.ts +37 -0
- package/src/lend/providers/morpho/sdk.ts +241 -84
- package/src/services/tokenBalance.spec.ts +2 -2
- package/src/services/tokenBalance.ts +6 -7
- package/src/supported/tokens.ts +18 -77
- package/src/swap/__mocks__/MockSwapProvider.ts +216 -0
- package/src/swap/core/SwapProvider.ts +319 -0
- package/src/swap/core/__tests__/SwapProvider.test.ts +478 -0
- package/src/swap/index.ts +14 -0
- package/src/swap/namespaces/ActionsSwapNamespace.ts +7 -0
- package/src/swap/namespaces/BaseSwapNamespace.ts +77 -0
- package/src/swap/namespaces/WalletSwapNamespace.ts +82 -0
- package/src/swap/namespaces/__tests__/BaseSwapNamespace.spec.ts +138 -0
- package/src/swap/namespaces/__tests__/WalletSwapNamespace.spec.ts +162 -0
- package/src/swap/providers/uniswap/UniswapSwapProvider.ts +304 -0
- package/src/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.ts +299 -0
- package/src/swap/providers/uniswap/__tests__/sdk.test.ts +370 -0
- package/src/swap/providers/uniswap/abis.ts +144 -0
- package/src/swap/providers/uniswap/addresses.ts +108 -0
- package/src/swap/providers/uniswap/encoding.ts +406 -0
- package/src/swap/providers/uniswap/types.ts +24 -0
- package/src/types/actions.ts +22 -6
- package/src/types/asset.ts +3 -3
- package/src/types/index.ts +2 -0
- package/src/types/lend/base.ts +12 -25
- package/src/types/lend/contracts.ts +18 -0
- package/src/types/lend/index.ts +1 -0
- package/src/types/swap/base.ts +259 -0
- package/src/types/swap/index.ts +1 -0
- package/src/types/transaction.ts +14 -0
- package/src/utils/assets.test.ts +17 -2
- package/src/utils/assets.ts +28 -11
- package/src/utils/constants.ts +4 -0
- package/src/utils/permit2.test.ts +142 -0
- package/src/utils/permit2.ts +144 -0
- package/src/utils/validation.ts +76 -0
- package/src/wallet/core/namespace/WalletNamespace.ts +2 -4
- package/src/wallet/core/namespace/__tests__/WalletNamespace.spec.ts +6 -6
- package/src/wallet/core/providers/__tests__/WalletProvider.spec.ts +6 -6
- package/src/wallet/core/providers/hosted/abstract/HostedWalletProvider.ts +9 -1
- package/src/wallet/core/providers/hosted/registry/__tests__/HostedWalletProviderRegistry.spec.ts +3 -3
- package/src/wallet/core/providers/hosted/types/index.ts +5 -1
- package/src/wallet/core/providers/smart/default/DefaultSmartWalletProvider.ts +13 -1
- package/src/wallet/core/providers/smart/default/__tests__/DefaultSmartWalletProvider.spec.ts +9 -9
- package/src/wallet/core/wallets/abstract/Wallet.ts +18 -2
- package/src/wallet/core/wallets/abstract/__tests__/Wallet.spec.ts +2 -2
- package/src/wallet/core/wallets/eoa/__tests__/EOAWallet.spec.ts +2 -2
- package/src/wallet/core/wallets/smart/default/DefaultSmartWallet.ts +14 -5
- package/src/wallet/core/wallets/smart/default/__tests__/DefaultSmartWallet.spec.ts +3 -3
- package/src/wallet/core/wallets/smart/default/utils/__tests__/findSignerInArray.spec.ts +1 -1
- package/src/wallet/core/wallets/smart/default/utils/__tests__/getSignerPublicKey.spec.ts +1 -1
- package/src/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.ts +13 -2
- package/src/wallet/node/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.ts +5 -5
- package/src/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.ts +10 -2
- package/src/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.ts +3 -3
- package/src/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.ts +8 -2
- package/src/wallet/node/providers/hosted/turnkey/__tests__/TurnkeyHostedWalletProvider.spec.ts +2 -2
- package/src/wallet/node/wallets/hosted/privy/PrivyWallet.ts +11 -2
- package/src/wallet/node/wallets/hosted/privy/__tests__/PrivyWallet.spec.ts +4 -4
- package/src/wallet/node/wallets/hosted/privy/utils/__tests__/createSigner.spec.ts +2 -2
- package/src/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.ts +10 -2
- package/src/wallet/node/wallets/hosted/turnkey/__tests__/TurnkeyWallet.spec.ts +2 -2
- package/src/wallet/node/wallets/hosted/turnkey/utils/__tests__/createSigner.spec.ts +1 -1
- package/src/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.ts +10 -2
- package/src/wallet/react/providers/hosted/dynamic/__mocks__/DynamicHostedWalletProviderMock.ts +1 -1
- package/src/wallet/react/providers/hosted/dynamic/__tests__/DynamicHostedWalletProvider.spec.ts +9 -5
- package/src/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.ts +9 -2
- package/src/wallet/react/providers/hosted/privy/__mocks__/PrivyHostedWalletProviderMock.ts +1 -1
- package/src/wallet/react/providers/hosted/privy/__tests__/PrivyHostedWalletProvider.spec.ts +5 -5
- package/src/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.ts +9 -4
- package/src/wallet/react/providers/hosted/turnkey/__tests__/TurnkeyHostedWalletProvider.spec.ts +2 -2
- package/src/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.ts +18 -6
- package/src/wallet/react/providers/registry/__tests__/ReactHostedWalletProviderRegistry.spec.ts +5 -7
- package/src/wallet/react/wallets/hosted/dynamic/DynamicWallet.ts +12 -2
- package/src/wallet/react/wallets/hosted/dynamic/__tests__/DynamicWallet.spec.ts +2 -2
- package/src/wallet/react/wallets/hosted/dynamic/utils/__tests__/createSigner.spec.ts +1 -1
- package/src/wallet/react/wallets/hosted/privy/PrivyWallet.ts +10 -2
- package/src/wallet/react/wallets/hosted/privy/__tests__/PrivyWallet.spec.ts +2 -2
- package/src/wallet/react/wallets/hosted/privy/utils/__tests__/createSigner.spec.ts +1 -1
- package/src/wallet/react/wallets/hosted/turnkey/TurnkeyWallet.ts +10 -2
- package/src/wallet/react/wallets/hosted/turnkey/__tests__/TurnkeyWallet.spec.ts +2 -2
- package/src/wallet/react/wallets/hosted/turnkey/utils/__tests__/createSigner.spec.ts +1 -1
- package/dist/actions.test.d.ts.map +0 -1
- package/dist/actions.test.js.map +0 -1
- package/dist/test/MockAssets.d.ts.map +0 -1
- package/dist/test/MockAssets.js.map +0 -1
- package/dist/test/MockChainManager.d.ts.map +0 -1
- package/dist/test/MockChainManager.js.map +0 -1
- package/dist/test/MockLendProvider.d.ts.map +0 -1
- package/dist/test/MockLendProvider.js.map +0 -1
- package/dist/test/MockMarkets.d.ts.map +0 -1
- package/dist/test/MockMarkets.js.map +0 -1
- package/dist/test/MockPrivyClient.d.ts.map +0 -1
- package/dist/test/MockPrivyClient.js.map +0 -1
- package/dist/test/utils.d.ts.map +0 -1
- package/dist/test/utils.js.map +0 -1
- /package/dist/{test → __mocks__}/MockAssets.d.ts +0 -0
- /package/dist/{test → __mocks__}/MockPrivyClient.d.ts +0 -0
- /package/dist/{test → __mocks__}/MockPrivyClient.js +0 -0
- /package/dist/{test → __mocks__}/utils.d.ts +0 -0
- /package/dist/{test → __mocks__}/utils.js +0 -0
- /package/dist/{actions.test.d.ts → __tests__/actions.test.d.ts} +0 -0
- /package/dist/{test → services/__mocks__}/MockChainManager.js +0 -0
- /package/src/{test → __mocks__}/utils.ts +0 -0
- /package/src/{test → services/__mocks__}/MockChainManager.ts +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address } from 'viem'
|
|
2
|
-
import { encodeFunctionData, erc20Abi, formatUnits
|
|
2
|
+
import { encodeFunctionData, erc20Abi, formatUnits } from 'viem'
|
|
3
3
|
|
|
4
|
+
import { WETH } from '@/constants/assets.js'
|
|
4
5
|
import { LendProvider } from '@/lend/core/LendProvider.js'
|
|
5
6
|
import type { ChainManager } from '@/services/ChainManager.js'
|
|
6
7
|
import type { LendProviderConfig } from '@/types/actions.js'
|
|
@@ -14,36 +15,15 @@ import type {
|
|
|
14
15
|
LendOpenPositionInternalParams,
|
|
15
16
|
LendTransaction,
|
|
16
17
|
} from '@/types/lend/index.js'
|
|
17
|
-
import { getAssetAddress } from '@/utils/assets.js'
|
|
18
|
+
import { getAssetAddress, isNativeAsset } from '@/utils/assets.js'
|
|
18
19
|
|
|
20
|
+
import { POOL_ABI, WETH_GATEWAY_ABI } from './abis/pool.js'
|
|
19
21
|
import {
|
|
20
22
|
getPoolAddress,
|
|
21
23
|
getSupportedChainIds,
|
|
22
24
|
getWETHGatewayAddress,
|
|
23
25
|
} from './addresses.js'
|
|
24
|
-
import { getReserve, getReserves } from './sdk.js'
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* WETH predeploy address on OP Stack chains
|
|
28
|
-
* @description WETH is deployed at the same address on all OP Stack chains (Optimism, Base, etc.)
|
|
29
|
-
*/
|
|
30
|
-
const WETH_ADDRESS = '0x4200000000000000000000000000000000000006'
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Aave Pool ABI - only the functions we need
|
|
34
|
-
*/
|
|
35
|
-
const POOL_ABI = parseAbi([
|
|
36
|
-
'function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)',
|
|
37
|
-
'function withdraw(address asset, uint256 amount, address to) returns (uint256)',
|
|
38
|
-
])
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Aave WETHGateway ABI - for native ETH deposits/withdrawals
|
|
42
|
-
*/
|
|
43
|
-
const WETH_GATEWAY_ABI = parseAbi([
|
|
44
|
-
'function depositETH(address pool, address onBehalfOf, uint16 referralCode) payable',
|
|
45
|
-
'function withdrawETH(address pool, uint256 amount, address to)',
|
|
46
|
-
])
|
|
26
|
+
import { getATokenAddress, getReserve, getReserves } from './sdk.js'
|
|
47
27
|
|
|
48
28
|
/**
|
|
49
29
|
* Supported chain IDs for Aave lending
|
|
@@ -58,26 +38,13 @@ export const SUPPORTED_CHAIN_IDS = getSupportedChainIds() as readonly number[]
|
|
|
58
38
|
export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
59
39
|
protected readonly SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS
|
|
60
40
|
|
|
61
|
-
private chainManager: ChainManager
|
|
62
|
-
|
|
63
41
|
/**
|
|
64
42
|
* Create a new Aave lending provider
|
|
65
43
|
* @param config - Aave lending configuration
|
|
66
44
|
* @param chainManager - Chain manager for blockchain interactions
|
|
67
45
|
*/
|
|
68
46
|
constructor(config: LendProviderConfig, chainManager: ChainManager) {
|
|
69
|
-
super(config)
|
|
70
|
-
this.chainManager = chainManager
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Check if market is a WETH market
|
|
75
|
-
* @param marketId - Market identifier
|
|
76
|
-
* @returns true if market is for WETH
|
|
77
|
-
* @description WETH is a predeploy at the same address on all OP Stack chains
|
|
78
|
-
*/
|
|
79
|
-
private isWETHMarket(marketId: LendMarketId): boolean {
|
|
80
|
-
return marketId.address.toLowerCase() === WETH_ADDRESS.toLowerCase()
|
|
47
|
+
super(config, chainManager)
|
|
81
48
|
}
|
|
82
49
|
|
|
83
50
|
/**
|
|
@@ -104,27 +71,149 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
104
71
|
chainId: params.marketId.chainId,
|
|
105
72
|
})
|
|
106
73
|
|
|
107
|
-
// Check if this is a
|
|
108
|
-
if (
|
|
109
|
-
return this.
|
|
74
|
+
// Check if this is a native ETH market
|
|
75
|
+
if (isNativeAsset(params.asset)) {
|
|
76
|
+
return this._openETHPosition(params, poolAddress, marketInfo)
|
|
110
77
|
}
|
|
111
78
|
|
|
112
79
|
// Standard ERC-20 flow
|
|
113
80
|
return this._openERC20Position(params, poolAddress, marketInfo)
|
|
114
|
-
} catch
|
|
81
|
+
} catch {
|
|
115
82
|
throw new Error(
|
|
116
|
-
`Failed to open position with ${params.amountWei} of ${params.asset.metadata.symbol}
|
|
117
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
118
|
-
}`,
|
|
83
|
+
`Failed to open position with ${params.amountWei} of ${params.asset.metadata.symbol}`,
|
|
119
84
|
)
|
|
120
85
|
}
|
|
121
86
|
}
|
|
122
87
|
|
|
123
88
|
/**
|
|
124
|
-
*
|
|
89
|
+
* Close a position in an Aave market
|
|
90
|
+
* @description Withdraws assets from an Aave reserve
|
|
91
|
+
* @param params - Position closing operation parameters
|
|
92
|
+
* @returns Promise resolving to withdrawal transaction details
|
|
93
|
+
*/
|
|
94
|
+
protected async _closePosition(
|
|
95
|
+
params: LendClosePositionParams,
|
|
96
|
+
): Promise<LendTransaction> {
|
|
97
|
+
try {
|
|
98
|
+
// Get Pool address for this chain
|
|
99
|
+
const poolAddress = getPoolAddress(params.marketId.chainId)
|
|
100
|
+
if (!poolAddress) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Aave V3 not deployed on chain ${params.marketId.chainId}`,
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const marketInfo = await this.getMarket({
|
|
107
|
+
address: params.marketId.address,
|
|
108
|
+
chainId: params.marketId.chainId,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
// Check if this is a native ETH market
|
|
112
|
+
if (isNativeAsset(marketInfo.asset)) {
|
|
113
|
+
return this._closeETHPosition(params, poolAddress, marketInfo)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Standard ERC-20 flow
|
|
117
|
+
return this._closeERC20Position(params, poolAddress, marketInfo)
|
|
118
|
+
} catch {
|
|
119
|
+
throw new Error('Failed to close position')
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get detailed market information
|
|
125
|
+
* @param marketId - Market identifier containing address and chainId
|
|
126
|
+
* @returns Promise resolving to market information
|
|
127
|
+
*/
|
|
128
|
+
protected async _getMarket(marketId: LendMarketId): Promise<LendMarket> {
|
|
129
|
+
return getReserve({
|
|
130
|
+
marketId,
|
|
131
|
+
chainManager: this.chainManager,
|
|
132
|
+
lendConfig: this._config,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get list of available lending markets
|
|
138
|
+
* @param params - Filtering parameters
|
|
139
|
+
* @returns Promise resolving to array of market information
|
|
140
|
+
*/
|
|
141
|
+
protected async _getMarkets(
|
|
142
|
+
params: GetLendMarketsParams,
|
|
143
|
+
): Promise<LendMarket[]> {
|
|
144
|
+
const marketConfigs = params.markets || []
|
|
145
|
+
|
|
146
|
+
return getReserves({
|
|
147
|
+
chainManager: this.chainManager,
|
|
148
|
+
lendConfig: this._config,
|
|
149
|
+
markets: marketConfigs,
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get position for a specific wallet address
|
|
155
|
+
* @param params - Parameters for fetching position
|
|
156
|
+
* @returns Promise resolving to position information
|
|
157
|
+
*/
|
|
158
|
+
protected async _getPosition(
|
|
159
|
+
params: GetMarketBalanceParams,
|
|
160
|
+
): Promise<LendMarketPosition> {
|
|
161
|
+
try {
|
|
162
|
+
const publicClient = this.chainManager.getPublicClient(
|
|
163
|
+
params.marketId.chainId,
|
|
164
|
+
)
|
|
165
|
+
const market = await this._getMarket(params.marketId)
|
|
166
|
+
const poolAddress = getPoolAddress(params.marketId.chainId)
|
|
167
|
+
|
|
168
|
+
if (!poolAddress) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Aave V3 not deployed on chain ${params.marketId.chainId}`,
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Get the aToken address from Pool.getReserveData
|
|
175
|
+
// For native assets, use WETH address since Aave uses WETH internally
|
|
176
|
+
const assetAddress = isNativeAsset(market.asset)
|
|
177
|
+
? getAssetAddress(WETH, params.marketId.chainId)
|
|
178
|
+
: getAssetAddress(market.asset, params.marketId.chainId)
|
|
179
|
+
|
|
180
|
+
const aTokenAddress = await getATokenAddress({
|
|
181
|
+
underlyingAsset: assetAddress,
|
|
182
|
+
chainId: params.marketId.chainId,
|
|
183
|
+
chainManager: this.chainManager,
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
const balance = await publicClient.readContract({
|
|
187
|
+
address: aTokenAddress,
|
|
188
|
+
abi: erc20Abi,
|
|
189
|
+
functionName: 'balanceOf',
|
|
190
|
+
args: [params.walletAddress],
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
const balanceFormatted = formatUnits(
|
|
194
|
+
balance,
|
|
195
|
+
market.asset.metadata.decimals,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
balance,
|
|
200
|
+
balanceFormatted,
|
|
201
|
+
shares: balance, // In Aave, aTokens are 1:1 with underlying
|
|
202
|
+
sharesFormatted: balanceFormatted,
|
|
203
|
+
marketId: params.marketId,
|
|
204
|
+
}
|
|
205
|
+
} catch {
|
|
206
|
+
throw new Error(
|
|
207
|
+
`Failed to get market balance for ${params.walletAddress} in market ${params.marketId.address}`,
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Open position for native ETH using WETHGateway
|
|
125
214
|
* @description Deposits native ETH via WETHGateway which wraps and deposits in one tx
|
|
126
215
|
*/
|
|
127
|
-
private async
|
|
216
|
+
private async _openETHPosition(
|
|
128
217
|
params: LendOpenPositionInternalParams,
|
|
129
218
|
poolAddress: Address,
|
|
130
219
|
marketInfo: LendMarket,
|
|
@@ -147,19 +236,20 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
147
236
|
],
|
|
148
237
|
})
|
|
149
238
|
|
|
239
|
+
const wethAddress = getAssetAddress(WETH, params.marketId.chainId)
|
|
240
|
+
|
|
150
241
|
return {
|
|
151
242
|
amount: params.amountWei,
|
|
152
|
-
asset:
|
|
243
|
+
asset: wethAddress,
|
|
153
244
|
marketId: params.marketId.address,
|
|
154
245
|
apy: marketInfo.apy.total,
|
|
155
246
|
transactionData: {
|
|
156
|
-
|
|
247
|
+
position: {
|
|
157
248
|
to: gatewayAddress,
|
|
158
249
|
data: depositCallData,
|
|
159
250
|
value: params.amountWei, // Send ETH as msg.value
|
|
160
251
|
},
|
|
161
252
|
},
|
|
162
|
-
slippage: params.options?.slippage ?? 50,
|
|
163
253
|
}
|
|
164
254
|
}
|
|
165
255
|
|
|
@@ -172,18 +262,8 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
172
262
|
poolAddress: Address,
|
|
173
263
|
marketInfo: LendMarket,
|
|
174
264
|
): Promise<LendTransaction> {
|
|
175
|
-
// Get asset address for the chain
|
|
176
|
-
const assetAddress = params.asset
|
|
177
|
-
if (!assetAddress) {
|
|
178
|
-
throw new Error(`Asset not supported on chain ${params.marketId.chainId}`)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Generate approval transaction
|
|
182
|
-
const approvalCallData = encodeFunctionData({
|
|
183
|
-
abi: erc20Abi,
|
|
184
|
-
functionName: 'approve',
|
|
185
|
-
args: [poolAddress, params.amountWei],
|
|
186
|
-
})
|
|
265
|
+
// Get asset address for the chain (throws for native assets)
|
|
266
|
+
const assetAddress = getAssetAddress(params.asset, params.marketId.chainId)
|
|
187
267
|
|
|
188
268
|
// Generate supply transaction
|
|
189
269
|
const supplyCallData = encodeFunctionData({
|
|
@@ -203,65 +283,25 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
203
283
|
marketId: params.marketId.address,
|
|
204
284
|
apy: marketInfo.apy.total,
|
|
205
285
|
transactionData: {
|
|
206
|
-
approval:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
286
|
+
approval: this.buildApprovalTx(
|
|
287
|
+
assetAddress,
|
|
288
|
+
poolAddress,
|
|
289
|
+
params.amountWei,
|
|
290
|
+
),
|
|
291
|
+
position: {
|
|
212
292
|
to: poolAddress,
|
|
213
293
|
data: supplyCallData,
|
|
214
294
|
value: 0n,
|
|
215
295
|
},
|
|
216
296
|
},
|
|
217
|
-
slippage: params.options?.slippage ?? 50,
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Close a position in an Aave market
|
|
223
|
-
* @description Withdraws assets from an Aave reserve
|
|
224
|
-
* @param params - Position closing operation parameters
|
|
225
|
-
* @returns Promise resolving to withdrawal transaction details
|
|
226
|
-
*/
|
|
227
|
-
protected async _closePosition(
|
|
228
|
-
params: LendClosePositionParams,
|
|
229
|
-
): Promise<LendTransaction> {
|
|
230
|
-
try {
|
|
231
|
-
// Get Pool address for this chain
|
|
232
|
-
const poolAddress = getPoolAddress(params.marketId.chainId)
|
|
233
|
-
if (!poolAddress) {
|
|
234
|
-
throw new Error(
|
|
235
|
-
`Aave V3 not deployed on chain ${params.marketId.chainId}`,
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const marketInfo = await this.getMarket({
|
|
240
|
-
address: params.marketId.address,
|
|
241
|
-
chainId: params.marketId.chainId,
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
// Check if this is a WETH market
|
|
245
|
-
if (this.isWETHMarket(params.marketId)) {
|
|
246
|
-
return this._closeWETHPosition(params, poolAddress, marketInfo)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Standard ERC-20 flow
|
|
250
|
-
return this._closeERC20Position(params, poolAddress, marketInfo)
|
|
251
|
-
} catch (error) {
|
|
252
|
-
throw new Error(
|
|
253
|
-
`Failed to close position: ${
|
|
254
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
255
|
-
}`,
|
|
256
|
-
)
|
|
257
297
|
}
|
|
258
298
|
}
|
|
259
299
|
|
|
260
300
|
/**
|
|
261
|
-
* Close position for
|
|
301
|
+
* Close position for native ETH using WETHGateway
|
|
262
302
|
* @description Withdraws aWETH, unwraps to ETH, and sends to user
|
|
263
303
|
*/
|
|
264
|
-
private async
|
|
304
|
+
private async _closeETHPosition(
|
|
265
305
|
params: LendClosePositionParams,
|
|
266
306
|
poolAddress: Address,
|
|
267
307
|
marketInfo: LendMarket,
|
|
@@ -273,23 +313,16 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
273
313
|
)
|
|
274
314
|
}
|
|
275
315
|
|
|
316
|
+
const wethAddress = getAssetAddress(WETH, params.marketId.chainId)
|
|
317
|
+
|
|
276
318
|
// Get the aToken address for the underlying WETH asset
|
|
277
|
-
// Note: params.marketId.address is the underlying WETH address, not the aToken
|
|
278
|
-
const { getATokenAddress } = await import('./sdk.js')
|
|
279
319
|
const aWETHAddress = await getATokenAddress({
|
|
280
|
-
underlyingAsset:
|
|
320
|
+
underlyingAsset: wethAddress,
|
|
281
321
|
chainId: params.marketId.chainId,
|
|
282
322
|
chainManager: this.chainManager,
|
|
283
323
|
})
|
|
284
324
|
|
|
285
|
-
//
|
|
286
|
-
const approvalCallData = encodeFunctionData({
|
|
287
|
-
abi: erc20Abi,
|
|
288
|
-
functionName: 'approve',
|
|
289
|
-
args: [gatewayAddress, params.amount],
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
// Second: Call withdrawETH on gateway
|
|
325
|
+
// Call withdrawETH on gateway
|
|
293
326
|
const withdrawCallData = encodeFunctionData({
|
|
294
327
|
abi: WETH_GATEWAY_ABI,
|
|
295
328
|
functionName: 'withdrawETH',
|
|
@@ -302,22 +335,21 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
302
335
|
|
|
303
336
|
return {
|
|
304
337
|
amount: params.amount,
|
|
305
|
-
asset:
|
|
338
|
+
asset: wethAddress,
|
|
306
339
|
marketId: params.marketId.address,
|
|
307
340
|
apy: marketInfo.apy.total,
|
|
308
341
|
transactionData: {
|
|
309
|
-
approval:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
342
|
+
approval: this.buildApprovalTx(
|
|
343
|
+
aWETHAddress,
|
|
344
|
+
gatewayAddress,
|
|
345
|
+
params.amount,
|
|
346
|
+
),
|
|
347
|
+
position: {
|
|
315
348
|
to: gatewayAddress,
|
|
316
349
|
data: withdrawCallData,
|
|
317
350
|
value: 0n,
|
|
318
351
|
},
|
|
319
352
|
},
|
|
320
|
-
slippage: params.options?.slippage ?? 50,
|
|
321
353
|
}
|
|
322
354
|
}
|
|
323
355
|
|
|
@@ -352,112 +384,12 @@ export class AaveLendProvider extends LendProvider<LendProviderConfig> {
|
|
|
352
384
|
marketId: params.marketId.address,
|
|
353
385
|
apy: marketInfo.apy.total,
|
|
354
386
|
transactionData: {
|
|
355
|
-
|
|
387
|
+
position: {
|
|
356
388
|
to: poolAddress,
|
|
357
389
|
data: withdrawCallData,
|
|
358
390
|
value: 0n,
|
|
359
391
|
},
|
|
360
392
|
},
|
|
361
|
-
slippage: params.options?.slippage ?? 50,
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Get detailed market information
|
|
367
|
-
* @param marketId - Market identifier containing address and chainId
|
|
368
|
-
* @returns Promise resolving to market information
|
|
369
|
-
*/
|
|
370
|
-
protected async _getMarket(marketId: LendMarketId): Promise<LendMarket> {
|
|
371
|
-
return getReserve({
|
|
372
|
-
marketId,
|
|
373
|
-
chainManager: this.chainManager,
|
|
374
|
-
lendConfig: this._config,
|
|
375
|
-
})
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Get list of available lending markets
|
|
380
|
-
* @param params - Filtering parameters
|
|
381
|
-
* @returns Promise resolving to array of market information
|
|
382
|
-
*/
|
|
383
|
-
protected async _getMarkets(
|
|
384
|
-
params: GetLendMarketsParams,
|
|
385
|
-
): Promise<LendMarket[]> {
|
|
386
|
-
const marketConfigs = params.markets || []
|
|
387
|
-
|
|
388
|
-
return getReserves({
|
|
389
|
-
chainManager: this.chainManager,
|
|
390
|
-
lendConfig: this._config,
|
|
391
|
-
markets: marketConfigs,
|
|
392
|
-
})
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Get position for a specific wallet address
|
|
397
|
-
* @param params - Parameters for fetching position
|
|
398
|
-
* @returns Promise resolving to position information
|
|
399
|
-
*/
|
|
400
|
-
protected async _getPosition(
|
|
401
|
-
params: GetMarketBalanceParams,
|
|
402
|
-
): Promise<LendMarketPosition> {
|
|
403
|
-
try {
|
|
404
|
-
const publicClient = this.chainManager.getPublicClient(
|
|
405
|
-
params.marketId.chainId,
|
|
406
|
-
)
|
|
407
|
-
const market = await this._getMarket(params.marketId)
|
|
408
|
-
const poolAddress = getPoolAddress(params.marketId.chainId)
|
|
409
|
-
|
|
410
|
-
if (!poolAddress) {
|
|
411
|
-
throw new Error(
|
|
412
|
-
`Aave V3 not deployed on chain ${params.marketId.chainId}`,
|
|
413
|
-
)
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// Get the aToken address from Pool.getReserveData
|
|
417
|
-
const assetAddress = getAssetAddress(
|
|
418
|
-
market.asset,
|
|
419
|
-
params.marketId.chainId,
|
|
420
|
-
)
|
|
421
|
-
|
|
422
|
-
const reserveData = (await publicClient.readContract({
|
|
423
|
-
address: poolAddress,
|
|
424
|
-
abi: parseAbi([
|
|
425
|
-
'struct ReserveData { uint256 configuration; uint128 liquidityIndex; uint128 currentLiquidityRate; uint128 variableBorrowIndex; uint128 currentVariableBorrowRate; uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; uint16 id; address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; address interestRateStrategyAddress; uint128 accruedToTreasury; uint128 unbacked; uint128 isolationModeTotalDebt; }',
|
|
426
|
-
'function getReserveData(address asset) view returns (ReserveData)',
|
|
427
|
-
]),
|
|
428
|
-
functionName: 'getReserveData',
|
|
429
|
-
args: [assetAddress],
|
|
430
|
-
})) as {
|
|
431
|
-
aTokenAddress: Address
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const aTokenAddress = reserveData.aTokenAddress
|
|
435
|
-
|
|
436
|
-
const balance = await publicClient.readContract({
|
|
437
|
-
address: aTokenAddress,
|
|
438
|
-
abi: erc20Abi,
|
|
439
|
-
functionName: 'balanceOf',
|
|
440
|
-
args: [params.walletAddress],
|
|
441
|
-
})
|
|
442
|
-
|
|
443
|
-
const balanceFormatted = formatUnits(
|
|
444
|
-
balance,
|
|
445
|
-
market.asset.metadata.decimals,
|
|
446
|
-
)
|
|
447
|
-
|
|
448
|
-
return {
|
|
449
|
-
balance,
|
|
450
|
-
balanceFormatted,
|
|
451
|
-
shares: balance, // In Aave, aTokens are 1:1 with underlying
|
|
452
|
-
sharesFormatted: balanceFormatted,
|
|
453
|
-
marketId: params.marketId,
|
|
454
|
-
}
|
|
455
|
-
} catch (error) {
|
|
456
|
-
throw new Error(
|
|
457
|
-
`Failed to get market balance for ${params.walletAddress} in market ${params.marketId.address}: ${
|
|
458
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
459
|
-
}`,
|
|
460
|
-
)
|
|
461
393
|
}
|
|
462
394
|
}
|
|
463
395
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Address } from 'viem'
|
|
2
|
+
|
|
3
|
+
import type { LendMarket } from '@/types/lend/index.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates mock Aave reserve data for testing
|
|
7
|
+
*/
|
|
8
|
+
export function createMockAaveReserve(): LendMarket {
|
|
9
|
+
return {
|
|
10
|
+
marketId: {
|
|
11
|
+
address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' as Address, // USDC on Base
|
|
12
|
+
chainId: 8453,
|
|
13
|
+
},
|
|
14
|
+
name: 'Aave USDC Base',
|
|
15
|
+
asset: {
|
|
16
|
+
metadata: {
|
|
17
|
+
name: 'USD Coin',
|
|
18
|
+
symbol: 'USDC',
|
|
19
|
+
decimals: 6,
|
|
20
|
+
},
|
|
21
|
+
address: {
|
|
22
|
+
8453: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' as Address,
|
|
23
|
+
},
|
|
24
|
+
type: 'erc20',
|
|
25
|
+
},
|
|
26
|
+
supply: {
|
|
27
|
+
totalAssets: BigInt(10000000e6),
|
|
28
|
+
totalShares: BigInt(10000000e6),
|
|
29
|
+
},
|
|
30
|
+
apy: {
|
|
31
|
+
total: 0.0325, // 3.25%
|
|
32
|
+
native: 0.0325,
|
|
33
|
+
totalRewards: 0,
|
|
34
|
+
performanceFee: 0,
|
|
35
|
+
},
|
|
36
|
+
metadata: {
|
|
37
|
+
owner: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5' as Address,
|
|
38
|
+
curator: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5' as Address,
|
|
39
|
+
fee: 0,
|
|
40
|
+
lastUpdate: Math.floor(Date.now() / 1000),
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates mock ETH reserve data for testing (native asset)
|
|
47
|
+
* @description Uses type: 'native' to test native ETH handling via WETHGateway
|
|
48
|
+
*/
|
|
49
|
+
export function createMockWETHReserve(): LendMarket {
|
|
50
|
+
return {
|
|
51
|
+
marketId: {
|
|
52
|
+
address: '0x4200000000000000000000000000000000000006' as Address, // WETH on OP Stack
|
|
53
|
+
chainId: 8453,
|
|
54
|
+
},
|
|
55
|
+
name: 'Aave ETH Base',
|
|
56
|
+
asset: {
|
|
57
|
+
metadata: {
|
|
58
|
+
name: 'Ethereum',
|
|
59
|
+
symbol: 'ETH',
|
|
60
|
+
decimals: 18,
|
|
61
|
+
},
|
|
62
|
+
address: {
|
|
63
|
+
8453: 'native',
|
|
64
|
+
},
|
|
65
|
+
type: 'native',
|
|
66
|
+
},
|
|
67
|
+
supply: {
|
|
68
|
+
totalAssets: BigInt(5000e18),
|
|
69
|
+
totalShares: BigInt(5000e18),
|
|
70
|
+
},
|
|
71
|
+
apy: {
|
|
72
|
+
total: 0.018, // 1.8%
|
|
73
|
+
native: 0.018,
|
|
74
|
+
totalRewards: 0,
|
|
75
|
+
performanceFee: 0,
|
|
76
|
+
},
|
|
77
|
+
metadata: {
|
|
78
|
+
owner: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5' as Address,
|
|
79
|
+
curator: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5' as Address,
|
|
80
|
+
fee: 0,
|
|
81
|
+
lastUpdate: Math.floor(Date.now() / 1000),
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
}
|