@elizaos/plugin-wallet 2.0.0-beta.1 → 2.0.3-beta.5
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,116 @@
|
|
|
1
|
+
import { type IAgentRuntime, type ILpService, type LpPositionDetails, type PoolInfo, Service, type TokenBalance, type TransactionResult } from "@elizaos/core";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { AddLiquidityConfig, EvmPoolInfo, IEvmLpService, RemoveLiquidityConfig } from "../types.ts";
|
|
4
|
+
export declare const LP_MANAGEMENT_SERVICE_TYPE = "lp-management";
|
|
5
|
+
export type LpProtocolChain = "solana" | "evm";
|
|
6
|
+
export interface LpProtocolRequest {
|
|
7
|
+
chain?: LpProtocolChain | string;
|
|
8
|
+
dex?: string;
|
|
9
|
+
chainId?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface LpListPoolsParams extends LpProtocolRequest {
|
|
12
|
+
tokenA?: string;
|
|
13
|
+
tokenB?: string;
|
|
14
|
+
feeTier?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface LpPositionOperationParams extends LpProtocolRequest {
|
|
17
|
+
userVault?: object;
|
|
18
|
+
wallet?: {
|
|
19
|
+
address: Address;
|
|
20
|
+
privateKey: `0x${string}`;
|
|
21
|
+
};
|
|
22
|
+
owner?: string;
|
|
23
|
+
pool?: string | PoolInfo | EvmPoolInfo;
|
|
24
|
+
position?: string;
|
|
25
|
+
tokenId?: string | bigint;
|
|
26
|
+
amount?: string | number | bigint | {
|
|
27
|
+
value?: string | number | bigint;
|
|
28
|
+
tokenA?: string | number | bigint;
|
|
29
|
+
tokenB?: string | number | bigint;
|
|
30
|
+
lpToken?: string | number | bigint;
|
|
31
|
+
percentage?: number;
|
|
32
|
+
};
|
|
33
|
+
amounts?: {
|
|
34
|
+
tokenA?: string | number | bigint;
|
|
35
|
+
tokenB?: string | number | bigint;
|
|
36
|
+
lpToken?: string | number | bigint;
|
|
37
|
+
};
|
|
38
|
+
range?: {
|
|
39
|
+
tickLower?: number;
|
|
40
|
+
tickUpper?: number;
|
|
41
|
+
tickLowerIndex?: number;
|
|
42
|
+
tickUpperIndex?: number;
|
|
43
|
+
priceLower?: number;
|
|
44
|
+
priceUpper?: number;
|
|
45
|
+
};
|
|
46
|
+
slippageBps?: number;
|
|
47
|
+
deadline?: bigint;
|
|
48
|
+
}
|
|
49
|
+
export interface LpProtocolProvider {
|
|
50
|
+
id: string;
|
|
51
|
+
chain: LpProtocolChain;
|
|
52
|
+
dex: string;
|
|
53
|
+
label?: string;
|
|
54
|
+
service?: unknown;
|
|
55
|
+
supportedChainIds?: number[];
|
|
56
|
+
supportsRequest?: (request: LpProtocolRequest) => boolean;
|
|
57
|
+
listPools(params: LpListPoolsParams): Promise<PoolInfo[]>;
|
|
58
|
+
openPosition(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
59
|
+
closePosition(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
60
|
+
repositionPosition?(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
61
|
+
getPosition?(params: LpPositionOperationParams): Promise<LpPositionDetails | null>;
|
|
62
|
+
listPositions?(params: LpPositionOperationParams): Promise<LpPositionDetails[]>;
|
|
63
|
+
getMarketData?(poolIds: string[]): Promise<Record<string, Partial<PoolInfo>>>;
|
|
64
|
+
}
|
|
65
|
+
type SolanaLpServiceAdapter = Partial<ILpService> & {
|
|
66
|
+
repositionPosition?(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
67
|
+
};
|
|
68
|
+
export declare class NoMatchingLpProtocolError extends Error {
|
|
69
|
+
readonly code = "NO_MATCHING_LP_PROTOCOL";
|
|
70
|
+
constructor(request: LpProtocolRequest);
|
|
71
|
+
}
|
|
72
|
+
export declare class LpManagementService extends Service implements ILpService {
|
|
73
|
+
static readonly serviceType = "lp-management";
|
|
74
|
+
readonly capabilityDescription = "Provides standardized access to DEX liquidity pools.";
|
|
75
|
+
private protocols;
|
|
76
|
+
static start(runtime: IAgentRuntime): Promise<LpManagementService>;
|
|
77
|
+
stop(): Promise<void>;
|
|
78
|
+
getDexName(): string;
|
|
79
|
+
registerProtocol(provider: LpProtocolProvider): void;
|
|
80
|
+
unregisterProtocol(request: LpProtocolRequest): boolean;
|
|
81
|
+
listProtocols(request?: LpProtocolRequest): LpProtocolProvider[];
|
|
82
|
+
listPools(params?: LpListPoolsParams): Promise<PoolInfo[]>;
|
|
83
|
+
openPosition(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
84
|
+
closePosition(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
85
|
+
repositionPosition(params: LpPositionOperationParams): Promise<TransactionResult>;
|
|
86
|
+
getPosition(params: LpPositionOperationParams): Promise<LpPositionDetails | null>;
|
|
87
|
+
listPositions(params?: LpPositionOperationParams): Promise<LpPositionDetails[]>;
|
|
88
|
+
getPools(tokenAMint?: string, tokenBMint?: string): Promise<PoolInfo[]>;
|
|
89
|
+
addLiquidity(params: AddLiquidityConfig & {
|
|
90
|
+
chain?: string;
|
|
91
|
+
}): Promise<TransactionResult & {
|
|
92
|
+
lpTokensReceived?: TokenBalance;
|
|
93
|
+
}>;
|
|
94
|
+
removeLiquidity(params: RemoveLiquidityConfig & {
|
|
95
|
+
chain?: string;
|
|
96
|
+
}): Promise<TransactionResult & {
|
|
97
|
+
tokensReceived?: TokenBalance[];
|
|
98
|
+
}>;
|
|
99
|
+
getLpPositionDetails(userAccountPublicKey: string, poolOrPositionIdentifier: string): Promise<LpPositionDetails | null>;
|
|
100
|
+
getMarketDataForPools(poolIds: string[]): Promise<Record<string, Partial<PoolInfo>>>;
|
|
101
|
+
private matchingProtocols;
|
|
102
|
+
private resolveProtocol;
|
|
103
|
+
}
|
|
104
|
+
export declare function getLpManagementService(runtime: IAgentRuntime): Promise<LpManagementService | null>;
|
|
105
|
+
export declare function registerLpProtocolProvider(runtime: IAgentRuntime, provider: LpProtocolProvider): Promise<void>;
|
|
106
|
+
export declare function createSolanaLpProtocolProvider({ dex, label, service, }: {
|
|
107
|
+
dex: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
service: SolanaLpServiceAdapter;
|
|
110
|
+
}): LpProtocolProvider;
|
|
111
|
+
export declare function createEvmLpProtocolProvider({ dex, label, service, }: {
|
|
112
|
+
dex: string;
|
|
113
|
+
label?: string;
|
|
114
|
+
service: IEvmLpService;
|
|
115
|
+
}): LpProtocolProvider;
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
2
|
+
import type { IUserLpProfileService, TrackedLpPosition, TrackedLpPositionInput, UserLpProfile } from "../types.ts";
|
|
3
|
+
export declare class UserLpProfileService extends Service implements IUserLpProfileService {
|
|
4
|
+
static readonly serviceType = "UserLpProfileService";
|
|
5
|
+
readonly capabilityDescription = "Manages user profiles and preferences for LP management.";
|
|
6
|
+
private profiles;
|
|
7
|
+
start(_runtime?: IAgentRuntime): Promise<void>;
|
|
8
|
+
stop(_runtime?: IAgentRuntime): Promise<void>;
|
|
9
|
+
static start(runtime: IAgentRuntime): Promise<UserLpProfileService>;
|
|
10
|
+
static stop(_runtime: IAgentRuntime): Promise<void>;
|
|
11
|
+
ensureProfile(userId: string, vaultPublicKey: string, encryptedSecretKey: string, initialConfig?: Partial<UserLpProfile["autoRebalanceConfig"]>): Promise<UserLpProfile>;
|
|
12
|
+
getProfile(userId: string): Promise<UserLpProfile | null>;
|
|
13
|
+
updateProfile(userId: string, updates: Partial<Omit<UserLpProfile, "userId" | "createdAt" | "version">>): Promise<UserLpProfile>;
|
|
14
|
+
addTrackedPosition(userId: string, position: TrackedLpPositionInput): Promise<UserLpProfile>;
|
|
15
|
+
removeTrackedPosition(userId: string, positionIdentifier: string): Promise<UserLpProfile>;
|
|
16
|
+
getTrackedPositions(userId: string): Promise<TrackedLpPosition[]>;
|
|
17
|
+
getAllProfilesWithAutoRebalanceEnabled(): Promise<UserLpProfile[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
2
|
+
import { Keypair } from "@solana/web3.js";
|
|
3
|
+
import type { IVaultService, TokenBalance } from "../types.ts";
|
|
4
|
+
export declare class VaultService extends Service implements IVaultService {
|
|
5
|
+
static readonly serviceType = "VaultService";
|
|
6
|
+
readonly capabilityDescription = "Manages secure vaults for user cryptographic keys.";
|
|
7
|
+
private connection;
|
|
8
|
+
private vaultCache;
|
|
9
|
+
static start(runtime: IAgentRuntime): Promise<VaultService>;
|
|
10
|
+
static stop(_runtime: IAgentRuntime): Promise<void>;
|
|
11
|
+
start(runtime: IAgentRuntime): Promise<void>;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
createVault(userId: string): Promise<{
|
|
14
|
+
publicKey: string;
|
|
15
|
+
secretKeyEncrypted: string;
|
|
16
|
+
}>;
|
|
17
|
+
getVaultKeypair(userId: string, encryptedSecretKey: string): Promise<Keypair>;
|
|
18
|
+
getVaultPublicKey(userId: string): Promise<string | null>;
|
|
19
|
+
getBalances(publicKey: string): Promise<TokenBalance[]>;
|
|
20
|
+
exportPrivateKey(userId: string, encryptedSecretKey: string, confirmationToken: string): Promise<string>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
2
|
+
import type { LpPositionDetails, OptimizationOpportunity, PoolInfo, TokenBalance } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the YieldOptimizationService.
|
|
5
|
+
* This service is responsible for fetching data about available LP pools,
|
|
6
|
+
* finding better yield opportunities, and calculating the costs of rebalancing.
|
|
7
|
+
*/
|
|
8
|
+
export interface IYieldOptimizationService extends Service {
|
|
9
|
+
/**
|
|
10
|
+
* Fetches comprehensive data for all relevant pools across all supported DEXs.
|
|
11
|
+
* This data is used as the basis for finding optimization opportunities.
|
|
12
|
+
* @returns A promise that resolves to an array of PoolInfo objects.
|
|
13
|
+
*/
|
|
14
|
+
fetchAllPoolData(): Promise<PoolInfo[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Analyzes current LP positions and idle assets to find better yield opportunities.
|
|
17
|
+
* @param userId - The user's ID
|
|
18
|
+
* @param currentPositions - An array of the user's current LpPositionDetails.
|
|
19
|
+
* @param idleAssets - An array of the user's idle TokenBalance that could be deployed.
|
|
20
|
+
* @returns A promise that resolves to an array of OptimizationOpportunity objects.
|
|
21
|
+
*/
|
|
22
|
+
findBestYieldOpportunities(userId: string, currentPositions: LpPositionDetails[], idleAssets: TokenBalance[]): Promise<OptimizationOpportunity[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Calculates the estimated cost of moving liquidity from one position/pool to another.
|
|
25
|
+
* This includes transaction fees, swap fees (if tokens need to be swapped), and potential slippage.
|
|
26
|
+
* @param fromPosition - The user's current LpPositionDetails (if rebalancing an existing position).
|
|
27
|
+
* @param toPool - The target PoolInfo to move liquidity to.
|
|
28
|
+
* @param solPriceUsd - The current SOL price in USD
|
|
29
|
+
* @param amountToMoveLamports - Optional. The specific amount of LP value (in SOL or stablecoin equivalent) to move.
|
|
30
|
+
* @returns A promise that resolves to an object detailing the costs.
|
|
31
|
+
*/
|
|
32
|
+
calculateRebalanceCost(fromPosition: LpPositionDetails | null, toPool: PoolInfo, solPriceUsd: number, amountToMoveLamports?: string, underlyingTokensToMove?: TokenBalance[]): Promise<{
|
|
33
|
+
costSolLamports: string;
|
|
34
|
+
costUsd?: number;
|
|
35
|
+
steps: string[];
|
|
36
|
+
error?: string;
|
|
37
|
+
}>;
|
|
38
|
+
findBestYield(userId: string, currentTokenA: string, currentTokenB: string): Promise<OptimizationOpportunity[]>;
|
|
39
|
+
}
|
|
40
|
+
export declare class YieldOptimizationService extends Service implements IYieldOptimizationService {
|
|
41
|
+
static readonly serviceType = "YieldOptimizationService";
|
|
42
|
+
readonly capabilityDescription = "Finds and evaluates yield optimization opportunities across DEXs.";
|
|
43
|
+
private dexInteractionService;
|
|
44
|
+
private userLpProfileService;
|
|
45
|
+
private solPriceUsdForCosting;
|
|
46
|
+
static start(runtime: IAgentRuntime): Promise<YieldOptimizationService>;
|
|
47
|
+
static stop(_runtime: IAgentRuntime): Promise<void>;
|
|
48
|
+
start(runtime: IAgentRuntime): Promise<void>;
|
|
49
|
+
stop(): Promise<void>;
|
|
50
|
+
fetchAllPoolData(): Promise<PoolInfo[]>;
|
|
51
|
+
calculateRebalanceCost(fromPositionOrNull: LpPositionDetails | null, targetPool: PoolInfo, solPriceUsd: number, _valueOfLpTokensToMoveLamports?: string, underlyingTokensAvailable?: TokenBalance[]): Promise<{
|
|
52
|
+
costSolLamports: string;
|
|
53
|
+
costUsd?: number;
|
|
54
|
+
steps: string[];
|
|
55
|
+
error?: string;
|
|
56
|
+
}>;
|
|
57
|
+
findBestYieldOpportunities(userId: string, currentPositions: LpPositionDetails[], idleAssets: TokenBalance[]): Promise<OptimizationOpportunity[]>;
|
|
58
|
+
findBestYield(_userId: string, _currentTokenA: string, _currentTokenB: string): Promise<OptimizationOpportunity[]>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
2
|
+
import type { AddLiquidityConfig, ILpService, LpPositionDetails, PoolInfo, RemoveLiquidityConfig, TransactionResult } from "../../types.ts";
|
|
3
|
+
export declare class MockLpService extends Service implements ILpService {
|
|
4
|
+
private readonly dexName;
|
|
5
|
+
readonly capabilityDescription = "Provides standardized access to DEX liquidity pools.";
|
|
6
|
+
private positions;
|
|
7
|
+
constructor(runtime: IAgentRuntime, dexName?: string);
|
|
8
|
+
getDexName(): string;
|
|
9
|
+
getPools(tokenAMint?: string, tokenBMint?: string): Promise<PoolInfo[]>;
|
|
10
|
+
addLiquidity(config: AddLiquidityConfig): Promise<TransactionResult>;
|
|
11
|
+
removeLiquidity(config: RemoveLiquidityConfig): Promise<TransactionResult>;
|
|
12
|
+
getLpPositionDetails(owner: string, poolOrPositionIdentifier: string): Promise<LpPositionDetails | null>;
|
|
13
|
+
getMarketDataForPools(poolIds: string[]): Promise<Record<string, Partial<PoolInfo>>>;
|
|
14
|
+
start(): Promise<void>;
|
|
15
|
+
stop(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare function registerMockDexServices(runtime: IAgentRuntime): Promise<void>;
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import type { IAgentRuntime, ILpService, LpPositionDetails, PoolInfo, Service, TokenBalance, TransactionResult } from "@elizaos/core";
|
|
2
|
+
import type { Keypair as SolanaKeypair } from "@solana/web3.js";
|
|
3
|
+
import type { Address, Hash } from "viem";
|
|
4
|
+
export type { ILpService, LpPositionDetails, PoolInfo, TokenBalance, TransactionResult, } from "@elizaos/core";
|
|
5
|
+
export type ChainType = "solana" | "evm";
|
|
6
|
+
export type SolanaDex = "raydium" | "orca" | "meteora";
|
|
7
|
+
export type EvmDex = "uniswap" | "pancakeswap" | "aerodrome";
|
|
8
|
+
export type DexName = SolanaDex | EvmDex;
|
|
9
|
+
export interface RpcConfig {
|
|
10
|
+
/** Primary RPC URL */
|
|
11
|
+
url: string;
|
|
12
|
+
/** Fallback RPC URLs */
|
|
13
|
+
fallbacks?: string[];
|
|
14
|
+
/** RPC provider name for identification */
|
|
15
|
+
provider?: "alchemy" | "infura" | "quicknode" | "public" | "custom";
|
|
16
|
+
}
|
|
17
|
+
export interface SolanaConfig {
|
|
18
|
+
/** Solana RPC configuration */
|
|
19
|
+
rpc: RpcConfig;
|
|
20
|
+
/** Private key (base58 encoded) */
|
|
21
|
+
privateKey?: string;
|
|
22
|
+
/** Enabled DEXs on Solana */
|
|
23
|
+
enabledDexes: SolanaDex[];
|
|
24
|
+
}
|
|
25
|
+
export interface EvmChainConfig {
|
|
26
|
+
/** Chain ID */
|
|
27
|
+
chainId: number;
|
|
28
|
+
/** Chain name for display */
|
|
29
|
+
name: string;
|
|
30
|
+
/** RPC configuration */
|
|
31
|
+
rpc: RpcConfig;
|
|
32
|
+
/** Enabled DEXs on this chain */
|
|
33
|
+
enabledDexes: EvmDex[];
|
|
34
|
+
/** Native currency symbol */
|
|
35
|
+
nativeCurrency: string;
|
|
36
|
+
}
|
|
37
|
+
export interface EvmConfig {
|
|
38
|
+
/** Private key (hex string with 0x prefix) */
|
|
39
|
+
privateKey?: string;
|
|
40
|
+
/** Chain configurations */
|
|
41
|
+
chains: Record<string, EvmChainConfig>;
|
|
42
|
+
}
|
|
43
|
+
export interface LpManagerConfig {
|
|
44
|
+
/** Solana configuration (optional) */
|
|
45
|
+
solana?: SolanaConfig;
|
|
46
|
+
/** EVM configuration (optional) */
|
|
47
|
+
evm?: EvmConfig;
|
|
48
|
+
/** Default slippage in basis points */
|
|
49
|
+
defaultSlippageBps?: number;
|
|
50
|
+
/** Auto-rebalance settings */
|
|
51
|
+
autoRebalance?: {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
checkIntervalMs: number;
|
|
54
|
+
minGainThresholdPercent: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface EvmWallet {
|
|
58
|
+
address: Address;
|
|
59
|
+
privateKey: `0x${string}`;
|
|
60
|
+
}
|
|
61
|
+
export type EvmPoolTokenInfo = PoolInfo["tokenA"] & {
|
|
62
|
+
/** EVM token contract address. Also mirrored to mint for core PoolInfo compatibility. */
|
|
63
|
+
address: Address;
|
|
64
|
+
mint: Address;
|
|
65
|
+
decimals: number;
|
|
66
|
+
};
|
|
67
|
+
export interface EvmPoolInfo extends Omit<PoolInfo, "tokenA" | "tokenB"> {
|
|
68
|
+
/** Chain ID where the pool exists */
|
|
69
|
+
chainId: number;
|
|
70
|
+
/** Chain name */
|
|
71
|
+
chainName: string;
|
|
72
|
+
/** Pool contract address */
|
|
73
|
+
poolAddress: Address;
|
|
74
|
+
/** Token A info with EVM address */
|
|
75
|
+
tokenA: EvmPoolTokenInfo;
|
|
76
|
+
/** Token B info with EVM address */
|
|
77
|
+
tokenB: EvmPoolTokenInfo;
|
|
78
|
+
/** Fee tier (for Uniswap V3 style pools) */
|
|
79
|
+
feeTier?: number;
|
|
80
|
+
/** Tick spacing (for concentrated liquidity) */
|
|
81
|
+
tickSpacing?: number;
|
|
82
|
+
/** Current tick */
|
|
83
|
+
currentTick?: number;
|
|
84
|
+
/** Current sqrt price X96 */
|
|
85
|
+
sqrtPriceX96?: bigint;
|
|
86
|
+
}
|
|
87
|
+
export interface EvmPositionDetails extends Omit<LpPositionDetails, "lpTokenBalance" | "underlyingTokens"> {
|
|
88
|
+
/** Chain ID */
|
|
89
|
+
chainId: number;
|
|
90
|
+
/** Position NFT token ID (for Uniswap V3 style) */
|
|
91
|
+
tokenId?: bigint;
|
|
92
|
+
/** Position owner address */
|
|
93
|
+
owner: Address;
|
|
94
|
+
/** Lower tick (concentrated liquidity) */
|
|
95
|
+
tickLower?: number;
|
|
96
|
+
/** Upper tick (concentrated liquidity) */
|
|
97
|
+
tickUpper?: number;
|
|
98
|
+
/** Liquidity amount */
|
|
99
|
+
liquidity?: bigint;
|
|
100
|
+
/** LP token balance with EVM address */
|
|
101
|
+
lpTokenBalance: {
|
|
102
|
+
address: Address;
|
|
103
|
+
balance: string;
|
|
104
|
+
decimals: number;
|
|
105
|
+
symbol?: string;
|
|
106
|
+
uiAmount?: number;
|
|
107
|
+
name?: string;
|
|
108
|
+
logoURI?: string;
|
|
109
|
+
};
|
|
110
|
+
/** Underlying tokens with EVM addresses */
|
|
111
|
+
underlyingTokens: Array<{
|
|
112
|
+
address: Address;
|
|
113
|
+
balance: string;
|
|
114
|
+
decimals: number;
|
|
115
|
+
symbol?: string;
|
|
116
|
+
uiAmount?: number;
|
|
117
|
+
name?: string;
|
|
118
|
+
logoURI?: string;
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
export interface EvmAddLiquidityParams {
|
|
122
|
+
/** Wallet/signer */
|
|
123
|
+
wallet: EvmWallet;
|
|
124
|
+
/** Chain ID */
|
|
125
|
+
chainId: number;
|
|
126
|
+
/** Pool address */
|
|
127
|
+
poolAddress: Address;
|
|
128
|
+
/** Token A amount (in wei) */
|
|
129
|
+
tokenAAmount: bigint;
|
|
130
|
+
/** Token B amount (in wei) */
|
|
131
|
+
tokenBAmount?: bigint;
|
|
132
|
+
/** Slippage tolerance in bps */
|
|
133
|
+
slippageBps: number;
|
|
134
|
+
/** Lower tick for concentrated liquidity */
|
|
135
|
+
tickLower?: number;
|
|
136
|
+
/** Upper tick for concentrated liquidity */
|
|
137
|
+
tickUpper?: number;
|
|
138
|
+
/** Deadline timestamp */
|
|
139
|
+
deadline?: bigint;
|
|
140
|
+
}
|
|
141
|
+
export interface EvmRemoveLiquidityParams {
|
|
142
|
+
/** Wallet/signer */
|
|
143
|
+
wallet: EvmWallet;
|
|
144
|
+
/** Chain ID */
|
|
145
|
+
chainId: number;
|
|
146
|
+
/** Pool address */
|
|
147
|
+
poolAddress: Address;
|
|
148
|
+
/** Position token ID (for NFT positions) */
|
|
149
|
+
tokenId?: bigint;
|
|
150
|
+
/** LP token amount to remove (for standard pools) */
|
|
151
|
+
lpTokenAmount?: bigint;
|
|
152
|
+
/** Percentage to remove (0-100) */
|
|
153
|
+
percentageToRemove?: number;
|
|
154
|
+
/** Slippage tolerance in bps */
|
|
155
|
+
slippageBps: number;
|
|
156
|
+
/** Deadline timestamp */
|
|
157
|
+
deadline?: bigint;
|
|
158
|
+
}
|
|
159
|
+
export interface EvmTransactionResult extends TransactionResult {
|
|
160
|
+
/** Transaction hash */
|
|
161
|
+
hash?: Hash;
|
|
162
|
+
/** Chain ID */
|
|
163
|
+
chainId?: number;
|
|
164
|
+
/** Block number */
|
|
165
|
+
blockNumber?: bigint;
|
|
166
|
+
/** Gas used */
|
|
167
|
+
gasUsed?: bigint;
|
|
168
|
+
}
|
|
169
|
+
export interface IEvmLpService extends Service {
|
|
170
|
+
/** Returns the DEX name */
|
|
171
|
+
getDexName(): EvmDex;
|
|
172
|
+
/** Returns supported chain IDs */
|
|
173
|
+
getSupportedChainIds(): number[];
|
|
174
|
+
/** Check if a chain is supported */
|
|
175
|
+
supportsChain(chainId: number): boolean;
|
|
176
|
+
/** Get pools on a specific chain */
|
|
177
|
+
getPools(chainId: number, tokenA?: Address, tokenB?: Address, feeTier?: number): Promise<EvmPoolInfo[]>;
|
|
178
|
+
/** Add liquidity to a pool */
|
|
179
|
+
addLiquidity(params: EvmAddLiquidityParams): Promise<EvmTransactionResult>;
|
|
180
|
+
/** Remove liquidity from a pool */
|
|
181
|
+
removeLiquidity(params: EvmRemoveLiquidityParams): Promise<EvmTransactionResult>;
|
|
182
|
+
/** Get position details */
|
|
183
|
+
getPositionDetails(chainId: number, owner: Address, poolAddress: Address, tokenId?: bigint): Promise<EvmPositionDetails | null>;
|
|
184
|
+
/** Get all positions for an address */
|
|
185
|
+
getAllPositions(chainId: number, owner: Address): Promise<EvmPositionDetails[]>;
|
|
186
|
+
/** Get market data for pools */
|
|
187
|
+
getMarketData(poolAddresses: Address[]): Promise<Record<string, Partial<EvmPoolInfo>>>;
|
|
188
|
+
}
|
|
189
|
+
export declare const SUPPORTED_EVM_CHAINS: {
|
|
190
|
+
readonly ethereum: {
|
|
191
|
+
readonly chainId: 1;
|
|
192
|
+
readonly name: "Ethereum";
|
|
193
|
+
readonly nativeCurrency: "ETH";
|
|
194
|
+
readonly supportedDexes: EvmDex[];
|
|
195
|
+
readonly rpcEnvKeys: readonly ["ETHEREUM_RPC_URL", "ETH_RPC_URL", "EVM_PROVIDER_MAINNET"];
|
|
196
|
+
};
|
|
197
|
+
readonly base: {
|
|
198
|
+
readonly chainId: 8453;
|
|
199
|
+
readonly name: "Base";
|
|
200
|
+
readonly nativeCurrency: "ETH";
|
|
201
|
+
readonly supportedDexes: EvmDex[];
|
|
202
|
+
readonly rpcEnvKeys: readonly ["BASE_RPC_URL", "EVM_PROVIDER_BASE"];
|
|
203
|
+
};
|
|
204
|
+
readonly arbitrum: {
|
|
205
|
+
readonly chainId: 42161;
|
|
206
|
+
readonly name: "Arbitrum One";
|
|
207
|
+
readonly nativeCurrency: "ETH";
|
|
208
|
+
readonly supportedDexes: EvmDex[];
|
|
209
|
+
readonly rpcEnvKeys: readonly ["ARBITRUM_RPC_URL", "EVM_PROVIDER_ARBITRUM"];
|
|
210
|
+
};
|
|
211
|
+
readonly bsc: {
|
|
212
|
+
readonly chainId: 56;
|
|
213
|
+
readonly name: "BNB Smart Chain";
|
|
214
|
+
readonly nativeCurrency: "BNB";
|
|
215
|
+
readonly supportedDexes: EvmDex[];
|
|
216
|
+
readonly rpcEnvKeys: readonly ["BSC_RPC_URL", "EVM_PROVIDER_BSC"];
|
|
217
|
+
};
|
|
218
|
+
readonly polygon: {
|
|
219
|
+
readonly chainId: 137;
|
|
220
|
+
readonly name: "Polygon";
|
|
221
|
+
readonly nativeCurrency: "MATIC";
|
|
222
|
+
readonly supportedDexes: EvmDex[];
|
|
223
|
+
readonly rpcEnvKeys: readonly ["POLYGON_RPC_URL", "EVM_PROVIDER_POLYGON"];
|
|
224
|
+
};
|
|
225
|
+
readonly optimism: {
|
|
226
|
+
readonly chainId: 10;
|
|
227
|
+
readonly name: "Optimism";
|
|
228
|
+
readonly nativeCurrency: "ETH";
|
|
229
|
+
readonly supportedDexes: EvmDex[];
|
|
230
|
+
readonly rpcEnvKeys: readonly ["OPTIMISM_RPC_URL", "EVM_PROVIDER_OPTIMISM"];
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
export type SupportedEvmChain = keyof typeof SUPPORTED_EVM_CHAINS;
|
|
234
|
+
export declare function getChainConfig(chainNameOrId: string | number): {
|
|
235
|
+
readonly chainId: 1;
|
|
236
|
+
readonly name: "Ethereum";
|
|
237
|
+
readonly nativeCurrency: "ETH";
|
|
238
|
+
readonly supportedDexes: EvmDex[];
|
|
239
|
+
readonly rpcEnvKeys: readonly ["ETHEREUM_RPC_URL", "ETH_RPC_URL", "EVM_PROVIDER_MAINNET"];
|
|
240
|
+
} | {
|
|
241
|
+
readonly chainId: 8453;
|
|
242
|
+
readonly name: "Base";
|
|
243
|
+
readonly nativeCurrency: "ETH";
|
|
244
|
+
readonly supportedDexes: EvmDex[];
|
|
245
|
+
readonly rpcEnvKeys: readonly ["BASE_RPC_URL", "EVM_PROVIDER_BASE"];
|
|
246
|
+
} | {
|
|
247
|
+
readonly chainId: 42161;
|
|
248
|
+
readonly name: "Arbitrum One";
|
|
249
|
+
readonly nativeCurrency: "ETH";
|
|
250
|
+
readonly supportedDexes: EvmDex[];
|
|
251
|
+
readonly rpcEnvKeys: readonly ["ARBITRUM_RPC_URL", "EVM_PROVIDER_ARBITRUM"];
|
|
252
|
+
} | {
|
|
253
|
+
readonly chainId: 56;
|
|
254
|
+
readonly name: "BNB Smart Chain";
|
|
255
|
+
readonly nativeCurrency: "BNB";
|
|
256
|
+
readonly supportedDexes: EvmDex[];
|
|
257
|
+
readonly rpcEnvKeys: readonly ["BSC_RPC_URL", "EVM_PROVIDER_BSC"];
|
|
258
|
+
} | {
|
|
259
|
+
readonly chainId: 137;
|
|
260
|
+
readonly name: "Polygon";
|
|
261
|
+
readonly nativeCurrency: "MATIC";
|
|
262
|
+
readonly supportedDexes: EvmDex[];
|
|
263
|
+
readonly rpcEnvKeys: readonly ["POLYGON_RPC_URL", "EVM_PROVIDER_POLYGON"];
|
|
264
|
+
} | {
|
|
265
|
+
readonly chainId: 10;
|
|
266
|
+
readonly name: "Optimism";
|
|
267
|
+
readonly nativeCurrency: "ETH";
|
|
268
|
+
readonly supportedDexes: EvmDex[];
|
|
269
|
+
readonly rpcEnvKeys: readonly ["OPTIMISM_RPC_URL", "EVM_PROVIDER_OPTIMISM"];
|
|
270
|
+
} | undefined;
|
|
271
|
+
export type OptimizationOpportunity = {
|
|
272
|
+
sourcePosition?: LpPositionDetails;
|
|
273
|
+
sourcePool?: PoolInfo;
|
|
274
|
+
targetPool: PoolInfo;
|
|
275
|
+
estimatedNewYield: number;
|
|
276
|
+
currentYield?: number;
|
|
277
|
+
estimatedCostToMoveLamports?: string;
|
|
278
|
+
estimatedCostToMoveUsd?: number;
|
|
279
|
+
netGainPercent?: number;
|
|
280
|
+
reason?: string;
|
|
281
|
+
actions?: string[];
|
|
282
|
+
};
|
|
283
|
+
export type UserLpProfile = {
|
|
284
|
+
userId: string;
|
|
285
|
+
vaultPublicKey: string;
|
|
286
|
+
encryptedSecretKey: string;
|
|
287
|
+
autoRebalanceConfig: {
|
|
288
|
+
enabled: boolean;
|
|
289
|
+
minGainThresholdPercent: number;
|
|
290
|
+
preferredDexes?: string[];
|
|
291
|
+
maxSlippageBps: number;
|
|
292
|
+
maxGasFeeLamports?: string;
|
|
293
|
+
cycleIntervalHours?: number;
|
|
294
|
+
};
|
|
295
|
+
trackedPositions?: TrackedLpPosition[];
|
|
296
|
+
version: number;
|
|
297
|
+
createdAt: string;
|
|
298
|
+
updatedAt: string;
|
|
299
|
+
};
|
|
300
|
+
export interface TrackedLpPosition {
|
|
301
|
+
positionIdentifier: string;
|
|
302
|
+
dex: string;
|
|
303
|
+
poolAddress: string;
|
|
304
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
305
|
+
trackedAt: string;
|
|
306
|
+
}
|
|
307
|
+
export type TrackedLpPositionInput = Omit<TrackedLpPosition, "trackedAt">;
|
|
308
|
+
export interface AddLiquidityConfig {
|
|
309
|
+
userVault: SolanaKeypair;
|
|
310
|
+
dexName: string;
|
|
311
|
+
poolId: string;
|
|
312
|
+
tokenAAmountLamports: string;
|
|
313
|
+
tokenBAmountLamports?: string;
|
|
314
|
+
slippageBps: number;
|
|
315
|
+
tickLowerIndex?: number;
|
|
316
|
+
tickUpperIndex?: number;
|
|
317
|
+
}
|
|
318
|
+
export interface RemoveLiquidityConfig {
|
|
319
|
+
userVault: SolanaKeypair;
|
|
320
|
+
dexName: string;
|
|
321
|
+
poolId: string;
|
|
322
|
+
lpTokenAmountLamports: string;
|
|
323
|
+
slippageBps: number;
|
|
324
|
+
}
|
|
325
|
+
export type LpManagementSubaction = "onboard" | "list_pools" | "open" | "close" | "reposition" | "list_positions" | "get_position" | "set_preferences";
|
|
326
|
+
export interface LpActionParams {
|
|
327
|
+
subaction?: LpManagementSubaction;
|
|
328
|
+
chain?: ChainType | string;
|
|
329
|
+
chainId?: number;
|
|
330
|
+
dex?: string;
|
|
331
|
+
pool?: string;
|
|
332
|
+
position?: string;
|
|
333
|
+
amount?: string | number | {
|
|
334
|
+
value?: string | number;
|
|
335
|
+
tokenA?: string | number;
|
|
336
|
+
tokenB?: string | number;
|
|
337
|
+
lpToken?: string | number;
|
|
338
|
+
percentage?: number;
|
|
339
|
+
};
|
|
340
|
+
amounts?: {
|
|
341
|
+
tokenA?: string | number;
|
|
342
|
+
tokenB?: string | number;
|
|
343
|
+
lpToken?: string | number;
|
|
344
|
+
};
|
|
345
|
+
range?: {
|
|
346
|
+
tickLower?: number;
|
|
347
|
+
tickUpper?: number;
|
|
348
|
+
tickLowerIndex?: number;
|
|
349
|
+
tickUpperIndex?: number;
|
|
350
|
+
priceLower?: number;
|
|
351
|
+
priceUpper?: number;
|
|
352
|
+
};
|
|
353
|
+
tokenA?: string;
|
|
354
|
+
tokenB?: string;
|
|
355
|
+
feeTier?: number;
|
|
356
|
+
slippageBps?: number;
|
|
357
|
+
intent?: "onboard_lp" | "deposit_lp" | "withdraw_lp" | "show_lps" | "set_lp_preferences" | "create_concentrated_lp" | "rebalance_concentrated_lp" | "show_concentrated_lps";
|
|
358
|
+
userId?: string;
|
|
359
|
+
dexName?: string;
|
|
360
|
+
poolId?: string;
|
|
361
|
+
tokenAAmount?: string;
|
|
362
|
+
tokenBAmount?: string;
|
|
363
|
+
lpTokenAmount?: string;
|
|
364
|
+
percentage?: number;
|
|
365
|
+
autoRebalanceConfig?: Partial<UserLpProfile["autoRebalanceConfig"]>;
|
|
366
|
+
autoRebalanceEnabled?: boolean;
|
|
367
|
+
minGainThresholdPercent?: number;
|
|
368
|
+
maxSlippageBps?: number;
|
|
369
|
+
preferredDexes?: string[];
|
|
370
|
+
cycleIntervalHours?: number;
|
|
371
|
+
maxGasFeeLamports?: string;
|
|
372
|
+
tickLowerIndex?: number;
|
|
373
|
+
tickUpperIndex?: number;
|
|
374
|
+
priceLower?: number;
|
|
375
|
+
priceUpper?: number;
|
|
376
|
+
rangeWidthPercent?: number;
|
|
377
|
+
positionId?: string;
|
|
378
|
+
}
|
|
379
|
+
export interface IVaultService extends Service {
|
|
380
|
+
createVault(userId: string): Promise<{
|
|
381
|
+
publicKey: string;
|
|
382
|
+
secretKeyEncrypted: string;
|
|
383
|
+
}>;
|
|
384
|
+
getVaultKeypair(userId: string, encryptedSecretKey: string): Promise<SolanaKeypair>;
|
|
385
|
+
getVaultPublicKey(userId: string): Promise<string | null>;
|
|
386
|
+
getBalances(publicKey: string): Promise<TokenBalance[]>;
|
|
387
|
+
exportPrivateKey(userId: string, encryptedSecretKey: string, confirmationToken: string): Promise<string>;
|
|
388
|
+
}
|
|
389
|
+
export interface IUserLpProfileService extends Service {
|
|
390
|
+
ensureProfile(userId: string, vaultPublicKey: string, encryptedSecretKey: string, initialConfig?: Partial<UserLpProfile["autoRebalanceConfig"]>): Promise<UserLpProfile>;
|
|
391
|
+
getProfile(userId: string): Promise<UserLpProfile | null>;
|
|
392
|
+
updateProfile(userId: string, updates: Partial<Omit<UserLpProfile, "userId">>): Promise<UserLpProfile>;
|
|
393
|
+
addTrackedPosition(userId: string, position: TrackedLpPositionInput): Promise<UserLpProfile>;
|
|
394
|
+
removeTrackedPosition(userId: string, positionIdentifier: string): Promise<UserLpProfile>;
|
|
395
|
+
getTrackedPositions(userId: string): Promise<TrackedLpPosition[]>;
|
|
396
|
+
getAllProfilesWithAutoRebalanceEnabled(): Promise<UserLpProfile[]>;
|
|
397
|
+
start(runtime?: IAgentRuntime): Promise<void>;
|
|
398
|
+
stop(runtime?: IAgentRuntime): Promise<void>;
|
|
399
|
+
}
|
|
400
|
+
export interface IDexInteractionService extends Service {
|
|
401
|
+
registerDexService(dexService: ILpService): void;
|
|
402
|
+
getPools(dexName?: string, tokenAMint?: string, tokenBMint?: string): Promise<PoolInfo[]>;
|
|
403
|
+
addLiquidity(config: AddLiquidityConfig): Promise<TransactionResult>;
|
|
404
|
+
removeLiquidity(config: RemoveLiquidityConfig): Promise<TransactionResult>;
|
|
405
|
+
getLpPosition(userId: string, poolIdOrPositionIdentifier: string, dexName: string): Promise<LpPositionDetails | null>;
|
|
406
|
+
getAllUserLpPositions(userId: string): Promise<LpPositionDetails[]>;
|
|
407
|
+
}
|
|
408
|
+
export interface IYieldOptimizationService extends Service {
|
|
409
|
+
fetchAllPoolData(): Promise<PoolInfo[]>;
|
|
410
|
+
findBestYieldOpportunities(userId: string, currentPositions: LpPositionDetails[], idleAssets: TokenBalance[]): Promise<OptimizationOpportunity[]>;
|
|
411
|
+
calculateRebalanceCost(fromPosition: LpPositionDetails | null, toPool: PoolInfo, solPriceUsd: number, amountToMoveLamports?: string, underlyingTokensToMove?: TokenBalance[]): Promise<{
|
|
412
|
+
costSolLamports: string;
|
|
413
|
+
costUsd?: number;
|
|
414
|
+
steps: string[];
|
|
415
|
+
error?: string;
|
|
416
|
+
}>;
|
|
417
|
+
findBestYield(userId: string, currentTokenA: string, currentTokenB: string): Promise<OptimizationOpportunity[]>;
|
|
418
|
+
}
|
|
419
|
+
export interface IConcentratedPosition extends LpPositionDetails {
|
|
420
|
+
priceLower: number;
|
|
421
|
+
priceUpper: number;
|
|
422
|
+
currentPrice: number;
|
|
423
|
+
inRange: boolean;
|
|
424
|
+
liquidityUtilization: number;
|
|
425
|
+
}
|
|
426
|
+
export interface IRangeParams {
|
|
427
|
+
poolAddress: string;
|
|
428
|
+
baseAmount?: number;
|
|
429
|
+
quoteAmount?: number;
|
|
430
|
+
priceLower?: number;
|
|
431
|
+
priceUpper?: number;
|
|
432
|
+
rangeWidthPercent?: number;
|
|
433
|
+
targetUtilization?: number;
|
|
434
|
+
}
|
|
435
|
+
export interface IConcentratedLiquidityService extends Service {
|
|
436
|
+
createConcentratedPosition(userId: string, params: IRangeParams): Promise<IConcentratedPosition>;
|
|
437
|
+
getConcentratedPositions(userId: string): Promise<IConcentratedPosition[]>;
|
|
438
|
+
rebalanceConcentratedPosition(userId: string, positionId: string, newRangeParams?: Partial<IRangeParams>): Promise<IConcentratedPosition>;
|
|
439
|
+
}
|