@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
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
_resetForTesting,
|
|
5
|
+
createHardenedExportGuard,
|
|
6
|
+
getWalletExportAuditLog,
|
|
7
|
+
} from "./wallet-export-guard";
|
|
8
|
+
|
|
9
|
+
function request(
|
|
10
|
+
remoteAddress: string | null = "127.0.0.1",
|
|
11
|
+
userAgent = "wallet-test",
|
|
12
|
+
): http.IncomingMessage {
|
|
13
|
+
return {
|
|
14
|
+
headers: { "user-agent": userAgent },
|
|
15
|
+
socket: { remoteAddress },
|
|
16
|
+
} as unknown as http.IncomingMessage;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseNonce(reason: string): string {
|
|
20
|
+
const parsed = JSON.parse(reason) as { nonce?: unknown };
|
|
21
|
+
if (typeof parsed.nonce !== "string") {
|
|
22
|
+
throw new Error(`missing nonce in ${reason}`);
|
|
23
|
+
}
|
|
24
|
+
return parsed.nonce;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("wallet export guard", () => {
|
|
28
|
+
const upstream = vi.fn(() => null);
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.useFakeTimers();
|
|
32
|
+
vi.setSystemTime(new Date("2026-01-01T00:00:00.000Z"));
|
|
33
|
+
upstream.mockReset();
|
|
34
|
+
upstream.mockReturnValue(null);
|
|
35
|
+
_resetForTesting();
|
|
36
|
+
vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
vi.restoreAllMocks();
|
|
41
|
+
vi.useRealTimers();
|
|
42
|
+
_resetForTesting();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("issues a nonce, enforces the confirmation delay, then allows exactly one export", () => {
|
|
46
|
+
const guard = createHardenedExportGuard(upstream);
|
|
47
|
+
const req = request();
|
|
48
|
+
const nonceResponse = guard(req, {
|
|
49
|
+
confirm: true,
|
|
50
|
+
exportToken: "valid",
|
|
51
|
+
requestNonce: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(nonceResponse?.status).toBe(403);
|
|
55
|
+
const nonce = parseNonce(nonceResponse?.reason ?? "");
|
|
56
|
+
expect(nonce).toMatch(/^wxn_[a-f0-9]{32}$/);
|
|
57
|
+
|
|
58
|
+
const tooEarly = guard(req, {
|
|
59
|
+
confirm: true,
|
|
60
|
+
exportToken: "valid",
|
|
61
|
+
exportNonce: nonce,
|
|
62
|
+
});
|
|
63
|
+
expect(tooEarly).toMatchObject({
|
|
64
|
+
status: 403,
|
|
65
|
+
reason: expect.stringContaining("Wait 10 more seconds"),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
vi.advanceTimersByTime(10_000);
|
|
69
|
+
expect(
|
|
70
|
+
guard(req, {
|
|
71
|
+
confirm: true,
|
|
72
|
+
exportToken: "valid",
|
|
73
|
+
exportNonce: nonce,
|
|
74
|
+
}),
|
|
75
|
+
).toBeNull();
|
|
76
|
+
|
|
77
|
+
const replay = guard(req, {
|
|
78
|
+
confirm: true,
|
|
79
|
+
exportToken: "valid",
|
|
80
|
+
exportNonce: nonce,
|
|
81
|
+
});
|
|
82
|
+
expect(replay).toMatchObject({
|
|
83
|
+
status: 403,
|
|
84
|
+
reason: "Invalid or expired export nonce.",
|
|
85
|
+
});
|
|
86
|
+
expect(getWalletExportAuditLog().at(-2)?.outcome).toBe("allowed");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("binds nonces to the socket IP and rejects requests without an IP", () => {
|
|
90
|
+
const guard = createHardenedExportGuard(upstream);
|
|
91
|
+
const nonceResponse = guard(request("127.0.0.1"), {
|
|
92
|
+
confirm: true,
|
|
93
|
+
exportToken: "valid",
|
|
94
|
+
requestNonce: true,
|
|
95
|
+
});
|
|
96
|
+
const nonce = parseNonce(nonceResponse?.reason ?? "");
|
|
97
|
+
vi.advanceTimersByTime(10_000);
|
|
98
|
+
|
|
99
|
+
expect(
|
|
100
|
+
guard(request("127.0.0.2"), {
|
|
101
|
+
confirm: true,
|
|
102
|
+
exportToken: "valid",
|
|
103
|
+
exportNonce: nonce,
|
|
104
|
+
}),
|
|
105
|
+
).toMatchObject({
|
|
106
|
+
status: 403,
|
|
107
|
+
reason: "Export nonce was issued to a different client.",
|
|
108
|
+
});
|
|
109
|
+
expect(
|
|
110
|
+
guard(request(null), {
|
|
111
|
+
confirm: true,
|
|
112
|
+
exportToken: "valid",
|
|
113
|
+
requestNonce: true,
|
|
114
|
+
}),
|
|
115
|
+
).toMatchObject({
|
|
116
|
+
status: 400,
|
|
117
|
+
reason: "Unable to determine client IP; request rejected.",
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("caps pending nonces per IP and trims the audit log", () => {
|
|
122
|
+
const guard = createHardenedExportGuard(upstream);
|
|
123
|
+
const req = request("10.0.0.1");
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < 3; i += 1) {
|
|
126
|
+
expect(
|
|
127
|
+
guard(req, {
|
|
128
|
+
confirm: true,
|
|
129
|
+
exportToken: "valid",
|
|
130
|
+
requestNonce: true,
|
|
131
|
+
})?.status,
|
|
132
|
+
).toBe(403);
|
|
133
|
+
}
|
|
134
|
+
expect(
|
|
135
|
+
guard(req, {
|
|
136
|
+
confirm: true,
|
|
137
|
+
exportToken: "valid",
|
|
138
|
+
requestNonce: true,
|
|
139
|
+
}),
|
|
140
|
+
).toMatchObject({
|
|
141
|
+
status: 429,
|
|
142
|
+
reason: expect.stringContaining("Too many pending export requests"),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
for (let i = 0; i < 120; i += 1) {
|
|
146
|
+
guard(request(`10.0.1.${i}`), {
|
|
147
|
+
confirm: true,
|
|
148
|
+
exportToken: "valid",
|
|
149
|
+
requestNonce: true,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
expect(getWalletExportAuditLog()).toHaveLength(100);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("rate limits successful exports per IP after nonce validation", () => {
|
|
156
|
+
const guard = createHardenedExportGuard(upstream);
|
|
157
|
+
const req = request("127.0.0.9");
|
|
158
|
+
const firstNonce = parseNonce(
|
|
159
|
+
guard(req, {
|
|
160
|
+
confirm: true,
|
|
161
|
+
exportToken: "valid",
|
|
162
|
+
requestNonce: true,
|
|
163
|
+
})?.reason ?? "",
|
|
164
|
+
);
|
|
165
|
+
vi.advanceTimersByTime(10_000);
|
|
166
|
+
expect(
|
|
167
|
+
guard(req, {
|
|
168
|
+
confirm: true,
|
|
169
|
+
exportToken: "valid",
|
|
170
|
+
exportNonce: firstNonce,
|
|
171
|
+
}),
|
|
172
|
+
).toBeNull();
|
|
173
|
+
|
|
174
|
+
const secondNonce = parseNonce(
|
|
175
|
+
guard(req, {
|
|
176
|
+
confirm: true,
|
|
177
|
+
exportToken: "valid",
|
|
178
|
+
requestNonce: true,
|
|
179
|
+
})?.reason ?? "",
|
|
180
|
+
);
|
|
181
|
+
vi.advanceTimersByTime(10_000);
|
|
182
|
+
expect(
|
|
183
|
+
guard(req, {
|
|
184
|
+
confirm: true,
|
|
185
|
+
exportToken: "valid",
|
|
186
|
+
exportNonce: secondNonce,
|
|
187
|
+
}),
|
|
188
|
+
).toMatchObject({
|
|
189
|
+
status: 429,
|
|
190
|
+
reason: expect.stringContaining("Rate limit exceeded"),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
vi.advanceTimersByTime(10 * 60 * 1000);
|
|
194
|
+
const thirdNonce = parseNonce(
|
|
195
|
+
guard(req, {
|
|
196
|
+
confirm: true,
|
|
197
|
+
exportToken: "valid",
|
|
198
|
+
requestNonce: true,
|
|
199
|
+
})?.reason ?? "",
|
|
200
|
+
);
|
|
201
|
+
vi.advanceTimersByTime(10_000);
|
|
202
|
+
expect(
|
|
203
|
+
guard(req, {
|
|
204
|
+
confirm: true,
|
|
205
|
+
exportToken: "valid",
|
|
206
|
+
exportNonce: thirdNonce,
|
|
207
|
+
}),
|
|
208
|
+
).toBeNull();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("runs upstream validation before issuing nonces or rate-limit checks", () => {
|
|
212
|
+
upstream.mockReturnValueOnce({
|
|
213
|
+
status: 403,
|
|
214
|
+
reason: "bad export token",
|
|
215
|
+
});
|
|
216
|
+
const guard = createHardenedExportGuard(upstream);
|
|
217
|
+
|
|
218
|
+
expect(
|
|
219
|
+
guard(request(), {
|
|
220
|
+
confirm: true,
|
|
221
|
+
exportToken: "invalid",
|
|
222
|
+
requestNonce: true,
|
|
223
|
+
}),
|
|
224
|
+
).toEqual({
|
|
225
|
+
status: 403,
|
|
226
|
+
reason: "bad export token",
|
|
227
|
+
});
|
|
228
|
+
expect(getWalletExportAuditLog().at(-1)).toMatchObject({
|
|
229
|
+
outcome: "rejected",
|
|
230
|
+
reason: "bad export token",
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
@@ -61,7 +61,7 @@ if (typeof sweepTimer === "object" && "unref" in sweepTimer) {
|
|
|
61
61
|
* IPs to bypass rate limits and nonce IP binding.
|
|
62
62
|
*/
|
|
63
63
|
function getClientIp(req: http.IncomingMessage): string | null {
|
|
64
|
-
return req.socket
|
|
64
|
+
return req.socket.remoteAddress ?? null;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function getUserAgent(req: http.IncomingMessage): string {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import type {
|
|
3
2
|
Action,
|
|
4
3
|
ActionExample,
|
|
@@ -27,6 +26,24 @@ import { getChainConfig } from "../types.ts";
|
|
|
27
26
|
const SOLANA_DEXES = new Set(["raydium", "orca", "meteora"]);
|
|
28
27
|
const EVM_DEXES = new Set(["uniswap", "aerodrome", "pancakeswap"]);
|
|
29
28
|
|
|
29
|
+
type PoolTokenWithAddress = PoolInfo["tokenA"] & { address?: string };
|
|
30
|
+
type TransactionWithHash = { transactionId?: string; hash?: string };
|
|
31
|
+
|
|
32
|
+
function tokenLabel(token: PoolInfo["tokenA"]): string | undefined {
|
|
33
|
+
const withAddress = token as PoolTokenWithAddress;
|
|
34
|
+
return token.symbol || token.mint || withAddress.address;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function transactionLabel(result: TransactionWithHash): string {
|
|
38
|
+
return result.transactionId || result.hash || "submitted";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isLpPosition(
|
|
42
|
+
position: LpPositionDetails | null,
|
|
43
|
+
): position is LpPositionDetails {
|
|
44
|
+
return position !== null;
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
function selectedContextMatches(
|
|
31
48
|
state: State | undefined,
|
|
32
49
|
contexts: readonly string[],
|
|
@@ -73,7 +90,7 @@ const formatPositions = (positions: LpPositionDetails[]): string => {
|
|
|
73
90
|
`\n${index + 1}. ${pos.poolId} on ${pos.dex}\n` +
|
|
74
91
|
` Value: $${pos.valueUsd?.toFixed(2) || "N/A"}\n` +
|
|
75
92
|
` Tokens: ${underlying || "N/A"}\n` +
|
|
76
|
-
` LP balance: ${pos.lpTokenBalance
|
|
93
|
+
` LP balance: ${pos.lpTokenBalance.uiAmount?.toFixed(6) || pos.lpTokenBalance.balance || "N/A"} ${pos.lpTokenBalance.symbol || ""}\n`;
|
|
77
94
|
});
|
|
78
95
|
return response;
|
|
79
96
|
};
|
|
@@ -85,16 +102,8 @@ const formatPools = (pools: PoolInfo[]): string => {
|
|
|
85
102
|
|
|
86
103
|
let response = "LP pools:\n";
|
|
87
104
|
pools.slice(0, 10).forEach((pool, index) => {
|
|
88
|
-
const tokenA =
|
|
89
|
-
|
|
90
|
-
pool.tokenA?.mint ||
|
|
91
|
-
pool.tokenA?.address ||
|
|
92
|
-
"tokenA";
|
|
93
|
-
const tokenB =
|
|
94
|
-
pool.tokenB?.symbol ||
|
|
95
|
-
pool.tokenB?.mint ||
|
|
96
|
-
pool.tokenB?.address ||
|
|
97
|
-
"tokenB";
|
|
105
|
+
const tokenA = tokenLabel(pool.tokenA) || "tokenA";
|
|
106
|
+
const tokenB = tokenLabel(pool.tokenB) || "tokenB";
|
|
98
107
|
response +=
|
|
99
108
|
`\n${index + 1}. ${pool.displayName || pool.id} on ${pool.dex}\n` +
|
|
100
109
|
` Pair: ${tokenA}/${tokenB}\n` +
|
|
@@ -204,7 +213,7 @@ function normalizeParams(
|
|
|
204
213
|
message: Memory,
|
|
205
214
|
handlerParams?: Record<string, unknown>,
|
|
206
215
|
): LpActionParams | null {
|
|
207
|
-
const contentParams = (message
|
|
216
|
+
const contentParams = (message.content || {}) as Record<string, unknown>;
|
|
208
217
|
const params = {
|
|
209
218
|
...contentParams,
|
|
210
219
|
...(handlerParams || {}),
|
|
@@ -242,7 +251,12 @@ function resolveChain(params: LpActionParams): {
|
|
|
242
251
|
let chainId = params.chainId;
|
|
243
252
|
|
|
244
253
|
const numericChain = chain && /^\d+$/.test(chain) ? Number(chain) : undefined;
|
|
245
|
-
const evmChain =
|
|
254
|
+
const evmChain =
|
|
255
|
+
numericChain !== undefined
|
|
256
|
+
? getChainConfig(numericChain)
|
|
257
|
+
: chain
|
|
258
|
+
? getChainConfig(chain)
|
|
259
|
+
: undefined;
|
|
246
260
|
if (evmChain) {
|
|
247
261
|
chain = "evm";
|
|
248
262
|
chainId = evmChain.chainId;
|
|
@@ -404,8 +418,9 @@ async function handlePreferences(
|
|
|
404
418
|
newConfig.minGainThresholdPercent = params.minGainThresholdPercent;
|
|
405
419
|
updates.push(`minGainThresholdPercent=${params.minGainThresholdPercent}`);
|
|
406
420
|
}
|
|
407
|
-
|
|
408
|
-
|
|
421
|
+
const maxSlippageBps = params.maxSlippageBps ?? params.slippageBps;
|
|
422
|
+
if (maxSlippageBps !== undefined) {
|
|
423
|
+
newConfig.maxSlippageBps = maxSlippageBps;
|
|
409
424
|
updates.push(`maxSlippageBps=${newConfig.maxSlippageBps}`);
|
|
410
425
|
}
|
|
411
426
|
if (params.preferredDexes) {
|
|
@@ -482,7 +497,7 @@ async function handleLpOperation(
|
|
|
482
497
|
.catch(() => null),
|
|
483
498
|
),
|
|
484
499
|
)
|
|
485
|
-
).filter(
|
|
500
|
+
).filter(isLpPosition);
|
|
486
501
|
}
|
|
487
502
|
return {
|
|
488
503
|
success: true,
|
|
@@ -528,7 +543,7 @@ async function handleLpOperation(
|
|
|
528
543
|
return {
|
|
529
544
|
success: result.success,
|
|
530
545
|
text: result.success
|
|
531
|
-
? `LP position opened on ${route.dex || "registered protocol"}. Transaction: ${result
|
|
546
|
+
? `LP position opened on ${route.dex || "registered protocol"}. Transaction: ${transactionLabel(result)}`
|
|
532
547
|
: `LP open failed: ${result.error || "unknown error"}`,
|
|
533
548
|
data: result,
|
|
534
549
|
};
|
|
@@ -552,7 +567,7 @@ async function handleLpOperation(
|
|
|
552
567
|
return {
|
|
553
568
|
success: result.success,
|
|
554
569
|
text: result.success
|
|
555
|
-
? `LP position closed on ${route.dex || "registered protocol"}. Transaction: ${result
|
|
570
|
+
? `LP position closed on ${route.dex || "registered protocol"}. Transaction: ${transactionLabel(result)}`
|
|
556
571
|
: `LP close failed: ${result.error || "unknown error"}`,
|
|
557
572
|
data: result,
|
|
558
573
|
};
|
|
@@ -577,7 +592,7 @@ async function handleLpOperation(
|
|
|
577
592
|
return {
|
|
578
593
|
success: result.success,
|
|
579
594
|
text: result.success
|
|
580
|
-
? `LP position repositioned on ${route.dex || "registered protocol"}. Transaction: ${result
|
|
595
|
+
? `LP position repositioned on ${route.dex || "registered protocol"}. Transaction: ${transactionLabel(result)}`
|
|
581
596
|
: `LP reposition failed: ${result.error || "unknown error"}`,
|
|
582
597
|
data: result,
|
|
583
598
|
};
|
|
@@ -656,7 +671,10 @@ export const liquidityAction: Action = {
|
|
|
656
671
|
description:
|
|
657
672
|
"Liquidity amount for open, close, or reposition operations.",
|
|
658
673
|
required: false,
|
|
659
|
-
schema: {
|
|
674
|
+
schema: {
|
|
675
|
+
type: "string",
|
|
676
|
+
anyOf: [{ type: "string" }, { type: "number" }],
|
|
677
|
+
},
|
|
660
678
|
},
|
|
661
679
|
{
|
|
662
680
|
name: "range",
|
|
@@ -712,7 +730,10 @@ export const liquidityAction: Action = {
|
|
|
712
730
|
[
|
|
713
731
|
{
|
|
714
732
|
name: "{{name1}}",
|
|
715
|
-
content: {
|
|
733
|
+
content: {
|
|
734
|
+
text: "Open a Raydium LP position with 100 USDC paired against SOL.",
|
|
735
|
+
source: "chat",
|
|
736
|
+
},
|
|
716
737
|
},
|
|
717
738
|
{
|
|
718
739
|
name: "{{agentName}}",
|
|
@@ -727,7 +748,10 @@ export const liquidityAction: Action = {
|
|
|
727
748
|
[
|
|
728
749
|
{
|
|
729
750
|
name: "{{name1}}",
|
|
730
|
-
content: {
|
|
751
|
+
content: {
|
|
752
|
+
text: "Show my current liquidity positions.",
|
|
753
|
+
source: "chat",
|
|
754
|
+
},
|
|
731
755
|
},
|
|
732
756
|
{
|
|
733
757
|
name: "{{agentName}}",
|
|
@@ -742,7 +766,10 @@ export const liquidityAction: Action = {
|
|
|
742
766
|
[
|
|
743
767
|
{
|
|
744
768
|
name: "{{name1}}",
|
|
745
|
-
content: {
|
|
769
|
+
content: {
|
|
770
|
+
text: "Close my SOL/USDC liquidity position.",
|
|
771
|
+
source: "chat",
|
|
772
|
+
},
|
|
746
773
|
},
|
|
747
774
|
{
|
|
748
775
|
name: "{{agentName}}",
|
|
@@ -761,7 +788,7 @@ export const liquidityAction: Action = {
|
|
|
761
788
|
message: Memory,
|
|
762
789
|
state?: State,
|
|
763
790
|
): Promise<boolean> => {
|
|
764
|
-
if (!message
|
|
791
|
+
if (!message.content) return false;
|
|
765
792
|
if ((message.content as LpActionParams & { action?: string }).action)
|
|
766
793
|
return true;
|
|
767
794
|
if ((message.content as LpActionParams).subaction) return true;
|
|
@@ -789,7 +816,7 @@ export const liquidityAction: Action = {
|
|
|
789
816
|
};
|
|
790
817
|
}
|
|
791
818
|
|
|
792
|
-
const userId = message.entityId ||
|
|
819
|
+
const userId = message.entityId || "unknown-user";
|
|
793
820
|
|
|
794
821
|
try {
|
|
795
822
|
if (params.subaction === "onboard") {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import { strict as assert } from "node:assert";
|
|
3
2
|
import type { IAgentRuntime, TestSuite } from "@elizaos/core";
|
|
4
3
|
import type { DexInteractionService } from "../services/DexInteractionService.ts";
|
package/src/lp/e2e/scenarios.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import { strict as assert } from "node:assert";
|
|
3
2
|
import type { IAgentRuntime, TestSuite } from "@elizaos/core";
|
|
4
3
|
import { sendMessageAndWaitForResponse, setupScenario } from "./test-utils.ts";
|
|
5
4
|
|
|
6
|
-
// Mock services are registered in setupScenario; this
|
|
5
|
+
// Mock services are registered in setupScenario; this hook is called for backward compatibility.
|
|
7
6
|
async function setupMockLpData(_runtime: IAgentRuntime) {}
|
|
8
7
|
|
|
9
8
|
/**
|
package/src/lp/e2e/test-utils.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import { strict as assert } from "node:assert";
|
|
3
2
|
import {
|
|
4
3
|
asUUID,
|
|
@@ -10,10 +9,24 @@ import {
|
|
|
10
9
|
type IAgentRuntime,
|
|
11
10
|
type Memory,
|
|
12
11
|
type Room,
|
|
12
|
+
type Setting,
|
|
13
13
|
type World,
|
|
14
14
|
} from "@elizaos/core";
|
|
15
15
|
import { v4 as uuid } from "uuid";
|
|
16
16
|
|
|
17
|
+
const E2E_TEST_SERVER_ID = "e2e-test-server";
|
|
18
|
+
|
|
19
|
+
function testSetting(name: string, value: string | boolean | null): Setting {
|
|
20
|
+
return {
|
|
21
|
+
name,
|
|
22
|
+
description: `E2E ${name}`,
|
|
23
|
+
usageDescription: `E2E ${name}`,
|
|
24
|
+
required: false,
|
|
25
|
+
value,
|
|
26
|
+
dependsOn: [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
/**
|
|
18
31
|
* Sets up a standard scenario environment for an E2E test.
|
|
19
32
|
*
|
|
@@ -51,16 +64,15 @@ export async function setupScenario(
|
|
|
51
64
|
id: asUUID(uuid()),
|
|
52
65
|
agentId: runtime.agentId,
|
|
53
66
|
name: "E2E Test World",
|
|
54
|
-
serverId: "e2e-test-server",
|
|
55
67
|
metadata: {
|
|
56
68
|
ownership: {
|
|
57
69
|
ownerId: user.id,
|
|
58
70
|
},
|
|
59
71
|
settings: {
|
|
60
72
|
lp_manager: {
|
|
61
|
-
onboarding_enabled: true,
|
|
62
|
-
auto_rebalance_enabled: true,
|
|
63
|
-
default_slippage_bps: 50,
|
|
73
|
+
onboarding_enabled: testSetting("onboarding_enabled", true),
|
|
74
|
+
auto_rebalance_enabled: testSetting("auto_rebalance_enabled", true),
|
|
75
|
+
default_slippage_bps: testSetting("default_slippage_bps", "50"),
|
|
64
76
|
},
|
|
65
77
|
},
|
|
66
78
|
},
|
|
@@ -74,7 +86,7 @@ export async function setupScenario(
|
|
|
74
86
|
type: ChannelType.DM,
|
|
75
87
|
source: "e2e-test",
|
|
76
88
|
worldId: world.id,
|
|
77
|
-
serverId:
|
|
89
|
+
serverId: E2E_TEST_SERVER_ID,
|
|
78
90
|
};
|
|
79
91
|
await runtime.createRoom(room);
|
|
80
92
|
|
|
@@ -131,8 +143,9 @@ export function sendMessageAndWaitForResponse(
|
|
|
131
143
|
|
|
132
144
|
// The callback function that the message handler will invoke with the agent's final response.
|
|
133
145
|
// We use this callback to resolve our promise.
|
|
134
|
-
const callback = (responseContent: Content) => {
|
|
146
|
+
const callback = async (responseContent: Content): Promise<Memory[]> => {
|
|
135
147
|
resolve(responseContent);
|
|
148
|
+
return [];
|
|
136
149
|
};
|
|
137
150
|
|
|
138
151
|
// Emit the event to trigger the agent's message processing logic.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import {
|
|
3
2
|
type IAgentRuntime,
|
|
4
3
|
logger,
|
|
@@ -144,7 +143,7 @@ async function loadSolanaDexes(
|
|
|
144
143
|
const meteoraPlugin = await import(
|
|
145
144
|
"../chains/solana/dex/meteora/index.ts"
|
|
146
145
|
);
|
|
147
|
-
if (meteoraPlugin.default
|
|
146
|
+
if (meteoraPlugin.default.init) {
|
|
148
147
|
await meteoraPlugin.default.init(config, runtime);
|
|
149
148
|
}
|
|
150
149
|
logger.info(`[LP Manager] Loaded Meteora DEX`);
|
|
@@ -214,7 +213,7 @@ async function loadEvmDexes(
|
|
|
214
213
|
const lpManagerPlugin: Plugin = {
|
|
215
214
|
name: LP_MANAGER_PLUGIN_NAME,
|
|
216
215
|
description:
|
|
217
|
-
"
|
|
216
|
+
"Liquidity Pool manager for Solana DEXs (Raydium, Orca, Meteora) and EVM DEXs (Uniswap, PancakeSwap, Aerodrome).",
|
|
218
217
|
actions: [...promoteSubactionsToActions(liquidityAction)],
|
|
219
218
|
services: [
|
|
220
219
|
LpManagementService,
|
|
@@ -290,13 +289,11 @@ export { raydiumPlugin } from "../chains/solana/dex/raydium/index.ts";
|
|
|
290
289
|
// Export types
|
|
291
290
|
export * from "./types.ts";
|
|
292
291
|
// Export all services and utilities
|
|
293
|
-
// Back-compat alias for older imports.
|
|
294
292
|
export {
|
|
295
293
|
ConcentratedLiquidityService,
|
|
296
294
|
DexInteractionService,
|
|
297
295
|
LpManagementService,
|
|
298
296
|
liquidityAction,
|
|
299
|
-
liquidityAction as LpManagementAgentAction,
|
|
300
297
|
UserLpProfileService,
|
|
301
298
|
VaultService,
|
|
302
299
|
YieldOptimizationService,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
3
2
|
import type {
|
|
4
3
|
IConcentratedLiquidityService,
|
|
@@ -7,8 +6,8 @@ import type {
|
|
|
7
6
|
} from "../types";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
* ConcentratedLiquidityService
|
|
11
|
-
*
|
|
9
|
+
* ConcentratedLiquidityService exposes the concentrated-liquidity surface while
|
|
10
|
+
* DEX-specific providers add position creation and rebalancing support.
|
|
12
11
|
*/
|
|
13
12
|
export class ConcentratedLiquidityService
|
|
14
13
|
extends Service
|
|
@@ -32,21 +31,17 @@ export class ConcentratedLiquidityService
|
|
|
32
31
|
|
|
33
32
|
async start(_runtime: IAgentRuntime): Promise<void> {
|
|
34
33
|
// Service initialization
|
|
35
|
-
this.isInitialized = true;
|
|
36
34
|
console.info(
|
|
37
35
|
"ConcentratedLiquidityService started - awaiting DEX integration",
|
|
38
36
|
);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
async stop(): Promise<void> {
|
|
42
|
-
this.isInitialized = false;
|
|
43
|
-
}
|
|
39
|
+
async stop(): Promise<void> {}
|
|
44
40
|
|
|
45
41
|
async createConcentratedPosition(
|
|
46
42
|
_userId: string,
|
|
47
43
|
_params: IRangeParams,
|
|
48
44
|
): Promise<IConcentratedPosition> {
|
|
49
|
-
// Placeholder implementation
|
|
50
45
|
throw new Error(
|
|
51
46
|
"Concentrated liquidity positions are coming soon! This feature requires DEX integration.",
|
|
52
47
|
);
|
|
@@ -55,7 +50,6 @@ export class ConcentratedLiquidityService
|
|
|
55
50
|
async getConcentratedPositions(
|
|
56
51
|
userId: string,
|
|
57
52
|
): Promise<IConcentratedPosition[]> {
|
|
58
|
-
// Placeholder implementation
|
|
59
53
|
console.info(`Getting concentrated positions for user ${userId}`);
|
|
60
54
|
return [];
|
|
61
55
|
}
|
|
@@ -65,7 +59,6 @@ export class ConcentratedLiquidityService
|
|
|
65
59
|
_positionId: string,
|
|
66
60
|
_newRangeParams?: Partial<IRangeParams>,
|
|
67
61
|
): Promise<IConcentratedPosition> {
|
|
68
|
-
// Placeholder implementation
|
|
69
62
|
throw new Error("Concentrated position rebalancing is coming soon!");
|
|
70
63
|
}
|
|
71
64
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
|
|
2
1
|
import { type IAgentRuntime, logger, Service } from "@elizaos/core";
|
|
3
2
|
import type {
|
|
4
3
|
AddLiquidityConfig,
|
|
@@ -79,7 +78,7 @@ export class DexInteractionService
|
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
async stop(): Promise<void> {
|
|
82
|
-
//
|
|
81
|
+
// Protocol providers are owned by LpManagementService.
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
rediscoverServices(): void {
|