@eth-optimism/actions-sdk 0.3.0 → 0.4.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/dist/__mocks__/MockAssets.d.ts +17 -2
- package/dist/__mocks__/MockAssets.d.ts.map +1 -1
- package/dist/__mocks__/MockAssets.js +49 -6
- package/dist/__mocks__/MockAssets.js.map +1 -1
- package/dist/__tests__/actions.test.js +1 -1
- package/dist/__tests__/actions.test.js.map +1 -1
- package/dist/actions.d.ts +8 -13
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +35 -27
- package/dist/actions.js.map +1 -1
- package/dist/constants/assets.d.ts +215 -4
- package/dist/constants/assets.d.ts.map +1 -1
- package/dist/constants/assets.js +734 -11
- package/dist/constants/assets.js.map +1 -1
- package/dist/constants/providers.d.ts +6 -0
- package/dist/constants/providers.d.ts.map +1 -0
- package/dist/constants/providers.js +6 -0
- package/dist/constants/providers.js.map +1 -0
- package/dist/constants/supportedChains.d.ts +2 -2
- package/dist/constants/supportedChains.d.ts.map +1 -1
- package/dist/constants/supportedChains.js +12 -2
- package/dist/constants/supportedChains.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/lend/__mocks__/MockLendProvider.d.ts +1 -1
- package/dist/lend/__mocks__/MockLendProvider.d.ts.map +1 -1
- package/dist/lend/__mocks__/MockLendProvider.js +7 -2
- package/dist/lend/__mocks__/MockLendProvider.js.map +1 -1
- package/dist/lend/core/LendProvider.d.ts +12 -8
- package/dist/lend/core/LendProvider.d.ts.map +1 -1
- package/dist/lend/core/LendProvider.js +15 -21
- package/dist/lend/core/LendProvider.js.map +1 -1
- package/dist/lend/namespaces/BaseLendNamespace.d.ts +2 -6
- package/dist/lend/namespaces/BaseLendNamespace.d.ts.map +1 -1
- package/dist/lend/namespaces/BaseLendNamespace.js.map +1 -1
- package/dist/lend/namespaces/__tests__/BaseLendNamespace.spec.js +7 -4
- package/dist/lend/namespaces/__tests__/BaseLendNamespace.spec.js.map +1 -1
- package/dist/lend/providers/aave/AaveLendProvider.d.ts +1 -6
- package/dist/lend/providers/aave/AaveLendProvider.d.ts.map +1 -1
- package/dist/lend/providers/aave/AaveLendProvider.js +3 -6
- package/dist/lend/providers/aave/AaveLendProvider.js.map +1 -1
- package/dist/lend/providers/aave/__tests__/AaveLendProvider.test.js +14 -6
- package/dist/lend/providers/aave/__tests__/AaveLendProvider.test.js.map +1 -1
- package/dist/lend/providers/aave/addresses.d.ts +13 -39
- package/dist/lend/providers/aave/addresses.d.ts.map +1 -1
- package/dist/lend/providers/aave/addresses.js +65 -60
- package/dist/lend/providers/aave/addresses.js.map +1 -1
- package/dist/lend/providers/aave/sdk.d.ts +2 -2
- package/dist/lend/providers/aave/sdk.d.ts.map +1 -1
- package/dist/lend/providers/aave/sdk.js +6 -28
- package/dist/lend/providers/aave/sdk.js.map +1 -1
- package/dist/lend/providers/morpho/MorphoLendProvider.d.ts +1 -6
- package/dist/lend/providers/morpho/MorphoLendProvider.d.ts.map +1 -1
- package/dist/lend/providers/morpho/MorphoLendProvider.js +4 -13
- package/dist/lend/providers/morpho/MorphoLendProvider.js.map +1 -1
- package/dist/lend/providers/morpho/__tests__/api.test.js +52 -43
- package/dist/lend/providers/morpho/__tests__/api.test.js.map +1 -1
- package/dist/lend/providers/morpho/__tests__/sdk.test.js +41 -42
- package/dist/lend/providers/morpho/__tests__/sdk.test.js.map +1 -1
- package/dist/lend/providers/morpho/api.d.ts +3 -7
- package/dist/lend/providers/morpho/api.d.ts.map +1 -1
- package/dist/lend/providers/morpho/api.js +2 -2
- package/dist/lend/providers/morpho/api.js.map +1 -1
- package/dist/lend/providers/morpho/contracts.d.ts +11 -10
- package/dist/lend/providers/morpho/contracts.d.ts.map +1 -1
- package/dist/lend/providers/morpho/contracts.js +43 -10
- package/dist/lend/providers/morpho/contracts.js.map +1 -1
- package/dist/lend/providers/morpho/sdk.d.ts +7 -2
- package/dist/lend/providers/morpho/sdk.d.ts.map +1 -1
- package/dist/lend/providers/morpho/sdk.js +67 -63
- package/dist/lend/providers/morpho/sdk.js.map +1 -1
- package/dist/nodeActionsFactory.d.ts +1 -1
- package/dist/reactActionsFactory.d.ts +1 -1
- package/dist/services/ChainManager.d.ts +8 -8
- package/dist/services/ChainManager.d.ts.map +1 -1
- package/dist/services/ChainManager.js.map +1 -1
- package/dist/services/__mocks__/MockChainManager.d.ts +4 -4
- package/dist/services/__mocks__/MockChainManager.d.ts.map +1 -1
- package/dist/services/__mocks__/MockChainManager.js.map +1 -1
- package/dist/services/tokenBalance.d.ts +1 -1
- package/dist/services/tokenBalance.d.ts.map +1 -1
- package/dist/services/tokenBalance.js +31 -30
- package/dist/services/tokenBalance.js.map +1 -1
- package/dist/services/tokenBalance.spec.js +20 -24
- package/dist/services/tokenBalance.spec.js.map +1 -1
- package/dist/swap/__mocks__/MockSwapProvider.d.ts +20 -8
- package/dist/swap/__mocks__/MockSwapProvider.d.ts.map +1 -1
- package/dist/swap/__mocks__/MockSwapProvider.js +52 -29
- package/dist/swap/__mocks__/MockSwapProvider.js.map +1 -1
- package/dist/swap/core/SwapProvider.d.ts +105 -16
- package/dist/swap/core/SwapProvider.d.ts.map +1 -1
- package/dist/swap/core/SwapProvider.js +218 -36
- package/dist/swap/core/SwapProvider.js.map +1 -1
- package/dist/swap/core/__tests__/SwapProvider.test.js +115 -9
- package/dist/swap/core/__tests__/SwapProvider.test.js.map +1 -1
- package/dist/swap/core/markets.d.ts +47 -0
- package/dist/swap/core/markets.d.ts.map +1 -0
- package/dist/swap/core/markets.js +65 -0
- package/dist/swap/core/markets.js.map +1 -0
- package/dist/swap/index.d.ts +2 -0
- package/dist/swap/index.d.ts.map +1 -1
- package/dist/swap/index.js +1 -0
- package/dist/swap/index.js.map +1 -1
- package/dist/swap/namespaces/ActionsSwapNamespace.d.ts +2 -2
- package/dist/swap/namespaces/ActionsSwapNamespace.js +2 -2
- package/dist/swap/namespaces/BaseSwapNamespace.d.ts +48 -8
- package/dist/swap/namespaces/BaseSwapNamespace.d.ts.map +1 -1
- package/dist/swap/namespaces/BaseSwapNamespace.js +139 -16
- package/dist/swap/namespaces/BaseSwapNamespace.js.map +1 -1
- package/dist/swap/namespaces/WalletSwapNamespace.d.ts +19 -7
- package/dist/swap/namespaces/WalletSwapNamespace.d.ts.map +1 -1
- package/dist/swap/namespaces/WalletSwapNamespace.js +39 -15
- package/dist/swap/namespaces/WalletSwapNamespace.js.map +1 -1
- package/dist/swap/namespaces/__tests__/BaseSwapNamespace.spec.js +150 -11
- package/dist/swap/namespaces/__tests__/BaseSwapNamespace.spec.js.map +1 -1
- package/dist/swap/namespaces/__tests__/WalletSwapNamespace.spec.js +85 -8
- package/dist/swap/namespaces/__tests__/WalletSwapNamespace.spec.js.map +1 -1
- package/dist/swap/providers/uniswap/UniswapSwapProvider.d.ts +9 -42
- package/dist/swap/providers/uniswap/UniswapSwapProvider.d.ts.map +1 -1
- package/dist/swap/providers/uniswap/UniswapSwapProvider.js +81 -139
- package/dist/swap/providers/uniswap/UniswapSwapProvider.js.map +1 -1
- package/dist/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.js +10 -9
- package/dist/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.js.map +1 -1
- package/dist/swap/providers/uniswap/__tests__/sdk.test.js +17 -17
- package/dist/swap/providers/uniswap/__tests__/sdk.test.js.map +1 -1
- package/dist/swap/providers/uniswap/addresses.d.ts +5 -0
- package/dist/swap/providers/uniswap/addresses.d.ts.map +1 -1
- package/dist/swap/providers/uniswap/addresses.js +1 -1
- package/dist/swap/providers/uniswap/addresses.js.map +1 -1
- package/dist/swap/providers/uniswap/encoding.d.ts +4 -4
- package/dist/swap/providers/uniswap/encoding.js +17 -17
- package/dist/swap/providers/uniswap/markets.d.ts +19 -0
- package/dist/swap/providers/uniswap/markets.d.ts.map +1 -0
- package/dist/swap/providers/uniswap/markets.js +48 -0
- package/dist/swap/providers/uniswap/markets.js.map +1 -0
- package/dist/swap/providers/uniswap/types.d.ts +4 -3
- package/dist/swap/providers/uniswap/types.d.ts.map +1 -1
- package/dist/swap/providers/velodrome/VelodromeSwapProvider.d.ts +49 -0
- package/dist/swap/providers/velodrome/VelodromeSwapProvider.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/VelodromeSwapProvider.js +140 -0
- package/dist/swap/providers/velodrome/VelodromeSwapProvider.js.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.network.test.d.ts +2 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.network.test.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.network.test.js +255 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.network.test.js.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.routing.test.d.ts +2 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.routing.test.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.routing.test.js +166 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.routing.test.js.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.test.d.ts +2 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.test.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.test.js +419 -0
- package/dist/swap/providers/velodrome/__tests__/VelodromeSwapProvider.test.js.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.cl.test.d.ts +2 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.cl.test.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.cl.test.js +51 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.cl.test.js.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.helpers.d.ts +14 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.helpers.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.helpers.js +13 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.helpers.js.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.v2.test.d.ts +2 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.v2.test.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.v2.test.js +173 -0
- package/dist/swap/providers/velodrome/__tests__/encoding.v2.test.js.map +1 -0
- package/dist/swap/providers/velodrome/abis.d.ts +396 -0
- package/dist/swap/providers/velodrome/abis.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/abis.js +257 -0
- package/dist/swap/providers/velodrome/abis.js.map +1 -0
- package/dist/swap/providers/velodrome/addresses.d.ts +39 -0
- package/dist/swap/providers/velodrome/addresses.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/addresses.js +57 -0
- package/dist/swap/providers/velodrome/addresses.js.map +1 -0
- package/dist/swap/providers/velodrome/config.d.ts +22 -0
- package/dist/swap/providers/velodrome/config.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/config.js +29 -0
- package/dist/swap/providers/velodrome/config.js.map +1 -0
- package/dist/swap/providers/velodrome/encoding/helpers.d.ts +37 -0
- package/dist/swap/providers/velodrome/encoding/helpers.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/encoding/helpers.js +60 -0
- package/dist/swap/providers/velodrome/encoding/helpers.js.map +1 -0
- package/dist/swap/providers/velodrome/encoding/index.d.ts +8 -0
- package/dist/swap/providers/velodrome/encoding/index.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/encoding/index.js +5 -0
- package/dist/swap/providers/velodrome/encoding/index.js.map +1 -0
- package/dist/swap/providers/velodrome/encoding/poolRouter.d.ts +39 -0
- package/dist/swap/providers/velodrome/encoding/poolRouter.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/encoding/poolRouter.js +83 -0
- package/dist/swap/providers/velodrome/encoding/poolRouter.js.map +1 -0
- package/dist/swap/providers/velodrome/encoding/routers/approval.d.ts +15 -0
- package/dist/swap/providers/velodrome/encoding/routers/approval.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/encoding/routers/approval.js +33 -0
- package/dist/swap/providers/velodrome/encoding/routers/approval.js.map +1 -0
- package/dist/swap/providers/velodrome/encoding/routers/cl.d.ts +40 -0
- package/dist/swap/providers/velodrome/encoding/routers/cl.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/encoding/routers/cl.js +80 -0
- package/dist/swap/providers/velodrome/encoding/routers/cl.js.map +1 -0
- package/dist/swap/providers/velodrome/encoding/routers/v2.d.ts +42 -0
- package/dist/swap/providers/velodrome/encoding/routers/v2.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/encoding/routers/v2.js +166 -0
- package/dist/swap/providers/velodrome/encoding/routers/v2.js.map +1 -0
- package/dist/swap/providers/velodrome/markets.d.ts +21 -0
- package/dist/swap/providers/velodrome/markets.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/markets.js +69 -0
- package/dist/swap/providers/velodrome/markets.js.map +1 -0
- package/dist/swap/providers/velodrome/types.d.ts +31 -0
- package/dist/swap/providers/velodrome/types.d.ts.map +1 -0
- package/dist/swap/providers/velodrome/types.js +2 -0
- package/dist/swap/providers/velodrome/types.js.map +1 -0
- package/dist/types/actions.d.ts +44 -9
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/asset.d.ts +7 -9
- package/dist/types/asset.d.ts.map +1 -1
- package/dist/types/chain.d.ts +2 -2
- package/dist/types/chain.d.ts.map +1 -1
- package/dist/types/lend/base.d.ts +6 -6
- 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 +2 -1
- package/dist/types/lend/contracts.d.ts.map +1 -1
- package/dist/types/providers.d.ts +21 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/providers.js +2 -0
- package/dist/types/providers.js.map +1 -0
- package/dist/types/swap/base.d.ts +133 -33
- package/dist/types/swap/base.d.ts.map +1 -1
- package/dist/utils/approve.d.ts +82 -0
- package/dist/utils/approve.d.ts.map +1 -0
- package/dist/utils/{permit2.js → approve.js} +48 -14
- package/dist/utils/approve.js.map +1 -0
- package/dist/utils/approve.test.d.ts +2 -0
- package/dist/utils/approve.test.d.ts.map +1 -0
- package/dist/utils/{permit2.test.js → approve.test.js} +95 -2
- package/dist/utils/approve.test.js.map +1 -0
- package/dist/utils/assets.d.ts +6 -0
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/assets.js +10 -0
- package/dist/utils/assets.js.map +1 -1
- package/dist/utils/validateAddresses.d.ts +32 -0
- package/dist/utils/validateAddresses.d.ts.map +1 -0
- package/dist/utils/validateAddresses.js +103 -0
- package/dist/utils/validateAddresses.js.map +1 -0
- package/dist/utils/validateAddresses.test.d.ts +2 -0
- package/dist/utils/validateAddresses.test.d.ts.map +1 -0
- package/dist/utils/validateAddresses.test.js +314 -0
- package/dist/utils/validateAddresses.test.js.map +1 -0
- package/dist/wallet/core/namespace/WalletNamespace.d.ts +21 -9
- package/dist/wallet/core/namespace/WalletNamespace.d.ts.map +1 -1
- package/dist/wallet/core/namespace/WalletNamespace.js +44 -15
- 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/hosted/abstract/HostedWalletProvider.d.ts +4 -16
- package/dist/wallet/core/providers/hosted/abstract/HostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/core/providers/hosted/abstract/HostedWalletProvider.js.map +1 -1
- package/dist/wallet/core/providers/hosted/types/index.d.ts +6 -11
- package/dist/wallet/core/providers/hosted/types/index.d.ts.map +1 -1
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.d.ts +2 -9
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.d.ts.map +1 -1
- package/dist/wallet/core/providers/smart/default/DefaultSmartWalletProvider.js.map +1 -1
- package/dist/wallet/core/wallets/abstract/Wallet.d.ts +6 -17
- package/dist/wallet/core/wallets/abstract/Wallet.d.ts.map +1 -1
- package/dist/wallet/core/wallets/abstract/Wallet.js +5 -6
- package/dist/wallet/core/wallets/abstract/Wallet.js.map +1 -1
- package/dist/wallet/core/wallets/abstract/__mocks__/TestWallet.d.ts +10 -1
- package/dist/wallet/core/wallets/abstract/__mocks__/TestWallet.d.ts.map +1 -1
- package/dist/wallet/core/wallets/abstract/__mocks__/TestWallet.js +2 -2
- package/dist/wallet/core/wallets/abstract/__mocks__/TestWallet.js.map +1 -1
- package/dist/wallet/core/wallets/abstract/__tests__/Wallet.spec.js +12 -4
- package/dist/wallet/core/wallets/abstract/__tests__/Wallet.spec.js.map +1 -1
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.d.ts +3 -10
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.d.ts.map +1 -1
- package/dist/wallet/core/wallets/smart/default/DefaultSmartWallet.js.map +1 -1
- package/dist/wallet/core/wallets/smart/default/__tests__/DefaultSmartWallet.spec.js.map +1 -1
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.d.ts +3 -10
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.d.ts +2 -4
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.d.ts.map +1 -1
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.js +6 -8
- package/dist/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.js.map +1 -1
- package/dist/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.js +4 -4
- package/dist/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.js.map +1 -1
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts +2 -9
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.d.ts +3 -10
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.d.ts.map +1 -1
- package/dist/wallet/node/wallets/hosted/privy/PrivyWallet.js.map +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.d.ts +3 -10
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.d.ts.map +1 -1
- package/dist/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.js.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.d.ts +3 -9
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.js +3 -2
- package/dist/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.js.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.d.ts +3 -9
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.js +3 -2
- package/dist/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts +3 -9
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.d.ts.map +1 -1
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js +3 -2
- package/dist/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.js.map +1 -1
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.d.ts +2 -4
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.d.ts.map +1 -1
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.js +11 -13
- package/dist/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.js.map +1 -1
- package/dist/wallet/react/providers/registry/__tests__/ReactHostedWalletProviderRegistry.spec.js +6 -6
- package/dist/wallet/react/providers/registry/__tests__/ReactHostedWalletProviderRegistry.spec.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.d.ts +5 -10
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.d.ts.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.js +3 -3
- package/dist/wallet/react/wallets/hosted/dynamic/DynamicWallet.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/__mocks__/DynamicWalletMock.d.ts +2 -6
- package/dist/wallet/react/wallets/hosted/dynamic/__mocks__/DynamicWalletMock.d.ts.map +1 -1
- package/dist/wallet/react/wallets/hosted/dynamic/__mocks__/DynamicWalletMock.js.map +1 -1
- package/dist/wallet/react/wallets/hosted/privy/PrivyWallet.d.ts +5 -10
- 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/turnkey/TurnkeyWallet.d.ts +5 -10
- 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/package.json +3 -2
- package/src/__mocks__/MockAssets.ts +54 -6
- package/src/__tests__/actions.test.ts +1 -1
- package/src/actions.ts +58 -61
- package/src/constants/assets.ts +781 -10
- package/src/constants/providers.ts +5 -0
- package/src/constants/supportedChains.ts +22 -2
- package/src/index.ts +50 -8
- package/src/lend/__mocks__/MockLendProvider.ts +8 -3
- package/src/lend/core/LendProvider.ts +27 -28
- package/src/lend/namespaces/BaseLendNamespace.ts +2 -6
- package/src/lend/namespaces/__tests__/BaseLendNamespace.spec.ts +12 -5
- package/src/lend/providers/aave/AaveLendProvider.ts +3 -7
- package/src/lend/providers/aave/__tests__/AaveLendProvider.test.ts +16 -7
- package/src/lend/providers/aave/addresses.ts +82 -64
- package/src/lend/providers/aave/sdk.ts +11 -36
- package/src/lend/providers/morpho/MorphoLendProvider.ts +4 -16
- package/src/lend/providers/morpho/__tests__/api.test.ts +65 -44
- package/src/lend/providers/morpho/__tests__/sdk.test.ts +43 -43
- package/src/lend/providers/morpho/api.ts +7 -8
- package/src/lend/providers/morpho/contracts.ts +62 -13
- package/src/lend/providers/morpho/sdk.ts +85 -63
- package/src/services/ChainManager.ts +12 -21
- package/src/services/__mocks__/MockChainManager.ts +4 -7
- package/src/services/tokenBalance.spec.ts +20 -24
- package/src/services/tokenBalance.ts +39 -33
- package/src/swap/__mocks__/MockSwapProvider.ts +77 -42
- package/src/swap/core/SwapProvider.ts +307 -49
- package/src/swap/core/__tests__/SwapProvider.test.ts +151 -9
- package/src/swap/core/markets.ts +104 -0
- package/src/swap/index.ts +5 -0
- package/src/swap/namespaces/ActionsSwapNamespace.ts +2 -2
- package/src/swap/namespaces/BaseSwapNamespace.ts +199 -18
- package/src/swap/namespaces/WalletSwapNamespace.ts +53 -14
- package/src/swap/namespaces/__tests__/BaseSwapNamespace.spec.ts +241 -14
- package/src/swap/namespaces/__tests__/WalletSwapNamespace.spec.ts +103 -8
- package/src/swap/providers/uniswap/UniswapSwapProvider.ts +108 -195
- package/src/swap/providers/uniswap/__tests__/UniswapSwapProvider.test.ts +12 -12
- package/src/swap/providers/uniswap/__tests__/sdk.test.ts +19 -20
- package/src/swap/providers/uniswap/addresses.ts +3 -1
- package/src/swap/providers/uniswap/encoding.ts +22 -22
- package/src/swap/providers/uniswap/markets.ts +84 -0
- package/src/swap/providers/uniswap/types.ts +4 -3
- package/src/swap/providers/velodrome/VelodromeSwapProvider.ts +224 -0
- package/src/swap/providers/velodrome/__tests__/VelodromeSwapProvider.network.test.ts +341 -0
- package/src/swap/providers/velodrome/__tests__/VelodromeSwapProvider.routing.test.ts +202 -0
- package/src/swap/providers/velodrome/__tests__/VelodromeSwapProvider.test.ts +506 -0
- package/src/swap/providers/velodrome/__tests__/encoding.cl.test.ts +69 -0
- package/src/swap/providers/velodrome/__tests__/encoding.helpers.ts +20 -0
- package/src/swap/providers/velodrome/__tests__/encoding.v2.test.ts +235 -0
- package/src/swap/providers/velodrome/abis.ts +264 -0
- package/src/swap/providers/velodrome/addresses.ts +107 -0
- package/src/swap/providers/velodrome/config.ts +46 -0
- package/src/swap/providers/velodrome/encoding/helpers.ts +82 -0
- package/src/swap/providers/velodrome/encoding/index.ts +7 -0
- package/src/swap/providers/velodrome/encoding/poolRouter.ts +124 -0
- package/src/swap/providers/velodrome/encoding/routers/approval.ts +45 -0
- package/src/swap/providers/velodrome/encoding/routers/cl.ts +156 -0
- package/src/swap/providers/velodrome/encoding/routers/v2.ts +267 -0
- package/src/swap/providers/velodrome/markets.ts +100 -0
- package/src/swap/providers/velodrome/types.ts +30 -0
- package/src/types/actions.ts +49 -9
- package/src/types/asset.ts +12 -9
- package/src/types/chain.ts +2 -2
- package/src/types/lend/base.ts +6 -6
- package/src/types/lend/contracts.ts +5 -1
- package/src/types/providers.ts +22 -0
- package/src/types/swap/base.ts +147 -34
- package/src/utils/{permit2.test.ts → approve.test.ts} +117 -1
- package/src/utils/{permit2.ts → approve.ts} +67 -14
- package/src/utils/assets.ts +14 -0
- package/src/utils/validateAddresses.test.ts +439 -0
- package/src/utils/validateAddresses.ts +153 -0
- package/src/wallet/core/namespace/WalletNamespace.ts +70 -16
- package/src/wallet/core/namespace/__tests__/WalletNamespace.spec.ts +8 -4
- package/src/wallet/core/providers/hosted/abstract/HostedWalletProvider.ts +5 -17
- package/src/wallet/core/providers/hosted/types/index.ts +9 -11
- package/src/wallet/core/providers/smart/default/DefaultSmartWalletProvider.ts +5 -17
- package/src/wallet/core/wallets/abstract/Wallet.ts +15 -22
- package/src/wallet/core/wallets/abstract/__mocks__/TestWallet.ts +13 -1
- package/src/wallet/core/wallets/abstract/__tests__/Wallet.spec.ts +21 -5
- package/src/wallet/core/wallets/smart/default/DefaultSmartWallet.ts +5 -17
- package/src/wallet/core/wallets/smart/default/__tests__/DefaultSmartWallet.spec.ts +0 -1
- package/src/wallet/node/providers/hosted/privy/PrivyHostedWalletProvider.ts +3 -10
- package/src/wallet/node/providers/hosted/registry/NodeHostedWalletProviderRegistry.ts +8 -8
- package/src/wallet/node/providers/hosted/registry/__tests__/NodeHostedWalletProviderRegistry.spec.ts +4 -4
- package/src/wallet/node/providers/hosted/turnkey/TurnkeyHostedWalletProvider.ts +3 -10
- package/src/wallet/node/wallets/hosted/privy/PrivyWallet.ts +5 -17
- package/src/wallet/node/wallets/hosted/turnkey/TurnkeyWallet.ts +5 -17
- package/src/wallet/react/providers/hosted/dynamic/DynamicHostedWalletProvider.ts +7 -11
- package/src/wallet/react/providers/hosted/privy/PrivyHostedWalletProvider.ts +7 -11
- package/src/wallet/react/providers/hosted/turnkey/TurnkeyHostedWalletProvider.ts +7 -11
- package/src/wallet/react/providers/registry/ReactHostedWalletProviderRegistry.ts +23 -10
- package/src/wallet/react/providers/registry/__tests__/ReactHostedWalletProviderRegistry.spec.ts +6 -6
- package/src/wallet/react/wallets/hosted/dynamic/DynamicWallet.ts +10 -18
- package/src/wallet/react/wallets/hosted/dynamic/__mocks__/DynamicWalletMock.ts +2 -6
- package/src/wallet/react/wallets/hosted/privy/PrivyWallet.ts +10 -18
- package/src/wallet/react/wallets/hosted/turnkey/TurnkeyWallet.ts +10 -18
- package/dist/supported/tokens.d.ts +0 -25
- package/dist/supported/tokens.d.ts.map +0 -1
- package/dist/supported/tokens.js +0 -44
- package/dist/supported/tokens.js.map +0 -1
- package/dist/utils/permit2.d.ts +0 -46
- package/dist/utils/permit2.d.ts.map +0 -1
- package/dist/utils/permit2.js.map +0 -1
- package/dist/utils/permit2.test.d.ts +0 -2
- package/dist/utils/permit2.test.d.ts.map +0 -1
- package/dist/utils/permit2.test.js.map +0 -1
- package/src/supported/tokens.ts +0 -66
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Address } from 'viem'
|
|
2
|
+
import { concat, keccak256 } from 'viem'
|
|
3
|
+
|
|
4
|
+
import { VELODROME } from '@/constants/providers.js'
|
|
5
|
+
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
6
|
+
import { assetPairs } from '@/swap/core/markets.js'
|
|
7
|
+
import type { Asset } from '@/types/asset.js'
|
|
8
|
+
import type { SwapMarket } from '@/types/swap/index.js'
|
|
9
|
+
|
|
10
|
+
import type { ResolvedPoolConfig, VelodromeMarketConfig } from './types.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a VelodromeMarketConfig to a discriminated ResolvedPoolConfig.
|
|
14
|
+
* Exactly one of stable or tickSpacing must be set.
|
|
15
|
+
* @param config - Raw market config
|
|
16
|
+
* @returns Resolved pool config with discriminated type
|
|
17
|
+
* @throws If both or neither of stable/tickSpacing are set
|
|
18
|
+
*/
|
|
19
|
+
export function resolvePoolConfig(
|
|
20
|
+
config: VelodromeMarketConfig,
|
|
21
|
+
): ResolvedPoolConfig {
|
|
22
|
+
const hasStable = config.stable !== undefined
|
|
23
|
+
const hasTick = config.tickSpacing !== undefined
|
|
24
|
+
if (hasStable && hasTick) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
'stable and tickSpacing are mutually exclusive — set one, not both',
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
if (!hasStable && !hasTick) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
'Either stable (v2 AMM) or tickSpacing (CL) must be configured',
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
if (hasTick) {
|
|
35
|
+
return { type: 'cl', tickSpacing: config.tickSpacing! }
|
|
36
|
+
}
|
|
37
|
+
return { type: 'v2', stable: config.stable! }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Expand a single VelodromeMarketConfig into SwapMarket objects for a given chain.
|
|
42
|
+
* Used as the `toMarkets` callback for shared findMarket/expandMarkets.
|
|
43
|
+
* @param config - Market config with pool parameters
|
|
44
|
+
* @param chainId - Target chain
|
|
45
|
+
* @param asset - If provided, only return markets containing this asset
|
|
46
|
+
*/
|
|
47
|
+
export function configToMarkets(
|
|
48
|
+
config: VelodromeMarketConfig,
|
|
49
|
+
chainId: SupportedChainId,
|
|
50
|
+
asset?: Asset,
|
|
51
|
+
): SwapMarket[] {
|
|
52
|
+
const poolConfig = resolvePoolConfig(config)
|
|
53
|
+
return assetPairs(config.assets, asset)
|
|
54
|
+
.map(([a, b]) => pairToMarket(a, b, chainId, poolConfig))
|
|
55
|
+
.filter((m): m is SwapMarket => m !== null)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Build a SwapMarket from two assets and Velodrome pool parameters.
|
|
60
|
+
* For v2: poolId = keccak256(sortedA, sortedB, stable)
|
|
61
|
+
* For CL: poolId = keccak256(sortedA, sortedB, tickSpacing as int24)
|
|
62
|
+
* @returns SwapMarket, or null if either asset lacks an address on this chain
|
|
63
|
+
*/
|
|
64
|
+
function pairToMarket(
|
|
65
|
+
assetA: Asset,
|
|
66
|
+
assetB: Asset,
|
|
67
|
+
chainId: SupportedChainId,
|
|
68
|
+
poolConfig: ResolvedPoolConfig,
|
|
69
|
+
): SwapMarket | null {
|
|
70
|
+
const addrA = assetA.address[chainId]
|
|
71
|
+
const addrB = assetB.address[chainId]
|
|
72
|
+
if (!addrA || addrA === 'native' || !addrB || addrB === 'native') return null
|
|
73
|
+
|
|
74
|
+
const [sortedA, sortedB] =
|
|
75
|
+
addrA.toLowerCase() < addrB.toLowerCase() ? [addrA, addrB] : [addrB, addrA]
|
|
76
|
+
|
|
77
|
+
let poolId: string
|
|
78
|
+
if (poolConfig.type === 'cl') {
|
|
79
|
+
const tickBytes =
|
|
80
|
+
`0x${(poolConfig.tickSpacing & 0xffffff).toString(16).padStart(6, '0')}` as `0x${string}`
|
|
81
|
+
poolId = keccak256(
|
|
82
|
+
concat([sortedA as Address, sortedB as Address, tickBytes]),
|
|
83
|
+
)
|
|
84
|
+
} else {
|
|
85
|
+
poolId = keccak256(
|
|
86
|
+
concat([
|
|
87
|
+
sortedA as Address,
|
|
88
|
+
sortedB as Address,
|
|
89
|
+
poolConfig.stable ? '0x01' : '0x00',
|
|
90
|
+
]),
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
marketId: { poolId, chainId },
|
|
96
|
+
assets: [assetA, assetB],
|
|
97
|
+
fee: 0,
|
|
98
|
+
provider: VELODROME,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SwapMarketConfig,
|
|
3
|
+
SwapProviderConfig,
|
|
4
|
+
} from '@/types/swap/index.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Velodrome/Aerodrome market config.
|
|
8
|
+
* Exactly one of `stable` (v2 AMM) or `tickSpacing` (CL/Slipstream) must be set.
|
|
9
|
+
*/
|
|
10
|
+
export interface VelodromeMarketConfig extends SwapMarketConfig {
|
|
11
|
+
/** true = stable pool (correlated assets), false = volatile pool. For v2 AMM pools. */
|
|
12
|
+
stable?: boolean
|
|
13
|
+
/** Tick spacing for CL/Slipstream pools. Mutually exclusive with stable. */
|
|
14
|
+
tickSpacing?: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Resolved v2 AMM pool config */
|
|
18
|
+
export type ResolvedV2Config = { type: 'v2'; stable: boolean }
|
|
19
|
+
/** Resolved CL/Slipstream pool config */
|
|
20
|
+
export type ResolvedCLConfig = { type: 'cl'; tickSpacing: number }
|
|
21
|
+
/** Discriminated union of resolved pool configs */
|
|
22
|
+
export type ResolvedPoolConfig = ResolvedV2Config | ResolvedCLConfig
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Velodrome/Aerodrome swap provider configuration
|
|
26
|
+
*/
|
|
27
|
+
export interface VelodromeSwapProviderConfig extends SwapProviderConfig {
|
|
28
|
+
marketAllowlist?: VelodromeMarketConfig[]
|
|
29
|
+
marketBlocklist?: VelodromeMarketConfig[]
|
|
30
|
+
}
|
package/src/types/actions.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { UniswapSwapProviderConfig } from '@/swap/providers/uniswap/types.js'
|
|
2
|
+
import type { VelodromeSwapProviderConfig } from '@/swap/providers/velodrome/types.js'
|
|
2
3
|
import type { Asset } from '@/types/asset.js'
|
|
3
4
|
import type { ChainConfig } from '@/types/chain.js'
|
|
4
5
|
import type { LendProviderConfig } from '@/types/lend/index.js'
|
|
6
|
+
import type { LendProviders, SwapProviders } from '@/types/providers.js'
|
|
5
7
|
import type { SwapProviderConfig } from '@/types/swap/index.js'
|
|
6
8
|
import type { ProviderSpec } from '@/wallet/core/providers/hosted/types/index.js'
|
|
7
9
|
|
|
8
10
|
// Re-export provider configs for convenience
|
|
9
11
|
export type { LendProviderConfig, SwapProviderConfig }
|
|
12
|
+
// Re-export centralized provider maps
|
|
13
|
+
export type { LendProviders, SwapProviders } from '@/types/providers.js'
|
|
10
14
|
|
|
11
15
|
/** Require at least one property to be defined */
|
|
12
16
|
type RequireAtLeastOne<T> = {
|
|
@@ -17,19 +21,54 @@ type RequireAtLeastOne<T> = {
|
|
|
17
21
|
* Lending configuration — at least one provider must be configured
|
|
18
22
|
*/
|
|
19
23
|
export type LendConfig = RequireAtLeastOne<{
|
|
20
|
-
|
|
21
|
-
morpho?: LendProviderConfig
|
|
22
|
-
/** Aave lending provider configuration */
|
|
23
|
-
aave?: LendProviderConfig
|
|
24
|
+
[K in keyof LendProviders]: LendProviderConfig
|
|
24
25
|
}>
|
|
25
26
|
|
|
27
|
+
/** Names of available swap providers — derived from SwapProviders registry */
|
|
28
|
+
export type SwapProviderName = keyof SwapProviders
|
|
29
|
+
|
|
30
|
+
/** Names of available lend providers — derived from LendProviders registry */
|
|
31
|
+
export type LendProviderName = keyof LendProviders
|
|
32
|
+
|
|
33
|
+
/** Routing strategy for selecting a provider when multiple are configured. */
|
|
34
|
+
export type SwapRoutingStrategy = 'price'
|
|
35
|
+
|
|
26
36
|
/**
|
|
27
|
-
*
|
|
37
|
+
* Shared swap settings applied across all providers.
|
|
38
|
+
* Provider-level values override these when set.
|
|
39
|
+
*/
|
|
40
|
+
export interface SwapSettings {
|
|
41
|
+
/** Default slippage tolerance (e.g., 0.005 for 0.5%). Defaults to 0.005. */
|
|
42
|
+
defaultSlippage?: number
|
|
43
|
+
/** Maximum allowed slippage (e.g., 0.5 for 50%). Defaults to 0.5. */
|
|
44
|
+
maxSlippage?: number
|
|
45
|
+
/** Quote expiration in seconds from now. Defaults to 60. */
|
|
46
|
+
quoteExpirationSeconds?: number
|
|
47
|
+
/** Permit2 sub-approval expiration in seconds from now. Defaults to 2592000 (30 days). */
|
|
48
|
+
permit2ExpirationSeconds?: number
|
|
49
|
+
/**
|
|
50
|
+
* Routing strategy for multi-provider selection.
|
|
51
|
+
* 'price' fetches quotes from all eligible providers and returns the best price.
|
|
52
|
+
* Omit to fall back to market-matching heuristics.
|
|
53
|
+
*/
|
|
54
|
+
routing?: SwapRoutingStrategy
|
|
55
|
+
/** Provider to prefer when routing produces a tie, or to always use when no routing strategy is set. */
|
|
56
|
+
defaultProvider?: SwapProviderName
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Swap configuration — at least one provider must be configured.
|
|
61
|
+
* Shared settings go in `config`; per-provider settings go under the provider key.
|
|
28
62
|
*/
|
|
29
63
|
export type SwapConfig = RequireAtLeastOne<{
|
|
30
64
|
/** Uniswap swap provider configuration */
|
|
31
65
|
uniswap?: UniswapSwapProviderConfig
|
|
32
|
-
|
|
66
|
+
/** Velodrome/Aerodrome swap provider configuration */
|
|
67
|
+
velodrome?: VelodromeSwapProviderConfig
|
|
68
|
+
}> & {
|
|
69
|
+
/** Shared settings applied across all providers */
|
|
70
|
+
settings?: SwapSettings
|
|
71
|
+
}
|
|
33
72
|
|
|
34
73
|
/**
|
|
35
74
|
* Network configuration for lending providers
|
|
@@ -42,12 +81,13 @@ export interface LendNetworkConfig {
|
|
|
42
81
|
|
|
43
82
|
/**
|
|
44
83
|
* Assets configuration
|
|
45
|
-
* @description Configuration for supported assets
|
|
84
|
+
* @description Configuration for supported assets. Import token constants from the SDK
|
|
85
|
+
* or define your own Asset objects.
|
|
46
86
|
*/
|
|
47
87
|
export interface AssetsConfig {
|
|
48
|
-
/** Allowlist of assets to support
|
|
88
|
+
/** Allowlist of assets to support. No default — developers must explicitly configure. */
|
|
49
89
|
allow?: Asset[]
|
|
50
|
-
/** Blocklist of assets to exclude
|
|
90
|
+
/** Blocklist of assets to exclude from the allow list. Only effective when allow is also set. For future use with runtime asset fetching. */
|
|
51
91
|
block?: Asset[]
|
|
52
92
|
}
|
|
53
93
|
|
package/src/types/asset.ts
CHANGED
|
@@ -22,13 +22,16 @@ export interface Asset {
|
|
|
22
22
|
* Detailed token balance information
|
|
23
23
|
*/
|
|
24
24
|
export interface TokenBalance {
|
|
25
|
-
|
|
26
|
-
totalBalance:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
asset: Asset
|
|
26
|
+
totalBalance: number
|
|
27
|
+
totalBalanceRaw: bigint
|
|
28
|
+
chains: Partial<
|
|
29
|
+
Record<
|
|
30
|
+
SupportedChainId,
|
|
31
|
+
{
|
|
32
|
+
balance: number
|
|
33
|
+
balanceRaw: bigint
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
>
|
|
34
37
|
}
|
package/src/types/chain.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Chain configuration
|
|
@@ -6,7 +6,7 @@ import type { SUPPORTED_CHAIN_IDS } from '@/constants/supportedChains.js'
|
|
|
6
6
|
*/
|
|
7
7
|
export interface ChainConfig {
|
|
8
8
|
/** Chain ID */
|
|
9
|
-
chainId:
|
|
9
|
+
chainId: SupportedChainId
|
|
10
10
|
/** RPC URL for the chain */
|
|
11
11
|
rpcUrls?: string[]
|
|
12
12
|
/** Bundler configuration */
|
package/src/types/lend/base.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Address } from 'viem'
|
|
2
2
|
|
|
3
3
|
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
4
|
+
import type { LendProviderName } from '@/types/actions.js'
|
|
4
5
|
import type { Asset } from '@/types/asset.js'
|
|
5
6
|
// Import and re-export shared transaction type for backwards compatibility
|
|
6
7
|
import type { TransactionData } from '@/types/transaction.js'
|
|
@@ -33,7 +34,7 @@ export type LendMarketConfigMetadata = {
|
|
|
33
34
|
/** Asset information for this market */
|
|
34
35
|
asset: Asset
|
|
35
36
|
/** Lending provider type */
|
|
36
|
-
lendProvider:
|
|
37
|
+
lendProvider: LendProviderName
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -135,7 +136,8 @@ export interface LendMarketInfo extends LendMarketBase {
|
|
|
135
136
|
|
|
136
137
|
/**
|
|
137
138
|
* APY breakdown for detailed display
|
|
138
|
-
* @description Breakdown of APY components following Morpho's official methodology
|
|
139
|
+
* @description Breakdown of APY components following Morpho's official methodology.
|
|
140
|
+
* Individual token reward APRs are keyed by lowercase token address.
|
|
139
141
|
*/
|
|
140
142
|
export interface ApyBreakdown {
|
|
141
143
|
/** Total net APY after all components and fees */
|
|
@@ -144,12 +146,10 @@ export interface ApyBreakdown {
|
|
|
144
146
|
native: number
|
|
145
147
|
/** Total rewards APR from all sources */
|
|
146
148
|
totalRewards: number
|
|
147
|
-
/** Individual token rewards APRs (dynamically populated) */
|
|
148
|
-
usdc?: number
|
|
149
|
-
morpho?: number
|
|
150
|
-
other?: number
|
|
151
149
|
/** Performance/management fee rate */
|
|
152
150
|
performanceFee: number
|
|
151
|
+
/** Individual token reward APRs keyed by address, plus 'other' for unrecognized */
|
|
152
|
+
[key: string]: number | undefined
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Address } from 'viem'
|
|
2
2
|
|
|
3
|
+
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Morpho contract addresses needed per chain
|
|
5
7
|
*/
|
|
@@ -15,4 +17,6 @@ export interface MorphoContracts {
|
|
|
15
17
|
/**
|
|
16
18
|
* Registry mapping chainId to Morpho contracts
|
|
17
19
|
*/
|
|
18
|
-
export type MorphoContractsRegistry =
|
|
20
|
+
export type MorphoContractsRegistry = Partial<
|
|
21
|
+
Record<SupportedChainId, MorphoContracts>
|
|
22
|
+
>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LendProvider } from '@/lend/core/LendProvider.js'
|
|
2
|
+
import type { SwapProvider } from '@/swap/core/SwapProvider.js'
|
|
3
|
+
import type { LendProviderConfig } from '@/types/lend/index.js'
|
|
4
|
+
import type { SwapProviderConfig } from '@/types/swap/index.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Map of available lend providers keyed by provider name.
|
|
8
|
+
* Add new lend providers here — this is the single source of truth.
|
|
9
|
+
*/
|
|
10
|
+
export type LendProviders = {
|
|
11
|
+
morpho?: LendProvider<LendProviderConfig>
|
|
12
|
+
aave?: LendProvider<LendProviderConfig>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Map of available swap providers keyed by provider name.
|
|
17
|
+
* Add new swap providers here — this is the single source of truth.
|
|
18
|
+
*/
|
|
19
|
+
export type SwapProviders = {
|
|
20
|
+
uniswap?: SwapProvider<SwapProviderConfig>
|
|
21
|
+
velodrome?: SwapProvider<SwapProviderConfig>
|
|
22
|
+
}
|
package/src/types/swap/base.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Address } from 'viem'
|
|
1
|
+
import type { Address, Hex } from 'viem'
|
|
2
2
|
|
|
3
3
|
import type { SupportedChainId } from '@/constants/supportedChains.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type { SwapProviderName } from '@/types/actions.js'
|
|
5
5
|
import type { Asset } from '@/types/asset.js'
|
|
6
6
|
import type { TransactionData } from '@/types/transaction.js'
|
|
7
7
|
import type {
|
|
@@ -12,23 +12,19 @@ import type {
|
|
|
12
12
|
export { SwapProvider } from '@/swap/core/SwapProvider.js'
|
|
13
13
|
export { ActionsSwapNamespace } from '@/swap/namespaces/ActionsSwapNamespace.js'
|
|
14
14
|
export { WalletSwapNamespace } from '@/swap/namespaces/WalletSwapNamespace.js'
|
|
15
|
+
export type { SwapProviders } from '@/types/providers.js'
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
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)
|
|
18
|
+
* Per-provider swap configuration.
|
|
19
|
+
* Provider-level values override the shared SwapGlobalConfig defaults.
|
|
26
20
|
*/
|
|
27
21
|
export interface SwapProviderConfig {
|
|
28
|
-
/**
|
|
22
|
+
/** Slippage tolerance override for this provider (e.g., 0.005 for 0.5%) */
|
|
29
23
|
defaultSlippage?: number
|
|
30
|
-
/** Maximum allowed slippage (e.g., 0.5 for 50%)
|
|
24
|
+
/** Maximum allowed slippage override for this provider (e.g., 0.5 for 50%) */
|
|
31
25
|
maxSlippage?: number
|
|
26
|
+
/** Quote expiration override for this provider, in seconds from now */
|
|
27
|
+
quoteExpirationSeconds?: number
|
|
32
28
|
/** Allowlist of swap markets (optional - defaults to all supported assets) */
|
|
33
29
|
marketAllowlist?: SwapMarketConfig[]
|
|
34
30
|
/** Blocklist of swap markets to exclude */
|
|
@@ -94,6 +90,8 @@ export interface WalletSwapParams {
|
|
|
94
90
|
deadline?: number
|
|
95
91
|
/** Recipient address. Defaults to wallet address. */
|
|
96
92
|
recipient?: Address
|
|
93
|
+
/** Explicitly select a swap provider. Overrides routing config. */
|
|
94
|
+
provider?: SwapProviderName
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
/**
|
|
@@ -105,12 +103,12 @@ export interface SwapExecuteParams extends WalletSwapParams {
|
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
/**
|
|
108
|
-
* Fully resolved swap parameters with defaults applied and amounts
|
|
106
|
+
* Fully resolved swap parameters with defaults applied and amounts as raw bigint.
|
|
109
107
|
* Passed to provider _execute() implementations.
|
|
110
108
|
*/
|
|
111
109
|
export interface ResolvedSwapParams {
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
amountInRaw?: bigint
|
|
111
|
+
amountOutRaw?: bigint
|
|
114
112
|
assetIn: Asset
|
|
115
113
|
assetOut: Asset
|
|
116
114
|
slippage: number
|
|
@@ -136,6 +134,121 @@ export interface SwapPriceParams {
|
|
|
136
134
|
amountOut?: number
|
|
137
135
|
/** Chain to get price on */
|
|
138
136
|
chainId: SupportedChainId
|
|
137
|
+
/** Explicitly select a swap provider. Overrides routing config. */
|
|
138
|
+
provider?: SwapProviderName
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Parameters for getting a swap quote with pre-built execution data.
|
|
143
|
+
*/
|
|
144
|
+
export interface SwapQuoteParams {
|
|
145
|
+
/** Token to sell */
|
|
146
|
+
assetIn: Asset
|
|
147
|
+
/** Token to buy (required) */
|
|
148
|
+
assetOut: Asset
|
|
149
|
+
/** Amount of input token (human-readable). Mutually exclusive with amountOut. */
|
|
150
|
+
amountIn?: number
|
|
151
|
+
/** Amount of output token (human-readable). Mutually exclusive with amountIn. */
|
|
152
|
+
amountOut?: number
|
|
153
|
+
/** Chain to execute swap on */
|
|
154
|
+
chainId: SupportedChainId
|
|
155
|
+
/** Slippage tolerance baked into the quote */
|
|
156
|
+
slippage?: number
|
|
157
|
+
/** Transaction deadline as Unix timestamp */
|
|
158
|
+
deadline?: number
|
|
159
|
+
/** Recipient address */
|
|
160
|
+
recipient?: Address
|
|
161
|
+
/** Explicitly select a swap provider */
|
|
162
|
+
provider?: SwapProviderName
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Pre-built execution data from a quote, ready to submit on-chain.
|
|
167
|
+
*/
|
|
168
|
+
export interface SwapQuoteExecution {
|
|
169
|
+
/** Encoded swap calldata */
|
|
170
|
+
swapCalldata: Hex
|
|
171
|
+
/** Router/contract to send the swap transaction to */
|
|
172
|
+
routerAddress: Address
|
|
173
|
+
/** Native ETH value for ETH-in swaps, else 0n */
|
|
174
|
+
value: bigint
|
|
175
|
+
/** Opaque provider-specific context (e.g. stable flag, factory address) */
|
|
176
|
+
providerContext?: Record<string, unknown>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A complete swap quote: pricing, amounts, and pre-built execution data.
|
|
181
|
+
* Pass to execute() to skip re-quoting.
|
|
182
|
+
*
|
|
183
|
+
* **Precision note:** `Raw` fields (bigint) are the on-chain source of truth.
|
|
184
|
+
* Number fields (`amountIn`, `amountOut`, `price`, etc.) are display approximations
|
|
185
|
+
* derived via `formatUnits` → `parseFloat`. For tokens with many significant digits,
|
|
186
|
+
* numbers may lose precision. Use `Raw` fields for any math that matters.
|
|
187
|
+
*/
|
|
188
|
+
export interface SwapQuote {
|
|
189
|
+
// ── What you're swapping ──
|
|
190
|
+
/** Token being sold */
|
|
191
|
+
assetIn: Asset
|
|
192
|
+
/** Token being bought */
|
|
193
|
+
assetOut: Asset
|
|
194
|
+
/** Chain to execute on */
|
|
195
|
+
chainId: SupportedChainId
|
|
196
|
+
|
|
197
|
+
// ── Amounts (Raw = on-chain precision, number = display approximation) ──
|
|
198
|
+
/** Human-readable input amount (display only — use amountInRaw for precision) */
|
|
199
|
+
amountIn: number
|
|
200
|
+
/** Input amount as raw bigint (native decimals). Source of truth. */
|
|
201
|
+
amountInRaw: bigint
|
|
202
|
+
/** Human-readable expected output (display only — use amountOutRaw for precision) */
|
|
203
|
+
amountOut: number
|
|
204
|
+
/** Expected output as raw bigint. Source of truth. */
|
|
205
|
+
amountOutRaw: bigint
|
|
206
|
+
/** Human-readable minimum output after slippage (display only) */
|
|
207
|
+
amountOutMin: number
|
|
208
|
+
/** Minimum output as raw bigint after slippage. Source of truth for on-chain execution. */
|
|
209
|
+
amountOutMinRaw: bigint
|
|
210
|
+
|
|
211
|
+
// ── Price (display approximations derived from number amounts) ──
|
|
212
|
+
/** Exchange rate: amountOut / amountIn. Display approximation. */
|
|
213
|
+
price: number
|
|
214
|
+
/** Inverse exchange rate: amountIn / amountOut. Display approximation. */
|
|
215
|
+
priceInverse: number
|
|
216
|
+
/** Price impact as decimal (0.03 = 3%) */
|
|
217
|
+
priceImpact: number
|
|
218
|
+
|
|
219
|
+
// ── Route ──
|
|
220
|
+
/** Route taken for the swap */
|
|
221
|
+
route: SwapRoute
|
|
222
|
+
|
|
223
|
+
// ── Execution ──
|
|
224
|
+
/** Pre-built transaction data. Pass quote to execute() to use. */
|
|
225
|
+
execution: SwapQuoteExecution
|
|
226
|
+
|
|
227
|
+
// ── Metadata ──
|
|
228
|
+
/** Provider that generated this quote */
|
|
229
|
+
provider: SwapProviderName
|
|
230
|
+
/** Slippage tolerance applied to this quote */
|
|
231
|
+
slippage: number
|
|
232
|
+
/** Transaction deadline (Unix seconds) */
|
|
233
|
+
deadline: number
|
|
234
|
+
/** When the quote was generated (Unix seconds) */
|
|
235
|
+
quotedAt: number
|
|
236
|
+
/** When the quote expires (Unix seconds) */
|
|
237
|
+
expiresAt: number
|
|
238
|
+
/** Estimated gas cost as raw bigint (native decimals) */
|
|
239
|
+
gasEstimate?: bigint
|
|
240
|
+
/**
|
|
241
|
+
* Wallet address that will execute this quote.
|
|
242
|
+
* Set by WalletSwapNamespace before execution — not available on price-only quotes.
|
|
243
|
+
* Used to check existing on-chain allowances and skip redundant approvals.
|
|
244
|
+
*/
|
|
245
|
+
recipient?: Address
|
|
246
|
+
/**
|
|
247
|
+
* The recipient address baked into execution.swapCalldata at quote time.
|
|
248
|
+
* If recipient differs from quotedRecipient at execute time, calldata is re-encoded
|
|
249
|
+
* with the correct recipient to prevent tokens from being sent to the wrong address.
|
|
250
|
+
*/
|
|
251
|
+
quotedRecipient: Address
|
|
139
252
|
}
|
|
140
253
|
|
|
141
254
|
/**
|
|
@@ -172,15 +285,15 @@ export interface SwapPrice {
|
|
|
172
285
|
amountIn: number
|
|
173
286
|
/** Human-readable output amount */
|
|
174
287
|
amountOut: number
|
|
175
|
-
/** Input amount
|
|
176
|
-
|
|
177
|
-
/** Expected output amount
|
|
178
|
-
|
|
288
|
+
/** Input amount as raw bigint (native decimals) */
|
|
289
|
+
amountInRaw: bigint
|
|
290
|
+
/** Expected output amount as raw bigint (native decimals) */
|
|
291
|
+
amountOutRaw: bigint
|
|
179
292
|
/** Price impact as decimal (0.03 = 3%). Derived from pool mid-price vs execution price. */
|
|
180
293
|
priceImpact: number
|
|
181
294
|
/** Route taken for the swap */
|
|
182
295
|
route: SwapRoute
|
|
183
|
-
/** Estimated gas cost
|
|
296
|
+
/** Estimated gas cost as raw bigint (native decimals) */
|
|
184
297
|
gasEstimate?: bigint
|
|
185
298
|
}
|
|
186
299
|
|
|
@@ -204,16 +317,16 @@ export interface SwapTransaction {
|
|
|
204
317
|
amountIn: number
|
|
205
318
|
/** Human-readable output amount */
|
|
206
319
|
amountOut: number
|
|
207
|
-
/** Input amount
|
|
208
|
-
|
|
209
|
-
/** Output amount
|
|
210
|
-
|
|
320
|
+
/** Input amount as raw bigint (native decimals) */
|
|
321
|
+
amountInRaw: bigint
|
|
322
|
+
/** Output amount as raw bigint (native decimals) (expected) */
|
|
323
|
+
amountOutRaw: bigint
|
|
211
324
|
/** Input asset */
|
|
212
325
|
assetIn: Asset
|
|
213
326
|
/** Output asset */
|
|
214
327
|
assetOut: Asset
|
|
215
|
-
/**
|
|
216
|
-
price:
|
|
328
|
+
/** Exchange rate: amountOut / amountIn */
|
|
329
|
+
price: number
|
|
217
330
|
/** Price impact as decimal (0.03 = 3%) */
|
|
218
331
|
priceImpact: number
|
|
219
332
|
/** Transaction data for execution */
|
|
@@ -230,16 +343,16 @@ export interface SwapReceipt {
|
|
|
230
343
|
amountIn: number
|
|
231
344
|
/** Human-readable output amount */
|
|
232
345
|
amountOut: number
|
|
233
|
-
/** Actual input amount
|
|
234
|
-
|
|
235
|
-
/** Actual output amount
|
|
236
|
-
|
|
346
|
+
/** Actual input amount as raw bigint (native decimals) */
|
|
347
|
+
amountInRaw: bigint
|
|
348
|
+
/** Actual output amount as raw bigint (native decimals) */
|
|
349
|
+
amountOutRaw: bigint
|
|
237
350
|
/** Input asset */
|
|
238
351
|
assetIn: Asset
|
|
239
352
|
/** Output asset */
|
|
240
353
|
assetOut: Asset
|
|
241
|
-
/**
|
|
242
|
-
price:
|
|
354
|
+
/** Exchange rate: amountOut / amountIn */
|
|
355
|
+
price: number
|
|
243
356
|
/** Price impact as decimal (0.03 = 3%) */
|
|
244
357
|
priceImpact: number
|
|
245
358
|
}
|
|
@@ -255,5 +368,5 @@ export interface SwapMarket {
|
|
|
255
368
|
/** Fee tier in pips (500 = 0.05%) */
|
|
256
369
|
fee: number
|
|
257
370
|
/** Provider name */
|
|
258
|
-
provider:
|
|
371
|
+
provider: SwapProviderName
|
|
259
372
|
}
|