@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
package/src/types/actions.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
|
+
import type { UniswapSwapProviderConfig } from '@/swap/providers/uniswap/types.js'
|
|
1
2
|
import type { Asset } from '@/types/asset.js'
|
|
2
3
|
import type { ChainConfig } from '@/types/chain.js'
|
|
3
4
|
import type { LendProviderConfig } from '@/types/lend/index.js'
|
|
5
|
+
import type { SwapProviderConfig } from '@/types/swap/index.js'
|
|
4
6
|
import type { ProviderSpec } from '@/wallet/core/providers/hosted/types/index.js'
|
|
5
7
|
|
|
6
|
-
// Re-export
|
|
7
|
-
export type { LendProviderConfig }
|
|
8
|
+
// Re-export provider configs for convenience
|
|
9
|
+
export type { LendProviderConfig, SwapProviderConfig }
|
|
10
|
+
|
|
11
|
+
/** Require at least one property to be defined */
|
|
12
|
+
type RequireAtLeastOne<T> = {
|
|
13
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
|
|
14
|
+
}[keyof T]
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
|
-
* Lending configuration
|
|
11
|
-
* @description Configuration for all lending providers
|
|
17
|
+
* Lending configuration — at least one provider must be configured
|
|
12
18
|
*/
|
|
13
|
-
export
|
|
19
|
+
export type LendConfig = RequireAtLeastOne<{
|
|
14
20
|
/** Morpho lending provider configuration */
|
|
15
21
|
morpho?: LendProviderConfig
|
|
16
22
|
/** Aave lending provider configuration */
|
|
17
23
|
aave?: LendProviderConfig
|
|
18
|
-
}
|
|
24
|
+
}>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Swap configuration — at least one provider must be configured
|
|
28
|
+
*/
|
|
29
|
+
export type SwapConfig = RequireAtLeastOne<{
|
|
30
|
+
/** Uniswap swap provider configuration */
|
|
31
|
+
uniswap?: UniswapSwapProviderConfig
|
|
32
|
+
}>
|
|
19
33
|
|
|
20
34
|
/**
|
|
21
35
|
* Network configuration for lending providers
|
|
@@ -49,6 +63,8 @@ export interface ActionsConfig<
|
|
|
49
63
|
wallet: WalletConfig<THostedWalletProviderType, TConfigMap>
|
|
50
64
|
/** Lending providers configuration (optional) */
|
|
51
65
|
lend?: LendConfig
|
|
66
|
+
/** Swap providers configuration (optional) */
|
|
67
|
+
swap?: SwapConfig
|
|
52
68
|
/** Assets configuration (optional) */
|
|
53
69
|
assets?: AssetsConfig
|
|
54
70
|
/** Chains to use for the SDK */
|
package/src/types/asset.ts
CHANGED
|
@@ -6,8 +6,8 @@ import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
|
6
6
|
* Asset type inspired by EIP 7811 but adapted for multi-chain asset definitions
|
|
7
7
|
*/
|
|
8
8
|
export interface Asset {
|
|
9
|
-
/** Multi-chain address mapping */
|
|
10
|
-
address: Partial<Record<SupportedChainId, Address>>
|
|
9
|
+
/** Multi-chain address mapping. Native assets use 'native' string to prevent accidental contract calls. */
|
|
10
|
+
address: Partial<Record<SupportedChainId, Address | 'native'>>
|
|
11
11
|
/** Asset metadata */
|
|
12
12
|
metadata: {
|
|
13
13
|
decimals: number
|
|
@@ -28,7 +28,7 @@ export interface TokenBalance {
|
|
|
28
28
|
chainBalances: Array<{
|
|
29
29
|
chainId: SupportedChainId
|
|
30
30
|
balance: bigint
|
|
31
|
-
tokenAddress: Address
|
|
31
|
+
tokenAddress: Address | 'native'
|
|
32
32
|
formattedBalance: string
|
|
33
33
|
}>
|
|
34
34
|
}
|
package/src/types/index.ts
CHANGED
package/src/types/lend/base.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { Address
|
|
1
|
+
import type { Address } from 'viem'
|
|
2
2
|
|
|
3
3
|
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
4
4
|
import type { Asset } from '@/types/asset.js'
|
|
5
|
+
// Import and re-export shared transaction type for backwards compatibility
|
|
6
|
+
import type { TransactionData } from '@/types/transaction.js'
|
|
5
7
|
import type {
|
|
6
8
|
BatchTransactionReturnType,
|
|
7
9
|
TransactionReturnType,
|
|
@@ -10,6 +12,7 @@ import type {
|
|
|
10
12
|
export { LendProvider } from '@/lend/core/LendProvider.js'
|
|
11
13
|
export { ActionsLendNamespace } from '@/lend/namespaces/ActionsLendNamespace.js'
|
|
12
14
|
export { WalletLendNamespace } from '@/lend/namespaces/WalletLendNamespace.js'
|
|
15
|
+
export type { TransactionData }
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Lending market identifier
|
|
@@ -45,19 +48,6 @@ export type LendMarketConfig = LendMarketId & LendMarketConfigMetadata
|
|
|
45
48
|
*/
|
|
46
49
|
export type GetLendMarketParams = LendMarketId
|
|
47
50
|
|
|
48
|
-
/**
|
|
49
|
-
* Transaction data for execution
|
|
50
|
-
* @description Raw transaction data for wallet execution
|
|
51
|
-
*/
|
|
52
|
-
export interface TransactionData {
|
|
53
|
-
/** Target contract address */
|
|
54
|
-
to: Address
|
|
55
|
-
/** Encoded function call data */
|
|
56
|
-
data: Hex
|
|
57
|
-
/** ETH value to send */
|
|
58
|
-
value: bigint
|
|
59
|
-
}
|
|
60
|
-
|
|
61
51
|
/**
|
|
62
52
|
* Supply metrics for a lending market
|
|
63
53
|
* @description Total assets and shares in the vault
|
|
@@ -83,16 +73,13 @@ export interface LendTransaction {
|
|
|
83
73
|
marketId: string
|
|
84
74
|
/** Estimated APY at time of lending */
|
|
85
75
|
apy: number
|
|
86
|
-
/** Transaction data for execution
|
|
87
|
-
transactionData
|
|
76
|
+
/** Transaction data for execution */
|
|
77
|
+
transactionData: {
|
|
88
78
|
/** Approval transaction (if needed) */
|
|
89
79
|
approval?: TransactionData
|
|
90
|
-
/** Main
|
|
91
|
-
|
|
92
|
-
closePosition?: TransactionData
|
|
80
|
+
/** Main position transaction */
|
|
81
|
+
position: TransactionData
|
|
93
82
|
}
|
|
94
|
-
/** Slippage tolerance used */
|
|
95
|
-
slippage?: number
|
|
96
83
|
}
|
|
97
84
|
|
|
98
85
|
/**
|
|
@@ -204,8 +191,6 @@ export interface LendMarket {
|
|
|
204
191
|
* @description Configuration options for lending operations
|
|
205
192
|
*/
|
|
206
193
|
export interface LendOptions {
|
|
207
|
-
/** Maximum slippage tolerance (basis points) */
|
|
208
|
-
slippage?: number
|
|
209
194
|
/** Deadline for transaction (timestamp) */
|
|
210
195
|
deadline?: number
|
|
211
196
|
/** Gas limit override */
|
|
@@ -268,8 +253,10 @@ export interface LendOpenPositionParams extends LendOpenPositionBaseParams {
|
|
|
268
253
|
/**
|
|
269
254
|
* Internal parameters for provider _openPosition method with amount already converted to wei
|
|
270
255
|
*/
|
|
271
|
-
export interface LendOpenPositionInternalParams
|
|
272
|
-
|
|
256
|
+
export interface LendOpenPositionInternalParams extends Omit<
|
|
257
|
+
LendOpenPositionBaseParams,
|
|
258
|
+
'walletAddress'
|
|
259
|
+
> {
|
|
273
260
|
/** Amount to lend in wei */
|
|
274
261
|
amountWei: bigint
|
|
275
262
|
/** Wallet address for receiving shares and as owner (required in internal params) */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Morpho contract addresses needed per chain
|
|
5
|
+
*/
|
|
6
|
+
export interface MorphoContracts {
|
|
7
|
+
/** Morpho Blue core contract - market state, positions, supply/withdraw */
|
|
8
|
+
morphoBlue: Address
|
|
9
|
+
/** Interest Rate Model contract - borrow rate calculation for APY */
|
|
10
|
+
irm: Address
|
|
11
|
+
/** MetaMorpho vault factory (optional, only for vault creation) */
|
|
12
|
+
metaMorphoFactory?: Address
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Registry mapping chainId to Morpho contracts
|
|
17
|
+
*/
|
|
18
|
+
export type MorphoContractsRegistry = Record<number, MorphoContracts>
|
package/src/types/lend/index.ts
CHANGED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { Address } from 'viem'
|
|
2
|
+
|
|
3
|
+
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
4
|
+
import type { SwapProvider } from '@/swap/core/SwapProvider.js'
|
|
5
|
+
import type { Asset } from '@/types/asset.js'
|
|
6
|
+
import type { TransactionData } from '@/types/transaction.js'
|
|
7
|
+
import type {
|
|
8
|
+
BatchTransactionReturnType,
|
|
9
|
+
TransactionReturnType,
|
|
10
|
+
} from '@/wallet/core/wallets/abstract/types/index.js'
|
|
11
|
+
|
|
12
|
+
export { SwapProvider } from '@/swap/core/SwapProvider.js'
|
|
13
|
+
export { ActionsSwapNamespace } from '@/swap/namespaces/ActionsSwapNamespace.js'
|
|
14
|
+
export { WalletSwapNamespace } from '@/swap/namespaces/WalletSwapNamespace.js'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Map of available swap providers keyed by provider name
|
|
18
|
+
*/
|
|
19
|
+
export type SwapProviders = {
|
|
20
|
+
uniswap?: SwapProvider<SwapProviderConfig>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Swap provider configuration
|
|
25
|
+
* @description Configuration for a single swap provider (mirrors LendProviderConfig pattern)
|
|
26
|
+
*/
|
|
27
|
+
export interface SwapProviderConfig {
|
|
28
|
+
/** Default slippage tolerance (e.g., 0.005 for 0.5%) */
|
|
29
|
+
defaultSlippage?: number
|
|
30
|
+
/** Maximum allowed slippage (e.g., 0.5 for 50%). Defaults to 0.5. */
|
|
31
|
+
maxSlippage?: number
|
|
32
|
+
/** Allowlist of swap markets (optional - defaults to all supported assets) */
|
|
33
|
+
marketAllowlist?: SwapMarketConfig[]
|
|
34
|
+
/** Blocklist of swap markets to exclude */
|
|
35
|
+
marketBlocklist?: SwapMarketConfig[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Swap market filter
|
|
40
|
+
* @description Define allowed/blocked trading markets by assets.
|
|
41
|
+
* 2 assets = one explicit pair. 3+ = all pairs between them.
|
|
42
|
+
*/
|
|
43
|
+
export interface SwapMarketConfig {
|
|
44
|
+
/** 2 assets = one explicit pair. 3+ = all pairs between them. */
|
|
45
|
+
assets: [Asset, Asset, ...Asset[]]
|
|
46
|
+
/** Restrict to a specific chain. Omit = all configured chains. */
|
|
47
|
+
chainId?: SupportedChainId
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Swap market identifier
|
|
52
|
+
* @description Unique identifier for a swap market (mirrors LendMarketId pattern)
|
|
53
|
+
*/
|
|
54
|
+
export type SwapMarketId = {
|
|
55
|
+
/** Pool identifier (keccak256 hash of PoolKey) */
|
|
56
|
+
poolId: string
|
|
57
|
+
/** Chain ID where this market exists */
|
|
58
|
+
chainId: SupportedChainId
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Parameters for getting a specific swap market
|
|
63
|
+
*/
|
|
64
|
+
export type GetSwapMarketParams = SwapMarketId
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Parameters for getting swap markets
|
|
68
|
+
*/
|
|
69
|
+
export interface GetSwapMarketsParams {
|
|
70
|
+
/** Filter by chain ID */
|
|
71
|
+
chainId?: SupportedChainId
|
|
72
|
+
/** Filter by asset (returns markets containing this asset) */
|
|
73
|
+
asset?: Asset
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Parameters for a wallet swap — what the developer passes.
|
|
78
|
+
* Exactly one of amountIn or amountOut must be provided.
|
|
79
|
+
*/
|
|
80
|
+
export interface WalletSwapParams {
|
|
81
|
+
/** Amount of input token (human-readable). For exact-in swaps. Mutually exclusive with amountOut. */
|
|
82
|
+
amountIn?: number
|
|
83
|
+
/** Amount of output token (human-readable). For exact-out swaps. Mutually exclusive with amountIn. */
|
|
84
|
+
amountOut?: number
|
|
85
|
+
/** Token to sell */
|
|
86
|
+
assetIn: Asset
|
|
87
|
+
/** Token to buy */
|
|
88
|
+
assetOut: Asset
|
|
89
|
+
/** Chain to execute swap on */
|
|
90
|
+
chainId: SupportedChainId
|
|
91
|
+
/** Slippage tolerance override (e.g., 0.01 for 1%). Overrides provider and config defaults. */
|
|
92
|
+
slippage?: number
|
|
93
|
+
/** Transaction deadline as Unix timestamp. Defaults to now + 1 minute. */
|
|
94
|
+
deadline?: number
|
|
95
|
+
/** Recipient address. Defaults to wallet address. */
|
|
96
|
+
recipient?: Address
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Full swap execute parameters including wallet address.
|
|
101
|
+
* walletAddress is auto-injected by the wallet namespace.
|
|
102
|
+
*/
|
|
103
|
+
export interface SwapExecuteParams extends WalletSwapParams {
|
|
104
|
+
walletAddress: Address
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Fully resolved swap parameters with defaults applied and amounts in wei.
|
|
109
|
+
* Passed to provider _execute() implementations.
|
|
110
|
+
*/
|
|
111
|
+
export interface ResolvedSwapParams {
|
|
112
|
+
amountInWei?: bigint
|
|
113
|
+
amountOutWei?: bigint
|
|
114
|
+
assetIn: Asset
|
|
115
|
+
assetOut: Asset
|
|
116
|
+
slippage: number
|
|
117
|
+
deadline: number
|
|
118
|
+
recipient: Address
|
|
119
|
+
walletAddress: Address
|
|
120
|
+
chainId: SupportedChainId
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Parameters for getting a swap price quote
|
|
125
|
+
* @description Specify either amountIn (for exact-in) or amountOut (for exact-out),
|
|
126
|
+
* not both. Amounts should be human-readable numbers (e.g., 100 for 100 USDC).
|
|
127
|
+
*/
|
|
128
|
+
export interface SwapPriceParams {
|
|
129
|
+
/** Token to get price for (required) */
|
|
130
|
+
assetIn: Asset
|
|
131
|
+
/** Token to price against. Defaults to USDC if not provided. */
|
|
132
|
+
assetOut?: Asset
|
|
133
|
+
/** Amount of input token (human-readable). Defaults to 1 unit. For exact-in quotes. */
|
|
134
|
+
amountIn?: number
|
|
135
|
+
/** Amount of output token (human-readable). For exact-out quotes. */
|
|
136
|
+
amountOut?: number
|
|
137
|
+
/** Chain to get price on */
|
|
138
|
+
chainId: SupportedChainId
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Market information for a swap hop
|
|
143
|
+
*/
|
|
144
|
+
export interface SwapMarketInfo {
|
|
145
|
+
/** Market address or identifier */
|
|
146
|
+
address: Address
|
|
147
|
+
/** Fee tier in pips */
|
|
148
|
+
fee: number
|
|
149
|
+
/** Protocol version used (v2, v3, v4) */
|
|
150
|
+
version: 'v2' | 'v3' | 'v4'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Swap route information
|
|
155
|
+
*/
|
|
156
|
+
export interface SwapRoute {
|
|
157
|
+
/** Ordered list of assets in the route path */
|
|
158
|
+
path: Asset[]
|
|
159
|
+
/** Market information for each hop */
|
|
160
|
+
pools: SwapMarketInfo[]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Swap price quote response
|
|
165
|
+
*/
|
|
166
|
+
export interface SwapPrice {
|
|
167
|
+
/** Exchange rate as human-readable string (e.g., "3245.50") */
|
|
168
|
+
price: string
|
|
169
|
+
/** Inverse exchange rate */
|
|
170
|
+
priceInverse: string
|
|
171
|
+
/** Human-readable input amount */
|
|
172
|
+
amountIn: number
|
|
173
|
+
/** Human-readable output amount */
|
|
174
|
+
amountOut: number
|
|
175
|
+
/** Input amount in wei */
|
|
176
|
+
amountInWei: bigint
|
|
177
|
+
/** Expected output amount in wei */
|
|
178
|
+
amountOutWei: bigint
|
|
179
|
+
/** Price impact as decimal (0.03 = 3%). Derived from pool mid-price vs execution price. */
|
|
180
|
+
priceImpact: number
|
|
181
|
+
/** Route taken for the swap */
|
|
182
|
+
route: SwapRoute
|
|
183
|
+
/** Estimated gas cost in wei */
|
|
184
|
+
gasEstimate?: bigint
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Transaction data for swap execution
|
|
189
|
+
*/
|
|
190
|
+
export interface SwapTransactionData {
|
|
191
|
+
/** Permit2 approval transaction (if needed) */
|
|
192
|
+
permit2Approval?: TransactionData
|
|
193
|
+
/** Token approval to Permit2 (if needed) */
|
|
194
|
+
tokenApproval?: TransactionData
|
|
195
|
+
/** Main swap transaction */
|
|
196
|
+
swap: TransactionData
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Swap transaction result
|
|
201
|
+
*/
|
|
202
|
+
export interface SwapTransaction {
|
|
203
|
+
/** Human-readable input amount */
|
|
204
|
+
amountIn: number
|
|
205
|
+
/** Human-readable output amount */
|
|
206
|
+
amountOut: number
|
|
207
|
+
/** Input amount in wei */
|
|
208
|
+
amountInWei: bigint
|
|
209
|
+
/** Output amount in wei (expected) */
|
|
210
|
+
amountOutWei: bigint
|
|
211
|
+
/** Input asset */
|
|
212
|
+
assetIn: Asset
|
|
213
|
+
/** Output asset */
|
|
214
|
+
assetOut: Asset
|
|
215
|
+
/** Execution price */
|
|
216
|
+
price: string
|
|
217
|
+
/** Price impact as decimal (0.03 = 3%) */
|
|
218
|
+
priceImpact: number
|
|
219
|
+
/** Transaction data for execution */
|
|
220
|
+
transactionData: SwapTransactionData
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Swap execution receipt
|
|
225
|
+
*/
|
|
226
|
+
export interface SwapReceipt {
|
|
227
|
+
/** Transaction receipt(s) */
|
|
228
|
+
receipt: TransactionReturnType | BatchTransactionReturnType
|
|
229
|
+
/** Human-readable input amount */
|
|
230
|
+
amountIn: number
|
|
231
|
+
/** Human-readable output amount */
|
|
232
|
+
amountOut: number
|
|
233
|
+
/** Actual input amount in wei */
|
|
234
|
+
amountInWei: bigint
|
|
235
|
+
/** Actual output amount in wei */
|
|
236
|
+
amountOutWei: bigint
|
|
237
|
+
/** Input asset */
|
|
238
|
+
assetIn: Asset
|
|
239
|
+
/** Output asset */
|
|
240
|
+
assetOut: Asset
|
|
241
|
+
/** Execution price as human-readable string */
|
|
242
|
+
price: string
|
|
243
|
+
/** Price impact as decimal (0.03 = 3%) */
|
|
244
|
+
priceImpact: number
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Swap market information
|
|
249
|
+
*/
|
|
250
|
+
export interface SwapMarket {
|
|
251
|
+
/** Market identifier (contains poolId and chainId) */
|
|
252
|
+
marketId: SwapMarketId
|
|
253
|
+
/** Token pair in the market */
|
|
254
|
+
assets: [Asset, Asset]
|
|
255
|
+
/** Fee tier in pips (500 = 0.05%) */
|
|
256
|
+
fee: number
|
|
257
|
+
/** Provider name */
|
|
258
|
+
provider: 'uniswap'
|
|
259
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@/types/swap/base.js'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Transaction data for execution
|
|
5
|
+
* @description Raw transaction data for wallet execution
|
|
6
|
+
*/
|
|
7
|
+
export interface TransactionData {
|
|
8
|
+
/** Target contract address */
|
|
9
|
+
to: Address
|
|
10
|
+
/** Encoded function call data */
|
|
11
|
+
data: Hex
|
|
12
|
+
/** ETH value to send */
|
|
13
|
+
value: bigint
|
|
14
|
+
}
|
package/src/utils/assets.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest'
|
|
2
2
|
|
|
3
|
-
import { MockUSDCAsset, MockWETHAsset } from '@/
|
|
4
|
-
import { isAssetSupportedOnChain } from '@/utils/assets.js'
|
|
3
|
+
import { MockUSDCAsset, MockWETHAsset } from '@/__mocks__/MockAssets.js'
|
|
4
|
+
import { isAssetSupportedOnChain, parseAssetAmount } from '@/utils/assets.js'
|
|
5
5
|
|
|
6
6
|
describe('Asset Utilities', () => {
|
|
7
7
|
describe('isAssetSupportedOnChain', () => {
|
|
@@ -25,4 +25,19 @@ describe('Asset Utilities', () => {
|
|
|
25
25
|
expect(MockWETHAsset.type).toBe('erc20')
|
|
26
26
|
})
|
|
27
27
|
})
|
|
28
|
+
|
|
29
|
+
describe('parseAssetAmount', () => {
|
|
30
|
+
it('converts human-readable amount to wei using asset decimals', () => {
|
|
31
|
+
expect(parseAssetAmount(MockUSDCAsset, 100)).toBe(100000000n)
|
|
32
|
+
expect(parseAssetAmount(MockWETHAsset, 1)).toBe(1000000000000000000n)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('returns undefined when amount is undefined', () => {
|
|
36
|
+
expect(parseAssetAmount(MockUSDCAsset, undefined)).toBeUndefined()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('handles fractional amounts', () => {
|
|
40
|
+
expect(parseAssetAmount(MockUSDCAsset, 0.5)).toBe(500000n)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
28
43
|
})
|
package/src/utils/assets.ts
CHANGED
|
@@ -5,17 +5,20 @@ import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
|
5
5
|
import type { Asset } from '@/types/asset.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Parse human-readable amount to wei
|
|
9
|
-
*
|
|
10
|
-
* @param decimals - Token decimals
|
|
11
|
-
* @returns Amount in smallest unit (wei equivalent)
|
|
8
|
+
* Parse human-readable amount to wei using an asset's decimals.
|
|
9
|
+
* Returns undefined when amount is undefined.
|
|
12
10
|
*/
|
|
13
|
-
export function parseAssetAmount(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export function parseAssetAmount(asset: Asset, amount: number): bigint
|
|
12
|
+
export function parseAssetAmount(
|
|
13
|
+
asset: Asset,
|
|
14
|
+
amount: number | undefined,
|
|
15
|
+
): bigint | undefined
|
|
16
|
+
export function parseAssetAmount(
|
|
17
|
+
asset: Asset,
|
|
18
|
+
amount: number | undefined,
|
|
19
|
+
): bigint | undefined {
|
|
20
|
+
if (amount === undefined) return undefined
|
|
21
|
+
return parseUnits(amount.toString(), asset.metadata.decimals)
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -37,6 +40,15 @@ export function formatAssetAmount(amount: bigint, decimals: number): number {
|
|
|
37
40
|
return parseFloat(result)
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Check if asset is a native asset (e.g. ETH)
|
|
45
|
+
* @param asset - Asset definition
|
|
46
|
+
* @returns Whether the asset is native
|
|
47
|
+
*/
|
|
48
|
+
export function isNativeAsset(asset: Asset): boolean {
|
|
49
|
+
return asset.type === 'native'
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
/**
|
|
41
53
|
* Check if asset is supported on a specific chain
|
|
42
54
|
* @param asset - Asset definition
|
|
@@ -55,7 +67,7 @@ export function isAssetSupportedOnChain(
|
|
|
55
67
|
* @param asset - Asset definition
|
|
56
68
|
* @param chainId - Chain ID
|
|
57
69
|
* @returns Asset address on the specified chain
|
|
58
|
-
* @throws Error if asset is not supported on the chain
|
|
70
|
+
* @throws Error if asset is not supported on the chain or is a native asset
|
|
59
71
|
*/
|
|
60
72
|
export function getAssetAddress(
|
|
61
73
|
asset: Asset,
|
|
@@ -67,5 +79,10 @@ export function getAssetAddress(
|
|
|
67
79
|
`Asset ${asset.metadata.symbol} is not supported on chain ${chainId}`,
|
|
68
80
|
)
|
|
69
81
|
}
|
|
82
|
+
if (address === 'native') {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Asset ${asset.metadata.symbol} is a native asset and has no contract address.`,
|
|
85
|
+
)
|
|
86
|
+
}
|
|
70
87
|
return address
|
|
71
88
|
}
|