@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
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
ILpService,
|
|
3
|
+
type ILpService,
|
|
5
4
|
type LpPositionDetails,
|
|
6
5
|
logger,
|
|
7
6
|
type PoolInfo,
|
|
7
|
+
Service,
|
|
8
8
|
type TokenBalance,
|
|
9
9
|
type TransactionResult,
|
|
10
10
|
} from "@elizaos/core";
|
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
EvmAddLiquidityParams,
|
|
15
15
|
EvmPoolInfo,
|
|
16
16
|
EvmRemoveLiquidityParams,
|
|
17
|
-
EvmTransactionResult,
|
|
18
17
|
IEvmLpService,
|
|
19
18
|
RemoveLiquidityConfig,
|
|
20
19
|
} from "../types.ts";
|
|
@@ -93,6 +92,12 @@ export interface LpProtocolProvider {
|
|
|
93
92
|
getMarketData?(poolIds: string[]): Promise<Record<string, Partial<PoolInfo>>>;
|
|
94
93
|
}
|
|
95
94
|
|
|
95
|
+
type SolanaLpServiceAdapter = Partial<ILpService> & {
|
|
96
|
+
repositionPosition?(
|
|
97
|
+
params: LpPositionOperationParams,
|
|
98
|
+
): Promise<TransactionResult>;
|
|
99
|
+
};
|
|
100
|
+
|
|
96
101
|
export class NoMatchingLpProtocolError extends Error {
|
|
97
102
|
public readonly code = "NO_MATCHING_LP_PROTOCOL";
|
|
98
103
|
|
|
@@ -113,6 +118,10 @@ function normalizeDex(dex?: string): string | undefined {
|
|
|
113
118
|
return dex?.trim().toLowerCase();
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
function normalizeRequiredDex(dex: string): string {
|
|
122
|
+
return dex.trim().toLowerCase();
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
function normalizeChain(chain?: string): string | undefined {
|
|
117
126
|
return chain?.trim().toLowerCase();
|
|
118
127
|
}
|
|
@@ -134,7 +143,7 @@ function poolId(pool?: string | PoolInfo | EvmPoolInfo): string | undefined {
|
|
|
134
143
|
function amountValue(
|
|
135
144
|
params: LpPositionOperationParams,
|
|
136
145
|
key: "tokenA" | "tokenB" | "lpToken" | "value",
|
|
137
|
-
fallback
|
|
146
|
+
fallback: string,
|
|
138
147
|
): string {
|
|
139
148
|
const amount = params.amount;
|
|
140
149
|
if (
|
|
@@ -152,6 +161,27 @@ function amountValue(
|
|
|
152
161
|
return fallback;
|
|
153
162
|
}
|
|
154
163
|
|
|
164
|
+
function optionalAmountValue(
|
|
165
|
+
params: LpPositionOperationParams,
|
|
166
|
+
key: "tokenA" | "tokenB" | "lpToken" | "value",
|
|
167
|
+
fallback?: string,
|
|
168
|
+
): string | undefined {
|
|
169
|
+
const amount = params.amount;
|
|
170
|
+
if (
|
|
171
|
+
key === "value" &&
|
|
172
|
+
["string", "number", "bigint"].includes(typeof amount)
|
|
173
|
+
) {
|
|
174
|
+
return String(amount);
|
|
175
|
+
}
|
|
176
|
+
if (amount && typeof amount === "object" && key in amount) {
|
|
177
|
+
const value = amount[key];
|
|
178
|
+
if (value !== undefined && value !== null) return String(value);
|
|
179
|
+
}
|
|
180
|
+
const nested = params.amounts?.[key as keyof typeof params.amounts];
|
|
181
|
+
if (nested !== undefined && nested !== null) return String(nested);
|
|
182
|
+
return fallback;
|
|
183
|
+
}
|
|
184
|
+
|
|
155
185
|
function bigintAmount(value: unknown, fallback = 0n): bigint {
|
|
156
186
|
if (typeof value === "bigint") return value;
|
|
157
187
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
@@ -163,20 +193,25 @@ function bigintAmount(value: unknown, fallback = 0n): bigint {
|
|
|
163
193
|
return fallback;
|
|
164
194
|
}
|
|
165
195
|
|
|
196
|
+
function optionalBigintAmount(value: unknown): bigint | undefined {
|
|
197
|
+
if (value === undefined || value === null || value === "") return undefined;
|
|
198
|
+
return bigintAmount(value);
|
|
199
|
+
}
|
|
200
|
+
|
|
166
201
|
function unsupported(
|
|
167
202
|
protocol: LpProtocolProvider,
|
|
168
203
|
operation: string,
|
|
169
204
|
): TransactionResult {
|
|
170
205
|
return {
|
|
171
206
|
success: false,
|
|
172
|
-
error: `${operation} is
|
|
207
|
+
error: `${operation} is unavailable for ${protocol.dex} on ${protocol.chain}`,
|
|
173
208
|
};
|
|
174
209
|
}
|
|
175
210
|
|
|
176
|
-
export class LpManagementService extends ILpService {
|
|
211
|
+
export class LpManagementService extends Service implements ILpService {
|
|
177
212
|
public static override readonly serviceType = LP_MANAGEMENT_SERVICE_TYPE;
|
|
178
213
|
public readonly capabilityDescription =
|
|
179
|
-
"
|
|
214
|
+
"Provides standardized access to DEX liquidity pools.";
|
|
180
215
|
|
|
181
216
|
private protocols = new Map<string, LpProtocolProvider>();
|
|
182
217
|
|
|
@@ -197,11 +232,11 @@ export class LpManagementService extends ILpService {
|
|
|
197
232
|
|
|
198
233
|
registerProtocol(provider: LpProtocolProvider): void {
|
|
199
234
|
const key = protocolKey(provider.chain, provider.dex);
|
|
200
|
-
const normalizedProvider = {
|
|
235
|
+
const normalizedProvider: LpProtocolProvider = {
|
|
201
236
|
...provider,
|
|
202
237
|
id: provider.id || key,
|
|
203
238
|
chain: normalizeChain(provider.chain) as LpProtocolChain,
|
|
204
|
-
dex:
|
|
239
|
+
dex: normalizeRequiredDex(provider.dex),
|
|
205
240
|
};
|
|
206
241
|
if (this.protocols.has(key)) {
|
|
207
242
|
logger.warn(
|
|
@@ -425,17 +460,18 @@ export function createSolanaLpProtocolProvider({
|
|
|
425
460
|
}: {
|
|
426
461
|
dex: string;
|
|
427
462
|
label?: string;
|
|
428
|
-
service:
|
|
463
|
+
service: SolanaLpServiceAdapter;
|
|
429
464
|
}): LpProtocolProvider {
|
|
465
|
+
const normalizedDex = normalizeRequiredDex(dex);
|
|
430
466
|
const provider: LpProtocolProvider = {
|
|
431
|
-
id: `solana:${
|
|
467
|
+
id: `solana:${normalizedDex}`,
|
|
432
468
|
chain: "solana",
|
|
433
|
-
dex:
|
|
469
|
+
dex: normalizedDex,
|
|
434
470
|
label,
|
|
435
471
|
service,
|
|
436
472
|
supportsRequest: (request) =>
|
|
437
473
|
(!request.chain || normalizeChain(request.chain) === "solana") &&
|
|
438
|
-
(!request.dex || normalizeDex(request.dex) ===
|
|
474
|
+
(!request.dex || normalizeDex(request.dex) === normalizedDex),
|
|
439
475
|
listPools: async (params) => {
|
|
440
476
|
if (typeof service.getPools !== "function") return [];
|
|
441
477
|
return service.getPools(params.tokenA, params.tokenB);
|
|
@@ -444,6 +480,9 @@ export function createSolanaLpProtocolProvider({
|
|
|
444
480
|
if (typeof service.addLiquidity !== "function") {
|
|
445
481
|
return unsupported(provider, "open");
|
|
446
482
|
}
|
|
483
|
+
if (!params.userVault) {
|
|
484
|
+
return { success: false, error: "User vault is required" };
|
|
485
|
+
}
|
|
447
486
|
const id = poolId(params.pool);
|
|
448
487
|
if (!id) return { success: false, error: "Pool is required" };
|
|
449
488
|
return service.addLiquidity({
|
|
@@ -452,9 +491,9 @@ export function createSolanaLpProtocolProvider({
|
|
|
452
491
|
tokenAAmountLamports: amountValue(
|
|
453
492
|
params,
|
|
454
493
|
"tokenA",
|
|
455
|
-
amountValue(params, "value"),
|
|
494
|
+
amountValue(params, "value", "0"),
|
|
456
495
|
),
|
|
457
|
-
tokenBAmountLamports:
|
|
496
|
+
tokenBAmountLamports: optionalAmountValue(params, "tokenB"),
|
|
458
497
|
slippageBps: params.slippageBps ?? 50,
|
|
459
498
|
tickLowerIndex: params.range?.tickLowerIndex ?? params.range?.tickLower,
|
|
460
499
|
tickUpperIndex: params.range?.tickUpperIndex ?? params.range?.tickUpper,
|
|
@@ -464,6 +503,9 @@ export function createSolanaLpProtocolProvider({
|
|
|
464
503
|
if (typeof service.removeLiquidity !== "function") {
|
|
465
504
|
return unsupported(provider, "close");
|
|
466
505
|
}
|
|
506
|
+
if (!params.userVault) {
|
|
507
|
+
return { success: false, error: "User vault is required" };
|
|
508
|
+
}
|
|
467
509
|
const id = poolId(params.pool) || params.position;
|
|
468
510
|
if (!id) return { success: false, error: "Pool or position is required" };
|
|
469
511
|
return service.removeLiquidity({
|
|
@@ -472,7 +514,7 @@ export function createSolanaLpProtocolProvider({
|
|
|
472
514
|
lpTokenAmountLamports: amountValue(
|
|
473
515
|
params,
|
|
474
516
|
"lpToken",
|
|
475
|
-
amountValue(params, "value"),
|
|
517
|
+
amountValue(params, "value", "0"),
|
|
476
518
|
),
|
|
477
519
|
slippageBps: params.slippageBps ?? 50,
|
|
478
520
|
});
|
|
@@ -489,9 +531,9 @@ export function createSolanaLpProtocolProvider({
|
|
|
489
531
|
},
|
|
490
532
|
};
|
|
491
533
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
534
|
+
const repositionPosition = service.repositionPosition;
|
|
535
|
+
if (typeof repositionPosition === "function") {
|
|
536
|
+
provider.repositionPosition = (params) => repositionPosition(params);
|
|
495
537
|
}
|
|
496
538
|
|
|
497
539
|
return provider;
|
|
@@ -510,10 +552,11 @@ export function createEvmLpProtocolProvider({
|
|
|
510
552
|
typeof service.getSupportedChainIds === "function"
|
|
511
553
|
? service.getSupportedChainIds()
|
|
512
554
|
: [];
|
|
555
|
+
const normalizedDex = normalizeRequiredDex(dex);
|
|
513
556
|
const provider: LpProtocolProvider = {
|
|
514
|
-
id: `evm:${
|
|
557
|
+
id: `evm:${normalizedDex}`,
|
|
515
558
|
chain: "evm",
|
|
516
|
-
dex:
|
|
559
|
+
dex: normalizedDex,
|
|
517
560
|
label,
|
|
518
561
|
service,
|
|
519
562
|
supportedChainIds,
|
|
@@ -521,7 +564,7 @@ export function createEvmLpProtocolProvider({
|
|
|
521
564
|
if (request.chain && normalizeChain(request.chain) !== "evm") {
|
|
522
565
|
return false;
|
|
523
566
|
}
|
|
524
|
-
if (request.dex && normalizeDex(request.dex) !==
|
|
567
|
+
if (request.dex && normalizeDex(request.dex) !== normalizedDex) {
|
|
525
568
|
return false;
|
|
526
569
|
}
|
|
527
570
|
if (request.chainId !== undefined && supportedChainIds.length > 0) {
|
|
@@ -555,11 +598,10 @@ export function createEvmLpProtocolProvider({
|
|
|
555
598
|
chainId: params.chainId,
|
|
556
599
|
poolAddress: id as Address,
|
|
557
600
|
tokenAAmount: bigintAmount(
|
|
558
|
-
amountValue(params, "tokenA", amountValue(params, "value")),
|
|
601
|
+
amountValue(params, "tokenA", amountValue(params, "value", "0")),
|
|
559
602
|
),
|
|
560
|
-
tokenBAmount:
|
|
561
|
-
|
|
562
|
-
undefined,
|
|
603
|
+
tokenBAmount: optionalBigintAmount(
|
|
604
|
+
optionalAmountValue(params, "tokenB"),
|
|
563
605
|
),
|
|
564
606
|
slippageBps: params.slippageBps ?? 50,
|
|
565
607
|
tickLower: params.range?.tickLower ?? params.range?.tickLowerIndex,
|
|
@@ -585,13 +627,16 @@ export function createEvmLpProtocolProvider({
|
|
|
585
627
|
: params.position
|
|
586
628
|
? bigintAmount(params.position)
|
|
587
629
|
: undefined,
|
|
588
|
-
lpTokenAmount:
|
|
589
|
-
|
|
590
|
-
|
|
630
|
+
lpTokenAmount: optionalBigintAmount(
|
|
631
|
+
optionalAmountValue(
|
|
632
|
+
params,
|
|
633
|
+
"lpToken",
|
|
634
|
+
optionalAmountValue(params, "value"),
|
|
635
|
+
),
|
|
591
636
|
),
|
|
592
637
|
percentageToRemove:
|
|
593
638
|
typeof params.amount === "object"
|
|
594
|
-
? params.amount
|
|
639
|
+
? params.amount.percentage
|
|
595
640
|
: undefined,
|
|
596
641
|
slippageBps: params.slippageBps ?? 50,
|
|
597
642
|
deadline: params.deadline,
|
|
@@ -623,10 +668,5 @@ export function createEvmLpProtocolProvider({
|
|
|
623
668
|
},
|
|
624
669
|
};
|
|
625
670
|
|
|
626
|
-
if (typeof service.repositionPosition === "function") {
|
|
627
|
-
provider.repositionPosition = (params) =>
|
|
628
|
-
service.repositionPosition(params) as Promise<EvmTransactionResult>;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
671
|
return provider;
|
|
632
672
|
}
|
|
@@ -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
|
IUserLpProfileService,
|
|
@@ -17,11 +16,11 @@ export class UserLpProfileService
|
|
|
17
16
|
private profiles: Map<string, UserLpProfile> = new Map();
|
|
18
17
|
|
|
19
18
|
async start(_runtime?: IAgentRuntime): Promise<void> {
|
|
20
|
-
//
|
|
19
|
+
// In-memory profiles are ready immediately.
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
async stop(_runtime?: IAgentRuntime): Promise<void> {
|
|
24
|
-
// No
|
|
23
|
+
// No external resources to release.
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
// Static methods required by ElizaOS Service architecture
|
|
@@ -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 { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
|
4
3
|
import {
|
|
@@ -35,7 +34,7 @@ export class VaultService extends Service implements IVaultService {
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
async stop(): Promise<void> {
|
|
38
|
-
//
|
|
37
|
+
// Connection lifecycle is managed by the Solana client helper.
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
public async createVault(
|
|
@@ -136,8 +135,15 @@ export class VaultService extends Service implements IVaultService {
|
|
|
136
135
|
): Promise<string> {
|
|
137
136
|
// In a real implementation, you would verify the confirmationToken
|
|
138
137
|
// For now, we'll do a simple check
|
|
139
|
-
if (
|
|
140
|
-
|
|
138
|
+
if (
|
|
139
|
+
!confirmationToken ||
|
|
140
|
+
confirmationToken.length < 32 ||
|
|
141
|
+
confirmationToken.length > 256 ||
|
|
142
|
+
!/^[A-Za-z0-9_-]+$/.test(confirmationToken)
|
|
143
|
+
) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Invalid confirmation token — use a cryptographically random token (32+ chars)",
|
|
146
|
+
);
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
try {
|
|
@@ -1,6 +1,5 @@
|
|
|
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
|
-
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
|
|
2
|
+
import { LAMPORTS_PER_SOL } from "@solana/web3.js";
|
|
4
3
|
import type {
|
|
5
4
|
IDexInteractionService,
|
|
6
5
|
IUserLpProfileService,
|
|
@@ -12,12 +11,10 @@ import type {
|
|
|
12
11
|
import type { DexInteractionService } from "./DexInteractionService.ts";
|
|
13
12
|
import type { UserLpProfileService } from "./UserLpProfileService.ts";
|
|
14
13
|
|
|
15
|
-
// Placeholder constants - should be configurable or dynamically fetched
|
|
16
14
|
const _AVG_SOL_TX_FEE_LAMPORTS = BigInt(5000); // Average fee for a simple Solana transaction
|
|
17
15
|
const AVG_SWAP_TX_FEE_LAMPORTS = BigInt(10000); // Potentially higher for swaps involving more accounts/CUs
|
|
18
16
|
const AVG_LP_ADD_REMOVE_TX_FEE_LAMPORTS = BigInt(15000); // LP operations can be more complex
|
|
19
|
-
const
|
|
20
|
-
const _PLACEHOLDER_SWAP_FEE_BPS = 30; // Placeholder for swap fee in basis points (0.3%)
|
|
17
|
+
const DEFAULT_SOL_PRICE_USD = 150;
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
20
|
* Interface for the YieldOptimizationService.
|
|
@@ -74,6 +71,22 @@ export interface IYieldOptimizationService extends Service {
|
|
|
74
71
|
): Promise<OptimizationOpportunity[]>;
|
|
75
72
|
}
|
|
76
73
|
|
|
74
|
+
function readPositiveNumberSetting(
|
|
75
|
+
runtime: IAgentRuntime,
|
|
76
|
+
key: string,
|
|
77
|
+
fallback: number,
|
|
78
|
+
): number {
|
|
79
|
+
const fromSetting =
|
|
80
|
+
typeof runtime.getSetting === "function"
|
|
81
|
+
? runtime.getSetting(key)
|
|
82
|
+
: undefined;
|
|
83
|
+
const raw =
|
|
84
|
+
(typeof fromSetting === "string" && fromSetting) ||
|
|
85
|
+
(typeof process !== "undefined" ? process.env?.[key] : undefined);
|
|
86
|
+
const parsed = Number(raw);
|
|
87
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
88
|
+
}
|
|
89
|
+
|
|
77
90
|
export class YieldOptimizationService
|
|
78
91
|
extends Service
|
|
79
92
|
implements IYieldOptimizationService
|
|
@@ -84,6 +97,7 @@ export class YieldOptimizationService
|
|
|
84
97
|
|
|
85
98
|
private dexInteractionService!: IDexInteractionService;
|
|
86
99
|
private userLpProfileService!: IUserLpProfileService;
|
|
100
|
+
private solPriceUsdForCosting = DEFAULT_SOL_PRICE_USD;
|
|
87
101
|
|
|
88
102
|
// Static methods required by ElizaOS Service architecture
|
|
89
103
|
static async start(
|
|
@@ -111,10 +125,15 @@ export class YieldOptimizationService
|
|
|
111
125
|
}
|
|
112
126
|
this.dexInteractionService = dexInteractionService;
|
|
113
127
|
this.userLpProfileService = userLpProfileService;
|
|
128
|
+
this.solPriceUsdForCosting = readPositiveNumberSetting(
|
|
129
|
+
runtime,
|
|
130
|
+
"LP_SOL_PRICE_USD",
|
|
131
|
+
DEFAULT_SOL_PRICE_USD,
|
|
132
|
+
);
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
async stop(): Promise<void> {
|
|
117
|
-
//
|
|
136
|
+
// Collaborating services own their own lifecycles.
|
|
118
137
|
}
|
|
119
138
|
|
|
120
139
|
async fetchAllPoolData(): Promise<PoolInfo[]> {
|
|
@@ -205,7 +224,7 @@ export class YieldOptimizationService
|
|
|
205
224
|
}
|
|
206
225
|
const allAvailablePools = await this.fetchAllPoolData();
|
|
207
226
|
const opportunities: OptimizationOpportunity[] = [];
|
|
208
|
-
const solPriceUsdForCosting =
|
|
227
|
+
const solPriceUsdForCosting = this.solPriceUsdForCosting;
|
|
209
228
|
|
|
210
229
|
for (const position of currentPositions) {
|
|
211
230
|
const { underlyingTokens } = position;
|
|
@@ -332,13 +351,10 @@ export class YieldOptimizationService
|
|
|
332
351
|
}
|
|
333
352
|
|
|
334
353
|
public async findBestYield(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
354
|
+
_userId: string,
|
|
355
|
+
_currentTokenA: string,
|
|
356
|
+
_currentTokenB: string,
|
|
338
357
|
): Promise<OptimizationOpportunity[]> {
|
|
339
|
-
console.log(
|
|
340
|
-
`Finding best yield for user ${userId} with tokens ${currentTokenA} and ${currentTokenB}`,
|
|
341
|
-
);
|
|
342
358
|
return [];
|
|
343
359
|
}
|
|
344
360
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — test-only mock for LP registry and E2E setup
|
|
2
1
|
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
3
2
|
import type {
|
|
4
3
|
AddLiquidityConfig,
|
|
@@ -15,7 +14,7 @@ import {
|
|
|
15
14
|
|
|
16
15
|
export class MockLpService extends Service implements ILpService {
|
|
17
16
|
public readonly capabilityDescription =
|
|
18
|
-
"
|
|
17
|
+
"Provides standardized access to DEX liquidity pools.";
|
|
19
18
|
private positions = new Map<string, LpPositionDetails[]>();
|
|
20
19
|
|
|
21
20
|
constructor(
|
package/src/lp/types.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 type {
|
|
3
2
|
IAgentRuntime,
|
|
4
3
|
ILpService,
|
|
@@ -92,6 +91,13 @@ export interface EvmWallet {
|
|
|
92
91
|
privateKey: `0x${string}`;
|
|
93
92
|
}
|
|
94
93
|
|
|
94
|
+
export type EvmPoolTokenInfo = PoolInfo["tokenA"] & {
|
|
95
|
+
/** EVM token contract address. Also mirrored to mint for core PoolInfo compatibility. */
|
|
96
|
+
address: Address;
|
|
97
|
+
mint: Address;
|
|
98
|
+
decimals: number;
|
|
99
|
+
};
|
|
100
|
+
|
|
95
101
|
export interface EvmPoolInfo extends Omit<PoolInfo, "tokenA" | "tokenB"> {
|
|
96
102
|
/** Chain ID where the pool exists */
|
|
97
103
|
chainId: number;
|
|
@@ -100,19 +106,9 @@ export interface EvmPoolInfo extends Omit<PoolInfo, "tokenA" | "tokenB"> {
|
|
|
100
106
|
/** Pool contract address */
|
|
101
107
|
poolAddress: Address;
|
|
102
108
|
/** Token A info with EVM address */
|
|
103
|
-
tokenA:
|
|
104
|
-
address: Address;
|
|
105
|
-
symbol?: string;
|
|
106
|
-
decimals: number;
|
|
107
|
-
reserve?: string;
|
|
108
|
-
};
|
|
109
|
+
tokenA: EvmPoolTokenInfo;
|
|
109
110
|
/** Token B info with EVM address */
|
|
110
|
-
tokenB:
|
|
111
|
-
address: Address;
|
|
112
|
-
symbol?: string;
|
|
113
|
-
decimals: number;
|
|
114
|
-
reserve?: string;
|
|
115
|
-
};
|
|
111
|
+
tokenB: EvmPoolTokenInfo;
|
|
116
112
|
/** Fee tier (for Uniswap V3 style pools) */
|
|
117
113
|
feeTier?: number;
|
|
118
114
|
/** Tick spacing (for concentrated liquidity) */
|
|
@@ -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 } from "@elizaos/core";
|
|
3
2
|
import { Connection, clusterApiUrl, Keypair, PublicKey } from "@solana/web3.js";
|
|
4
3
|
import bs58 from "bs58";
|
|
@@ -75,7 +74,10 @@ export async function loadWallet(
|
|
|
75
74
|
const signer = Keypair.fromSecretKey(secretKey);
|
|
76
75
|
return { signer, address: signer.publicKey };
|
|
77
76
|
} catch (e2) {
|
|
78
|
-
logger.error(
|
|
77
|
+
logger.error(
|
|
78
|
+
"Error decoding private key:",
|
|
79
|
+
e2 instanceof Error ? e2.message : String(e2),
|
|
80
|
+
);
|
|
79
81
|
throw new Error(
|
|
80
82
|
"Invalid private key format - must be base58 or base64 encoded",
|
|
81
83
|
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { walletPlugin } from "./plugin";
|
|
3
|
+
|
|
4
|
+
describe("walletPlugin route contract", () => {
|
|
5
|
+
it("exposes both EVM and Solana browser signing routes through the aggregate plugin", () => {
|
|
6
|
+
const routeNames =
|
|
7
|
+
walletPlugin.routes?.map((route) => route.name).filter(Boolean) ?? [];
|
|
8
|
+
|
|
9
|
+
expect(routeNames).toEqual(
|
|
10
|
+
expect.arrayContaining([
|
|
11
|
+
"wallet-evm-address",
|
|
12
|
+
"wallet-evm-personal-sign",
|
|
13
|
+
"wallet-evm-sign-typed-data",
|
|
14
|
+
"wallet-evm-sign-transaction",
|
|
15
|
+
"wallet-evm-send-transaction",
|
|
16
|
+
"wallet-solana-pubkey",
|
|
17
|
+
"wallet-solana-sign-message",
|
|
18
|
+
"wallet-solana-sign-transaction",
|
|
19
|
+
"wallet-solana-sign-all-transactions",
|
|
20
|
+
"wallet-solana-sign-and-send-transaction",
|
|
21
|
+
]),
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
package/src/plugin.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
parseBooleanFromText,
|
|
6
6
|
type ServiceClass,
|
|
7
7
|
} from "@elizaos/core";
|
|
8
|
-
import { walletSearchAddressAction } from "./analytics/birdeye/actions/wallet-search-address.js";
|
|
9
8
|
import { agentPortfolioProvider } from "./analytics/birdeye/providers/agent-portfolio-provider.js";
|
|
10
9
|
import { marketProvider } from "./analytics/birdeye/providers/market.js";
|
|
11
10
|
import { trendingProvider } from "./analytics/birdeye/providers/trending.js";
|
|
@@ -16,19 +15,20 @@ import {
|
|
|
16
15
|
} from "./analytics/birdeye/service.js";
|
|
17
16
|
import { registerDexScreenerSearchCategory } from "./analytics/dexscreener/search-category.js";
|
|
18
17
|
import { DexScreenerService } from "./analytics/dexscreener/service.js";
|
|
19
|
-
import { tokenInfoAction } from "./analytics/token-info/action.js";
|
|
20
18
|
import { TokenInfoService } from "./analytics/token-info/service.js";
|
|
21
19
|
import evmPlugin from "./chains/evm/index.js";
|
|
22
20
|
import solanaPlugin from "./chains/solana/index.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
21
|
+
import { walletProvider } from "./providers/wallet-provider.js";
|
|
22
|
+
import {
|
|
23
|
+
WALLET_BACKEND_SERVICE_TYPE,
|
|
24
|
+
WalletBackendService,
|
|
25
|
+
} from "./services/wallet-backend-service.js";
|
|
25
26
|
|
|
26
27
|
const coreWalletPlugin: Plugin = {
|
|
27
28
|
name: "wallet-backend",
|
|
28
|
-
description:
|
|
29
|
-
"Wallet backend service + unified wallet provider (Steward / local).",
|
|
29
|
+
description: "Wallet backend service + wallet provider (Steward / local).",
|
|
30
30
|
services: [WalletBackendService],
|
|
31
|
-
providers: [
|
|
31
|
+
providers: [walletProvider],
|
|
32
32
|
actions: [],
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -100,7 +100,7 @@ const analyticsServices: ServiceClass[] = [
|
|
|
100
100
|
export const walletPlugin: Plugin = {
|
|
101
101
|
name: "wallet",
|
|
102
102
|
description:
|
|
103
|
-
"
|
|
103
|
+
"Non-custodial wallet for elizaOS — EVM + Solana, Steward/local backends, x402, CCTP, and venue routing.",
|
|
104
104
|
services: concatServices(
|
|
105
105
|
coreWalletPlugin.services,
|
|
106
106
|
evmPlugin.services as ServiceClass[] | undefined,
|
|
@@ -108,11 +108,8 @@ export const walletPlugin: Plugin = {
|
|
|
108
108
|
analyticsServices,
|
|
109
109
|
),
|
|
110
110
|
providers: concatPlugins(coreWalletPlugin.providers, evmPlugin.providers),
|
|
111
|
-
actions: concatPlugins(coreWalletPlugin.actions, evmPlugin.actions,
|
|
112
|
-
|
|
113
|
-
walletSearchAddressAction,
|
|
114
|
-
]),
|
|
115
|
-
routes: concatPlugins(solanaPlugin.routes),
|
|
111
|
+
actions: concatPlugins(coreWalletPlugin.actions, evmPlugin.actions),
|
|
112
|
+
routes: concatPlugins(evmPlugin.routes, solanaPlugin.routes),
|
|
116
113
|
init: async (config, runtime) => {
|
|
117
114
|
await coreWalletPlugin.init?.(config, runtime);
|
|
118
115
|
await evmPlugin.init?.(config, runtime);
|
|
@@ -120,6 +117,26 @@ export const walletPlugin: Plugin = {
|
|
|
120
117
|
registerDexScreenerSearchCategory(runtime);
|
|
121
118
|
await initBirdeyeAnalytics(runtime);
|
|
122
119
|
},
|
|
120
|
+
async dispose(runtime: IAgentRuntime) {
|
|
121
|
+
await evmPlugin.dispose?.(runtime);
|
|
122
|
+
await solanaPlugin.dispose?.(runtime);
|
|
123
|
+
const birdeye = runtime.getService<BirdeyeService>(
|
|
124
|
+
BirdeyeService.serviceType,
|
|
125
|
+
);
|
|
126
|
+
await birdeye?.stop();
|
|
127
|
+
const dexscreener = runtime.getService<DexScreenerService>(
|
|
128
|
+
DexScreenerService.serviceType,
|
|
129
|
+
);
|
|
130
|
+
await dexscreener?.stop();
|
|
131
|
+
const tokenInfo = runtime.getService<TokenInfoService>(
|
|
132
|
+
TokenInfoService.serviceType,
|
|
133
|
+
);
|
|
134
|
+
await tokenInfo?.stop();
|
|
135
|
+
const walletBackend = runtime.getService<WalletBackendService>(
|
|
136
|
+
WALLET_BACKEND_SERVICE_TYPE,
|
|
137
|
+
);
|
|
138
|
+
await walletBackend?.stop();
|
|
139
|
+
},
|
|
123
140
|
};
|
|
124
141
|
|
|
125
142
|
export default walletPlugin;
|
|
@@ -9,7 +9,7 @@ export type HealthStatus = { ok: true } | { ok: false; reason: string };
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Typed venue / data-source adapter. Canonical actions dispatch into concrete
|
|
12
|
-
* provider classes registered on the runtime provider registry
|
|
12
|
+
* provider classes registered on the runtime provider registry.
|
|
13
13
|
*
|
|
14
14
|
* See docs/architecture/wallet-and-trading.md §B.3.
|
|
15
15
|
*/
|
|
@@ -10,12 +10,12 @@ const MAX_WALLET_TEXT_CHARS = 1000;
|
|
|
10
10
|
/**
|
|
11
11
|
* Injects live addresses into planner context. Always-on (200-token budget in spec).
|
|
12
12
|
*/
|
|
13
|
-
export const
|
|
13
|
+
export const walletProvider: Provider = {
|
|
14
14
|
name: "wallet",
|
|
15
15
|
description:
|
|
16
|
-
"
|
|
16
|
+
"Non-custodial wallet — EVM + Solana addresses (@elizaos/plugin-wallet).",
|
|
17
17
|
descriptionCompressed:
|
|
18
|
-
"
|
|
18
|
+
"non-custodial wallet EVM + Solana address (elizaos/plugin-wallet)",
|
|
19
19
|
contexts: ["finance", "crypto", "wallet"],
|
|
20
20
|
contextGate: { anyOf: ["finance", "crypto", "wallet"] },
|
|
21
21
|
cacheStable: false,
|