@elizaos/plugin-wallet 2.0.0-beta.1 → 2.0.3-beta.6
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/README.md +70 -45
- package/auto-enable.ts +1 -1
- package/dist/actions/failure-codes.d.ts +12 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/analytics/birdeye/actions/wallet-search-address.d.ts +7 -0
- package/dist/analytics/birdeye/birdeye-task.d.ts +27 -0
- package/dist/analytics/birdeye/birdeye.d.ts +140 -0
- package/dist/analytics/birdeye/constants.d.ts +68 -0
- package/dist/analytics/birdeye/providers/agent-portfolio-provider.d.ts +8 -0
- package/dist/analytics/birdeye/providers/market.d.ts +18 -0
- package/dist/analytics/birdeye/providers/portfolio-factory.d.ts +10 -0
- package/dist/analytics/birdeye/providers/trending.d.ts +19 -0
- package/dist/analytics/birdeye/providers/wallet.d.ts +5 -0
- package/dist/analytics/birdeye/search-category.d.ts +52 -0
- package/dist/analytics/birdeye/service.d.ts +94 -0
- package/dist/analytics/birdeye/types/api/common.d.ts +199 -0
- package/dist/analytics/birdeye/types/api/defi.d.ts +187 -0
- package/dist/analytics/birdeye/types/api/pair.d.ts +182 -0
- package/dist/analytics/birdeye/types/api/search.d.ts +64 -0
- package/dist/analytics/birdeye/types/api/token.d.ts +580 -0
- package/dist/analytics/birdeye/types/api/trader.d.ts +70 -0
- package/dist/analytics/birdeye/types/api/wallet.d.ts +161 -0
- package/dist/analytics/birdeye/types/shared.d.ts +83 -0
- package/dist/analytics/birdeye/utils.d.ts +74 -0
- package/dist/analytics/dexscreener/errors.d.ts +2 -0
- package/dist/analytics/dexscreener/index.d.ts +3 -0
- package/dist/analytics/dexscreener/search-category.d.ts +3 -0
- package/dist/analytics/dexscreener/service.d.ts +34 -0
- package/dist/analytics/dexscreener/types.d.ts +131 -0
- package/dist/analytics/lpinfo/index.d.ts +31 -0
- package/dist/analytics/lpinfo/kamino/index.d.ts +7 -0
- package/dist/analytics/lpinfo/kamino/providers/kaminoLiquidityProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/kamino/providers/kaminoPoolProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/kamino/providers/kaminoProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/kamino/services/kaminoLiquidityService.d.ts +203 -0
- package/dist/analytics/lpinfo/kamino/services/kaminoService.d.ts +171 -0
- package/dist/analytics/lpinfo/steer/index.d.ts +7 -0
- package/dist/analytics/lpinfo/steer/providers/steerLiquidityProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/steer/services/steerLiquidityService.d.ts +208 -0
- package/dist/analytics/lpinfo/steer/steer-display-types.d.ts +97 -0
- package/dist/analytics/news/index.d.ts +32 -0
- package/dist/analytics/news/interfaces/types.d.ts +177 -0
- package/dist/analytics/news/providers/defiNewsProvider.d.ts +106 -0
- package/dist/analytics/news/services/newsDataService.d.ts +72 -0
- package/dist/analytics/news/utils/formatters.d.ts +54 -0
- package/dist/analytics/token-info/action.d.ts +6 -0
- package/dist/analytics/token-info/index.d.ts +3 -0
- package/dist/analytics/token-info/params.d.ts +10 -0
- package/dist/analytics/token-info/providers.d.ts +4 -0
- package/dist/analytics/token-info/service.d.ts +19 -0
- package/dist/analytics/token-info/types.d.ts +45 -0
- package/dist/api/wallet-routes.d.ts +100 -0
- package/dist/audit/audit-log.d.ts +29 -0
- package/dist/browser-shim/build-shim.d.ts +31 -0
- package/dist/browser-shim/index.d.ts +1 -0
- package/dist/chains/evm/actions/helpers.d.ts +31 -0
- package/dist/chains/evm/actions/swap.d.ts +53 -0
- package/dist/chains/evm/actions/transfer.d.ts +10 -0
- package/dist/chains/evm/bridge-router.d.ts +44 -0
- package/dist/chains/evm/build.d.ts +2 -0
- package/dist/chains/evm/chain-handler.d.ts +37 -0
- package/dist/chains/evm/constants.d.ts +16 -0
- package/dist/chains/evm/dex/aerodrome/index.d.ts +6 -0
- package/dist/chains/evm/dex/aerodrome/services/AerodromeLpService.d.ts +27 -0
- package/dist/chains/evm/dex/aerodrome/types.d.ts +435 -0
- package/dist/chains/evm/dex/pancakeswp/index.d.ts +6 -0
- package/dist/chains/evm/dex/pancakeswp/services/PancakeSwapV3LpService.d.ts +28 -0
- package/dist/chains/evm/dex/pancakeswp/types.d.ts +19 -0
- package/dist/chains/evm/dex/uniswap/index.d.ts +6 -0
- package/dist/chains/evm/dex/uniswap/services/UniswapV3LpService.d.ts +28 -0
- package/dist/chains/evm/dex/uniswap/types.d.ts +458 -0
- package/dist/chains/evm/generated/specs/spec-helpers.d.ts +35 -0
- package/dist/chains/evm/generated/specs/specs.d.ts +99 -0
- package/dist/chains/evm/gov-router.d.ts +6 -0
- package/dist/chains/evm/index.browser.d.ts +3 -0
- package/dist/chains/evm/index.d.ts +6 -0
- package/dist/chains/evm/prompts.d.ts +24 -0
- package/dist/chains/evm/providers/get-balance.d.ts +2 -0
- package/dist/chains/evm/providers/wallet.d.ts +35 -0
- package/dist/chains/evm/routes/sign.d.ts +13 -0
- package/dist/chains/evm/rpc-providers.d.ts +26 -0
- package/dist/chains/evm/service.d.ts +26 -0
- package/dist/chains/evm/templates/index.d.ts +1 -0
- package/dist/chains/evm/types/index.d.ts +296 -0
- package/dist/chains/evm/vitest.config.d.ts +2 -0
- package/dist/chains/registry.d.ts +3 -0
- package/dist/chains/solana/actions/confirmation.d.ts +9 -0
- package/dist/chains/solana/bn.d.ts +6 -0
- package/dist/chains/solana/build.d.ts +2 -0
- package/dist/chains/solana/constants.d.ts +2 -0
- package/dist/chains/solana/dex/meteora/e2e/scenarios.d.ts +10 -0
- package/dist/chains/solana/dex/meteora/e2e/test-utils.d.ts +28 -0
- package/dist/chains/solana/dex/meteora/index.d.ts +3 -0
- package/dist/chains/solana/dex/meteora/providers/positionProvider.d.ts +9 -0
- package/dist/chains/solana/dex/meteora/services/MeteoraLpService.d.ts +37 -0
- package/dist/chains/solana/dex/meteora/utils/dlmm.d.ts +6 -0
- package/dist/chains/solana/dex/meteora/utils/loadWallet.d.ts +14 -0
- package/dist/chains/solana/dex/meteora/utils/sendTransaction.d.ts +2 -0
- package/dist/chains/solana/dex/orca/index.d.ts +6 -0
- package/dist/chains/solana/dex/orca/providers/positionProvider.d.ts +10 -0
- package/dist/chains/solana/dex/orca/services/srv_orca.d.ts +10 -0
- package/dist/chains/solana/dex/orca/types.d.ts +61 -0
- package/dist/chains/solana/dex/orca/utils/loadWallet.d.ts +1 -0
- package/dist/chains/solana/dex/orca/utils/sendTransaction.d.ts +2 -0
- package/dist/chains/solana/dex/raydium/index.d.ts +6 -0
- package/dist/chains/solana/dex/raydium/providers/positionProvider.d.ts +10 -0
- package/dist/chains/solana/dex/raydium/services/srv_raydium.d.ts +104 -0
- package/dist/chains/solana/dex/raydium/types.d.ts +42 -0
- package/dist/chains/solana/environment.d.ts +15 -0
- package/dist/chains/solana/generated/specs/spec-helpers.d.ts +35 -0
- package/dist/chains/solana/generated/specs/specs.d.ts +73 -0
- package/dist/chains/solana/index.browser.d.ts +3 -0
- package/dist/chains/solana/index.d.ts +7 -0
- package/dist/chains/solana/keypairUtils.d.ts +7 -0
- package/dist/chains/solana/prompts.d.ts +12 -0
- package/dist/chains/solana/providers/wallet.d.ts +2 -0
- package/dist/chains/solana/routes/index.d.ts +2 -0
- package/dist/chains/solana/routes/sign.d.ts +16 -0
- package/dist/chains/solana/service.d.ts +237 -0
- package/dist/chains/solana/types.d.ts +377 -0
- package/dist/chains/solana/vitest.config.d.ts +2 -0
- package/dist/chains/wallet-action.d.ts +3 -0
- package/dist/contracts.d.ts +58 -0
- package/dist/core-augmentation.d.ts +9 -0
- package/dist/index.d.mts +27 -34727
- package/dist/index.d.ts +27 -0
- package/dist/index.mjs +28246 -21186
- package/dist/index.mjs.map +153 -0
- package/dist/lib/server-wallet-trade.d.ts +22 -0
- package/dist/lib/server-wallet-trade.js +333 -0
- package/dist/lib/server-wallet-trade.js.map +11 -0
- package/dist/lib/wallet-export-guard.d.ts +45 -0
- package/dist/lp/actions/liquidity.d.ts +2 -0
- package/dist/lp/e2e/real-token-tests.d.ts +6 -0
- package/dist/lp/e2e/scenarios.d.ts +9 -0
- package/dist/lp/e2e/test-utils.d.ts +28 -0
- package/dist/lp/lp-manager-entry.d.ts +18 -0
- package/dist/lp/services/ConcentratedLiquidityService.d.ts +32 -0
- package/dist/lp/services/DexInteractionService.d.ts +34 -0
- package/dist/lp/services/LpManagementService.d.ts +116 -0
- package/dist/lp/services/UserLpProfileService.d.ts +18 -0
- package/dist/lp/services/VaultService.d.ts +21 -0
- package/dist/lp/services/YieldOptimizationService.d.ts +59 -0
- package/dist/lp/services/__tests__/MockLpService.d.ts +17 -0
- package/dist/lp/types.d.ts +439 -0
- package/dist/lp/utils/solanaClient.d.ts +26 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/policy/policy.d.ts +14 -0
- package/dist/providers/canonical-provider.d.ts +19 -0
- package/dist/providers/wallet-provider.d.ts +5 -0
- package/dist/register-routes.d.ts +1 -0
- package/dist/routes/plugin.d.ts +14 -0
- package/dist/routes/wallet-market-overview-route.d.ts +7 -0
- package/dist/sdk/abi.d.ts +396 -0
- package/dist/sdk/bridge/abis.d.ts +63 -0
- package/dist/sdk/bridge/client.d.ts +48 -0
- package/dist/sdk/bridge/index.d.ts +14 -0
- package/dist/sdk/bridge/solana.d.ts +131 -0
- package/dist/sdk/bridge/types.d.ts +92 -0
- package/dist/sdk/convenience.d.ts +104 -0
- package/dist/sdk/escrow/MutualStakeEscrow.d.ts +75 -0
- package/dist/sdk/escrow/types.d.ts +58 -0
- package/dist/sdk/escrow/verifiers.d.ts +25 -0
- package/dist/sdk/identity/erc8004.d.ts +304 -0
- package/dist/sdk/identity/reputation.d.ts +317 -0
- package/dist/sdk/identity/uaid.d.ts +192 -0
- package/dist/sdk/identity/validation.d.ts +282 -0
- package/dist/sdk/index.d.ts +133 -0
- package/dist/sdk/index.js +5284 -0
- package/dist/sdk/index.js.map +40 -0
- package/dist/sdk/policy/SpendingPolicy.d.ts +105 -0
- package/dist/sdk/policy/UptoBillingPolicy.d.ts +87 -0
- package/dist/sdk/router/PaymentRouter.d.ts +77 -0
- package/dist/sdk/router/index.d.ts +2 -0
- package/dist/sdk/swap/SwapModule.d.ts +47 -0
- package/dist/sdk/swap/abi.d.ts +50 -0
- package/dist/sdk/swap/index.d.ts +11 -0
- package/dist/sdk/swap/types.d.ts +101 -0
- package/dist/sdk/tokens/decimals.d.ts +64 -0
- package/dist/sdk/tokens/registry.d.ts +81 -0
- package/dist/sdk/tokens/solana.d.ts +107 -0
- package/dist/sdk/tokens/transfers.d.ts +94 -0
- package/dist/sdk/types.d.ts +129 -0
- package/dist/sdk/wallet-core.d.ts +29450 -0
- package/dist/sdk/x402/budget.d.ts +51 -0
- package/dist/sdk/x402/chains/abstract/index.d.ts +134 -0
- package/dist/sdk/x402/client.d.ts +66 -0
- package/dist/sdk/x402/index.d.ts +8 -0
- package/dist/sdk/x402/middleware.d.ts +37 -0
- package/dist/sdk/x402/multi-asset.d.ts +53 -0
- package/dist/sdk/x402/types.d.ts +109 -0
- package/dist/security/wallet-context-safety.d.ts +7 -0
- package/dist/security/wallet-financial-confirmation.d.ts +23 -0
- package/dist/services/wallet-backend-service.d.ts +39 -0
- package/dist/types/wallet-router.d.ts +130 -0
- package/dist/utils/intent-trajectory.d.ts +34 -0
- package/dist/wallet/backend.d.ts +41 -0
- package/dist/wallet/errors.d.ts +17 -0
- package/dist/wallet/index.d.ts +6 -0
- package/dist/wallet/local-eoa-backend.d.ts +37 -0
- package/dist/wallet/pending.d.ts +47 -0
- package/dist/wallet/select-backend.d.ts +11 -0
- package/dist/wallet/steward-backend.d.ts +22 -0
- package/dist/wallet-action.d.ts +1 -0
- package/dist/wallet-action.js +6292 -0
- package/dist/wallet-action.js.map +44 -0
- package/package.json +35 -21
- package/registry-entry.json +134 -0
- package/src/analytics/birdeye/actions/wallet-search-address.ts +85 -5
- package/src/analytics/birdeye/birdeye-task.ts +25 -9
- package/src/analytics/birdeye/birdeye.ts +6 -7
- package/src/analytics/birdeye/constants.ts +0 -1
- package/src/analytics/birdeye/providers/agent-portfolio-provider.ts +0 -1
- package/src/analytics/birdeye/providers/market.ts +51 -45
- package/src/analytics/birdeye/providers/portfolio-factory.ts +79 -38
- package/src/analytics/birdeye/providers/trending.ts +43 -46
- package/src/analytics/birdeye/providers/wallet.ts +0 -1
- package/src/analytics/birdeye/search-category.test.ts +1 -1
- package/src/analytics/birdeye/search-category.ts +77 -12
- package/src/analytics/birdeye/service.test.ts +146 -0
- package/src/analytics/birdeye/service.ts +220 -105
- package/src/analytics/birdeye/types/api/common.ts +0 -1
- package/src/analytics/birdeye/types/api/defi.ts +0 -1
- package/src/analytics/birdeye/types/api/pair.ts +0 -1
- package/src/analytics/birdeye/types/api/search.ts +0 -1
- package/src/analytics/birdeye/types/api/token.ts +0 -1
- package/src/analytics/birdeye/types/api/trader.ts +0 -1
- package/src/analytics/birdeye/types/api/wallet.ts +0 -1
- package/src/analytics/birdeye/types/shared.ts +0 -11
- package/src/analytics/birdeye/utils.test.ts +69 -0
- package/src/analytics/birdeye/utils.ts +11 -8
- package/src/analytics/dexscreener/search-category.ts +0 -1
- package/src/analytics/dexscreener/service.ts +7 -12
- package/src/analytics/dexscreener/types.ts +0 -1
- package/src/analytics/lpinfo/index.ts +5 -2
- package/src/analytics/lpinfo/kamino/README.md +2 -2
- package/src/analytics/lpinfo/kamino/index.ts +9 -2
- package/src/analytics/lpinfo/kamino/providers/kaminoLiquidityProvider.ts +6 -26
- package/src/analytics/lpinfo/kamino/providers/kaminoPoolProvider.ts +11 -12
- package/src/analytics/lpinfo/kamino/providers/kaminoProvider.ts +76 -32
- package/src/analytics/lpinfo/kamino/services/kaminoLiquidityService.ts +78 -38
- package/src/analytics/lpinfo/kamino/services/kaminoService.ts +71 -31
- package/src/analytics/lpinfo/steer/index.ts +7 -2
- package/src/analytics/lpinfo/steer/providers/steerLiquidityProvider.ts +25 -26
- package/src/analytics/lpinfo/steer/services/steerLiquidityService.ts +367 -149
- package/src/analytics/news/index.ts +7 -2
- package/src/analytics/news/interfaces/types.ts +0 -1
- package/src/analytics/news/providers/defiNewsProvider.ts +17 -44
- package/src/analytics/news/services/newsDataService.ts +1 -22
- package/src/analytics/news/utils/formatters.test.ts +60 -0
- package/src/analytics/news/utils/formatters.ts +0 -1
- package/src/analytics/token-info/action.ts +52 -212
- package/src/analytics/token-info/index.ts +1 -1
- package/src/analytics/token-info/params.test.ts +69 -0
- package/src/analytics/token-info/params.ts +13 -11
- package/src/analytics/token-info/providers.ts +46 -17
- package/src/analytics/token-info/service.ts +3 -3
- package/src/analytics/token-info/types.ts +2 -2
- package/src/api/wallet-routes.test.ts +56 -0
- package/src/api/wallet-routes.ts +1728 -0
- package/src/audit/audit-log.ts +57 -2
- package/src/browser-shim/build-shim.ts +1 -1
- package/src/browser-shim/shim.template.js +107 -117
- package/src/chains/{wallet-router.test.ts → __tests__/wallet-router.test.ts} +57 -10
- package/src/chains/evm/actions/helpers.ts +9 -7
- package/src/chains/evm/actions/swap.ts +176 -22
- package/src/chains/evm/actions/transfer.ts +29 -22
- package/src/chains/evm/biome.json +1 -1
- package/src/chains/evm/build.ts +6 -1
- package/src/chains/evm/constants.ts +19 -0
- package/src/chains/evm/contracts/artifacts/OZGovernor.json +25 -1682
- package/src/chains/evm/dex/aerodrome/index.ts +6 -1
- package/src/chains/evm/dex/aerodrome/services/AerodromeLpService.ts +41 -15
- package/src/chains/evm/dex/aerodrome/types.ts +1 -2
- package/src/chains/evm/dex/pancakeswp/index.ts +6 -1
- package/src/chains/evm/dex/pancakeswp/services/PancakeSwapV3LpService.ts +54 -17
- package/src/chains/evm/dex/pancakeswp/types.ts +1 -2
- package/src/chains/evm/dex/uniswap/index.ts +6 -1
- package/src/chains/evm/dex/uniswap/services/UniswapV3LpService.ts +20 -9
- package/src/chains/evm/dex/uniswap/types.ts +1 -2
- package/src/chains/evm/gov-router.ts +3 -1
- package/src/chains/evm/index.browser.ts +1 -1
- package/src/chains/evm/index.ts +5 -1
- package/src/chains/evm/prompts.ts +5 -0
- package/src/chains/evm/providers/get-balance.ts +1 -1
- package/src/chains/evm/providers/wallet.ts +80 -9
- package/src/chains/evm/routes/sign.ts +35 -26
- package/src/chains/evm/rpc-providers.ts +1 -1
- package/src/chains/evm/types/index.ts +22 -2
- package/src/chains/registry.ts +1 -1
- package/src/chains/wallet-action.ts +301 -91
- package/src/index.ts +9 -5
- package/src/lib/wallet-export-guard.test.ts +233 -0
- package/src/lib/wallet-export-guard.ts +1 -1
- package/src/lp/actions/liquidity.ts +53 -26
- package/src/lp/e2e/real-token-tests.ts +0 -1
- package/src/lp/e2e/scenarios.ts +1 -2
- package/src/lp/e2e/test-utils.ts +20 -7
- package/src/lp/lp-manager-entry.ts +2 -5
- package/src/lp/services/ConcentratedLiquidityService.ts +3 -10
- package/src/lp/services/DexInteractionService.ts +1 -2
- package/src/lp/services/LpManagementService.test.ts +0 -1
- package/src/lp/services/LpManagementService.ts +75 -35
- package/src/lp/services/UserLpProfileService.ts +2 -3
- package/src/lp/services/VaultService.ts +10 -4
- package/src/lp/services/YieldOptimizationService.ts +29 -13
- package/src/lp/services/__tests__/MockLpService.ts +1 -2
- package/src/lp/types.ts +9 -13
- package/src/lp/utils/solanaClient.ts +4 -2
- package/src/plugin.routes.test.ts +24 -0
- package/src/plugin.ts +30 -13
- package/src/providers/canonical-provider.ts +1 -1
- package/src/providers/{unified-wallet-provider.ts → wallet-provider.ts} +3 -3
- package/src/routes/__fixtures__/coingecko-markets.recorded.json +97 -0
- package/src/routes/wallet-market-overview-route.ts +1 -1
- package/src/routes/wallet-market-overview.contract.test.ts +139 -0
- package/src/routes/wallet-market-overview.real.test.ts +83 -0
- package/src/sdk/escrow/MutualStakeEscrow.ts +1 -2
- package/src/sdk/identity/erc8004.ts +1 -1
- package/src/sdk/identity/validation.ts +3 -4
- package/src/sdk/index.ts +2 -2
- package/src/sdk/policy/SpendingPolicy.ts +1 -1
- package/src/sdk/router/PaymentRouter.ts +8 -11
- package/src/sdk/swap/SwapModule.ts +1 -1
- package/src/sdk/tokens/registry.ts +1 -1
- package/src/sdk/x402/middleware.ts +2 -8
- package/src/security/__tests__/wallet-context-safety.test.ts +79 -0
- package/src/security/__tests__/wallet-financial-confirmation.test.ts +88 -0
- package/src/security/wallet-context-safety.ts +128 -0
- package/src/security/wallet-financial-confirmation.ts +150 -0
- package/src/services/wallet-backend-service.ts +15 -1
- package/src/utils/intent-trajectory.ts +2 -2
- package/src/wallet/steward-backend.ts +4 -4
- package/dist/LpManagementService-BWrQ5-cO.mjs +0 -353
- package/dist/MockLpService-D_Apn4Fd.mjs +0 -99
- package/dist/aerodrome-CfnESC32.mjs +0 -890
- package/dist/chunk-hT5z_Zn9.mjs +0 -35
- package/dist/lib/server-wallet-trade.d.mts +0 -34
- package/dist/lib/server-wallet-trade.mjs +0 -306
- package/dist/meteora-BPX39hZo.mjs +0 -22640
- package/dist/orca-Bybp1HXO.mjs +0 -249
- package/dist/pancakeswp-CkEXlXti.mjs +0 -604
- package/dist/plugin-ZO_MTyd0.mjs +0 -529
- package/dist/raydium-rfaM9yEf.mjs +0 -539
- package/dist/sdk/index.d.mts +0 -32492
- package/dist/sdk/index.mjs +0 -6415
- package/dist/types-D5252NZk.mjs +0 -487
- package/dist/uniswap-CReXgXVN.mjs +0 -573
- package/dist/wallet-action.d.mts +0 -6
- package/dist/wallet-action.mjs +0 -820
- package/src/analytics/birdeye/tasks/birdeye.ts +0 -232
- package/src/analytics/lpinfo/index.d.ts +0 -7
- package/src/chains/evm/contracts/artifacts/TimelockController.json +0 -1007
- package/src/chains/evm/contracts/artifacts/VoteToken.json +0 -895
- package/src/lp/tasks/LpAutoRebalanceTask.ts +0 -117
- package/src/lp/tasks/__tests__/LpAutoRebalanceTask.test.ts +0 -370
|
@@ -29,8 +29,12 @@ export function hasEvmPrivateKey(runtime: IAgentRuntime): boolean {
|
|
|
29
29
|
return typeof privateKey === "string" && privateKey.startsWith("0x");
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* LLM-supplied `confirmed` / TOON flags are never trusted (GHSA-rqm7-f4jc-84x3).
|
|
34
|
+
* Use {@link gateWalletFinancialExecution} from `security/wallet-financial-confirmation.ts`.
|
|
35
|
+
*/
|
|
36
|
+
export function isConfirmed(_options?: Record<string, unknown>): boolean {
|
|
37
|
+
return false;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
function toConfirmationValue(value: unknown): ConfirmationValue {
|
|
@@ -71,11 +75,9 @@ export async function confirmationRequired(params: {
|
|
|
71
75
|
}): Promise<ActionResult> {
|
|
72
76
|
const confirmation = {
|
|
73
77
|
actionName: params.actionName,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
confirmed: true,
|
|
78
|
-
},
|
|
78
|
+
parameters: toConfirmationRecord(params.parameters),
|
|
79
|
+
instructions:
|
|
80
|
+
"Reply yes to confirm or no to cancel. Do not set confirmed:true in action parameters.",
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
const content = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { ActionResult, HandlerCallback, IAgentRuntime, Memory, State } from "@elizaos/core";
|
|
2
|
-
import { requireActionSpec } from "../generated/specs/spec-helpers";
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./helpers";
|
|
3
|
+
gateWalletFinancialExecution,
|
|
4
|
+
walletFinancialGateActionResult,
|
|
5
|
+
} from "../../../security/wallet-financial-confirmation.js";
|
|
6
|
+
import { requireActionSpec } from "../generated/specs/spec-helpers";
|
|
7
|
+
import { buildSendTxParams, createEvmActionValidator } from "./helpers";
|
|
9
8
|
|
|
10
9
|
const legacySpec = requireActionSpec("EVM_SWAP");
|
|
11
10
|
const spec = { ...legacySpec, name: "WALLET" };
|
|
@@ -27,6 +26,8 @@ import {
|
|
|
27
26
|
DEFAULT_SLIPPAGE_PERCENT,
|
|
28
27
|
GAS_BUFFER_MULTIPLIER,
|
|
29
28
|
GAS_PRICE_MULTIPLIER,
|
|
29
|
+
KYBERSWAP_CHAIN_MAP,
|
|
30
|
+
KYBERSWAP_NATIVE_SENTINEL,
|
|
30
31
|
NATIVE_TOKEN_ADDRESS,
|
|
31
32
|
TX_CONFIRMATION_TIMEOUT_MS,
|
|
32
33
|
} from "../constants";
|
|
@@ -37,6 +38,8 @@ import {
|
|
|
37
38
|
BebopRouteSchema,
|
|
38
39
|
EVMError,
|
|
39
40
|
EVMErrorCode,
|
|
41
|
+
type KyberSwapRouteData,
|
|
42
|
+
type KyberSwapRouteSummary,
|
|
40
43
|
parseSwapParams,
|
|
41
44
|
type SupportedChain,
|
|
42
45
|
type SwapParams,
|
|
@@ -173,6 +176,9 @@ export class SwapAction {
|
|
|
173
176
|
case "bebop":
|
|
174
177
|
result = await this.executeBebopQuote(quote, resolvedParams);
|
|
175
178
|
break;
|
|
179
|
+
case "kyberswap":
|
|
180
|
+
result = await this.executeKyberSwapQuote(quote, resolvedParams);
|
|
181
|
+
break;
|
|
176
182
|
}
|
|
177
183
|
|
|
178
184
|
if (result) {
|
|
@@ -242,6 +248,7 @@ export class SwapAction {
|
|
|
242
248
|
const quotesPromises: Promise<SwapQuote | undefined>[] = [
|
|
243
249
|
this.getLifiQuote(fromAddress, params, fromTokenDecimals, slippage),
|
|
244
250
|
this.getBebopQuote(fromAddress, params, fromTokenDecimals),
|
|
251
|
+
this.getKyberSwapQuote(fromAddress, params, fromTokenDecimals, slippage),
|
|
245
252
|
];
|
|
246
253
|
|
|
247
254
|
const quotesResults = await Promise.all(quotesPromises);
|
|
@@ -384,6 +391,68 @@ export class SwapAction {
|
|
|
384
391
|
}
|
|
385
392
|
}
|
|
386
393
|
|
|
394
|
+
private async getKyberSwapQuote(
|
|
395
|
+
fromAddress: Address,
|
|
396
|
+
params: SwapParams,
|
|
397
|
+
fromTokenDecimals: number,
|
|
398
|
+
slippage: number
|
|
399
|
+
): Promise<SwapQuote | undefined> {
|
|
400
|
+
try {
|
|
401
|
+
const chainSlug = KYBERSWAP_CHAIN_MAP[params.chain];
|
|
402
|
+
if (!chainSlug) return undefined;
|
|
403
|
+
|
|
404
|
+
const fromToken =
|
|
405
|
+
params.fromToken === NATIVE_TOKEN_ADDRESS ? KYBERSWAP_NATIVE_SENTINEL : params.fromToken;
|
|
406
|
+
const toToken =
|
|
407
|
+
params.toToken === NATIVE_TOKEN_ADDRESS ? KYBERSWAP_NATIVE_SENTINEL : params.toToken;
|
|
408
|
+
const amountIn = parseUnits(params.amount, fromTokenDecimals).toString();
|
|
409
|
+
|
|
410
|
+
const url = new URL(`https://aggregator-api.kyberswap.com/${chainSlug}/api/v1/routes`);
|
|
411
|
+
url.searchParams.set("tokenIn", fromToken);
|
|
412
|
+
url.searchParams.set("tokenOut", toToken);
|
|
413
|
+
url.searchParams.set("amountIn", amountIn);
|
|
414
|
+
url.searchParams.set("gasInclude", "true");
|
|
415
|
+
url.searchParams.set("source", "elizaos");
|
|
416
|
+
|
|
417
|
+
const res = await fetch(url.toString(), {
|
|
418
|
+
headers: { "X-Client-Id": "elizaos", Accept: "application/json" },
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
if (!res.ok) throw new Error(`KyberSwap API error: ${res.status}`);
|
|
422
|
+
|
|
423
|
+
const data = await res.json();
|
|
424
|
+
const routeSummary = data?.data?.routeSummary as KyberSwapRouteSummary | undefined;
|
|
425
|
+
if (!routeSummary?.amountOut) throw new Error("No route found from KyberSwap");
|
|
426
|
+
|
|
427
|
+
const slippageBps = Math.round(slippage * 10000);
|
|
428
|
+
// KyberSwap's quote endpoint returns the expected gross output; the
|
|
429
|
+
// guaranteed minimum is computed client-side by applying the slippage
|
|
430
|
+
// tolerance (same math the build endpoint uses internally).
|
|
431
|
+
const minOut = (BigInt(routeSummary.amountOut) * BigInt(10000 - slippageBps)) / 10000n;
|
|
432
|
+
|
|
433
|
+
return {
|
|
434
|
+
aggregator: "kyberswap",
|
|
435
|
+
minOutputAmount: minOut.toString(),
|
|
436
|
+
swapData: {
|
|
437
|
+
routeSummary,
|
|
438
|
+
routerAddress: data.data.routerAddress,
|
|
439
|
+
chainSlug,
|
|
440
|
+
fromToken,
|
|
441
|
+
toToken,
|
|
442
|
+
amountIn,
|
|
443
|
+
slippageBps,
|
|
444
|
+
fromAddress,
|
|
445
|
+
} satisfies KyberSwapRouteData,
|
|
446
|
+
};
|
|
447
|
+
} catch (error) {
|
|
448
|
+
logger.error(
|
|
449
|
+
"Error in getKyberSwapQuote:",
|
|
450
|
+
error instanceof Error ? error.message : String(error)
|
|
451
|
+
);
|
|
452
|
+
return undefined;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
387
456
|
private async executeLifiQuote(quote: SwapQuote): Promise<Transaction | undefined> {
|
|
388
457
|
const route = quote.swapData as Route;
|
|
389
458
|
const step = route.steps[0];
|
|
@@ -522,6 +591,89 @@ export class SwapAction {
|
|
|
522
591
|
};
|
|
523
592
|
}
|
|
524
593
|
|
|
594
|
+
private async executeKyberSwapQuote(
|
|
595
|
+
quote: SwapQuote,
|
|
596
|
+
params: SwapParams
|
|
597
|
+
): Promise<Transaction | undefined> {
|
|
598
|
+
const ks = quote.swapData as KyberSwapRouteData;
|
|
599
|
+
const walletClient = this.walletProvider.getWalletClient(params.chain);
|
|
600
|
+
const publicClient = this.walletProvider.getPublicClient(params.chain);
|
|
601
|
+
|
|
602
|
+
const account = walletClient.account;
|
|
603
|
+
if (!account) {
|
|
604
|
+
throw new EVMError(EVMErrorCode.WALLET_NOT_INITIALIZED, "Wallet account is not available");
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const buildRes = await fetch(
|
|
608
|
+
`https://aggregator-api.kyberswap.com/${ks.chainSlug}/api/v1/route/build`,
|
|
609
|
+
{
|
|
610
|
+
method: "POST",
|
|
611
|
+
headers: {
|
|
612
|
+
"X-Client-Id": "elizaos",
|
|
613
|
+
"Content-Type": "application/json",
|
|
614
|
+
Accept: "application/json",
|
|
615
|
+
},
|
|
616
|
+
body: JSON.stringify({
|
|
617
|
+
routeSummary: ks.routeSummary,
|
|
618
|
+
sender: account.address,
|
|
619
|
+
recipient: account.address,
|
|
620
|
+
slippageTolerance: ks.slippageBps,
|
|
621
|
+
deadline: Math.floor(Date.now() / 1000) + 1200,
|
|
622
|
+
enableGasEstimation: true,
|
|
623
|
+
source: "elizaos",
|
|
624
|
+
}),
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
if (!buildRes.ok) {
|
|
629
|
+
throw new Error(`KyberSwap build failed: ${buildRes.status} ${buildRes.statusText}`);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const buildData = await buildRes.json();
|
|
633
|
+
const tx = buildData?.data;
|
|
634
|
+
if (!tx?.routerAddress || !tx?.data) {
|
|
635
|
+
throw new Error("Invalid transaction data from KyberSwap build");
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (ks.fromToken.toLowerCase() !== KYBERSWAP_NATIVE_SENTINEL.toLowerCase()) {
|
|
639
|
+
await this.handleTokenApproval(
|
|
640
|
+
publicClient,
|
|
641
|
+
walletClient,
|
|
642
|
+
ks.fromToken as Address,
|
|
643
|
+
tx.routerAddress as Address,
|
|
644
|
+
BigInt(ks.amountIn)
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const hash = await walletClient.sendTransaction(
|
|
649
|
+
buildSendTxParams({
|
|
650
|
+
account,
|
|
651
|
+
to: tx.routerAddress as Address,
|
|
652
|
+
value: BigInt(tx.transactionValue ?? "0"),
|
|
653
|
+
data: tx.data as Hex,
|
|
654
|
+
chain: walletClient.chain,
|
|
655
|
+
})
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
659
|
+
hash,
|
|
660
|
+
timeout: TX_CONFIRMATION_TIMEOUT_MS,
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
if (receipt.status === "reverted") {
|
|
664
|
+
throw new EVMError(EVMErrorCode.CONTRACT_REVERT, `KyberSwap swap reverted. Hash: ${hash}`);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return {
|
|
668
|
+
hash,
|
|
669
|
+
from: account.address,
|
|
670
|
+
to: tx.routerAddress as Address,
|
|
671
|
+
value: BigInt(tx.transactionValue ?? "0"),
|
|
672
|
+
data: tx.data as Hex,
|
|
673
|
+
chainId: this.walletProvider.getChainConfigs(params.chain).id,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
525
677
|
private async handleTokenApproval(
|
|
526
678
|
publicClient: ReturnType<WalletProvider["getPublicClient"]>,
|
|
527
679
|
walletClient: ReturnType<WalletProvider["getWalletClient"]>,
|
|
@@ -678,7 +830,7 @@ export const swapAction = {
|
|
|
678
830
|
descriptionCompressed: spec.descriptionCompressed,
|
|
679
831
|
contexts: ["finance", "crypto", "wallet"],
|
|
680
832
|
contextGate: { anyOf: ["finance", "crypto", "wallet"] },
|
|
681
|
-
roleGate: { minRole: "
|
|
833
|
+
roleGate: { minRole: "ADMIN" },
|
|
682
834
|
parameters: [
|
|
683
835
|
{
|
|
684
836
|
name: "fromToken",
|
|
@@ -704,19 +856,13 @@ export const swapAction = {
|
|
|
704
856
|
required: false,
|
|
705
857
|
schema: { type: "string" },
|
|
706
858
|
},
|
|
707
|
-
{
|
|
708
|
-
name: "confirmed",
|
|
709
|
-
description: "Set true after preview confirmation to submit.",
|
|
710
|
-
required: false,
|
|
711
|
-
schema: { type: "boolean", default: false },
|
|
712
|
-
},
|
|
713
859
|
],
|
|
714
860
|
|
|
715
861
|
handler: async (
|
|
716
862
|
runtime: IAgentRuntime,
|
|
717
863
|
message: Memory,
|
|
718
864
|
state?: State,
|
|
719
|
-
|
|
865
|
+
_options?: Record<string, unknown>,
|
|
720
866
|
callback?: HandlerCallback
|
|
721
867
|
): Promise<ActionResult> => {
|
|
722
868
|
const walletProvider = await initWalletProvider(runtime);
|
|
@@ -727,14 +873,22 @@ export const swapAction = {
|
|
|
727
873
|
|
|
728
874
|
const swapOptions = await buildSwapDetails(state, message, runtime, walletProvider);
|
|
729
875
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
876
|
+
const gate = await gateWalletFinancialExecution({
|
|
877
|
+
runtime,
|
|
878
|
+
message,
|
|
879
|
+
params: {
|
|
880
|
+
subaction: "swap",
|
|
881
|
+
chain: swapOptions.chain,
|
|
882
|
+
amount: swapOptions.amount,
|
|
883
|
+
fromToken: swapOptions.fromToken,
|
|
884
|
+
toToken: swapOptions.toToken,
|
|
885
|
+
mode: "execute",
|
|
886
|
+
dryRun: false,
|
|
887
|
+
},
|
|
888
|
+
callback,
|
|
889
|
+
});
|
|
890
|
+
if (!gate.proceed) {
|
|
891
|
+
return walletFinancialGateActionResult(gate);
|
|
738
892
|
}
|
|
739
893
|
|
|
740
894
|
const action = new SwapAction(walletProvider);
|
|
@@ -10,6 +10,14 @@ import {
|
|
|
10
10
|
type State,
|
|
11
11
|
} from "@elizaos/core";
|
|
12
12
|
import { formatEther, type Hex, parseEther } from "viem";
|
|
13
|
+
import {
|
|
14
|
+
assertEvmTransferRecipientAuthorized,
|
|
15
|
+
assertWalletFinancialActionAllowed,
|
|
16
|
+
} from "../../../security/wallet-context-safety.js";
|
|
17
|
+
import {
|
|
18
|
+
gateWalletFinancialExecution,
|
|
19
|
+
walletFinancialGateActionResult,
|
|
20
|
+
} from "../../../security/wallet-financial-confirmation.js";
|
|
13
21
|
import { runIntentModel } from "../../../utils/intent-trajectory";
|
|
14
22
|
import { requireActionSpec } from "../generated/specs/spec-helpers";
|
|
15
23
|
import { initWalletProvider, type WalletProvider } from "../providers/wallet";
|
|
@@ -22,12 +30,7 @@ import {
|
|
|
22
30
|
type Transaction,
|
|
23
31
|
type TransferParams,
|
|
24
32
|
} from "../types";
|
|
25
|
-
import {
|
|
26
|
-
buildSendTxParams,
|
|
27
|
-
confirmationRequired,
|
|
28
|
-
createEvmActionValidator,
|
|
29
|
-
isConfirmed,
|
|
30
|
-
} from "./helpers";
|
|
33
|
+
import { buildSendTxParams, createEvmActionValidator } from "./helpers";
|
|
31
34
|
|
|
32
35
|
export class TransferAction {
|
|
33
36
|
constructor(private readonly walletProvider: WalletProvider) {}
|
|
@@ -134,7 +137,7 @@ export const transferAction: Action = {
|
|
|
134
137
|
descriptionCompressed: spec.descriptionCompressed,
|
|
135
138
|
contexts: ["finance", "crypto", "wallet", "payments"],
|
|
136
139
|
contextGate: { anyOf: ["finance", "crypto", "wallet", "payments"] },
|
|
137
|
-
roleGate: { minRole: "
|
|
140
|
+
roleGate: { minRole: "ADMIN" },
|
|
138
141
|
parameters: [
|
|
139
142
|
{
|
|
140
143
|
name: "amount",
|
|
@@ -160,12 +163,6 @@ export const transferAction: Action = {
|
|
|
160
163
|
required: false,
|
|
161
164
|
schema: { type: "string" },
|
|
162
165
|
},
|
|
163
|
-
{
|
|
164
|
-
name: "confirmed",
|
|
165
|
-
description: "Set true after preview confirmation to submit.",
|
|
166
|
-
required: false,
|
|
167
|
-
schema: { type: "boolean", default: false },
|
|
168
|
-
},
|
|
169
166
|
],
|
|
170
167
|
|
|
171
168
|
handler: async (
|
|
@@ -179,18 +176,28 @@ export const transferAction: Action = {
|
|
|
179
176
|
state = (await runtime.composeState(message)) as State;
|
|
180
177
|
}
|
|
181
178
|
|
|
179
|
+
assertWalletFinancialActionAllowed(message, "transfer");
|
|
180
|
+
|
|
182
181
|
const walletProvider = await initWalletProvider(runtime);
|
|
183
182
|
const paramOptions = await buildTransferDetails(state, message, runtime, walletProvider);
|
|
183
|
+
assertEvmTransferRecipientAuthorized(message, options, paramOptions.toAddress);
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
const gate = await gateWalletFinancialExecution({
|
|
186
|
+
runtime,
|
|
187
|
+
message,
|
|
188
|
+
params: {
|
|
189
|
+
subaction: "transfer",
|
|
190
|
+
chain: paramOptions.fromChain,
|
|
191
|
+
amount: paramOptions.amount,
|
|
192
|
+
recipient: paramOptions.toAddress,
|
|
193
|
+
fromToken: paramOptions.token,
|
|
194
|
+
mode: "execute",
|
|
195
|
+
dryRun: false,
|
|
196
|
+
},
|
|
197
|
+
callback,
|
|
198
|
+
});
|
|
199
|
+
if (!gate.proceed) {
|
|
200
|
+
return walletFinancialGateActionResult(gate);
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
const action = new TransferAction(walletProvider);
|
package/src/chains/evm/build.ts
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const rmPathRecursive = fileURLToPath(
|
|
9
|
+
new URL("../../../../../packages/scripts/rm-path-recursive.mjs", import.meta.url)
|
|
10
|
+
);
|
|
6
11
|
|
|
7
12
|
async function runBuild(): Promise<boolean> {
|
|
8
13
|
console.log("Building @elizaos/plugin-wallet evm chain...");
|
|
@@ -10,7 +15,7 @@ async function runBuild(): Promise<boolean> {
|
|
|
10
15
|
const distDir = join(process.cwd(), "dist");
|
|
11
16
|
|
|
12
17
|
if (existsSync(distDir)) {
|
|
13
|
-
await Bun.$`
|
|
18
|
+
await Bun.$`node ${rmPathRecursive} ${distDir}`;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
await mkdir(distDir, { recursive: true });
|
|
@@ -10,6 +10,7 @@ export const TX_CONFIRMATION_TIMEOUT_MS = 60000;
|
|
|
10
10
|
export const BRIDGE_POLL_INTERVAL_MS = 5000;
|
|
11
11
|
export const MAX_BRIDGE_POLL_ATTEMPTS = 60 as const;
|
|
12
12
|
export const NATIVE_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000" as const;
|
|
13
|
+
export const KYBERSWAP_NATIVE_SENTINEL = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" as const;
|
|
13
14
|
|
|
14
15
|
export const BEBOP_CHAIN_MAP: Readonly<Record<string, string>> = {
|
|
15
16
|
mainnet: "ethereum",
|
|
@@ -20,4 +21,22 @@ export const BEBOP_CHAIN_MAP: Readonly<Record<string, string>> = {
|
|
|
20
21
|
linea: "linea",
|
|
21
22
|
} as const;
|
|
22
23
|
|
|
24
|
+
export const KYBERSWAP_CHAIN_MAP: Readonly<Record<string, string>> = {
|
|
25
|
+
mainnet: "ethereum",
|
|
26
|
+
arbitrum: "arbitrum",
|
|
27
|
+
base: "base",
|
|
28
|
+
polygon: "polygon",
|
|
29
|
+
optimism: "optimism",
|
|
30
|
+
bsc: "bsc",
|
|
31
|
+
linea: "linea",
|
|
32
|
+
avalanche: "avalanche",
|
|
33
|
+
mantle: "mantle",
|
|
34
|
+
zksync: "zksync",
|
|
35
|
+
scroll: "scroll",
|
|
36
|
+
blast: "blast",
|
|
37
|
+
mode: "mode",
|
|
38
|
+
sonic: "sonic",
|
|
39
|
+
berachain: "berachain",
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
23
42
|
export const DEFAULT_CHAINS = ["mainnet", "base", "bsc"] as const;
|