diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b98d9184..2ef0c43a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,10 +10,10 @@ importers: dependencies: '@3land/listings-sdk': specifier: ^0.0.4 - version: 0.0.4(@types/node@22.10.5)(arweave@1.15.5)(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) + version: 0.0.4(@types/node@22.10.5)(arweave@1.15.5)(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) '@ai-sdk/openai': specifier: ^1.0.11 - version: 1.0.13(zod@3.24.1) + version: 1.0.11(zod@3.24.1) '@bonfida/spl-name-service': specifier: ^3.0.7 version: 3.0.7(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) @@ -109,7 +109,7 @@ importers: version: 16.4.7 flash-sdk: specifier: ^2.24.3 - version: 2.24.3(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) + version: 2.24.3(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) form-data: specifier: ^4.0.1 version: 4.0.1 @@ -134,7 +134,7 @@ importers: version: 5.0.1 '@types/node': specifier: ^22.10.2 - version: 22.10.2 + version: 22.10.5 '@typescript-eslint/eslint-plugin': specifier: ^8.18.2 version: 8.19.0(@typescript-eslint/parser@8.19.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2) @@ -161,7 +161,7 @@ importers: version: 3.4.2 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@22.10.2)(typescript@5.7.2) + version: 10.9.2(@types/node@22.10.5)(typescript@5.7.2) typescript: specifier: ^5.7.2 version: 5.7.2 @@ -855,6 +855,9 @@ packages: '@shikijs/vscode-textmate@10.0.1': resolution: {integrity: sha512-fTIQwLF+Qhuws31iw7Ncl1R3HUDtGwIipiJ9iU+UsDUwMhegFcQKQHd51nZjb7CArq0MvON8rbgCGQYWHUKAdg==} + '@shikijs/vscode-textmate@9.3.1': + resolution: {integrity: sha512-79QfK1393x9Ho60QFyLti+QfdJzRQCVLFb97kOIV7Eo9vQU/roINgk7m24uv0a7AUvN//RDH36FLjjK48v0s9g==} + '@sindresorhus/is@4.6.0': resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} engines: {node: '>=10'} @@ -1036,6 +1039,10 @@ packages: '@solana/web3.js@1.98.0': resolution: {integrity: sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA==} + '@sqds/multisig@2.1.3': + resolution: {integrity: sha512-WOiL7La+RSiJsz7jVO85yhSiiSvNMUthiWuLPeWVOoD6IYa34BEAzanF1RdXRWGglSbRFYCTkyr+Ay1WmXmSRQ==} + engines: {node: '>=14'} + '@supercharge/promise-pool@3.2.0': resolution: {integrity: sha512-pj0cAALblTZBPtMltWOlZTQSLT07jIaFNeM8TWoJD1cQMgDB9mcMlVMoetiB35OzNJpqQ2b+QEtwiR9f20mADg==} engines: {node: '>=8'} @@ -2121,12 +2128,8 @@ packages: resolution: {integrity: sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ==} engines: {node: '>=18'} - get-intrinsic@1.2.7: - resolution: {integrity: sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==} - engines: {node: '>= 0.4'} - - get-proto@1.0.1: - resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} + get-intrinsic@1.2.6: + resolution: {integrity: sha512-qxsEs+9A+u85HhllWJJFicJfPDhRmjzoYdl64aMWW9yRIJmSyxdn8IEkuIM530/7T+lv0TIHd8L6Q/ra0tEoeA==} engines: {node: '>= 0.4'} get-stream@5.2.0: @@ -2284,6 +2287,9 @@ packages: resolution: {integrity: sha512-M1WuAmb7pn9zdFRtQYk26ZBoY043Sse0wVDdk4Bppr+JOXyQYybdtvK+l9wUibhtjdjvtoiNy8tk+EgsYIUqKg==} engines: {node: '>=12.0.0'} + invariant@2.2.4: + resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} + ipaddr.js@1.9.1: resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} engines: {node: '>= 0.10'} @@ -2347,10 +2353,6 @@ packages: resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} engines: {node: '>=8'} - is-regex@1.2.1: - resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} - engines: {node: '>= 0.4'} - is-retry-allowed@2.2.0: resolution: {integrity: sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==} engines: {node: '>=10'} @@ -3060,8 +3062,8 @@ packages: regex-utilities@2.3.0: resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==} - regex@5.1.1: - resolution: {integrity: sha512-dN5I359AVGPnwzJm2jN1k0W9LPZ+ePvoOeVMMfqIMFz53sSwXkxaJoxr50ptnsC771lK95BnTrVSZxq0b9yCGw==} + regex@5.0.2: + resolution: {integrity: sha512-/pczGbKIQgfTMRV0XjABvc5RzLqQmwqxLHdQao2RTXPk+pmTXB2P0IaUHYdYyk412YLwUIkaeMd5T+RzVgTqnQ==} resolve-alpn@1.2.1: resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==} @@ -3661,14 +3663,14 @@ packages: snapshots: - '@3land/listings-sdk@0.0.4(@types/node@22.10.5)(arweave@1.15.5)(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': + '@3land/listings-sdk@0.0.4(@types/node@22.10.5)(arweave@1.15.5)(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': dependencies: - '@coral-xyz/borsh': 0.30.1(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) - '@irys/sdk': 0.2.11(arweave@1.15.5)(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@coral-xyz/borsh': 0.30.1(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@irys/sdk': 0.2.11(arweave@1.15.5)(bufferutil@4.0.8)(utf-8-validate@5.0.10) '@metaplex-foundation/beet': 0.7.2 - '@metaplex-foundation/mpl-token-metadata': 2.13.0(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) - '@project-serum/anchor': 0.26.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@metaplex-foundation/mpl-token-metadata': 2.13.0(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) + '@project-serum/anchor': 0.26.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) bn: 1.0.5 bn.js: 5.2.1 bs58: 6.0.0 @@ -3743,8 +3745,8 @@ snapshots: dependencies: '@aptos-labs/aptos-cli': 1.0.2 '@aptos-labs/aptos-client': 0.1.1 - '@noble/curves': 1.8.0 - '@noble/hashes': 1.7.0 + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 '@scure/bip32': 1.4.0 '@scure/bip39': 1.3.0 eventemitter3: 5.0.1 @@ -3838,16 +3840,16 @@ snapshots: - encoding - utf-8-validate - '@coral-xyz/anchor@0.27.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@coral-xyz/anchor@0.27.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: - '@coral-xyz/borsh': 0.27.0(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@coral-xyz/borsh': 0.27.0(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) base64-js: 1.5.1 bn.js: 5.2.1 bs58: 4.0.1 buffer-layout: 1.2.2 camelcase: 6.3.0 - cross-fetch: 3.2.0 + cross-fetch: 3.1.8 crypto-hash: 1.3.0 eventemitter3: 4.0.7 js-sha256: 0.9.0 @@ -3860,7 +3862,7 @@ snapshots: - encoding - utf-8-validate - '@coral-xyz/anchor@0.29.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@coral-xyz/anchor@0.29.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@coral-xyz/borsh': 0.29.0(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) '@noble/hashes': 1.6.1 @@ -3887,27 +3889,27 @@ snapshots: bn.js: 5.2.1 buffer-layout: 1.2.2 - '@coral-xyz/borsh@0.27.0(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': + '@coral-xyz/borsh@0.27.0(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) bn.js: 5.2.1 buffer-layout: 1.2.2 - '@coral-xyz/borsh@0.28.0(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))': + '@coral-xyz/borsh@0.28.0(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: - '@solana/web3.js': 1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) bn.js: 5.2.1 buffer-layout: 1.2.2 - '@coral-xyz/borsh@0.29.0(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': + '@coral-xyz/borsh@0.29.0(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) bn.js: 5.2.1 buffer-layout: 1.2.2 - '@coral-xyz/borsh@0.30.1(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))': + '@coral-xyz/borsh@0.30.1(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) bn.js: 5.2.1 buffer-layout: 1.2.2 @@ -4122,7 +4124,7 @@ snapshots: dependencies: '@ethersproject/logger': 5.7.0 - '@ethersproject/providers@5.7.2(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@ethersproject/providers@5.7.2(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@ethersproject/abstract-provider': 5.7.0 '@ethersproject/abstract-signer': 5.7.0 @@ -4143,7 +4145,7 @@ snapshots: '@ethersproject/transactions': 5.7.0 '@ethersproject/web': 5.7.1 bech32: 1.1.4 - ws: 7.4.6(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ws: 7.4.6(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - utf-8-validate @@ -4271,22 +4273,22 @@ snapshots: transitivePeerDependencies: - debug - '@irys/sdk@0.2.11(arweave@1.15.5)(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@irys/sdk@0.2.11(arweave@1.15.5)(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@aptos-labs/ts-sdk': 1.33.1 '@ethersproject/bignumber': 5.7.0 '@ethersproject/contracts': 5.7.0 - '@ethersproject/providers': 5.7.2(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@ethersproject/providers': 5.7.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) '@ethersproject/wallet': 5.7.0 '@irys/query': 0.0.8 '@near-js/crypto': 0.0.3 '@near-js/keystores-browser': 0.0.3 '@near-js/providers': 0.0.4 '@near-js/transactions': 0.1.1 - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) '@supercharge/promise-pool': 3.2.0 algosdk: 1.24.1 - arbundles: 0.11.2(arweave@1.15.5)(bufferutil@4.0.9)(utf-8-validate@5.0.10) + arbundles: 0.11.2(arweave@1.15.5)(bufferutil@4.0.8)(utf-8-validate@5.0.10) async-retry: 1.3.3 axios: 1.7.9 base64url: 3.0.1 @@ -4778,7 +4780,7 @@ snapshots: '@noble/curves@1.7.0': dependencies: - '@noble/hashes': 1.7.0 + '@noble/hashes': 1.6.0 '@noble/ed25519@1.7.3': {} @@ -4839,16 +4841,16 @@ snapshots: '@pkgr/core@0.1.1': {} - '@project-serum/anchor@0.26.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@project-serum/anchor@0.26.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: - '@coral-xyz/borsh': 0.26.0(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) - '@solana/web3.js': 1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@coral-xyz/borsh': 0.26.0(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) base64-js: 1.5.1 bn.js: 5.2.1 bs58: 4.0.1 buffer-layout: 1.2.2 camelcase: 6.3.0 - cross-fetch: 3.2.0 + cross-fetch: 3.1.8 crypto-hash: 1.3.0 eventemitter3: 4.0.7 js-sha256: 0.9.0 @@ -4861,11 +4863,11 @@ snapshots: - encoding - utf-8-validate - '@pythnetwork/client@2.22.0(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@pythnetwork/client@2.22.0(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: - '@coral-xyz/anchor': 0.29.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10)) - '@solana/web3.js': 1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@coral-xyz/anchor': 0.29.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + '@solana/web3.js': 1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) buffer: 6.0.3 transitivePeerDependencies: - bufferutil @@ -4880,15 +4882,15 @@ snapshots: transitivePeerDependencies: - axios - '@pythnetwork/price-service-client@1.9.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@pythnetwork/price-service-client@1.9.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@pythnetwork/price-service-sdk': 1.8.0 '@types/ws': 8.5.13 axios: 1.7.9 axios-retry: 3.9.1 - isomorphic-ws: 4.0.1(ws@8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)) + isomorphic-ws: 4.0.1(ws@8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)) ts-log: 2.2.7 - ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - debug @@ -4906,7 +4908,7 @@ snapshots: '@randlabs/communication-bridge': 1.0.1 optional: true - '@raydium-io/raydium-sdk-v2@0.1.95-alpha(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': + '@raydium-io/raydium-sdk-v2@0.1.95-alpha(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': dependencies: '@solana/buffer-layout': 4.0.1 '@solana/spl-token': 0.4.9(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) @@ -4997,9 +4999,11 @@ snapshots: '@shikijs/vscode-textmate@10.0.1': {} + '@shikijs/vscode-textmate@9.3.1': {} + '@sindresorhus/is@4.6.0': {} - '@solana/buffer-layout-utils@0.2.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@solana/buffer-layout-utils@0.2.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@solana/buffer-layout': 4.0.1 '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -5266,15 +5270,15 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)': + '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)': dependencies: '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2) - '@solana/web3.js': 1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - fastestsmallesttextencoderdecoder - typescript - '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@4.9.5)': + '@solana/spl-token-metadata@0.1.6(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@4.9.5)': dependencies: '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@4.9.5) '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -5303,12 +5307,12 @@ snapshots: - encoding - utf-8-validate - '@solana/spl-token@0.3.11(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': + '@solana/spl-token@0.3.11(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': dependencies: '@solana/buffer-layout': 4.0.1 - '@solana/buffer-layout-utils': 0.2.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@solana/spl-token-metadata': 0.1.6(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2) - '@solana/web3.js': 1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@solana/buffer-layout-utils': 0.2.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/spl-token-metadata': 0.1.6(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2) + '@solana/web3.js': 1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) buffer: 6.0.3 transitivePeerDependencies: - bufferutil @@ -5317,7 +5321,7 @@ snapshots: - typescript - utf-8-validate - '@solana/spl-token@0.3.11(@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@4.9.5)(utf-8-validate@5.0.10)': + '@solana/spl-token@0.3.11(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@4.9.5)(utf-8-validate@5.0.10)': dependencies: '@solana/buffer-layout': 4.0.1 '@solana/buffer-layout-utils': 0.2.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -5400,7 +5404,7 @@ snapshots: '@noble/curves': 1.7.0 '@noble/hashes': 1.6.1 '@solana/buffer-layout': 4.0.1 - agentkeepalive: 4.5.0 + agentkeepalive: 4.6.0 bigint-buffer: 1.1.5 bn.js: 5.2.1 borsh: 0.7.0 @@ -5416,11 +5420,11 @@ snapshots: - encoding - utf-8-validate - '@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@babel/runtime': 7.26.0 - '@noble/curves': 1.8.0 - '@noble/hashes': 1.7.0 + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 '@solana/buffer-layout': 4.0.1 agentkeepalive: 4.6.0 bigint-buffer: 1.1.5 @@ -5429,7 +5433,7 @@ snapshots: bs58: 4.0.1 buffer: 6.0.3 fast-stable-stringify: 1.0.0 - jayson: 4.1.3(bufferutil@4.0.9)(utf-8-validate@5.0.10) + jayson: 4.1.3(bufferutil@4.0.8)(utf-8-validate@5.0.10) node-fetch: 2.7.0 rpc-websockets: 9.0.4 superstruct: 2.0.2 @@ -5438,13 +5442,13 @@ snapshots: - encoding - utf-8-validate - '@solana/web3.js@1.98.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)': + '@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@babel/runtime': 7.26.0 '@noble/curves': 1.7.0 '@noble/hashes': 1.6.1 '@solana/buffer-layout': 4.0.1 - agentkeepalive: 4.5.0 + agentkeepalive: 4.6.0 bigint-buffer: 1.1.5 bn.js: 5.2.1 borsh: 0.7.0 @@ -5460,6 +5464,26 @@ snapshots: - encoding - utf-8-validate + '@sqds/multisig@2.1.3(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': + dependencies: + '@metaplex-foundation/beet': 0.7.1 + '@metaplex-foundation/beet-solana': 0.4.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@metaplex-foundation/cusper': 0.0.2 + '@solana/spl-token': 0.3.11(@solana/web3.js@1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.98.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@types/bn.js': 5.1.6 + assert: 2.1.0 + bn.js: 5.2.1 + buffer: 6.0.3 + invariant: 2.2.4 + transitivePeerDependencies: + - bufferutil + - encoding + - fastestsmallesttextencoderdecoder + - supports-color + - typescript + - utf-8-validate + '@supercharge/promise-pool@3.2.0': {} '@swc/helpers@0.5.15': @@ -5470,7 +5494,7 @@ snapshots: dependencies: defer-to-connect: 2.0.1 - '@tensor-hq/tensor-common@8.3.1(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': + '@tensor-hq/tensor-common@8.3.1(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10)': dependencies: '@coral-xyz/anchor': 0.26.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) '@metaplex-foundation/mpl-auction-house': 2.5.1(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) @@ -5550,7 +5574,7 @@ snapshots: '@types/bn.js@5.1.6': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/body-parser@1.19.5': dependencies: @@ -5570,7 +5594,7 @@ snapshots: '@types/connect@3.4.38': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/deep-eql@4.0.2': {} @@ -5580,7 +5604,7 @@ snapshots: '@types/express-serve-static-core@4.19.6': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -5614,7 +5638,7 @@ snapshots: '@types/node-fetch@2.6.12': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 form-data: 4.0.1 '@types/node@11.11.6': {} @@ -5652,12 +5676,12 @@ snapshots: '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/serve-static@1.15.7': dependencies: '@types/http-errors': 2.0.4 - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/send': 0.17.4 '@types/unist@3.0.3': {} @@ -5668,11 +5692,11 @@ snapshots: '@types/ws@7.4.7': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@types/ws@8.5.13': dependencies: - '@types/node': 22.10.2 + '@types/node': 22.10.5 '@typescript-eslint/eslint-plugin@8.19.0(@typescript-eslint/parser@8.19.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1)(typescript@5.7.2)': dependencies: @@ -5814,7 +5838,7 @@ snapshots: dependencies: algo-msgpack-with-bigint: 2.1.1 buffer: 6.0.3 - cross-fetch: 3.2.0 + cross-fetch: 3.1.8 hi-base32: 0.5.1 js-sha256: 0.9.0 js-sha3: 0.8.0 @@ -5847,11 +5871,11 @@ snapshots: ansicolors@0.3.2: {} - arbundles@0.11.2(arweave@1.15.5)(bufferutil@4.0.9)(utf-8-validate@5.0.10): + arbundles@0.11.2(arweave@1.15.5)(bufferutil@4.0.8)(utf-8-validate@5.0.10): dependencies: '@ethersproject/bytes': 5.7.0 '@ethersproject/hash': 5.7.0 - '@ethersproject/providers': 5.7.2(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@ethersproject/providers': 5.7.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) '@ethersproject/signing-key': 5.7.0 '@ethersproject/transactions': 5.7.0 '@ethersproject/wallet': 5.7.0 @@ -5901,7 +5925,7 @@ snapshots: asn1.js@5.4.1: dependencies: - bn.js: 4.11.6 + bn.js: 4.12.1 inherits: 2.0.4 minimalistic-assert: 1.0.1 safer-buffer: 2.1.2 @@ -6715,13 +6739,13 @@ snapshots: locate-path: 6.0.0 path-exists: 4.0.0 - flash-sdk@2.24.3(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10): + flash-sdk@2.24.3(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10): dependencies: - '@coral-xyz/anchor': 0.27.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@pythnetwork/client': 2.22.0(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@pythnetwork/price-service-client': 1.9.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) - '@solana/spl-token': 0.3.11(@solana/web3.js@1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) - '@solana/web3.js': 1.95.8(bufferutil@4.0.9)(utf-8-validate@5.0.10) + '@coral-xyz/anchor': 0.27.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@pythnetwork/client': 2.22.0(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@pythnetwork/price-service-client': 1.9.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + '@solana/spl-token': 0.3.11(@solana/web3.js@1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10))(bufferutil@4.0.8)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.2)(utf-8-validate@5.0.10) + '@solana/web3.js': 1.95.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) '@types/node': 20.17.11 bignumber.js: 9.1.2 bs58: 5.0.0 @@ -6809,11 +6833,6 @@ snapshots: hasown: 2.0.2 math-intrinsics: 1.1.0 - get-proto@1.0.1: - dependencies: - dunder-proto: 1.0.1 - es-object-atoms: 1.0.0 - get-stream@5.2.0: dependencies: pump: 3.0.2 @@ -6892,7 +6911,7 @@ snapshots: '@types/node': 18.19.68 '@types/node-fetch': 2.6.12 abort-controller: 3.0.0 - agentkeepalive: 4.5.0 + agentkeepalive: 4.6.0 form-data-encoder: 1.7.2 formdata-node: 4.4.1 node-fetch: 2.7.0 @@ -7026,6 +7045,10 @@ snapshots: through: 2.3.8 wrap-ansi: 6.2.0 + invariant@2.2.4: + dependencies: + loose-envify: 1.4.0 + ipaddr.js@1.9.1: {} ipaddr.js@2.2.0: {} @@ -7070,13 +7093,6 @@ snapshots: is-path-inside@3.0.3: {} - is-regex@1.2.1: - dependencies: - call-bound: 1.0.3 - gopd: 1.2.0 - has-tostringtag: 1.0.2 - hasown: 2.0.2 - is-retry-allowed@2.2.0: {} is-stream@3.0.0: {} @@ -7093,11 +7109,11 @@ snapshots: isomorphic-ws@4.0.1(ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: - ws: 7.5.10(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10) - isomorphic-ws@4.0.1(ws@8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10)): + isomorphic-ws@4.0.1(ws@8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: - ws: 8.18.0(bufferutil@4.0.9)(utf-8-validate@5.0.10) + ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) jackspeak@3.4.3: dependencies: @@ -7553,7 +7569,7 @@ snapshots: '@types/node': 18.19.68 '@types/node-fetch': 2.6.12 abort-controller: 3.0.0 - agentkeepalive: 4.5.0 + agentkeepalive: 4.6.0 form-data-encoder: 1.7.2 formdata-node: 4.4.1 node-fetch: 2.7.0 @@ -7817,12 +7833,6 @@ snapshots: safe-buffer@5.2.1: {} - safe-regex-test@1.1.0: - dependencies: - call-bound: 1.0.3 - es-errors: 1.3.0 - is-regex: 1.2.1 - safer-buffer@2.1.2: {} scrypt-js@3.0.1: {} @@ -8116,7 +8126,7 @@ snapshots: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 22.10.2 + '@types/node': 22.10.5 acorn: 8.14.0 acorn-walk: 8.3.4 arg: 4.1.3 @@ -8338,12 +8348,12 @@ snapshots: wrappy@1.0.2: {} - ws@7.4.6(bufferutil@4.0.9)(utf-8-validate@5.0.10): + ws@7.4.6(bufferutil@4.0.8)(utf-8-validate@5.0.10): optionalDependencies: - bufferutil: 4.0.9 + bufferutil: 4.0.8 utf-8-validate: 5.0.10 - ws@7.5.10(bufferutil@4.0.9)(utf-8-validate@5.0.10): + ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10): optionalDependencies: bufferutil: 4.0.8 utf-8-validate: 5.0.10 diff --git a/src/actions/createImage.ts b/src/actions/agent/createImage.ts similarity index 94% rename from src/actions/createImage.ts rename to src/actions/agent/createImage.ts index adbf55cf..b7340701 100644 --- a/src/actions/createImage.ts +++ b/src/actions/agent/createImage.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { create_image } from "../tools/create_image"; +import { create_image } from "../../tools/agent/create_image"; const createImageAction: Action = { name: "CREATE_IMAGE", diff --git a/src/actions/getWalletAddress.ts b/src/actions/agent/getWalletAddress.ts similarity index 82% rename from src/actions/getWalletAddress.ts rename to src/actions/agent/getWalletAddress.ts index 7cd87c68..fa1aea89 100644 --- a/src/actions/getWalletAddress.ts +++ b/src/actions/agent/getWalletAddress.ts @@ -1,7 +1,7 @@ import { z } from "zod"; -import { SolanaAgentKit } from ".."; -import { get_wallet_address } from "../tools"; -import { Action } from "../types/action"; +import { SolanaAgentKit } from "../.."; +import { get_wallet_address } from "../../tools"; +import { Action } from "../../types/action"; const getWalletAddressAction: Action = { name: "GET_WALLET_ADDRESS", diff --git a/src/actions/getPrimaryDomain.ts b/src/actions/bonfida/getPrimaryDomain.ts similarity index 90% rename from src/actions/getPrimaryDomain.ts rename to src/actions/bonfida/getPrimaryDomain.ts index 2655dae4..b6f682fa 100644 --- a/src/actions/getPrimaryDomain.ts +++ b/src/actions/bonfida/getPrimaryDomain.ts @@ -1,8 +1,8 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { getPrimaryDomain } from "../tools"; +import { getPrimaryDomain } from "../../tools"; const getPrimaryDomainAction: Action = { name: "GET_PRIMARY_DOMAIN", diff --git a/src/actions/registerDomain.ts b/src/actions/bonfida/registerDomain.ts similarity index 91% rename from src/actions/registerDomain.ts rename to src/actions/bonfida/registerDomain.ts index 55f9354b..9f1badb1 100644 --- a/src/actions/registerDomain.ts +++ b/src/actions/bonfida/registerDomain.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { registerDomain } from "../tools"; +import { registerDomain } from "../../tools"; const registerDomainAction: Action = { name: "REGISTER_DOMAIN", diff --git a/src/actions/resolveSolDomain.ts b/src/actions/bonfida/resolveSolDomain.ts similarity index 90% rename from src/actions/resolveSolDomain.ts rename to src/actions/bonfida/resolveSolDomain.ts index 60281e20..c01a4c34 100644 --- a/src/actions/resolveSolDomain.ts +++ b/src/actions/bonfida/resolveSolDomain.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { resolveSolDomain } from "../tools"; +import { resolveSolDomain } from "../../tools"; const resolveSolDomainAction: Action = { name: "RESOLVE_SOL_DOMAIN", diff --git a/src/actions/flashCloseTrade.ts b/src/actions/flash/flashCloseTrade.ts similarity index 91% rename from src/actions/flashCloseTrade.ts rename to src/actions/flash/flashCloseTrade.ts index 3781d83a..6cf83fd8 100644 --- a/src/actions/flashCloseTrade.ts +++ b/src/actions/flash/flashCloseTrade.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { flashCloseTrade } from "../tools"; +import { flashCloseTrade } from "../../tools"; const flashCloseTradeAction: Action = { name: "FLASH_CLOSE_TRADE", diff --git a/src/actions/flashOpenTrade.ts b/src/actions/flash/flashOpenTrade.ts similarity index 93% rename from src/actions/flashOpenTrade.ts rename to src/actions/flash/flashOpenTrade.ts index 790bdefe..dd44b80e 100644 --- a/src/actions/flashOpenTrade.ts +++ b/src/actions/flash/flashOpenTrade.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { flashOpenTrade } from "../tools"; +import { flashOpenTrade } from "../../tools"; const flashOpenTradeAction: Action = { name: "FLASH_OPEN_TRADE", diff --git a/src/actions/createGibworkTask.ts b/src/actions/gibwork/createGibworkTask.ts similarity index 94% rename from src/actions/createGibworkTask.ts rename to src/actions/gibwork/createGibworkTask.ts index 12aa809b..dec67b1d 100644 --- a/src/actions/createGibworkTask.ts +++ b/src/actions/gibwork/createGibworkTask.ts @@ -1,8 +1,8 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { create_gibwork_task } from "../tools"; +import { create_gibwork_task } from "../../tools"; const createGibworkTaskAction: Action = { name: "CREATE_GIBWORK_TASK", diff --git a/src/actions/index.ts b/src/actions/index.ts index c9742098..8313d4d3 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -1,35 +1,35 @@ -import deployTokenAction from "./deployToken"; -import balanceAction from "./balance"; -import transferAction from "./transfer"; -import deployCollectionAction from "./deployCollection"; -import mintNFTAction from "./mintNFT"; -import tradeAction from "./trade"; -import requestFundsAction from "./requestFunds"; -import resolveDomainAction from "./resolveDomain"; -import getTokenDataAction from "./getTokenData"; -import getTPSAction from "./getTPS"; -import fetchPriceAction from "./fetchPrice"; -import stakeWithJupAction from "./stakeWithJup"; -import stakeWithSolayerAction from "./stakeWithSolayer"; -import registerDomainAction from "./registerDomain"; -import lendAssetAction from "./lendAsset"; -import createGibworkTaskAction from "./createGibworkTask"; -import resolveSolDomainAction from "./resolveSolDomain"; -import pythFetchPriceAction from "./pythFetchPrice"; -import getOwnedDomainsForTLDAction from "./getOwnedDomainsForTLD"; -import getPrimaryDomainAction from "./getPrimaryDomain"; -import getAllDomainsTLDsAction from "./getAllDomainsTLDs"; -import getOwnedAllDomainsAction from "./getOwnedAllDomains"; -import createImageAction from "./createImage"; -import getMainAllDomainsDomainAction from "./getMainAllDomainsDomain"; -import getAllRegisteredAllDomainsAction from "./getAllRegisteredAllDomains"; -import raydiumCreateCpmmAction from "./raydiumCreateCpmm"; -import raydiumCreateAmmV4Action from "./raydiumCreateAmmV4"; -import createOrcaSingleSidedWhirlpoolAction from "./createOrcaSingleSidedWhirlpool"; -import launchPumpfunTokenAction from "./launchPumpfunToken"; -import getWalletAddressAction from "./getWalletAddress"; -import flashOpenTradeAction from "./flashOpenTrade"; -import flashCloseTradeAction from "./flashCloseTrade"; +import deployTokenAction from "./metaplex/deployToken"; +import balanceAction from "./solana_native/balance"; +import transferAction from "./solana_native/transfer"; +import deployCollectionAction from "./metaplex/deployCollection"; +import mintNFTAction from "./metaplex/mintNFT"; +import tradeAction from "./jupiter/trade"; +import requestFundsAction from "./solana_native/requestFunds"; +import resolveDomainAction from "./onsol_labs/resolveDomain"; +import getTokenDataAction from "./jupiter/getTokenData"; +import getTPSAction from "./solana_native/getTPS"; +import fetchPriceAction from "./jupiter/fetchPrice"; +import stakeWithJupAction from "./jupiter/stakeWithJup"; +import stakeWithSolayerAction from "./solayer/stakeWithSolayer"; +import registerDomainAction from "./bonfida/registerDomain"; +import lendAssetAction from "./lulo/lendAsset"; +import createGibworkTaskAction from "./gibwork/createGibworkTask"; +import resolveSolDomainAction from "./bonfida/resolveSolDomain"; +import pythFetchPriceAction from "./pyth/pythFetchPrice"; +import getOwnedDomainsForTLDAction from "./onsol_labs/getOwnedDomainsForTLD"; +import getPrimaryDomainAction from "./bonfida/getPrimaryDomain"; +import getAllDomainsTLDsAction from "./onsol_labs/getAllDomainsTLDs"; +import getOwnedAllDomainsAction from "./onsol_labs/getOwnedAllDomains"; +import createImageAction from "./agent/createImage"; +import getMainAllDomainsDomainAction from "./onsol_labs/getMainAllDomainsDomain"; +import getAllRegisteredAllDomainsAction from "./onsol_labs/getAllRegisteredAllDomains"; +import raydiumCreateCpmmAction from "./raydium/raydiumCreateCpmm"; +import raydiumCreateAmmV4Action from "./raydium/raydiumCreateAmmV4"; +import createOrcaSingleSidedWhirlpoolAction from "./orca/createOrcaSingleSidedWhirlpool"; +import launchPumpfunTokenAction from "./pumpfun/launchPumpfunToken"; +import getWalletAddressAction from "./agent/getWalletAddress"; +import flashOpenTradeAction from "./flash/flashOpenTrade"; +import flashCloseTradeAction from "./flash/flashCloseTrade"; export const ACTIONS = { WALLET_ADDRESS_ACTION: getWalletAddressAction, diff --git a/src/actions/fetchPrice.ts b/src/actions/jupiter/fetchPrice.ts similarity index 90% rename from src/actions/fetchPrice.ts rename to src/actions/jupiter/fetchPrice.ts index b2326718..f17beaba 100644 --- a/src/actions/fetchPrice.ts +++ b/src/actions/jupiter/fetchPrice.ts @@ -1,8 +1,8 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { fetchPrice } from "../tools"; +import { fetchPrice } from "../../tools"; const fetchPriceAction: Action = { name: "FETCH_PRICE", diff --git a/src/actions/getTokenData.ts b/src/actions/jupiter/getTokenData.ts similarity index 94% rename from src/actions/getTokenData.ts rename to src/actions/jupiter/getTokenData.ts index bf820dcf..6b7f3082 100644 --- a/src/actions/getTokenData.ts +++ b/src/actions/jupiter/getTokenData.ts @@ -1,9 +1,9 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { JupiterTokenData } from "../types"; -import { getTokenAddressFromTicker, getTokenDataByAddress } from "../tools"; +import { JupiterTokenData } from "../../types"; +import { getTokenAddressFromTicker, getTokenDataByAddress } from "../../tools"; const getTokenDataAction: Action = { name: "GET_TOKEN_DATA", diff --git a/src/actions/stakeWithJup.ts b/src/actions/jupiter/stakeWithJup.ts similarity index 90% rename from src/actions/stakeWithJup.ts rename to src/actions/jupiter/stakeWithJup.ts index 7f7680f0..34cf91b7 100644 --- a/src/actions/stakeWithJup.ts +++ b/src/actions/jupiter/stakeWithJup.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { stakeWithJup } from "../tools"; +import { stakeWithJup } from "../../tools"; const stakeWithJupAction: Action = { name: "STAKE_WITH_JUPITER", diff --git a/src/actions/tokenDataByTicker.ts b/src/actions/jupiter/tokenDataByTicker.ts similarity index 91% rename from src/actions/tokenDataByTicker.ts rename to src/actions/jupiter/tokenDataByTicker.ts index 28995a53..3b5e59f8 100644 --- a/src/actions/tokenDataByTicker.ts +++ b/src/actions/jupiter/tokenDataByTicker.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { getTokenDataByTicker } from "../tools"; +import { getTokenDataByTicker } from "../../tools"; const tokenDataByTickerAction: Action = { name: "GET_TOKEN_DATA_BY_TICKER", diff --git a/src/actions/trade.ts b/src/actions/jupiter/trade.ts similarity index 95% rename from src/actions/trade.ts rename to src/actions/jupiter/trade.ts index a4c9e480..47109909 100644 --- a/src/actions/trade.ts +++ b/src/actions/jupiter/trade.ts @@ -1,8 +1,8 @@ import { PublicKey } from "@solana/web3.js"; -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { trade } from "../tools"; +import { trade } from "../../tools"; const tradeAction: Action = { name: "TRADE", diff --git a/src/actions/compressedAirdrop.ts b/src/actions/light_protocol/compressedAirdrop.ts similarity index 95% rename from src/actions/compressedAirdrop.ts rename to src/actions/light_protocol/compressedAirdrop.ts index 107d3523..2abdc72e 100644 --- a/src/actions/compressedAirdrop.ts +++ b/src/actions/light_protocol/compressedAirdrop.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { sendCompressedAirdrop } from "../tools"; +import { sendCompressedAirdrop } from "../../tools"; const compressedAirdropAction: Action = { name: "COMPRESSED_AIRDROP", diff --git a/src/actions/lendAsset.ts b/src/actions/lulo/lendAsset.ts similarity index 89% rename from src/actions/lendAsset.ts rename to src/actions/lulo/lendAsset.ts index 9ceb20ee..cdc7b886 100644 --- a/src/actions/lendAsset.ts +++ b/src/actions/lulo/lendAsset.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { lendAsset } from "../tools"; +import { lendAsset } from "../../tools"; const lendAssetAction: Action = { name: "LEND_ASSET", diff --git a/src/actions/deployCollection.ts b/src/actions/metaplex/deployCollection.ts similarity index 93% rename from src/actions/deployCollection.ts rename to src/actions/metaplex/deployCollection.ts index 1ca5e140..97653674 100644 --- a/src/actions/deployCollection.ts +++ b/src/actions/metaplex/deployCollection.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { deploy_collection } from "../tools"; +import { deploy_collection } from "../../tools"; interface CollectionOptions { name: string; diff --git a/src/actions/deployToken.ts b/src/actions/metaplex/deployToken.ts similarity index 93% rename from src/actions/deployToken.ts rename to src/actions/metaplex/deployToken.ts index 3a3f25da..02c5a513 100644 --- a/src/actions/deployToken.ts +++ b/src/actions/metaplex/deployToken.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { deploy_token } from "../tools"; +import { deploy_token } from "../../tools"; const deployTokenAction: Action = { name: "DEPLOY_TOKEN", diff --git a/src/actions/mintNFT.ts b/src/actions/metaplex/mintNFT.ts similarity index 94% rename from src/actions/mintNFT.ts rename to src/actions/metaplex/mintNFT.ts index f04cfb73..71ef8e6c 100644 --- a/src/actions/mintNFT.ts +++ b/src/actions/metaplex/mintNFT.ts @@ -1,8 +1,8 @@ import { PublicKey } from "@solana/web3.js"; -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { mintCollectionNFT } from "../tools"; +import { mintCollectionNFT } from "../../tools"; const mintNFTAction: Action = { name: "MINT_NFT", diff --git a/src/actions/getAllDomainsTLDs.ts b/src/actions/onsol_labs/getAllDomainsTLDs.ts similarity index 89% rename from src/actions/getAllDomainsTLDs.ts rename to src/actions/onsol_labs/getAllDomainsTLDs.ts index d8d2b642..3ab642e4 100644 --- a/src/actions/getAllDomainsTLDs.ts +++ b/src/actions/onsol_labs/getAllDomainsTLDs.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { getAllDomainsTLDs } from "../tools"; +import { getAllDomainsTLDs } from "../../tools"; const getAllDomainsTLDsAction: Action = { name: "GET_ALL_TLDS", diff --git a/src/actions/getAllRegisteredAllDomains.ts b/src/actions/onsol_labs/getAllRegisteredAllDomains.ts similarity index 92% rename from src/actions/getAllRegisteredAllDomains.ts rename to src/actions/onsol_labs/getAllRegisteredAllDomains.ts index a4d5688a..541c0691 100644 --- a/src/actions/getAllRegisteredAllDomains.ts +++ b/src/actions/onsol_labs/getAllRegisteredAllDomains.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { getAllRegisteredAllDomains } from "../tools"; +import { getAllRegisteredAllDomains } from "../../tools"; const getAllRegisteredAllDomainsAction: Action = { name: "GET_ALL_REGISTERED_ALL_DOMAINS", diff --git a/src/actions/getMainAllDomainsDomain.ts b/src/actions/onsol_labs/getMainAllDomainsDomain.ts similarity index 91% rename from src/actions/getMainAllDomainsDomain.ts rename to src/actions/onsol_labs/getMainAllDomainsDomain.ts index 1071050b..4dfbaecc 100644 --- a/src/actions/getMainAllDomainsDomain.ts +++ b/src/actions/onsol_labs/getMainAllDomainsDomain.ts @@ -1,8 +1,8 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { getMainAllDomainsDomain } from "../tools"; +import { getMainAllDomainsDomain } from "../../tools"; const getMainAllDomainsDomainAction: Action = { name: "GET_MAIN_ALL_DOMAINS_DOMAIN", diff --git a/src/actions/getOwnedAllDomains.ts b/src/actions/onsol_labs/getOwnedAllDomains.ts similarity index 91% rename from src/actions/getOwnedAllDomains.ts rename to src/actions/onsol_labs/getOwnedAllDomains.ts index e9f294ac..712625d3 100644 --- a/src/actions/getOwnedAllDomains.ts +++ b/src/actions/onsol_labs/getOwnedAllDomains.ts @@ -1,8 +1,8 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { getOwnedAllDomains } from "../tools"; +import { getOwnedAllDomains } from "../../tools"; const getOwnedAllDomainsAction: Action = { name: "GET_OWNED_ALL_DOMAINS", diff --git a/src/actions/getOwnedDomainsForTLD.ts b/src/actions/onsol_labs/getOwnedDomainsForTLD.ts similarity index 91% rename from src/actions/getOwnedDomainsForTLD.ts rename to src/actions/onsol_labs/getOwnedDomainsForTLD.ts index 4343488e..d49f30bc 100644 --- a/src/actions/getOwnedDomainsForTLD.ts +++ b/src/actions/onsol_labs/getOwnedDomainsForTLD.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { getOwnedDomainsForTLD } from "../tools"; +import { getOwnedDomainsForTLD } from "../../tools"; const getOwnedDomainsForTLDAction: Action = { name: "GET_OWNED_DOMAINS_FOR_TLD", diff --git a/src/actions/resolveDomain.ts b/src/actions/onsol_labs/resolveDomain.ts similarity index 89% rename from src/actions/resolveDomain.ts rename to src/actions/onsol_labs/resolveDomain.ts index e54adea5..347a0d6b 100644 --- a/src/actions/resolveDomain.ts +++ b/src/actions/onsol_labs/resolveDomain.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { resolveAllDomains } from "../tools"; +import { resolveAllDomains } from "../../tools"; const resolveDomainAction: Action = { name: "RESOLVE_ALL_DOMAINS", diff --git a/src/actions/createOrcaSingleSidedWhirlpool.ts b/src/actions/orca/createOrcaSingleSidedWhirlpool.ts similarity index 95% rename from src/actions/createOrcaSingleSidedWhirlpool.ts rename to src/actions/orca/createOrcaSingleSidedWhirlpool.ts index f53c8816..97eaca05 100644 --- a/src/actions/createOrcaSingleSidedWhirlpool.ts +++ b/src/actions/orca/createOrcaSingleSidedWhirlpool.ts @@ -1,9 +1,9 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; import { Decimal } from "decimal.js"; -import { orcaCreateSingleSidedLiquidityPool } from "../tools"; +import { orcaCreateSingleSidedLiquidityPool } from "../../tools"; // Fee tiers mapping from the original tool const FEE_TIERS = { diff --git a/src/actions/launchPumpfunToken.ts b/src/actions/pumpfun/launchPumpfunToken.ts similarity index 95% rename from src/actions/launchPumpfunToken.ts rename to src/actions/pumpfun/launchPumpfunToken.ts index 3c23394e..8d64c0c7 100644 --- a/src/actions/launchPumpfunToken.ts +++ b/src/actions/pumpfun/launchPumpfunToken.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { launchPumpFunToken } from "../tools"; +import { launchPumpFunToken } from "../../tools"; const launchPumpfunTokenAction: Action = { name: "LAUNCH_PUMPFUN_TOKEN", diff --git a/src/actions/pythFetchPrice.ts b/src/actions/pyth/pythFetchPrice.ts similarity index 89% rename from src/actions/pythFetchPrice.ts rename to src/actions/pyth/pythFetchPrice.ts index d9f7ae4c..fb06de95 100644 --- a/src/actions/pythFetchPrice.ts +++ b/src/actions/pyth/pythFetchPrice.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { fetchPythPrice, fetchPythPriceFeedID } from "../tools"; +import { fetchPythPrice, fetchPythPriceFeedID } from "../../tools"; const pythFetchPriceAction: Action = { name: "PYTH_FETCH_PRICE", diff --git a/src/actions/createOpenbookMarket.ts b/src/actions/raydium/createOpenbookMarket.ts similarity index 93% rename from src/actions/createOpenbookMarket.ts rename to src/actions/raydium/createOpenbookMarket.ts index ae765594..58b8dc95 100644 --- a/src/actions/createOpenbookMarket.ts +++ b/src/actions/raydium/createOpenbookMarket.ts @@ -1,8 +1,8 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; -import { openbookCreateMarket } from "../tools"; +import { openbookCreateMarket } from "../../tools"; const createOpenbookMarketAction: Action = { name: "CREATE_OPENBOOK_MARKET", diff --git a/src/actions/raydiumCreateAmmV4.ts b/src/actions/raydium/raydiumCreateAmmV4.ts similarity index 94% rename from src/actions/raydiumCreateAmmV4.ts rename to src/actions/raydium/raydiumCreateAmmV4.ts index 8ad228db..b6c496b8 100644 --- a/src/actions/raydiumCreateAmmV4.ts +++ b/src/actions/raydium/raydiumCreateAmmV4.ts @@ -1,9 +1,9 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import { raydiumCreateAmmV4 } from "../tools"; +import { raydiumCreateAmmV4 } from "../../tools"; const raydiumCreateAmmV4Action: Action = { name: "RAYDIUM_CREATE_AMM_V4", diff --git a/src/actions/raydiumCreateClmm.ts b/src/actions/raydium/raydiumCreateClmm.ts similarity index 94% rename from src/actions/raydiumCreateClmm.ts rename to src/actions/raydium/raydiumCreateClmm.ts index dd243227..cb776052 100644 --- a/src/actions/raydiumCreateClmm.ts +++ b/src/actions/raydium/raydiumCreateClmm.ts @@ -1,10 +1,10 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; import { BN } from "@coral-xyz/anchor"; import Decimal from "decimal.js"; -import { raydiumCreateClmm } from "../tools"; +import { raydiumCreateClmm } from "../../tools"; const raydiumCreateClmmAction: Action = { name: "RAYDIUM_CREATE_CLMM", diff --git a/src/actions/raydiumCreateCpmm.ts b/src/actions/raydium/raydiumCreateCpmm.ts similarity index 94% rename from src/actions/raydiumCreateCpmm.ts rename to src/actions/raydium/raydiumCreateCpmm.ts index b2159b56..ee74d9e7 100644 --- a/src/actions/raydiumCreateCpmm.ts +++ b/src/actions/raydium/raydiumCreateCpmm.ts @@ -1,9 +1,9 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import { raydiumCreateCpmm } from "../tools"; +import { raydiumCreateCpmm } from "../../tools"; const raydiumCreateCpmmAction: Action = { name: "RAYDIUM_CREATE_CPMM", diff --git a/src/actions/balance.ts b/src/actions/solana_native/balance.ts similarity index 91% rename from src/actions/balance.ts rename to src/actions/solana_native/balance.ts index 381b2a5d..10090333 100644 --- a/src/actions/balance.ts +++ b/src/actions/solana_native/balance.ts @@ -1,8 +1,8 @@ import { PublicKey } from "@solana/web3.js"; -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { get_balance } from "../tools"; +import { get_balance } from "../../tools"; const balanceAction: Action = { name: "BALANCE_ACTION", diff --git a/src/actions/closeEmptyTokenAccounts.ts b/src/actions/solana_native/closeEmptyTokenAccounts.ts similarity index 92% rename from src/actions/closeEmptyTokenAccounts.ts rename to src/actions/solana_native/closeEmptyTokenAccounts.ts index 867c25e3..85fb67b3 100644 --- a/src/actions/closeEmptyTokenAccounts.ts +++ b/src/actions/solana_native/closeEmptyTokenAccounts.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { closeEmptyTokenAccounts } from "../tools"; +import { closeEmptyTokenAccounts } from "../../tools"; const closeEmptyTokenAccountsAction: Action = { name: "CLOSE_EMPTY_TOKEN_ACCOUNTS", diff --git a/src/actions/getTPS.ts b/src/actions/solana_native/getTPS.ts similarity index 89% rename from src/actions/getTPS.ts rename to src/actions/solana_native/getTPS.ts index 490bfb4f..fe0d23c8 100644 --- a/src/actions/getTPS.ts +++ b/src/actions/solana_native/getTPS.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { getTPS } from "../tools"; +import { getTPS } from "../../tools"; const getTPSAction: Action = { name: "GET_TPS", diff --git a/src/actions/requestFunds.ts b/src/actions/solana_native/requestFunds.ts similarity index 86% rename from src/actions/requestFunds.ts rename to src/actions/solana_native/requestFunds.ts index a4a95c2b..a864b59b 100644 --- a/src/actions/requestFunds.ts +++ b/src/actions/solana_native/requestFunds.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { request_faucet_funds } from "../tools"; +import { request_faucet_funds } from "../../tools"; const requestFundsAction: Action = { name: "REQUEST_FUNDS", diff --git a/src/actions/transfer.ts b/src/actions/solana_native/transfer.ts similarity index 94% rename from src/actions/transfer.ts rename to src/actions/solana_native/transfer.ts index f4206aae..568d1a3c 100644 --- a/src/actions/transfer.ts +++ b/src/actions/solana_native/transfer.ts @@ -1,8 +1,8 @@ import { PublicKey } from "@solana/web3.js"; -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { transfer } from "../tools"; +import { transfer } from "../../tools"; const transferAction: Action = { name: "TRANSFER", diff --git a/src/actions/stakeWithSolayer.ts b/src/actions/solayer/stakeWithSolayer.ts similarity index 91% rename from src/actions/stakeWithSolayer.ts rename to src/actions/solayer/stakeWithSolayer.ts index ec579444..5095bd74 100644 --- a/src/actions/stakeWithSolayer.ts +++ b/src/actions/solayer/stakeWithSolayer.ts @@ -1,7 +1,7 @@ -import { Action } from "../types/action"; -import { SolanaAgentKit } from "../agent"; +import { Action } from "../../types/action"; +import { SolanaAgentKit } from "../../agent"; import { z } from "zod"; -import { stakeWithSolayer } from "../tools"; +import { stakeWithSolayer } from "../../tools"; const stakeWithSolayerAction: Action = { name: "STAKE_WITH_SOLAYER", diff --git a/src/agent/index.ts b/src/agent/index.ts index 56517037..6e1a32d2 100644 --- a/src/agent/index.ts +++ b/src/agent/index.ts @@ -79,7 +79,7 @@ import { import { createCollection, createSingle, -} from "../tools/create_3land_collectible"; +} from "../tools/3land/create_3land_collectible"; import { CreateCollectionOptions, CreateSingleOptions, diff --git a/src/langchain/3land/index.ts b/src/langchain/3land/index.ts new file mode 100644 index 00000000..df3fe2af --- /dev/null +++ b/src/langchain/3land/index.ts @@ -0,0 +1,154 @@ +import { + StoreInitOptions, + CreateSingleOptions, + CreateCollectionOptions, +} from "@3land/listings-sdk/dist/types/implementation/implementationTypes"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class Solana3LandCreateSingle extends Tool { + name = "3land_minting_tool"; + description = `Creates an NFT and lists it on 3.land's website + + Inputs: + privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string + collectionAccount (optional): represents the account for the nft collection + itemName (required): the name of the NFT + sellerFee (required): the fee of the seller + itemAmount (required): the amount of the NFTs that can be minted + itemDescription (required): the description of the NFT + traits (required): the traits of the NFT [{trait_type: string, value: string}] + price (required): the price of the item, if is 0 the listing will be free + mainImageUrl (required): the main image of the NFT + coverImageUrl (optional): the cover image of the NFT + splHash (optional): the hash of the spl token, if not provided listing will be in $SOL + isMainnet (required): defines is the tx takes places in mainnet + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const privateKey = inputFormat.privateKey; + const isMainnet = inputFormat.isMainnet; + + const optionsWithBase58: StoreInitOptions = { + ...(privateKey && { privateKey }), + ...(isMainnet && { isMainnet }), + }; + + const collectionAccount = inputFormat.collectionAccount; + + const itemName = inputFormat?.itemName; + const sellerFee = inputFormat?.sellerFee; + const itemAmount = inputFormat?.itemAmount; + const itemSymbol = inputFormat?.itemSymbol; + const itemDescription = inputFormat?.itemDescription; + const traits = inputFormat?.traits; + const price = inputFormat?.price; + const mainImageUrl = inputFormat?.mainImageUrl; + const coverImageUrl = inputFormat?.coverImageUrl; + const splHash = inputFormat?.splHash; + + const createItemOptions: CreateSingleOptions = { + ...(itemName && { itemName }), + ...(sellerFee && { sellerFee }), + ...(itemAmount && { itemAmount }), + ...(itemSymbol && { itemSymbol }), + ...(itemDescription && { itemDescription }), + ...(traits && { traits }), + ...(price && { price }), + ...(mainImageUrl && { mainImageUrl }), + ...(coverImageUrl && { coverImageUrl }), + ...(splHash && { splHash }), + }; + + if (!collectionAccount) { + throw new Error("Collection account is required"); + } + + const tx = await this.solanaKit.create3LandNft( + optionsWithBase58, + collectionAccount, + createItemOptions, + isMainnet, + ); + return JSON.stringify({ + status: "success", + message: `Created listing successfully ${tx}`, + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class Solana3LandCreateCollection extends Tool { + name = "3land_minting_tool"; + description = `Creates an NFT Collection that you can visit on 3.land's website (3.land/collection/{collectionAccount}) + + Inputs: + privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string + isMainnet (required): defines is the tx takes places in mainnet + collectionSymbol (required): the symbol of the collection + collectionName (required): the name of the collection + collectionDescription (required): the description of the collection + mainImageUrl (required): the image of the collection + coverImageUrl (optional): the cover image of the collection + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const privateKey = inputFormat.privateKey; + const isMainnet = inputFormat.isMainnet; + + const optionsWithBase58: StoreInitOptions = { + ...(privateKey && { privateKey }), + ...(isMainnet && { isMainnet }), + }; + + const collectionSymbol = inputFormat?.collectionSymbol; + const collectionName = inputFormat?.collectionName; + const collectionDescription = inputFormat?.collectionDescription; + const mainImageUrl = inputFormat?.mainImageUrl; + const coverImageUrl = inputFormat?.coverImageUrl; + + const collectionOpts: CreateCollectionOptions = { + ...(collectionSymbol && { collectionSymbol }), + ...(collectionName && { collectionName }), + ...(collectionDescription && { collectionDescription }), + ...(mainImageUrl && { mainImageUrl }), + ...(coverImageUrl && { coverImageUrl }), + }; + + const tx = await this.solanaKit.create3LandCollection( + optionsWithBase58, + collectionOpts, + ); + return JSON.stringify({ + status: "success", + message: `Created Collection successfully ${tx}`, + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/adrena/index.ts b/src/langchain/adrena/index.ts new file mode 100644 index 00000000..072fd122 --- /dev/null +++ b/src/langchain/adrena/index.ts @@ -0,0 +1,111 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaPerpCloseTradeTool extends Tool { + name = "solana_close_perp_trade"; + description = `This tool can be used to close perpetuals trade ( It uses Adrena Protocol ). + + Inputs ( input is a JSON string ): + tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional) + price?: number, eg 100 (optional) + side: string, eg: "long" or "short"`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const tx = + parsedInput.side === "long" + ? await this.solanaKit.closePerpTradeLong({ + price: parsedInput.price, + tradeMint: new PublicKey(parsedInput.tradeMint), + }) + : await this.solanaKit.closePerpTradeShort({ + price: parsedInput.price, + tradeMint: new PublicKey(parsedInput.tradeMint), + }); + + return JSON.stringify({ + status: "success", + message: "Perpetual trade closed successfully", + transaction: tx, + price: parsedInput.price, + tradeMint: new PublicKey(parsedInput.tradeMint), + side: parsedInput.side, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaPerpOpenTradeTool extends Tool { + name = "solana_open_perp_trade"; + description = `This tool can be used to open perpetuals trade ( It uses Adrena Protocol ). + + Inputs ( input is a JSON string ): + collateralAmount: number, eg 1 or 0.01 (required) + collateralMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn" or "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" etc. (optional) + tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional) + leverage: number, eg 50000 = x5, 100000 = x10, 1000000 = x100 (optional) + price?: number, eg 100 (optional) + slippage?: number, eg 0.3 (optional) + side: string, eg: "long" or "short"`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const tx = + parsedInput.side === "long" + ? await this.solanaKit.openPerpTradeLong({ + price: parsedInput.price, + collateralAmount: parsedInput.collateralAmount, + collateralMint: new PublicKey(parsedInput.collateralMint), + leverage: parsedInput.leverage, + tradeMint: new PublicKey(parsedInput.tradeMint), + slippage: parsedInput.slippage, + }) + : await this.solanaKit.openPerpTradeLong({ + price: parsedInput.price, + collateralAmount: parsedInput.collateralAmount, + collateralMint: new PublicKey(parsedInput.collateralMint), + leverage: parsedInput.leverage, + tradeMint: new PublicKey(parsedInput.tradeMint), + slippage: parsedInput.slippage, + }); + + return JSON.stringify({ + status: "success", + message: "Perpetual trade opened successfully", + transaction: tx, + price: parsedInput.price, + collateralAmount: parsedInput.collateralAmount, + collateralMint: new PublicKey(parsedInput.collateralMint), + leverage: parsedInput.leverage, + tradeMint: new PublicKey(parsedInput.tradeMint), + slippage: parsedInput.slippage, + side: parsedInput.side, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/agent/index.ts b/src/langchain/agent/index.ts new file mode 100644 index 00000000..a2e2f551 --- /dev/null +++ b/src/langchain/agent/index.ts @@ -0,0 +1,79 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { create_image } from "../../tools/agent/create_image"; + +export class SolanaGetWalletAddressTool extends Tool { + name = "solana_get_wallet_address"; + description = `Get the wallet address of the agent`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(_input: string): Promise { + return this.solanaKit.wallet_address.toString(); + } +} + +export class SolanaCreateImageTool extends Tool { + name = "solana_create_image"; + description = + "Create an image using OpenAI's DALL-E. Input should be a string prompt for the image."; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + private validateInput(input: string): void { + if (typeof input !== "string" || input.trim().length === 0) { + throw new Error("Input must be a non-empty string prompt"); + } + } + + protected async _call(input: string): Promise { + try { + this.validateInput(input); + const result = await create_image(this.solanaKit, input.trim()); + + return JSON.stringify({ + status: "success", + message: "Image created successfully", + ...result, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaCloseEmptyTokenAccounts extends Tool { + name = "close_empty_token_accounts"; + description = `Close all empty spl-token accounts and reclaim the rent`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(): Promise { + try { + const { signature, size } = + await this.solanaKit.closeEmptyTokenAccounts(); + + return JSON.stringify({ + status: "success", + message: `${size} accounts closed successfully. ${size === 48 ? "48 accounts can be closed in a single transaction try again to close more accounts" : ""}`, + signature, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/bonfida/index.ts b/src/langchain/bonfida/index.ts new file mode 100644 index 00000000..689a12c4 --- /dev/null +++ b/src/langchain/bonfida/index.ts @@ -0,0 +1,153 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { PublicKey } from "@solana/web3.js"; + +export class SolanaRegisterDomainTool extends Tool { + name = "solana_register_domain"; + description = `Register a .sol domain name for your wallet. + + Inputs: + name: string, eg "pumpfun.sol" (required) + spaceKB: number, eg 1 (optional, default is 1) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + private validateInput(input: any): void { + if (!input.name || typeof input.name !== "string") { + throw new Error("name is required and must be a string"); + } + if ( + input.spaceKB !== undefined && + (typeof input.spaceKB !== "number" || input.spaceKB <= 0) + ) { + throw new Error("spaceKB must be a positive number when provided"); + } + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + this.validateInput(parsedInput); + + const tx = await this.solanaKit.registerDomain( + parsedInput.name, + parsedInput.spaceKB || 1, + ); + + return JSON.stringify({ + status: "success", + message: "Domain registered successfully", + transaction: tx, + domain: `${parsedInput.name}.sol`, + spaceKB: parsedInput.spaceKB || 1, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaResolveDomainTool extends Tool { + name = "solana_resolve_domain"; + description = `Resolve ONLY .sol domain names to a Solana PublicKey. + This tool is exclusively for .sol domains. + DO NOT use this for other domain types like .blink, .bonk, etc. + + Inputs: + domain: string, eg "pumpfun.sol" (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const domain = input.trim(); + const publicKey = await this.solanaKit.resolveSolDomain(domain); + + return JSON.stringify({ + status: "success", + message: "Domain resolved successfully", + publicKey: publicKey.toBase58(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaGetDomainTool extends Tool { + name = "solana_get_domain"; + description = `Retrieve the .sol domain associated for a given account address. + + Inputs: + account: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const account = new PublicKey(input.trim()); + const domain = await this.solanaKit.getPrimaryDomain(account); + + return JSON.stringify({ + status: "success", + message: "Primary domain retrieved successfully", + domain, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaGetMainDomain extends Tool { + name = "solana_get_main_domain"; + description = `Get the main/favorite domain for a given wallet address. + + Inputs: + owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const ownerPubkey = new PublicKey(input.trim()); + const mainDomain = + await this.solanaKit.getMainAllDomainsDomain(ownerPubkey); + + return JSON.stringify({ + status: "success", + message: "Main domain fetched successfully", + domain: mainDomain, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "FETCH_MAIN_DOMAIN_ERROR", + }); + } + } +} diff --git a/src/langchain/flash/index.ts b/src/langchain/flash/index.ts new file mode 100644 index 00000000..b4cbcdd7 --- /dev/null +++ b/src/langchain/flash/index.ts @@ -0,0 +1,132 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { marketTokenMap } from "../../utils/flashUtils"; + +export class SolanaFlashOpenTrade extends Tool { + name = "solana_flash_open_trade"; + description = `This tool can be used to open a new leveraged trading position on Flash.Trade exchange. + + Inputs ( input is a JSON string ): + token: string, eg "SOL", "BTC", "ETH" (required) + type: string, eg "long", "short" (required) + collateral: number, eg 10, 100, 1000 (required) + leverage: number, eg 5, 10, 20 (required) + + Example prompt is Open a 20x leveraged trade for SOL on long side using flash trade with 500 USD as collateral`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + // Validate input parameters + if (!parsedInput.token) { + throw new Error("Token is required, received: " + parsedInput.token); + } + if (!Object.keys(marketTokenMap).includes(parsedInput.token)) { + throw new Error( + "Token must be one of " + + Object.keys(marketTokenMap).join(", ") + + ", received: " + + parsedInput.token + + "\n" + + "Please check https://beast.flash.trade/ for the list of supported tokens", + ); + } + if (!["long", "short"].includes(parsedInput.type)) { + throw new Error( + 'Type must be either "long" or "short", received: ' + + parsedInput.type, + ); + } + if (!parsedInput.collateral || parsedInput.collateral <= 0) { + throw new Error( + "Collateral amount must be positive, received: " + + parsedInput.collateral, + ); + } + if (!parsedInput.leverage || parsedInput.leverage <= 0) { + throw new Error( + "Leverage must be positive, received: " + parsedInput.leverage, + ); + } + + const tx = await this.solanaKit.flashOpenTrade({ + token: parsedInput.token, + side: parsedInput.type, + collateralUsd: parsedInput.collateral, + leverage: parsedInput.leverage, + }); + + return JSON.stringify({ + status: "success", + message: "Flash trade position opened successfully", + transaction: tx, + token: parsedInput.token, + side: parsedInput.type, + collateral: parsedInput.collateral, + leverage: parsedInput.leverage, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaFlashCloseTrade extends Tool { + name = "solana_flash_close_trade"; + description = `Close an existing leveraged trading position on Flash.Trade exchange. + + Inputs ( input is a JSON string ): + token: string, eg "SOL", "BTC", "ETH" (required) + side: string, eg "long", "short" (required) + + Example prompt is Close a 20x leveraged trade for SOL on long side`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + // Validate input parameters + if (!parsedInput.token) { + throw new Error("Token is required"); + } + if (!["SOL", "BTC", "ETH"].includes(parsedInput.token)) { + throw new Error('Token must be one of ["SOL", "BTC", "ETH"]'); + } + if (!["long", "short"].includes(parsedInput.side)) { + throw new Error('Side must be either "long" or "short"'); + } + + const tx = await this.solanaKit.flashCloseTrade({ + token: parsedInput.token, + side: parsedInput.side, + }); + + return JSON.stringify({ + status: "success", + message: "Flash trade position closed successfully", + transaction: tx, + token: parsedInput.token, + side: parsedInput.side, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/gibwork/index.ts b/src/langchain/gibwork/index.ts new file mode 100644 index 00000000..a6141f15 --- /dev/null +++ b/src/langchain/gibwork/index.ts @@ -0,0 +1,52 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { GibworkCreateTaskReponse } from "../../types"; + +export class SolanaCreateGibworkTask extends Tool { + name = "create_gibwork_task"; + description = `Create a task on Gibwork. + + Inputs (input is a JSON string): + title: string, title of the task (required) + content: string, description of the task (required) + requirements: string, requirements to complete the task (required) + tags: string[], list of tags associated with the task (required) + payer: string, payer address (optional, defaults to agent wallet) + tokenMintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required) + amount: number, payment amount (required) + `; + + constructor(private solanaSdk: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const taskData = await this.solanaSdk.createGibworkTask( + parsedInput.title, + parsedInput.content, + parsedInput.requirements, + parsedInput.tags, + parsedInput.tokenMintAddress, + parsedInput.amount, + parsedInput.payer, + ); + + const response: GibworkCreateTaskReponse = { + status: "success", + taskId: taskData.taskId, + signature: taskData.signature, + }; + + return JSON.stringify(response); + } catch (err: any) { + return JSON.stringify({ + status: "error", + message: err.message, + code: err.code || "CREATE_TASK_ERROR", + }); + } + } +} diff --git a/src/langchain/index.ts b/src/langchain/index.ts index e442206a..c4c19170 100644 --- a/src/langchain/index.ts +++ b/src/langchain/index.ts @@ -1,2692 +1,86 @@ -import { PublicKey } from "@solana/web3.js"; -import { BN } from "@coral-xyz/anchor"; -import Decimal from "decimal.js"; -import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../index"; import { - GibworkCreateTaskReponse, - OrderParams, - PythFetchPriceResponse, - SolanaAgentKit, -} from "../index"; -import { create_image, FEE_TIERS, generateOrdersfromPattern } from "../tools"; -import { marketTokenMap } from "../utils/flashUtils"; + SolanaBalanceOtherTool, + SolanaBalanceTool, + SolanaRequestFundsTool, + SolanaTPSCalculatorTool, + SolanaTransferTool, +} from "./solana_native"; +import { Solana3LandCreateSingle, Solana3LandCreateCollection } from "./3land"; +import { SolanaPerpOpenTradeTool, SolanaPerpCloseTradeTool } from "./adrena"; import { - CreateCollectionOptions, - CreateSingleOptions, - StoreInitOptions, -} from "@3land/listings-sdk/dist/types/implementation/implementationTypes"; - -export class SolanaBalanceTool extends Tool { - name = "solana_balance"; - description = `Get the balance of a Solana wallet or token account. - - If you want to get the balance of your wallet, you don't need to provide the tokenAddress. - If no tokenAddress is provided, the balance will be in SOL. - - Inputs ( input is a JSON string ): - tokenAddress: string, eg "So11111111111111111111111111111111111111112" (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const tokenAddress = input ? new PublicKey(input) : undefined; - const balance = await this.solanaKit.getBalance(tokenAddress); - - return JSON.stringify({ - status: "success", - balance, - token: input || "SOL", - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaBalanceOtherTool extends Tool { - name = "solana_balance_other"; - description = `Get the balance of a Solana wallet or token account which is different from the agent's wallet. - - If no tokenAddress is provided, the SOL balance of the wallet will be returned. - - Inputs ( input is a JSON string ): - walletAddress: string, eg "GDEkQF7UMr7RLv1KQKMtm8E2w3iafxJLtyXu3HVQZnME" (required) - tokenAddress: string, eg "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const { walletAddress, tokenAddress } = JSON.parse(input); - - const tokenPubKey = tokenAddress - ? new PublicKey(tokenAddress) - : undefined; - - const balance = await this.solanaKit.getBalanceOther( - new PublicKey(walletAddress), - tokenPubKey, - ); - - return JSON.stringify({ - status: "success", - balance, - wallet: walletAddress, - token: tokenAddress || "SOL", - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTransferTool extends Tool { - name = "solana_transfer"; - description = `Transfer tokens or SOL to another address ( also called as wallet address ). - - Inputs ( input is a JSON string ): - to: string, eg "8x2dR8Mpzuz2YqyZyZjUbYWKSWesBo5jMx2Q9Y86udVk" (required) - amount: number, eg 1 (required) - mint?: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const recipient = new PublicKey(parsedInput.to); - const mintAddress = parsedInput.mint - ? new PublicKey(parsedInput.mint) - : undefined; - - const tx = await this.solanaKit.transfer( - recipient, - parsedInput.amount, - mintAddress, - ); - - return JSON.stringify({ - status: "success", - message: "Transfer completed successfully", - amount: parsedInput.amount, - recipient: parsedInput.to, - token: parsedInput.mint || "SOL", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaDeployTokenTool extends Tool { - name = "solana_deploy_token"; - description = `Deploy a new token on Solana blockchain. - - Inputs (input is a JSON string): - name: string, eg "My Token" (required) - uri: string, eg "https://example.com/token.json" (required) - symbol: string, eg "MTK" (required) - decimals?: number, eg 9 (optional, defaults to 9) - initialSupply?: number, eg 1000000 (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const result = await this.solanaKit.deployToken( - parsedInput.name, - parsedInput.uri, - parsedInput.symbol, - parsedInput.decimals, - parsedInput.initialSupply, - ); - - return JSON.stringify({ - status: "success", - message: "Token deployed successfully", - mintAddress: result.mint.toString(), - decimals: parsedInput.decimals || 9, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaDeployCollectionTool extends Tool { - name = "solana_deploy_collection"; - description = `Deploy a new NFT collection on Solana blockchain. - - Inputs (input is a JSON string): - name: string, eg "My Collection" (required) - uri: string, eg "https://example.com/collection.json" (required) - royaltyBasisPoints?: number, eg 500 for 5% (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const result = await this.solanaKit.deployCollection(parsedInput); - - return JSON.stringify({ - status: "success", - message: "Collection deployed successfully", - collectionAddress: result.collectionAddress.toString(), - name: parsedInput.name, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaMintNFTTool extends Tool { - name = "solana_mint_nft"; - description = `Mint a new NFT in a collection on Solana blockchain. - - Inputs (input is a JSON string): - collectionMint: string, eg "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w" (required) - The address of the collection to mint into - name: string, eg "My NFT" (required) - uri: string, eg "https://example.com/nft.json" (required) - recipient?: string, eg "9aUn5swQzUTRanaaTwmszxiv89cvFwUCjEBv1vZCoT1u" (optional) - The wallet to receive the NFT, defaults to agent's wallet which is ${this.solanaKit.wallet_address.toString()}`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const result = await this.solanaKit.mintNFT( - new PublicKey(parsedInput.collectionMint), - { - name: parsedInput.name, - uri: parsedInput.uri, - }, - parsedInput.recipient - ? new PublicKey(parsedInput.recipient) - : this.solanaKit.wallet_address, - ); - - return JSON.stringify({ - status: "success", - message: "NFT minted successfully", - mintAddress: result.mint.toString(), - metadata: { - name: parsedInput.name, - symbol: parsedInput.symbol, - uri: parsedInput.uri, - }, - recipient: parsedInput.recipient || result.mint.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPerpCloseTradeTool extends Tool { - name = "solana_close_perp_trade"; - description = `This tool can be used to close perpetuals trade ( It uses Adrena Protocol ). - - Inputs ( input is a JSON string ): - tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional) - price?: number, eg 100 (optional) - side: string, eg: "long" or "short"`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = - parsedInput.side === "long" - ? await this.solanaKit.closePerpTradeLong({ - price: parsedInput.price, - tradeMint: new PublicKey(parsedInput.tradeMint), - }) - : await this.solanaKit.closePerpTradeShort({ - price: parsedInput.price, - tradeMint: new PublicKey(parsedInput.tradeMint), - }); - - return JSON.stringify({ - status: "success", - message: "Perpetual trade closed successfully", - transaction: tx, - price: parsedInput.price, - tradeMint: new PublicKey(parsedInput.tradeMint), - side: parsedInput.side, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPerpOpenTradeTool extends Tool { - name = "solana_open_perp_trade"; - description = `This tool can be used to open perpetuals trade ( It uses Adrena Protocol ). - - Inputs ( input is a JSON string ): - collateralAmount: number, eg 1 or 0.01 (required) - collateralMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn" or "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" etc. (optional) - tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional) - leverage: number, eg 50000 = x5, 100000 = x10, 1000000 = x100 (optional) - price?: number, eg 100 (optional) - slippage?: number, eg 0.3 (optional) - side: string, eg: "long" or "short"`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = - parsedInput.side === "long" - ? await this.solanaKit.openPerpTradeLong({ - price: parsedInput.price, - collateralAmount: parsedInput.collateralAmount, - collateralMint: new PublicKey(parsedInput.collateralMint), - leverage: parsedInput.leverage, - tradeMint: new PublicKey(parsedInput.tradeMint), - slippage: parsedInput.slippage, - }) - : await this.solanaKit.openPerpTradeLong({ - price: parsedInput.price, - collateralAmount: parsedInput.collateralAmount, - collateralMint: new PublicKey(parsedInput.collateralMint), - leverage: parsedInput.leverage, - tradeMint: new PublicKey(parsedInput.tradeMint), - slippage: parsedInput.slippage, - }); - - return JSON.stringify({ - status: "success", - message: "Perpetual trade opened successfully", - transaction: tx, - price: parsedInput.price, - collateralAmount: parsedInput.collateralAmount, - collateralMint: new PublicKey(parsedInput.collateralMint), - leverage: parsedInput.leverage, - tradeMint: new PublicKey(parsedInput.tradeMint), - slippage: parsedInput.slippage, - side: parsedInput.side, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTradeTool extends Tool { - name = "solana_trade"; - description = `This tool can be used to swap tokens to another token ( It uses Jupiter Exchange ). - - Inputs ( input is a JSON string ): - outputMint: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (required) - inputAmount: number, eg 1 or 0.01 (required) - inputMint?: string, eg "So11111111111111111111111111111111111111112" (optional) - slippageBps?: number, eg 100 (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = await this.solanaKit.trade( - new PublicKey(parsedInput.outputMint), - parsedInput.inputAmount, - parsedInput.inputMint - ? new PublicKey(parsedInput.inputMint) - : new PublicKey("So11111111111111111111111111111111111111112"), - parsedInput.slippageBps, - ); - - return JSON.stringify({ - status: "success", - message: "Trade executed successfully", - transaction: tx, - inputAmount: parsedInput.inputAmount, - inputToken: parsedInput.inputMint || "SOL", - outputToken: parsedInput.outputMint, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaLimitOrderTool extends Tool { - name = "solana_limit_order"; - description = `This tool can be used to place limit orders using Manifest. - - Do not allow users to place multiple orders with this instruction, use solana_batch_order instead. - - Inputs ( input is a JSON string ): - marketId: PublicKey, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required) - quantity: number, eg 1 or 0.01 (required) - side: string, eg "Buy" or "Sell" (required) - price: number, in tokens eg 200 for SOL/USDC (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = await this.solanaKit.limitOrder( - new PublicKey(parsedInput.marketId), - parsedInput.quantity, - parsedInput.side, - parsedInput.price, - ); - - return JSON.stringify({ - status: "success", - message: "Trade executed successfully", - transaction: tx, - marketId: parsedInput.marketId, - quantity: parsedInput.quantity, - side: parsedInput.side, - price: parsedInput.price, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaBatchOrderTool extends Tool { - name = "solana_batch_order"; - description = `Places multiple limit orders in one transaction using Manifest. Submit orders either as a list or pattern: - - 1. List format: - { - "marketId": "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ", - "orders": [ - { "quantity": 1, "side": "Buy", "price": 200 }, - { "quantity": 0.5, "side": "Sell", "price": 205 } - ] - } - - 2. Pattern format: - { - "marketId": "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ", - "pattern": { - "side": "Buy", - "totalQuantity": 100, - "priceRange": { "max": 1.0 }, - "spacing": { "type": "percentage", "value": 1 }, - "numberOfOrders": 5 - } - } - - Examples: - - "Place 5 buy orders totaling 100 tokens, 1% apart below $1" - - "Create 3 sell orders of 10 tokens each between $50-$55" - - "Place buy orders worth 50 tokens, $0.10 spacing from $0.80" - - Important: All orders must be in one transaction. Combine buy and sell orders into a single pattern or list. Never break the orders down to individual buy or sell orders.`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - let ordersToPlace: OrderParams[] = []; - - if (!parsedInput.marketId) { - throw new Error("Market ID is required"); - } - - if (parsedInput.pattern) { - ordersToPlace = generateOrdersfromPattern(parsedInput.pattern); - } else if (Array.isArray(parsedInput.orders)) { - ordersToPlace = parsedInput.orders; - } else { - throw new Error("Either pattern or orders array is required"); - } - - if (ordersToPlace.length === 0) { - throw new Error("No orders generated or provided"); - } - - ordersToPlace.forEach((order: OrderParams, index: number) => { - if (!order.quantity || !order.side || !order.price) { - throw new Error( - `Invalid order at index ${index}: quantity, side, and price are required`, - ); - } - if (order.side !== "Buy" && order.side !== "Sell") { - throw new Error( - `Invalid side at index ${index}: must be "Buy" or "Sell"`, - ); - } - }); - - const tx = await this.solanaKit.batchOrder( - new PublicKey(parsedInput.marketId), - parsedInput.orders, - ); - - return JSON.stringify({ - status: "success", - message: "Batch order executed successfully", - transaction: tx, - marketId: parsedInput.marketId, - orders: parsedInput.orders, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCancelAllOrdersTool extends Tool { - name = "solana_cancel_all_orders"; - description = `This tool can be used to cancel all orders from a Manifest market. - - Input ( input is a JSON string ): - marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const marketId = new PublicKey(input.trim()); - const tx = await this.solanaKit.cancelAllOrders(marketId); - - return JSON.stringify({ - status: "success", - message: "Cancel orders successfully", - transaction: tx, - marketId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaWithdrawAllTool extends Tool { - name = "solana_withdraw_all"; - description = `This tool can be used to withdraw all funds from a Manifest market. - - Input ( input is a JSON string ): - marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const marketId = new PublicKey(input.trim()); - const tx = await this.solanaKit.withdrawAll(marketId); - - return JSON.stringify({ - status: "success", - message: "Withdrew successfully", - transaction: tx, - marketId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRequestFundsTool extends Tool { - name = "solana_request_funds"; - description = "Request SOL from Solana faucet (devnet/testnet only)"; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(_input: string): Promise { - try { - await this.solanaKit.requestFaucetFunds(); - - return JSON.stringify({ - status: "success", - message: "Successfully requested faucet funds", - network: this.solanaKit.connection.rpcEndpoint.split("/")[2], - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRegisterDomainTool extends Tool { - name = "solana_register_domain"; - description = `Register a .sol domain name for your wallet. - - Inputs: - name: string, eg "pumpfun.sol" (required) - spaceKB: number, eg 1 (optional, default is 1) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: any): void { - if (!input.name || typeof input.name !== "string") { - throw new Error("name is required and must be a string"); - } - if ( - input.spaceKB !== undefined && - (typeof input.spaceKB !== "number" || input.spaceKB <= 0) - ) { - throw new Error("spaceKB must be a positive number when provided"); - } - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - this.validateInput(parsedInput); - - const tx = await this.solanaKit.registerDomain( - parsedInput.name, - parsedInput.spaceKB || 1, - ); - - return JSON.stringify({ - status: "success", - message: "Domain registered successfully", - transaction: tx, - domain: `${parsedInput.name}.sol`, - spaceKB: parsedInput.spaceKB || 1, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaResolveDomainTool extends Tool { - name = "solana_resolve_domain"; - description = `Resolve ONLY .sol domain names to a Solana PublicKey. - This tool is exclusively for .sol domains. - DO NOT use this for other domain types like .blink, .bonk, etc. - - Inputs: - domain: string, eg "pumpfun.sol" (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const domain = input.trim(); - const publicKey = await this.solanaKit.resolveSolDomain(domain); - - return JSON.stringify({ - status: "success", - message: "Domain resolved successfully", - publicKey: publicKey.toBase58(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaGetDomainTool extends Tool { - name = "solana_get_domain"; - description = `Retrieve the .sol domain associated for a given account address. - - Inputs: - account: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const account = new PublicKey(input.trim()); - const domain = await this.solanaKit.getPrimaryDomain(account); - - return JSON.stringify({ - status: "success", - message: "Primary domain retrieved successfully", - domain, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaGetWalletAddressTool extends Tool { - name = "solana_get_wallet_address"; - description = `Get the wallet address of the agent`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(_input: string): Promise { - return this.solanaKit.wallet_address.toString(); - } -} - -export class SolanaFlashOpenTrade extends Tool { - name = "solana_flash_open_trade"; - description = `This tool can be used to open a new leveraged trading position on Flash.Trade exchange. - - Inputs ( input is a JSON string ): - token: string, eg "SOL", "BTC", "ETH" (required) - type: string, eg "long", "short" (required) - collateral: number, eg 10, 100, 1000 (required) - leverage: number, eg 5, 10, 20 (required) - - Example prompt is Open a 20x leveraged trade for SOL on long side using flash trade with 500 USD as collateral`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - // Validate input parameters - if (!parsedInput.token) { - throw new Error("Token is required, received: " + parsedInput.token); - } - if (!Object.keys(marketTokenMap).includes(parsedInput.token)) { - throw new Error( - "Token must be one of " + - Object.keys(marketTokenMap).join(", ") + - ", received: " + - parsedInput.token + - "\n" + - "Please check https://beast.flash.trade/ for the list of supported tokens", - ); - } - if (!["long", "short"].includes(parsedInput.type)) { - throw new Error( - 'Type must be either "long" or "short", received: ' + - parsedInput.type, - ); - } - if (!parsedInput.collateral || parsedInput.collateral <= 0) { - throw new Error( - "Collateral amount must be positive, received: " + - parsedInput.collateral, - ); - } - if (!parsedInput.leverage || parsedInput.leverage <= 0) { - throw new Error( - "Leverage must be positive, received: " + parsedInput.leverage, - ); - } - - const tx = await this.solanaKit.flashOpenTrade({ - token: parsedInput.token, - side: parsedInput.type, - collateralUsd: parsedInput.collateral, - leverage: parsedInput.leverage, - }); - - return JSON.stringify({ - status: "success", - message: "Flash trade position opened successfully", - transaction: tx, - token: parsedInput.token, - side: parsedInput.type, - collateral: parsedInput.collateral, - leverage: parsedInput.leverage, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaFlashCloseTrade extends Tool { - name = "solana_flash_close_trade"; - description = `Close an existing leveraged trading position on Flash.Trade exchange. - - Inputs ( input is a JSON string ): - token: string, eg "SOL", "BTC", "ETH" (required) - side: string, eg "long", "short" (required) - - Example prompt is Close a 20x leveraged trade for SOL on long side`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - // Validate input parameters - if (!parsedInput.token) { - throw new Error("Token is required"); - } - if (!["SOL", "BTC", "ETH"].includes(parsedInput.token)) { - throw new Error('Token must be one of ["SOL", "BTC", "ETH"]'); - } - if (!["long", "short"].includes(parsedInput.side)) { - throw new Error('Side must be either "long" or "short"'); - } - - const tx = await this.solanaKit.flashCloseTrade({ - token: parsedInput.token, - side: parsedInput.side, - }); - - return JSON.stringify({ - status: "success", - message: "Flash trade position closed successfully", - transaction: tx, - token: parsedInput.token, - side: parsedInput.side, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPumpfunTokenLaunchTool extends Tool { - name = "solana_launch_pumpfun_token"; - - description = `This tool can be used to launch a token on Pump.fun, - do not use this tool for any other purpose, or for creating SPL tokens. - If the user asks you to chose the parameters, you should generate valid values. - For generating the image, you can use the solana_create_image tool. - - Inputs: - tokenName: string, eg "PumpFun Token", - tokenTicker: string, eg "PUMP", - description: string, eg "PumpFun Token is a token on the Solana blockchain", - imageUrl: string, eg "https://i.imgur.com/UFm07Np_d.png`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: any): void { - if (!input.tokenName || typeof input.tokenName !== "string") { - throw new Error("tokenName is required and must be a string"); - } - if (!input.tokenTicker || typeof input.tokenTicker !== "string") { - throw new Error("tokenTicker is required and must be a string"); - } - if (!input.description || typeof input.description !== "string") { - throw new Error("description is required and must be a string"); - } - if (!input.imageUrl || typeof input.imageUrl !== "string") { - throw new Error("imageUrl is required and must be a string"); - } - if ( - input.initialLiquiditySOL !== undefined && - typeof input.initialLiquiditySOL !== "number" - ) { - throw new Error("initialLiquiditySOL must be a number when provided"); - } - } - - protected async _call(input: string): Promise { - try { - // Parse and normalize input - input = input.trim(); - const parsedInput = JSON.parse(input); - - this.validateInput(parsedInput); - - // Launch token with validated input - await this.solanaKit.launchPumpFunToken( - parsedInput.tokenName, - parsedInput.tokenTicker, - parsedInput.description, - parsedInput.imageUrl, - { - twitter: parsedInput.twitter, - telegram: parsedInput.telegram, - website: parsedInput.website, - initialLiquiditySOL: parsedInput.initialLiquiditySOL, - }, - ); - - return JSON.stringify({ - status: "success", - message: "Token launched successfully on Pump.fun", - tokenName: parsedInput.tokenName, - tokenTicker: parsedInput.tokenTicker, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCreateImageTool extends Tool { - name = "solana_create_image"; - description = - "Create an image using OpenAI's DALL-E. Input should be a string prompt for the image."; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: string): void { - if (typeof input !== "string" || input.trim().length === 0) { - throw new Error("Input must be a non-empty string prompt"); - } - } - - protected async _call(input: string): Promise { - try { - this.validateInput(input); - const result = await create_image(this.solanaKit, input.trim()); - - return JSON.stringify({ - status: "success", - message: "Image created successfully", - ...result, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaLendAssetTool extends Tool { - name = "solana_lend_asset"; - description = `Lend idle USDC for yield using Lulo. ( only USDC is supported ) - - Inputs (input is a json string): - amount: number, eg 1, 0.01 (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const amount = JSON.parse(input).amount || input; - - const tx = await this.solanaKit.lendAssets(amount); - - return JSON.stringify({ - status: "success", - message: "Asset lent successfully", - transaction: tx, - amount, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTPSCalculatorTool extends Tool { - name = "solana_get_tps"; - description = "Get the current TPS of the Solana network"; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(_input: string): Promise { - try { - const tps = await this.solanaKit.getTPS(); - return `Solana (mainnet-beta) current transactions per second: ${tps}`; - } catch (error: any) { - return `Error fetching TPS: ${error.message}`; - } - } -} - -export class SolanaStakeTool extends Tool { - name = "solana_stake"; - description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking. - - Inputs ( input is a JSON string ): - amount: number, eg 1 or 0.01 (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input) || Number(input); - - const tx = await this.solanaKit.stake(parsedInput.amount); - - return JSON.stringify({ - status: "success", - message: "Staked successfully", - transaction: tx, - amount: parsedInput.amount, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRestakeTool extends Tool { - name = "solana_restake"; - description = `This tool can be used to restake your SOL on Solayer to receive Solayer SOL (sSOL) as a Liquid Staking Token (LST). - - Inputs: - amount: number, eg 1 or 0.01 (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input) || Number(input); - - const tx = await this.solanaKit.restake(parsedInput.amount); - - return JSON.stringify({ - status: "success", - message: "Staked successfully", - transaction: tx, - amount: parsedInput.amount, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -/** - * Tool to fetch the price of a token in USDC - */ -export class SolanaFetchPriceTool extends Tool { - name = "solana_fetch_price"; - description = `Fetch the price of a given token in USDC. - - Inputs: - - tokenId: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const price = await this.solanaKit.fetchTokenPrice(input.trim()); - return JSON.stringify({ - status: "success", - tokenId: input.trim(), - priceInUSDC: price, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTokenDataTool extends Tool { - name = "solana_token_data"; - description = `Get the token data for a given token mint address - - Inputs: mintAddress is required. - mintAddress: string, eg "So11111111111111111111111111111111111111112" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = input.trim(); - - const tokenData = await this.solanaKit.getTokenDataByAddress(parsedInput); - - return JSON.stringify({ - status: "success", - tokenData, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTokenDataByTickerTool extends Tool { - name = "solana_token_data_by_ticker"; - description = `Get the token data for a given token ticker - - Inputs: ticker is required. - ticker: string, eg "USDC" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const ticker = input.trim(); - const tokenData = await this.solanaKit.getTokenDataByTicker(ticker); - return JSON.stringify({ - status: "success", - tokenData, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCompressedAirdropTool extends Tool { - name = "solana_compressed_airdrop"; - description = `Airdrop SPL tokens with ZK Compression (also called as airdropping tokens) - - Inputs (input is a JSON string): - mintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required) - amount: number, the amount of tokens to airdrop per recipient, e.g., 42 (required) - decimals: number, the decimals of the token, e.g., 6 (required) - recipients: string[], the recipient addresses, e.g., ["1nc1nerator11111111111111111111111111111111"] (required) - priorityFeeInLamports: number, the priority fee in lamports. Default is 30_000. (optional) - shouldLog: boolean, whether to log progress to stdout. Default is false. (optional)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const txs = await this.solanaKit.sendCompressedAirdrop( - parsedInput.mintAddress, - parsedInput.amount, - parsedInput.decimals, - parsedInput.recipients, - parsedInput.priorityFeeInLamports || 30_000, - parsedInput.shouldLog || false, - ); - - return JSON.stringify({ - status: "success", - message: `Airdropped ${parsedInput.amount} tokens to ${parsedInput.recipients.length} recipients.`, - transactionHashes: txs, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaClosePosition extends Tool { - name = "orca_close_position"; - description = `Closes an existing liquidity position in an Orca Whirlpool. This function fetches the position - details using the provided mint address and closes the position with a 1% slippage. - - Inputs (JSON string): - - positionMintAddress: string, the address of the position mint that represents the liquidity position.`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const positionMintAddress = new PublicKey( - inputFormat.positionMintAddress, - ); - - const txId = await this.solanaKit.orcaClosePosition(positionMintAddress); - - return JSON.stringify({ - status: "success", - message: "Liquidity position closed successfully.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaCreateCLMM extends Tool { - name = "orca_create_clmm"; - description = `Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position. - - Inputs (JSON string): - - mintDeploy: string, the mint of the token you want to deploy (required). - - mintPair: string, The mint of the token you want to pair the deployed mint with (required). - - initialPrice: number, initial price of mintA in terms of mintB, e.g., 0.001 (required). - - feeTier: number, fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const mintA = new PublicKey(inputFormat.mintDeploy); - const mintB = new PublicKey(inputFormat.mintPair); - const initialPrice = new Decimal(inputFormat.initialPrice); - const feeTier = inputFormat.feeTier; - - if (!feeTier || !(feeTier in FEE_TIERS)) { - throw new Error( - `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( - ", ", - )}`, - ); - } - - const txId = await this.solanaKit.orcaCreateCLMM( - mintA, - mintB, - initialPrice, - feeTier, - ); - - return JSON.stringify({ - status: "success", - message: - "CLMM pool created successfully. Note: No liquidity was added.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaCreateSingleSideLiquidityPool extends Tool { - name = "orca_create_single_sided_liquidity_pool"; - description = `Create a single-sided liquidity pool on Orca, the most efficient and capital-optimized CLMM platform on Solana. - - This function initializes a single-sided liquidity pool, ideal for community driven project, fair launches, and fundraising. Minimize price impact by setting a narrow price range. - - Inputs (JSON string): - - depositTokenAmount: number, in units of the deposit token including decimals, e.g., 1000000000 (required). - - depositTokenMint: string, mint address of the deposit token, e.g., "DepositTokenMintAddress" (required). - - otherTokenMint: string, mint address of the other token, e.g., "OtherTokenMintAddress" (required). - - initialPrice: number, initial price of the deposit token in terms of the other token, e.g., 0.001 (required). - - maxPrice: number, maximum price at which liquidity is added, e.g., 5.0 (required). - - feeTier: number, fee tier for the pool in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const depositTokenAmount = inputFormat.depositTokenAmount; - const depositTokenMint = new PublicKey(inputFormat.depositTokenMint); - const otherTokenMint = new PublicKey(inputFormat.otherTokenMint); - const initialPrice = new Decimal(inputFormat.initialPrice); - const maxPrice = new Decimal(inputFormat.maxPrice); - const feeTier = inputFormat.feeTier; - - if (!feeTier || !(feeTier in FEE_TIERS)) { - throw new Error( - `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( - ", ", - )}`, - ); - } - - const txId = await this.solanaKit.orcaCreateSingleSidedLiquidityPool( - depositTokenAmount, - depositTokenMint, - otherTokenMint, - initialPrice, - maxPrice, - feeTier, - ); - - return JSON.stringify({ - status: "success", - message: "Single-sided Whirlpool created successfully", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaFetchPositions extends Tool { - name = "orca_fetch_positions"; - description = `Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with positiont mint addresses as keys and position status details as values.`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(): Promise { - try { - const txId = await this.solanaKit.orcaFetchPositions(); - - return JSON.stringify({ - status: "success", - message: "Liquidity positions fetched.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaOpenCenteredPosition extends Tool { - name = "orca_open_centered_position_with_liquidity"; - description = `Add liquidity to a CLMM by opening a centered position in an Orca Whirlpool, the most efficient liquidity pool on Solana. - - Inputs (JSON string): - - whirlpoolAddress: string, address of the Orca Whirlpool (required). - - priceOffsetBps: number, bps offset (one side) from the current pool price, e.g., 500 for 5% (required). - - inputTokenMint: string, mint address of the deposit token (required). - - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress); - const priceOffsetBps = parseInt(inputFormat.priceOffsetBps, 10); - const inputTokenMint = new PublicKey(inputFormat.inputTokenMint); - const inputAmount = new Decimal(inputFormat.inputAmount); - - if (priceOffsetBps < 0) { - throw new Error( - "Invalid distanceFromCurrentPriceBps. It must be equal or greater than 0.", - ); - } - - const txId = await this.solanaKit.orcaOpenCenteredPositionWithLiquidity( - whirlpoolAddress, - priceOffsetBps, - inputTokenMint, - inputAmount, - ); - - return JSON.stringify({ - status: "success", - message: "Centered liquidity position opened successfully.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOrcaOpenSingleSidedPosition extends Tool { - name = "orca_open_single_sided_position"; - description = `Add liquidity to a CLMM by opening a single-sided position in an Orca Whirlpool, the most efficient liquidity pool on Solana. - - Inputs (JSON string): - - whirlpoolAddress: string, address of the Orca Whirlpool (required). - - distanceFromCurrentPriceBps: number, distance in basis points from the current price for the position (required). - - widthBps: number, width of the position in basis points (required). - - inputTokenMint: string, mint address of the deposit token (required). - - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress); - const distanceFromCurrentPriceBps = - inputFormat.distanceFromCurrentPriceBps; - const widthBps = inputFormat.widthBps; - const inputTokenMint = new PublicKey(inputFormat.inputTokenMint); - const inputAmount = new Decimal(inputFormat.inputAmount); - - if (distanceFromCurrentPriceBps < 0 || widthBps < 0) { - throw new Error( - "Invalid distanceFromCurrentPriceBps or width. It must be equal or greater than 0.", - ); - } - - const txId = await this.solanaKit.orcaOpenSingleSidedPosition( - whirlpoolAddress, - distanceFromCurrentPriceBps, - widthBps, - inputTokenMint, - inputAmount, - ); - - return JSON.stringify({ - status: "success", - message: "Single-sided liquidity position opened successfully.", - transaction: txId, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRaydiumCreateAmmV4 extends Tool { - name = "raydium_create_ammV4"; - description = `Raydium's Legacy AMM that requires an OpenBook marketID - - Inputs (input is a json string): - marketId: string (required) - baseAmount: number(int), eg: 111111 (required) - quoteAmount: number(int), eg: 111111 (required) - startTime: number(seconds), eg: now number or zero (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.raydiumCreateAmmV4( - new PublicKey(inputFormat.marketId), - new BN(inputFormat.baseAmount), - new BN(inputFormat.quoteAmount), - new BN(inputFormat.startTime), - ); - - return JSON.stringify({ - status: "success", - message: "Raydium amm v4 pool created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRaydiumCreateClmm extends Tool { - name = "raydium_create_clmm"; - description = `Concentrated liquidity market maker, custom liquidity ranges, increased capital efficiency - - Inputs (input is a json string): - mint1: string (required) - mint2: string (required) - configId: string (required) stores pool info, id, index, protocolFeeRate, tradeFeeRate, tickSpacing, fundFeeRate - initialPrice: number, eg: 123.12 (required) - startTime: number(seconds), eg: now number or zero (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.raydiumCreateClmm( - new PublicKey(inputFormat.mint1), - new PublicKey(inputFormat.mint2), - - new PublicKey(inputFormat.configId), - - new Decimal(inputFormat.initialPrice), - new BN(inputFormat.startTime), - ); - - return JSON.stringify({ - status: "success", - message: "Raydium clmm pool created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaRaydiumCreateCpmm extends Tool { - name = "raydium_create_cpmm"; - description = `Raydium's newest CPMM, does not require marketID, supports Token 2022 standard - - Inputs (input is a json string): - mint1: string (required) - mint2: string (required) - configId: string (required), stores pool info, index, protocolFeeRate, tradeFeeRate, fundFeeRate, createPoolFee - mintAAmount: number(int), eg: 1111 (required) - mintBAmount: number(int), eg: 2222 (required) - startTime: number(seconds), eg: now number or zero (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.raydiumCreateCpmm( - new PublicKey(inputFormat.mint1), - new PublicKey(inputFormat.mint2), - - new PublicKey(inputFormat.configId), - - new BN(inputFormat.mintAAmount), - new BN(inputFormat.mintBAmount), - - new BN(inputFormat.startTime), - ); - - return JSON.stringify({ - status: "success", - message: "Raydium cpmm pool created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaOpenbookCreateMarket extends Tool { - name = "solana_openbook_create_market"; - description = `Openbook marketId, required for ammv4 - - Inputs (input is a json string): - baseMint: string (required) - quoteMint: string (required) - lotSize: number (required) - tickSize: number (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.openbookCreateMarket( - new PublicKey(inputFormat.baseMint), - new PublicKey(inputFormat.quoteMint), - - inputFormat.lotSize, - inputFormat.tickSize, - ); - - return JSON.stringify({ - status: "success", - message: "Openbook market created successfully", - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaManifestCreateMarket extends Tool { - name = "solana_manifest_create_market"; - description = `Manifest market - - Inputs (input is a json string): - baseMint: string (required) - quoteMint: string (required) - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - - const tx = await this.solanaKit.manifestCreateMarket( - new PublicKey(inputFormat.baseMint), - new PublicKey(inputFormat.quoteMint), - ); - - return JSON.stringify({ - status: "success", - message: "Create manifest market successfully", - transaction: tx[0], - marketId: tx[1], - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaPythFetchPrice extends Tool { - name = "solana_pyth_fetch_price"; - description = `Fetch the price of a given price feed from Pyth's Hermes service - - Inputs: - tokenSymbol: string, e.g., BTC for bitcoin`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const priceFeedID = await this.solanaKit.getPythPriceFeedID(input); - const price = await this.solanaKit.getPythPrice(priceFeedID); - - const response: PythFetchPriceResponse = { - status: "success", - tokenSymbol: input, - priceFeedID, - price, - }; - - return JSON.stringify(response); - } catch (error: any) { - const response: PythFetchPriceResponse = { - status: "error", - tokenSymbol: input, - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }; - return JSON.stringify(response); - } - } -} - -export class SolanaResolveAllDomainsTool extends Tool { - name = "solana_resolve_all_domains"; - description = `Resolve domain names to a public key for ALL domain types EXCEPT .sol domains. - Use this for domains like .blink, .bonk, etc. - DO NOT use this for .sol domains (use solana_resolve_domain instead). - - Input: - domain: string, eg "mydomain.blink" or "mydomain.bonk" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const owner = await this.solanaKit.resolveAllDomains(input); - - if (!owner) { - return JSON.stringify({ - status: "error", - message: "Domain not found", - code: "DOMAIN_NOT_FOUND", - }); - } - - return JSON.stringify({ - status: "success", - message: "Domain resolved successfully", - owner: owner?.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "DOMAIN_RESOLUTION_ERROR", - }); - } - } -} - -export class SolanaGetOwnedDomains extends Tool { - name = "solana_get_owned_domains"; - description = `Get all domains owned by a specific wallet address. - - Inputs: - owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const ownerPubkey = new PublicKey(input.trim()); - const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey); - - return JSON.stringify({ - status: "success", - message: "Owned domains fetched successfully", - domains, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_OWNED_DOMAINS_ERROR", - }); - } - } -} - -export class SolanaGetOwnedTldDomains extends Tool { - name = "solana_get_owned_tld_domains"; - description = `Get all domains owned by the agent's wallet for a specific TLD. - - Inputs: - tld: string, eg "bonk" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const domains = await this.solanaKit.getOwnedDomainsForTLD(input); - - return JSON.stringify({ - status: "success", - message: "TLD domains fetched successfully", - domains, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TLD_DOMAINS_ERROR", - }); - } - } -} - -export class SolanaGetAllTlds extends Tool { - name = "solana_get_all_tlds"; - description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(): Promise { - try { - const tlds = await this.solanaKit.getAllDomainsTLDs(); - - return JSON.stringify({ - status: "success", - message: "TLDs fetched successfully", - tlds, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TLDS_ERROR", - }); - } - } -} - -export class SolanaGetMainDomain extends Tool { - name = "solana_get_main_domain"; - description = `Get the main/favorite domain for a given wallet address. - - Inputs: - owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - async _call(input: string): Promise { - try { - const ownerPubkey = new PublicKey(input.trim()); - const mainDomain = - await this.solanaKit.getMainAllDomainsDomain(ownerPubkey); - - return JSON.stringify({ - status: "success", - message: "Main domain fetched successfully", - domain: mainDomain, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_MAIN_DOMAIN_ERROR", - }); - } - } -} - -export class SolanaCreateGibworkTask extends Tool { - name = "create_gibwork_task"; - description = `Create a task on Gibwork. - - Inputs (input is a JSON string): - title: string, title of the task (required) - content: string, description of the task (required) - requirements: string, requirements to complete the task (required) - tags: string[], list of tags associated with the task (required) - payer: string, payer address (optional, defaults to agent wallet) - tokenMintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required) - amount: number, payment amount (required) - `; - - constructor(private solanaSdk: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const taskData = await this.solanaSdk.createGibworkTask( - parsedInput.title, - parsedInput.content, - parsedInput.requirements, - parsedInput.tags, - parsedInput.tokenMintAddress, - parsedInput.amount, - parsedInput.payer, - ); - - const response: GibworkCreateTaskReponse = { - status: "success", - taskId: taskData.taskId, - signature: taskData.signature, - }; - - return JSON.stringify(response); - } catch (err: any) { - return JSON.stringify({ - status: "error", - message: err.message, - code: err.code || "CREATE_TASK_ERROR", - }); - } - } -} - -export class SolanaRockPaperScissorsTool extends Tool { - name = "rock_paper_scissors"; - description = `Play rock paper scissors to win SEND coins. - - Inputs (input is a JSON string): - choice: string, either "rock", "paper", or "scissors" (required) - amount: number, amount of SOL to play with - must be 0.1, 0.01, or 0.005 SOL (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - private validateInput(input: any): void { - if (input.choice !== undefined) { - throw new Error("choice is required."); - } - if ( - input.amount !== undefined && - (typeof input.spaceKB !== "number" || input.spaceKB <= 0) - ) { - throw new Error("amount must be a positive number when provided"); - } - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - this.validateInput(parsedInput); - const result = await this.solanaKit.rockPaperScissors( - Number(parsedInput['"amount"']), - parsedInput['"choice"'].replace(/^"|"$/g, "") as - | "rock" - | "paper" - | "scissors", - ); - - return JSON.stringify({ - status: "success", - message: result, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaTipLinkTool extends Tool { - name = "solana_tiplink"; - description = `Create a TipLink for transferring SOL or SPL tokens. - Input is a JSON string with: - - amount: number (required) - Amount to transfer - - splmintAddress: string (optional) - SPL token mint address`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - if (!parsedInput.amount) { - throw new Error("Amount is required"); - } - - const amount = parseFloat(parsedInput.amount); - const splmintAddress = parsedInput.splmintAddress - ? new PublicKey(parsedInput.splmintAddress) - : undefined; - - const { url, signature } = await this.solanaKit.createTiplink( - amount, - splmintAddress, - ); - - return JSON.stringify({ - status: "success", - url, - signature, - amount, - tokenType: splmintAddress ? "SPL" : "SOL", - message: `TipLink created successfully`, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaListNFTForSaleTool extends Tool { - name = "solana_list_nft_for_sale"; - description = `List an NFT for sale on Tensor Trade. - - Inputs (input is a JSON string): - nftMint: string, the mint address of the NFT (required) - price: number, price in SOL (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - // Validate NFT ownership first - const nftAccount = - await this.solanaKit.connection.getTokenAccountsByOwner( - this.solanaKit.wallet_address, - { mint: new PublicKey(parsedInput.nftMint) }, - ); - - if (nftAccount.value.length === 0) { - return JSON.stringify({ - status: "error", - message: - "NFT not found in wallet. Please make sure you own this NFT.", - code: "NFT_NOT_FOUND", - }); - } - - const tx = await this.solanaKit.tensorListNFT( - new PublicKey(parsedInput.nftMint), - parsedInput.price, - ); - - return JSON.stringify({ - status: "success", - message: "NFT listed for sale successfully", - transaction: tx, - price: parsedInput.price, - nftMint: parsedInput.nftMint, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCancelNFTListingTool extends Tool { - name = "solana_cancel_nft_listing"; - description = `Cancel an NFT listing on Tensor Trade. - - Inputs (input is a JSON string): - nftMint: string, the mint address of the NFT (required)`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const parsedInput = JSON.parse(input); - - const tx = await this.solanaKit.tensorCancelListing( - new PublicKey(parsedInput.nftMint), - ); - - return JSON.stringify({ - status: "success", - message: "NFT listing cancelled successfully", - transaction: tx, - nftMint: parsedInput.nftMint, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaFetchTokenReportSummaryTool extends Tool { - name = "solana_fetch_token_report_summary"; - description = `Fetches a summary report for a specific token from RugCheck. - Inputs: - - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const mint = input.trim(); - const report = await this.solanaKit.fetchTokenReportSummary(mint); - - return JSON.stringify({ - status: "success", - message: "Token report summary fetched successfully", - report, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TOKEN_REPORT_SUMMARY_ERROR", - }); - } - } -} - -export class SolanaFetchTokenDetailedReportTool extends Tool { - name = "solana_fetch_token_detailed_report"; - description = `Fetches a detailed report for a specific token from RugCheck. - Inputs: - - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const mint = input.trim(); - const detailedReport = - await this.solanaKit.fetchTokenDetailedReport(mint); - - return JSON.stringify({ - status: "success", - message: "Detailed token report fetched successfully", - report: detailedReport, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "FETCH_TOKEN_DETAILED_REPORT_ERROR", - }); - } - } -} - -export class Solana3LandCreateSingle extends Tool { - name = "3land_minting_tool"; - description = `Creates an NFT and lists it on 3.land's website - - Inputs: - privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string - collectionAccount (optional): represents the account for the nft collection - itemName (required): the name of the NFT - sellerFee (required): the fee of the seller - itemAmount (required): the amount of the NFTs that can be minted - itemDescription (required): the description of the NFT - traits (required): the traits of the NFT [{trait_type: string, value: string}] - price (required): the price of the item, if is 0 the listing will be free - mainImageUrl (required): the main image of the NFT - coverImageUrl (optional): the cover image of the NFT - splHash (optional): the hash of the spl token, if not provided listing will be in $SOL - isMainnet (required): defines is the tx takes places in mainnet - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const privateKey = inputFormat.privateKey; - const isMainnet = inputFormat.isMainnet; - - const optionsWithBase58: StoreInitOptions = { - ...(privateKey && { privateKey }), - ...(isMainnet && { isMainnet }), - }; - - const collectionAccount = inputFormat.collectionAccount; - - const itemName = inputFormat?.itemName; - const sellerFee = inputFormat?.sellerFee; - const itemAmount = inputFormat?.itemAmount; - const itemSymbol = inputFormat?.itemSymbol; - const itemDescription = inputFormat?.itemDescription; - const traits = inputFormat?.traits; - const price = inputFormat?.price; - const mainImageUrl = inputFormat?.mainImageUrl; - const coverImageUrl = inputFormat?.coverImageUrl; - const splHash = inputFormat?.splHash; - - const createItemOptions: CreateSingleOptions = { - ...(itemName && { itemName }), - ...(sellerFee && { sellerFee }), - ...(itemAmount && { itemAmount }), - ...(itemSymbol && { itemSymbol }), - ...(itemDescription && { itemDescription }), - ...(traits && { traits }), - ...(price && { price }), - ...(mainImageUrl && { mainImageUrl }), - ...(coverImageUrl && { coverImageUrl }), - ...(splHash && { splHash }), - }; - - if (!collectionAccount) { - throw new Error("Collection account is required"); - } - - const tx = await this.solanaKit.create3LandNft( - optionsWithBase58, - collectionAccount, - createItemOptions, - isMainnet, - ); - return JSON.stringify({ - status: "success", - message: `Created listing successfully ${tx}`, - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class Solana3LandCreateCollection extends Tool { - name = "3land_minting_tool"; - description = `Creates an NFT Collection that you can visit on 3.land's website (3.land/collection/{collectionAccount}) - - Inputs: - privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string - isMainnet (required): defines is the tx takes places in mainnet - collectionSymbol (required): the symbol of the collection - collectionName (required): the name of the collection - collectionDescription (required): the description of the collection - mainImageUrl (required): the image of the collection - coverImageUrl (optional): the cover image of the collection - `; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const privateKey = inputFormat.privateKey; - const isMainnet = inputFormat.isMainnet; - - const optionsWithBase58: StoreInitOptions = { - ...(privateKey && { privateKey }), - ...(isMainnet && { isMainnet }), - }; - - const collectionSymbol = inputFormat?.collectionSymbol; - const collectionName = inputFormat?.collectionName; - const collectionDescription = inputFormat?.collectionDescription; - const mainImageUrl = inputFormat?.mainImageUrl; - const coverImageUrl = inputFormat?.coverImageUrl; - - const collectionOpts: CreateCollectionOptions = { - ...(collectionSymbol && { collectionSymbol }), - ...(collectionName && { collectionName }), - ...(collectionDescription && { collectionDescription }), - ...(mainImageUrl && { mainImageUrl }), - ...(coverImageUrl && { coverImageUrl }), - }; - - const tx = await this.solanaKit.create3LandCollection( - optionsWithBase58, - collectionOpts, - ); - return JSON.stringify({ - status: "success", - message: `Created Collection successfully ${tx}`, - transaction: tx, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCloseEmptyTokenAccounts extends Tool { - name = "close_empty_token_accounts"; - description = `Close all empty spl-token accounts and reclaim the rent`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(): Promise { - try { - const { signature, size } = - await this.solanaKit.closeEmptyTokenAccounts(); - - return JSON.stringify({ - status: "success", - message: `${size} accounts closed successfully. ${size === 48 ? "48 accounts can be closed in a single transaction try again to close more accounts" : ""}`, - signature, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "UNKNOWN_ERROR", - }); - } - } -} - -export class SolanaCreate2by2Multisig extends Tool { - name = "create_2by2_multisig"; - description = `Create a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise. - - Inputs (JSON string): - - creator: string, the public key of the creator (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const creator = new PublicKey(inputFormat.creator); - - const multisig = await this.solanaKit.createSquadsMultisig(creator); - - return JSON.stringify({ - status: "success", - message: "2-by-2 multisig account created successfully", - multisig, - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "CREATE_2BY2_MULTISIG_ERROR", - }); - } - } -} - -export class SolanaDepositTo2by2Multisig extends Tool { - name = "deposit_to_2by2_multisig"; - description = `Deposit funds to a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - Inputs (JSON string): - - amount: number, the amount to deposit in SOL (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const amount = new Decimal(inputFormat.amount); - - const tx = await this.solanaKit.depositToMultisig(amount.toNumber()); - - return JSON.stringify({ - status: "success", - message: "Funds deposited to 2-by-2 multisig account successfully", - transaction: tx, - amount: amount.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "DEPOSIT_TO_2BY2_MULTISIG_ERROR", - }); - } - } -} - -export class SolanaTransferFrom2by2Multisig extends Tool { - name = "transfer_from_2by2_multisig"; - description = `Create a transaction to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - Inputs (JSON string): - - amount: number, the amount to transfer in SOL (required). - - recipient: string, the public key of the recipient (required).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const amount = new Decimal(inputFormat.amount); - const recipient = new PublicKey(inputFormat.recipient); - - const tx = await this.solanaKit.transferFromMultisig( - amount.toNumber(), - recipient, - ); - - return JSON.stringify({ - status: "success", - message: "Transaction added to 2-by-2 multisig account successfully", - transaction: tx, - amount: amount.toString(), - recipient: recipient.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "TRANSFER_FROM_2BY2_MULTISIG_ERROR", - }); - } - } -} - -export class SolanaCreateProposal2by2Multisig extends Tool { - name = "create_proposal_2by2_multisig"; - description = `Create a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - If transactionIndex is not provided, the latest index will automatically be fetched and used. - - Inputs (JSON string): - - transactionIndex: number, the index of the transaction (optional).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const transactionIndex = inputFormat.transactionIndex ?? undefined; - - const tx = await this.solanaKit.createMultisigProposal(transactionIndex); - - return JSON.stringify({ - status: "success", - message: "Proposal created successfully", - transaction: tx, - transactionIndex: transactionIndex?.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "CREATE_PROPOSAL_2BY2_MULTISIG_ERROR", - }); - } - } -} - -export class SolanaApproveProposal2by2Multisig extends Tool { - name = "approve_proposal_2by2_multisig"; - description = `Approve a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - If proposalIndex is not provided, the latest index will automatically be fetched and used. - - Inputs (JSON string): - - proposalIndex: number, the index of the proposal (optional).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const proposalIndex = inputFormat.proposalIndex ?? undefined; - - const tx = await this.solanaKit.approveMultisigProposal(proposalIndex); - - return JSON.stringify({ - status: "success", - message: "Proposal approved successfully", - transaction: tx, - proposalIndex: proposalIndex.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "APPROVE_PROPOSAL_2BY2_MULTISIG_ERROR", - }); - } - } -} - -export class SolanaRejectProposal2by2Multisig extends Tool { - name = "reject_proposal_2by2_multisig"; - description = `Reject a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - If proposalIndex is not provided, the latest index will automatically be fetched and used. - - Inputs (JSON string): - - proposalIndex: number, the index of the proposal (optional).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const proposalIndex = inputFormat.proposalIndex ?? undefined; - - const tx = await this.solanaKit.rejectMultisigProposal(proposalIndex); - - return JSON.stringify({ - status: "success", - message: "Proposal rejected successfully", - transaction: tx, - proposalIndex: proposalIndex.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "REJECT_PROPOSAL_2BY2_MULTISIG_ERROR", - }); - } - } -} - -export class SolanaExecuteProposal2by2Multisig extends Tool { - name = "execute_proposal_2by2_multisig"; - description = `Execute a proposal/transaction to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. - - If proposalIndex is not provided, the latest index will automatically be fetched and used. - - Inputs (JSON string): - - proposalIndex: number, the index of the proposal (optional).`; - - constructor(private solanaKit: SolanaAgentKit) { - super(); - } - - protected async _call(input: string): Promise { - try { - const inputFormat = JSON.parse(input); - const proposalIndex = inputFormat.proposalIndex ?? undefined; - - const tx = await this.solanaKit.executeMultisigTransaction(proposalIndex); - - return JSON.stringify({ - status: "success", - message: "Proposal executed successfully", - transaction: tx, - proposalIndex: proposalIndex.toString(), - }); - } catch (error: any) { - return JSON.stringify({ - status: "error", - message: error.message, - code: error.code || "EXECUTE_PROPOSAL_2BY2_MULTISIG_ERROR", - }); - } - } -} + SolanaGetWalletAddressTool, + SolanaCreateImageTool, + SolanaCloseEmptyTokenAccounts, +} from "./agent"; +import { + SolanaRegisterDomainTool, + SolanaGetDomainTool, + SolanaResolveDomainTool, + SolanaGetMainDomain, +} from "./bonfida"; +import { SolanaFlashOpenTrade, SolanaFlashCloseTrade } from "./flash"; +import { SolanaCreateGibworkTask } from "./gibwork"; +import { + SolanaTradeTool, + SolanaStakeTool, + SolanaFetchPriceTool, + SolanaTokenDataTool, + SolanaTokenDataByTickerTool, +} from "./jupiter"; +import { SolanaCompressedAirdropTool } from "./light_protocol"; +import { SolanaLendAssetTool } from "./lulo"; +import { + SolanaManifestCreateMarket, + SolanaLimitOrderTool, + SolanaBatchOrderTool, + SolanaCancelAllOrdersTool, + SolanaWithdrawAllTool, +} from "./manifest"; +import { + SolanaDeployTokenTool, + SolanaDeployCollectionTool, + SolanaMintNFTTool, +} from "./metaplex"; +import { + SolanaGetOwnedDomains, + SolanaGetOwnedTldDomains, + SolanaGetAllTlds, + SolanaResolveAllDomainsTool, +} from "./onsol_labs"; +import { + SolanaClosePosition, + SolanaOrcaCreateCLMM, + SolanaOrcaCreateSingleSideLiquidityPool, + SolanaOrcaFetchPositions, + SolanaOrcaOpenCenteredPosition, + SolanaOrcaOpenSingleSidedPosition, +} from "./orca"; +import { SolanaPumpfunTokenLaunchTool } from "./pumpfun"; +import { SolanaPythFetchPrice } from "./pyth"; +import { + SolanaRaydiumCreateAmmV4, + SolanaRaydiumCreateClmm, + SolanaRaydiumCreateCpmm, + SolanaOpenbookCreateMarket, +} from "./raydium"; +import { + SolanaFetchTokenReportSummaryTool, + SolanaFetchTokenDetailedReportTool, +} from "./rugcheck"; +import { SolanaRockPaperScissorsTool } from "./send_arcade"; +import { SolanaRestakeTool } from "./solayer"; +import { + SolanaCreate2by2Multisig, + SolanaDepositTo2by2Multisig, + SolanaTransferFrom2by2Multisig, + SolanaCreateProposal2by2Multisig, + SolanaApproveProposal2by2Multisig, + SolanaRejectProposal2by2Multisig, + SolanaExecuteProposal2by2Multisig, +} from "./squads_multisig"; +import { SolanaListNFTForSaleTool, SolanaCancelNFTListingTool } from "./tensor"; +import { SolanaTipLinkTool } from "./tiplink"; export function createSolanaTools(solanaKit: SolanaAgentKit) { return [ diff --git a/src/langchain/jupiter/index.ts b/src/langchain/jupiter/index.ts new file mode 100644 index 00000000..42da1314 --- /dev/null +++ b/src/langchain/jupiter/index.ts @@ -0,0 +1,173 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaTradeTool extends Tool { + name = "solana_trade"; + description = `This tool can be used to swap tokens to another token ( It uses Jupiter Exchange ). + + Inputs ( input is a JSON string ): + outputMint: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (required) + inputAmount: number, eg 1 or 0.01 (required) + inputMint?: string, eg "So11111111111111111111111111111111111111112" (optional) + slippageBps?: number, eg 100 (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const tx = await this.solanaKit.trade( + new PublicKey(parsedInput.outputMint), + parsedInput.inputAmount, + parsedInput.inputMint + ? new PublicKey(parsedInput.inputMint) + : new PublicKey("So11111111111111111111111111111111111111112"), + parsedInput.slippageBps, + ); + + return JSON.stringify({ + status: "success", + message: "Trade executed successfully", + transaction: tx, + inputAmount: parsedInput.inputAmount, + inputToken: parsedInput.inputMint || "SOL", + outputToken: parsedInput.outputMint, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaStakeTool extends Tool { + name = "solana_stake"; + description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking. + + Inputs ( input is a JSON string ): + amount: number, eg 1 or 0.01 (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input) || Number(input); + + const tx = await this.solanaKit.stake(parsedInput.amount); + + return JSON.stringify({ + status: "success", + message: "Staked successfully", + transaction: tx, + amount: parsedInput.amount, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +/** + * Tool to fetch the price of a token in USDC + */ +export class SolanaFetchPriceTool extends Tool { + name = "solana_fetch_price"; + description = `Fetch the price of a given token in USDC. + + Inputs: + - tokenId: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const price = await this.solanaKit.fetchTokenPrice(input.trim()); + return JSON.stringify({ + status: "success", + tokenId: input.trim(), + priceInUSDC: price, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaTokenDataTool extends Tool { + name = "solana_token_data"; + description = `Get the token data for a given token mint address + + Inputs: mintAddress is required. + mintAddress: string, eg "So11111111111111111111111111111111111111112" (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = input.trim(); + + const tokenData = await this.solanaKit.getTokenDataByAddress(parsedInput); + + return JSON.stringify({ + status: "success", + tokenData, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaTokenDataByTickerTool extends Tool { + name = "solana_token_data_by_ticker"; + description = `Get the token data for a given token ticker + + Inputs: ticker is required. + ticker: string, eg "USDC" (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const ticker = input.trim(); + const tokenData = await this.solanaKit.getTokenDataByTicker(ticker); + return JSON.stringify({ + status: "success", + tokenData, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/light_protocol/index.ts b/src/langchain/light_protocol/index.ts new file mode 100644 index 00000000..993c6984 --- /dev/null +++ b/src/langchain/light_protocol/index.ts @@ -0,0 +1,46 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaCompressedAirdropTool extends Tool { + name = "solana_compressed_airdrop"; + description = `Airdrop SPL tokens with ZK Compression (also called as airdropping tokens) + + Inputs (input is a JSON string): + mintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required) + amount: number, the amount of tokens to airdrop per recipient, e.g., 42 (required) + decimals: number, the decimals of the token, e.g., 6 (required) + recipients: string[], the recipient addresses, e.g., ["1nc1nerator11111111111111111111111111111111"] (required) + priorityFeeInLamports: number, the priority fee in lamports. Default is 30_000. (optional) + shouldLog: boolean, whether to log progress to stdout. Default is false. (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const txs = await this.solanaKit.sendCompressedAirdrop( + parsedInput.mintAddress, + parsedInput.amount, + parsedInput.decimals, + parsedInput.recipients, + parsedInput.priorityFeeInLamports || 30_000, + parsedInput.shouldLog || false, + ); + + return JSON.stringify({ + status: "success", + message: `Airdropped ${parsedInput.amount} tokens to ${parsedInput.recipients.length} recipients.`, + transactionHashes: txs, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/lulo/index.ts b/src/langchain/lulo/index.ts new file mode 100644 index 00000000..d1e2655b --- /dev/null +++ b/src/langchain/lulo/index.ts @@ -0,0 +1,35 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaLendAssetTool extends Tool { + name = "solana_lend_asset"; + description = `Lend idle USDC for yield using Lulo. ( only USDC is supported ) + + Inputs (input is a json string): + amount: number, eg 1, 0.01 (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const amount = JSON.parse(input).amount || input; + + const tx = await this.solanaKit.lendAssets(amount); + + return JSON.stringify({ + status: "success", + message: "Asset lent successfully", + transaction: tx, + amount, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/manifest/index.ts b/src/langchain/manifest/index.ts new file mode 100644 index 00000000..de33bcb7 --- /dev/null +++ b/src/langchain/manifest/index.ts @@ -0,0 +1,245 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { generateOrdersfromPattern } from "../../tools"; +import { OrderParams } from "../../types"; + +export class SolanaLimitOrderTool extends Tool { + name = "solana_limit_order"; + description = `This tool can be used to place limit orders using Manifest. + + Do not allow users to place multiple orders with this instruction, use solana_batch_order instead. + + Inputs ( input is a JSON string ): + marketId: PublicKey, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required) + quantity: number, eg 1 or 0.01 (required) + side: string, eg "Buy" or "Sell" (required) + price: number, in tokens eg 200 for SOL/USDC (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const tx = await this.solanaKit.limitOrder( + new PublicKey(parsedInput.marketId), + parsedInput.quantity, + parsedInput.side, + parsedInput.price, + ); + + return JSON.stringify({ + status: "success", + message: "Trade executed successfully", + transaction: tx, + marketId: parsedInput.marketId, + quantity: parsedInput.quantity, + side: parsedInput.side, + price: parsedInput.price, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaBatchOrderTool extends Tool { + name = "solana_batch_order"; + description = `Places multiple limit orders in one transaction using Manifest. Submit orders either as a list or pattern: + + 1. List format: + { + "marketId": "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ", + "orders": [ + { "quantity": 1, "side": "Buy", "price": 200 }, + { "quantity": 0.5, "side": "Sell", "price": 205 } + ] + } + + 2. Pattern format: + { + "marketId": "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ", + "pattern": { + "side": "Buy", + "totalQuantity": 100, + "priceRange": { "max": 1.0 }, + "spacing": { "type": "percentage", "value": 1 }, + "numberOfOrders": 5 + } + } + + Examples: + - "Place 5 buy orders totaling 100 tokens, 1% apart below $1" + - "Create 3 sell orders of 10 tokens each between $50-$55" + - "Place buy orders worth 50 tokens, $0.10 spacing from $0.80" + + Important: All orders must be in one transaction. Combine buy and sell orders into a single pattern or list. Never break the orders down to individual buy or sell orders.`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + let ordersToPlace: OrderParams[] = []; + + if (!parsedInput.marketId) { + throw new Error("Market ID is required"); + } + + if (parsedInput.pattern) { + ordersToPlace = generateOrdersfromPattern(parsedInput.pattern); + } else if (Array.isArray(parsedInput.orders)) { + ordersToPlace = parsedInput.orders; + } else { + throw new Error("Either pattern or orders array is required"); + } + + if (ordersToPlace.length === 0) { + throw new Error("No orders generated or provided"); + } + + ordersToPlace.forEach((order: OrderParams, index: number) => { + if (!order.quantity || !order.side || !order.price) { + throw new Error( + `Invalid order at index ${index}: quantity, side, and price are required`, + ); + } + if (order.side !== "Buy" && order.side !== "Sell") { + throw new Error( + `Invalid side at index ${index}: must be "Buy" or "Sell"`, + ); + } + }); + + const tx = await this.solanaKit.batchOrder( + new PublicKey(parsedInput.marketId), + parsedInput.orders, + ); + + return JSON.stringify({ + status: "success", + message: "Batch order executed successfully", + transaction: tx, + marketId: parsedInput.marketId, + orders: parsedInput.orders, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaCancelAllOrdersTool extends Tool { + name = "solana_cancel_all_orders"; + description = `This tool can be used to cancel all orders from a Manifest market. + + Input ( input is a JSON string ): + marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const marketId = new PublicKey(input.trim()); + const tx = await this.solanaKit.cancelAllOrders(marketId); + + return JSON.stringify({ + status: "success", + message: "Cancel orders successfully", + transaction: tx, + marketId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaWithdrawAllTool extends Tool { + name = "solana_withdraw_all"; + description = `This tool can be used to withdraw all funds from a Manifest market. + + Input ( input is a JSON string ): + marketId: string, eg "ENhU8LsaR7vDD2G1CsWcsuSGNrih9Cv5WZEk7q9kPapQ" for SOL/USDC (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const marketId = new PublicKey(input.trim()); + const tx = await this.solanaKit.withdrawAll(marketId); + + return JSON.stringify({ + status: "success", + message: "Withdrew successfully", + transaction: tx, + marketId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaManifestCreateMarket extends Tool { + name = "solana_manifest_create_market"; + description = `Manifest market + + Inputs (input is a json string): + baseMint: string (required) + quoteMint: string (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + + const tx = await this.solanaKit.manifestCreateMarket( + new PublicKey(inputFormat.baseMint), + new PublicKey(inputFormat.quoteMint), + ); + + return JSON.stringify({ + status: "success", + message: "Create manifest market successfully", + transaction: tx[0], + marketId: tx[1], + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/metaplex/index.ts b/src/langchain/metaplex/index.ts new file mode 100644 index 00000000..26991cce --- /dev/null +++ b/src/langchain/metaplex/index.ts @@ -0,0 +1,131 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaDeployTokenTool extends Tool { + name = "solana_deploy_token"; + description = `Deploy a new token on Solana blockchain. + + Inputs (input is a JSON string): + name: string, eg "My Token" (required) + uri: string, eg "https://example.com/token.json" (required) + symbol: string, eg "MTK" (required) + decimals?: number, eg 9 (optional, defaults to 9) + initialSupply?: number, eg 1000000 (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const result = await this.solanaKit.deployToken( + parsedInput.name, + parsedInput.uri, + parsedInput.symbol, + parsedInput.decimals, + parsedInput.initialSupply, + ); + + return JSON.stringify({ + status: "success", + message: "Token deployed successfully", + mintAddress: result.mint.toString(), + decimals: parsedInput.decimals || 9, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaDeployCollectionTool extends Tool { + name = "solana_deploy_collection"; + description = `Deploy a new NFT collection on Solana blockchain. + + Inputs (input is a JSON string): + name: string, eg "My Collection" (required) + uri: string, eg "https://example.com/collection.json" (required) + royaltyBasisPoints?: number, eg 500 for 5% (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const result = await this.solanaKit.deployCollection(parsedInput); + + return JSON.stringify({ + status: "success", + message: "Collection deployed successfully", + collectionAddress: result.collectionAddress.toString(), + name: parsedInput.name, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaMintNFTTool extends Tool { + name = "solana_mint_nft"; + description = `Mint a new NFT in a collection on Solana blockchain. + + Inputs (input is a JSON string): + collectionMint: string, eg "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w" (required) - The address of the collection to mint into + name: string, eg "My NFT" (required) + uri: string, eg "https://example.com/nft.json" (required) + recipient?: string, eg "9aUn5swQzUTRanaaTwmszxiv89cvFwUCjEBv1vZCoT1u" (optional) - The wallet to receive the NFT, defaults to agent's wallet which is ${this.solanaKit.wallet_address.toString()}`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const result = await this.solanaKit.mintNFT( + new PublicKey(parsedInput.collectionMint), + { + name: parsedInput.name, + uri: parsedInput.uri, + }, + parsedInput.recipient + ? new PublicKey(parsedInput.recipient) + : this.solanaKit.wallet_address, + ); + + return JSON.stringify({ + status: "success", + message: "NFT minted successfully", + mintAddress: result.mint.toString(), + metadata: { + name: parsedInput.name, + symbol: parsedInput.symbol, + uri: parsedInput.uri, + }, + recipient: parsedInput.recipient || result.mint.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/onsol_labs/index.ts b/src/langchain/onsol_labs/index.ts new file mode 100644 index 00000000..1b3fbbf0 --- /dev/null +++ b/src/langchain/onsol_labs/index.ts @@ -0,0 +1,131 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { PublicKey } from "@solana/web3.js"; + +export class SolanaResolveAllDomainsTool extends Tool { + name = "solana_resolve_all_domains"; + description = `Resolve domain names to a public key for ALL domain types EXCEPT .sol domains. + Use this for domains like .blink, .bonk, etc. + DO NOT use this for .sol domains (use solana_resolve_domain instead). + + Input: + domain: string, eg "mydomain.blink" or "mydomain.bonk" (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const owner = await this.solanaKit.resolveAllDomains(input); + + if (!owner) { + return JSON.stringify({ + status: "error", + message: "Domain not found", + code: "DOMAIN_NOT_FOUND", + }); + } + + return JSON.stringify({ + status: "success", + message: "Domain resolved successfully", + owner: owner?.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "DOMAIN_RESOLUTION_ERROR", + }); + } + } +} + +export class SolanaGetOwnedDomains extends Tool { + name = "solana_get_owned_domains"; + description = `Get all domains owned by a specific wallet address. + + Inputs: + owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const ownerPubkey = new PublicKey(input.trim()); + const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey); + + return JSON.stringify({ + status: "success", + message: "Owned domains fetched successfully", + domains, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "FETCH_OWNED_DOMAINS_ERROR", + }); + } + } +} + +export class SolanaGetOwnedTldDomains extends Tool { + name = "solana_get_owned_tld_domains"; + description = `Get all domains owned by the agent's wallet for a specific TLD. + + Inputs: + tld: string, eg "bonk" (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const domains = await this.solanaKit.getOwnedDomainsForTLD(input); + + return JSON.stringify({ + status: "success", + message: "TLD domains fetched successfully", + domains, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "FETCH_TLD_DOMAINS_ERROR", + }); + } + } +} + +export class SolanaGetAllTlds extends Tool { + name = "solana_get_all_tlds"; + description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(): Promise { + try { + const tlds = await this.solanaKit.getAllDomainsTLDs(); + + return JSON.stringify({ + status: "success", + message: "TLDs fetched successfully", + tlds, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "FETCH_TLDS_ERROR", + }); + } + } +} diff --git a/src/langchain/orca/index.ts b/src/langchain/orca/index.ts new file mode 100644 index 00000000..7c5c6d34 --- /dev/null +++ b/src/langchain/orca/index.ts @@ -0,0 +1,285 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import Decimal from "decimal.js"; +import { FEE_TIERS } from "../../tools"; + +export class SolanaClosePosition extends Tool { + name = "orca_close_position"; + description = `Closes an existing liquidity position in an Orca Whirlpool. This function fetches the position + details using the provided mint address and closes the position with a 1% slippage. + + Inputs (JSON string): + - positionMintAddress: string, the address of the position mint that represents the liquidity position.`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const positionMintAddress = new PublicKey( + inputFormat.positionMintAddress, + ); + + const txId = await this.solanaKit.orcaClosePosition(positionMintAddress); + + return JSON.stringify({ + status: "success", + message: "Liquidity position closed successfully.", + transaction: txId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaOrcaCreateCLMM extends Tool { + name = "orca_create_clmm"; + description = `Create a Concentrated Liquidity Market Maker (CLMM) pool on Orca, the most efficient and capital-optimized CLMM on Solana. This function initializes a CLMM pool but does not add liquidity. You can add liquidity later using a centered position or a single-sided position. + + Inputs (JSON string): + - mintDeploy: string, the mint of the token you want to deploy (required). + - mintPair: string, The mint of the token you want to pair the deployed mint with (required). + - initialPrice: number, initial price of mintA in terms of mintB, e.g., 0.001 (required). + - feeTier: number, fee tier in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const mintA = new PublicKey(inputFormat.mintDeploy); + const mintB = new PublicKey(inputFormat.mintPair); + const initialPrice = new Decimal(inputFormat.initialPrice); + const feeTier = inputFormat.feeTier; + + if (!feeTier || !(feeTier in FEE_TIERS)) { + throw new Error( + `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( + ", ", + )}`, + ); + } + + const txId = await this.solanaKit.orcaCreateCLMM( + mintA, + mintB, + initialPrice, + feeTier, + ); + + return JSON.stringify({ + status: "success", + message: + "CLMM pool created successfully. Note: No liquidity was added.", + transaction: txId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaOrcaCreateSingleSideLiquidityPool extends Tool { + name = "orca_create_single_sided_liquidity_pool"; + description = `Create a single-sided liquidity pool on Orca, the most efficient and capital-optimized CLMM platform on Solana. + + This function initializes a single-sided liquidity pool, ideal for community driven project, fair launches, and fundraising. Minimize price impact by setting a narrow price range. + + Inputs (JSON string): + - depositTokenAmount: number, in units of the deposit token including decimals, e.g., 1000000000 (required). + - depositTokenMint: string, mint address of the deposit token, e.g., "DepositTokenMintAddress" (required). + - otherTokenMint: string, mint address of the other token, e.g., "OtherTokenMintAddress" (required). + - initialPrice: number, initial price of the deposit token in terms of the other token, e.g., 0.001 (required). + - maxPrice: number, maximum price at which liquidity is added, e.g., 5.0 (required). + - feeTier: number, fee tier for the pool in bps. Options: 1, 2, 4, 5, 16, 30, 65, 100, 200 (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const depositTokenAmount = inputFormat.depositTokenAmount; + const depositTokenMint = new PublicKey(inputFormat.depositTokenMint); + const otherTokenMint = new PublicKey(inputFormat.otherTokenMint); + const initialPrice = new Decimal(inputFormat.initialPrice); + const maxPrice = new Decimal(inputFormat.maxPrice); + const feeTier = inputFormat.feeTier; + + if (!feeTier || !(feeTier in FEE_TIERS)) { + throw new Error( + `Invalid feeTier. Available options: ${Object.keys(FEE_TIERS).join( + ", ", + )}`, + ); + } + + const txId = await this.solanaKit.orcaCreateSingleSidedLiquidityPool( + depositTokenAmount, + depositTokenMint, + otherTokenMint, + initialPrice, + maxPrice, + feeTier, + ); + + return JSON.stringify({ + status: "success", + message: "Single-sided Whirlpool created successfully", + transaction: txId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaOrcaFetchPositions extends Tool { + name = "orca_fetch_positions"; + description = `Fetch all the liquidity positions in an Orca Whirlpool by owner. Returns an object with positiont mint addresses as keys and position status details as values.`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(): Promise { + try { + const txId = await this.solanaKit.orcaFetchPositions(); + + return JSON.stringify({ + status: "success", + message: "Liquidity positions fetched.", + transaction: txId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaOrcaOpenCenteredPosition extends Tool { + name = "orca_open_centered_position_with_liquidity"; + description = `Add liquidity to a CLMM by opening a centered position in an Orca Whirlpool, the most efficient liquidity pool on Solana. + + Inputs (JSON string): + - whirlpoolAddress: string, address of the Orca Whirlpool (required). + - priceOffsetBps: number, bps offset (one side) from the current pool price, e.g., 500 for 5% (required). + - inputTokenMint: string, mint address of the deposit token (required). + - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress); + const priceOffsetBps = parseInt(inputFormat.priceOffsetBps, 10); + const inputTokenMint = new PublicKey(inputFormat.inputTokenMint); + const inputAmount = new Decimal(inputFormat.inputAmount); + + if (priceOffsetBps < 0) { + throw new Error( + "Invalid distanceFromCurrentPriceBps. It must be equal or greater than 0.", + ); + } + + const txId = await this.solanaKit.orcaOpenCenteredPositionWithLiquidity( + whirlpoolAddress, + priceOffsetBps, + inputTokenMint, + inputAmount, + ); + + return JSON.stringify({ + status: "success", + message: "Centered liquidity position opened successfully.", + transaction: txId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaOrcaOpenSingleSidedPosition extends Tool { + name = "orca_open_single_sided_position"; + description = `Add liquidity to a CLMM by opening a single-sided position in an Orca Whirlpool, the most efficient liquidity pool on Solana. + + Inputs (JSON string): + - whirlpoolAddress: string, address of the Orca Whirlpool (required). + - distanceFromCurrentPriceBps: number, distance in basis points from the current price for the position (required). + - widthBps: number, width of the position in basis points (required). + - inputTokenMint: string, mint address of the deposit token (required). + - inputAmount: number, amount of the deposit token, e.g., 100.0 (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const whirlpoolAddress = new PublicKey(inputFormat.whirlpoolAddress); + const distanceFromCurrentPriceBps = + inputFormat.distanceFromCurrentPriceBps; + const widthBps = inputFormat.widthBps; + const inputTokenMint = new PublicKey(inputFormat.inputTokenMint); + const inputAmount = new Decimal(inputFormat.inputAmount); + + if (distanceFromCurrentPriceBps < 0 || widthBps < 0) { + throw new Error( + "Invalid distanceFromCurrentPriceBps or width. It must be equal or greater than 0.", + ); + } + + const txId = await this.solanaKit.orcaOpenSingleSidedPosition( + whirlpoolAddress, + distanceFromCurrentPriceBps, + widthBps, + inputTokenMint, + inputAmount, + ); + + return JSON.stringify({ + status: "success", + message: "Single-sided liquidity position opened successfully.", + transaction: txId, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/pumpfun/index.ts b/src/langchain/pumpfun/index.ts new file mode 100644 index 00000000..6fbabcf6 --- /dev/null +++ b/src/langchain/pumpfun/index.ts @@ -0,0 +1,79 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaPumpfunTokenLaunchTool extends Tool { + name = "solana_launch_pumpfun_token"; + + description = `This tool can be used to launch a token on Pump.fun, + do not use this tool for any other purpose, or for creating SPL tokens. + If the user asks you to chose the parameters, you should generate valid values. + For generating the image, you can use the solana_create_image tool. + + Inputs: + tokenName: string, eg "PumpFun Token", + tokenTicker: string, eg "PUMP", + description: string, eg "PumpFun Token is a token on the Solana blockchain", + imageUrl: string, eg "https://i.imgur.com/UFm07Np_d.png`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + private validateInput(input: any): void { + if (!input.tokenName || typeof input.tokenName !== "string") { + throw new Error("tokenName is required and must be a string"); + } + if (!input.tokenTicker || typeof input.tokenTicker !== "string") { + throw new Error("tokenTicker is required and must be a string"); + } + if (!input.description || typeof input.description !== "string") { + throw new Error("description is required and must be a string"); + } + if (!input.imageUrl || typeof input.imageUrl !== "string") { + throw new Error("imageUrl is required and must be a string"); + } + if ( + input.initialLiquiditySOL !== undefined && + typeof input.initialLiquiditySOL !== "number" + ) { + throw new Error("initialLiquiditySOL must be a number when provided"); + } + } + + protected async _call(input: string): Promise { + try { + // Parse and normalize input + input = input.trim(); + const parsedInput = JSON.parse(input); + + this.validateInput(parsedInput); + + // Launch token with validated input + await this.solanaKit.launchPumpFunToken( + parsedInput.tokenName, + parsedInput.tokenTicker, + parsedInput.description, + parsedInput.imageUrl, + { + twitter: parsedInput.twitter, + telegram: parsedInput.telegram, + website: parsedInput.website, + initialLiquiditySOL: parsedInput.initialLiquiditySOL, + }, + ); + + return JSON.stringify({ + status: "success", + message: "Token launched successfully on Pump.fun", + tokenName: parsedInput.tokenName, + tokenTicker: parsedInput.tokenTicker, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/pyth/index.ts b/src/langchain/pyth/index.ts new file mode 100644 index 00000000..a8519203 --- /dev/null +++ b/src/langchain/pyth/index.ts @@ -0,0 +1,39 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; +import { PythFetchPriceResponse } from "../../types"; + +export class SolanaPythFetchPrice extends Tool { + name = "solana_pyth_fetch_price"; + description = `Fetch the price of a given price feed from Pyth's Hermes service + + Inputs: + tokenSymbol: string, e.g., BTC for bitcoin`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const priceFeedID = await this.solanaKit.getPythPriceFeedID(input); + const price = await this.solanaKit.getPythPrice(priceFeedID); + + const response: PythFetchPriceResponse = { + status: "success", + tokenSymbol: input, + priceFeedID, + price, + }; + + return JSON.stringify(response); + } catch (error: any) { + const response: PythFetchPriceResponse = { + status: "error", + tokenSymbol: input, + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }; + return JSON.stringify(response); + } + } +} diff --git a/src/langchain/raydium/index.ts b/src/langchain/raydium/index.ts new file mode 100644 index 00000000..72894a1b --- /dev/null +++ b/src/langchain/raydium/index.ts @@ -0,0 +1,181 @@ +import { PublicKey } from "@solana/web3.js"; +import BN from "bn.js"; +import Decimal from "decimal.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaRaydiumCreateAmmV4 extends Tool { + name = "raydium_create_ammV4"; + description = `Raydium's Legacy AMM that requires an OpenBook marketID + + Inputs (input is a json string): + marketId: string (required) + baseAmount: number(int), eg: 111111 (required) + quoteAmount: number(int), eg: 111111 (required) + startTime: number(seconds), eg: now number or zero (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + + const tx = await this.solanaKit.raydiumCreateAmmV4( + new PublicKey(inputFormat.marketId), + new BN(inputFormat.baseAmount), + new BN(inputFormat.quoteAmount), + new BN(inputFormat.startTime), + ); + + return JSON.stringify({ + status: "success", + message: "Raydium amm v4 pool created successfully", + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaRaydiumCreateClmm extends Tool { + name = "raydium_create_clmm"; + description = `Concentrated liquidity market maker, custom liquidity ranges, increased capital efficiency + + Inputs (input is a json string): + mint1: string (required) + mint2: string (required) + configId: string (required) stores pool info, id, index, protocolFeeRate, tradeFeeRate, tickSpacing, fundFeeRate + initialPrice: number, eg: 123.12 (required) + startTime: number(seconds), eg: now number or zero (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + + const tx = await this.solanaKit.raydiumCreateClmm( + new PublicKey(inputFormat.mint1), + new PublicKey(inputFormat.mint2), + + new PublicKey(inputFormat.configId), + + new Decimal(inputFormat.initialPrice), + new BN(inputFormat.startTime), + ); + + return JSON.stringify({ + status: "success", + message: "Raydium clmm pool created successfully", + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaRaydiumCreateCpmm extends Tool { + name = "raydium_create_cpmm"; + description = `Raydium's newest CPMM, does not require marketID, supports Token 2022 standard + + Inputs (input is a json string): + mint1: string (required) + mint2: string (required) + configId: string (required), stores pool info, index, protocolFeeRate, tradeFeeRate, fundFeeRate, createPoolFee + mintAAmount: number(int), eg: 1111 (required) + mintBAmount: number(int), eg: 2222 (required) + startTime: number(seconds), eg: now number or zero (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + + const tx = await this.solanaKit.raydiumCreateCpmm( + new PublicKey(inputFormat.mint1), + new PublicKey(inputFormat.mint2), + + new PublicKey(inputFormat.configId), + + new BN(inputFormat.mintAAmount), + new BN(inputFormat.mintBAmount), + + new BN(inputFormat.startTime), + ); + + return JSON.stringify({ + status: "success", + message: "Raydium cpmm pool created successfully", + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaOpenbookCreateMarket extends Tool { + name = "solana_openbook_create_market"; + description = `Openbook marketId, required for ammv4 + + Inputs (input is a json string): + baseMint: string (required) + quoteMint: string (required) + lotSize: number (required) + tickSize: number (required) + `; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + + const tx = await this.solanaKit.openbookCreateMarket( + new PublicKey(inputFormat.baseMint), + new PublicKey(inputFormat.quoteMint), + + inputFormat.lotSize, + inputFormat.tickSize, + ); + + return JSON.stringify({ + status: "success", + message: "Openbook market created successfully", + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/rugcheck/index.ts b/src/langchain/rugcheck/index.ts new file mode 100644 index 00000000..6b992a8b --- /dev/null +++ b/src/langchain/rugcheck/index.ts @@ -0,0 +1,63 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaFetchTokenReportSummaryTool extends Tool { + name = "solana_fetch_token_report_summary"; + description = `Fetches a summary report for a specific token from RugCheck. + Inputs: + - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const mint = input.trim(); + const report = await this.solanaKit.fetchTokenReportSummary(mint); + + return JSON.stringify({ + status: "success", + message: "Token report summary fetched successfully", + report, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "FETCH_TOKEN_REPORT_SUMMARY_ERROR", + }); + } + } +} + +export class SolanaFetchTokenDetailedReportTool extends Tool { + name = "solana_fetch_token_detailed_report"; + description = `Fetches a detailed report for a specific token from RugCheck. + Inputs: + - mint: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const mint = input.trim(); + const detailedReport = + await this.solanaKit.fetchTokenDetailedReport(mint); + + return JSON.stringify({ + status: "success", + message: "Detailed token report fetched successfully", + report: detailedReport, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "FETCH_TOKEN_DETAILED_REPORT_ERROR", + }); + } + } +} diff --git a/src/langchain/send_arcade/index.ts b/src/langchain/send_arcade/index.ts new file mode 100644 index 00000000..6c20e254 --- /dev/null +++ b/src/langchain/send_arcade/index.ts @@ -0,0 +1,52 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaRockPaperScissorsTool extends Tool { + name = "rock_paper_scissors"; + description = `Play rock paper scissors to win SEND coins. + + Inputs (input is a JSON string): + choice: string, either "rock", "paper", or "scissors" (required) + amount: number, amount of SOL to play with - must be 0.1, 0.01, or 0.005 SOL (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + private validateInput(input: any): void { + if (input.choice !== undefined) { + throw new Error("choice is required."); + } + if ( + input.amount !== undefined && + (typeof input.spaceKB !== "number" || input.spaceKB <= 0) + ) { + throw new Error("amount must be a positive number when provided"); + } + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + this.validateInput(parsedInput); + const result = await this.solanaKit.rockPaperScissors( + Number(parsedInput['"amount"']), + parsedInput['"choice"'].replace(/^"|"$/g, "") as + | "rock" + | "paper" + | "scissors", + ); + + return JSON.stringify({ + status: "success", + message: result, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/solana_native/index.ts b/src/langchain/solana_native/index.ts new file mode 100644 index 00000000..e5191e50 --- /dev/null +++ b/src/langchain/solana_native/index.ts @@ -0,0 +1,171 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaBalanceTool extends Tool { + name = "solana_balance"; + description = `Get the balance of a Solana wallet or token account. + + If you want to get the balance of your wallet, you don't need to provide the tokenAddress. + If no tokenAddress is provided, the balance will be in SOL. + + Inputs ( input is a JSON string ): + tokenAddress: string, eg "So11111111111111111111111111111111111111112" (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const tokenAddress = input ? new PublicKey(input) : undefined; + const balance = await this.solanaKit.getBalance(tokenAddress); + + return JSON.stringify({ + status: "success", + balance, + token: input || "SOL", + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaBalanceOtherTool extends Tool { + name = "solana_balance_other"; + description = `Get the balance of a Solana wallet or token account which is different from the agent's wallet. + + If no tokenAddress is provided, the SOL balance of the wallet will be returned. + + Inputs ( input is a JSON string ): + walletAddress: string, eg "GDEkQF7UMr7RLv1KQKMtm8E2w3iafxJLtyXu3HVQZnME" (required) + tokenAddress: string, eg "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const { walletAddress, tokenAddress } = JSON.parse(input); + + const tokenPubKey = tokenAddress + ? new PublicKey(tokenAddress) + : undefined; + + const balance = await this.solanaKit.getBalanceOther( + new PublicKey(walletAddress), + tokenPubKey, + ); + + return JSON.stringify({ + status: "success", + balance, + wallet: walletAddress, + token: tokenAddress || "SOL", + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaTransferTool extends Tool { + name = "solana_transfer"; + description = `Transfer tokens or SOL to another address ( also called as wallet address ). + + Inputs ( input is a JSON string ): + to: string, eg "8x2dR8Mpzuz2YqyZyZjUbYWKSWesBo5jMx2Q9Y86udVk" (required) + amount: number, eg 1 (required) + mint?: string, eg "So11111111111111111111111111111111111111112" or "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa" (optional)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const recipient = new PublicKey(parsedInput.to); + const mintAddress = parsedInput.mint + ? new PublicKey(parsedInput.mint) + : undefined; + + const tx = await this.solanaKit.transfer( + recipient, + parsedInput.amount, + mintAddress, + ); + + return JSON.stringify({ + status: "success", + message: "Transfer completed successfully", + amount: parsedInput.amount, + recipient: parsedInput.to, + token: parsedInput.mint || "SOL", + transaction: tx, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaRequestFundsTool extends Tool { + name = "solana_request_funds"; + description = "Request SOL from Solana faucet (devnet/testnet only)"; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(_input: string): Promise { + try { + await this.solanaKit.requestFaucetFunds(); + + return JSON.stringify({ + status: "success", + message: "Successfully requested faucet funds", + network: this.solanaKit.connection.rpcEndpoint.split("/")[2], + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaTPSCalculatorTool extends Tool { + name = "solana_get_tps"; + description = "Get the current TPS of the Solana network"; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + async _call(_input: string): Promise { + try { + const tps = await this.solanaKit.getTPS(); + return `Solana (mainnet-beta) current transactions per second: ${tps}`; + } catch (error: any) { + return `Error fetching TPS: ${error.message}`; + } + } +} diff --git a/src/langchain/solayer/index.ts b/src/langchain/solayer/index.ts new file mode 100644 index 00000000..d13291f3 --- /dev/null +++ b/src/langchain/solayer/index.ts @@ -0,0 +1,35 @@ +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaRestakeTool extends Tool { + name = "solana_restake"; + description = `This tool can be used to restake your SOL on Solayer to receive Solayer SOL (sSOL) as a Liquid Staking Token (LST). + + Inputs: + amount: number, eg 1 or 0.01 (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input) || Number(input); + + const tx = await this.solanaKit.restake(parsedInput.amount); + + return JSON.stringify({ + status: "success", + message: "Staked successfully", + transaction: tx, + amount: parsedInput.amount, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/squads_multisig/index.ts b/src/langchain/squads_multisig/index.ts new file mode 100644 index 00000000..b7ae7fc0 --- /dev/null +++ b/src/langchain/squads_multisig/index.ts @@ -0,0 +1,257 @@ +import { PublicKey } from "@solana/web3.js"; +import Decimal from "decimal.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaCreate2by2Multisig extends Tool { + name = "create_2by2_multisig"; + description = `Create a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise. + + Inputs (JSON string): + - creator: string, the public key of the creator (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const creator = new PublicKey(inputFormat.creator); + + const multisig = await this.solanaKit.createSquadsMultisig(creator); + + return JSON.stringify({ + status: "success", + message: "2-by-2 multisig account created successfully", + multisig, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "CREATE_2BY2_MULTISIG_ERROR", + }); + } + } +} + +export class SolanaDepositTo2by2Multisig extends Tool { + name = "deposit_to_2by2_multisig"; + description = `Deposit funds to a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + Inputs (JSON string): + - amount: number, the amount to deposit in SOL (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const amount = new Decimal(inputFormat.amount); + + const tx = await this.solanaKit.depositToMultisig(amount.toNumber()); + + return JSON.stringify({ + status: "success", + message: "Funds deposited to 2-by-2 multisig account successfully", + transaction: tx, + amount: amount.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "DEPOSIT_TO_2BY2_MULTISIG_ERROR", + }); + } + } +} + +export class SolanaTransferFrom2by2Multisig extends Tool { + name = "transfer_from_2by2_multisig"; + description = `Create a transaction to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + Inputs (JSON string): + - amount: number, the amount to transfer in SOL (required). + - recipient: string, the public key of the recipient (required).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const amount = new Decimal(inputFormat.amount); + const recipient = new PublicKey(inputFormat.recipient); + + const tx = await this.solanaKit.transferFromMultisig( + amount.toNumber(), + recipient, + ); + + return JSON.stringify({ + status: "success", + message: "Transaction added to 2-by-2 multisig account successfully", + transaction: tx, + amount: amount.toString(), + recipient: recipient.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "TRANSFER_FROM_2BY2_MULTISIG_ERROR", + }); + } + } +} + +export class SolanaCreateProposal2by2Multisig extends Tool { + name = "create_proposal_2by2_multisig"; + description = `Create a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + If transactionIndex is not provided, the latest index will automatically be fetched and used. + + Inputs (JSON string): + - transactionIndex: number, the index of the transaction (optional).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const transactionIndex = inputFormat.transactionIndex ?? undefined; + + const tx = await this.solanaKit.createMultisigProposal(transactionIndex); + + return JSON.stringify({ + status: "success", + message: "Proposal created successfully", + transaction: tx, + transactionIndex: transactionIndex?.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "CREATE_PROPOSAL_2BY2_MULTISIG_ERROR", + }); + } + } +} + +export class SolanaApproveProposal2by2Multisig extends Tool { + name = "approve_proposal_2by2_multisig"; + description = `Approve a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + If proposalIndex is not provided, the latest index will automatically be fetched and used. + + Inputs (JSON string): + - proposalIndex: number, the index of the proposal (optional).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const proposalIndex = inputFormat.proposalIndex ?? undefined; + + const tx = await this.solanaKit.approveMultisigProposal(proposalIndex); + + return JSON.stringify({ + status: "success", + message: "Proposal approved successfully", + transaction: tx, + proposalIndex: proposalIndex.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "APPROVE_PROPOSAL_2BY2_MULTISIG_ERROR", + }); + } + } +} + +export class SolanaRejectProposal2by2Multisig extends Tool { + name = "reject_proposal_2by2_multisig"; + description = `Reject a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + If proposalIndex is not provided, the latest index will automatically be fetched and used. + + Inputs (JSON string): + - proposalIndex: number, the index of the proposal (optional).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const proposalIndex = inputFormat.proposalIndex ?? undefined; + + const tx = await this.solanaKit.rejectMultisigProposal(proposalIndex); + + return JSON.stringify({ + status: "success", + message: "Proposal rejected successfully", + transaction: tx, + proposalIndex: proposalIndex.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "REJECT_PROPOSAL_2BY2_MULTISIG_ERROR", + }); + } + } +} + +export class SolanaExecuteProposal2by2Multisig extends Tool { + name = "execute_proposal_2by2_multisig"; + description = `Execute a proposal/transaction to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions. + + If proposalIndex is not provided, the latest index will automatically be fetched and used. + + Inputs (JSON string): + - proposalIndex: number, the index of the proposal (optional).`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const inputFormat = JSON.parse(input); + const proposalIndex = inputFormat.proposalIndex ?? undefined; + + const tx = await this.solanaKit.executeMultisigTransaction(proposalIndex); + + return JSON.stringify({ + status: "success", + message: "Proposal executed successfully", + transaction: tx, + proposalIndex: proposalIndex.toString(), + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "EXECUTE_PROPOSAL_2BY2_MULTISIG_ERROR", + }); + } + } +} diff --git a/src/langchain/tensor/index.ts b/src/langchain/tensor/index.ts new file mode 100644 index 00000000..0eb01e2f --- /dev/null +++ b/src/langchain/tensor/index.ts @@ -0,0 +1,92 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaListNFTForSaleTool extends Tool { + name = "solana_list_nft_for_sale"; + description = `List an NFT for sale on Tensor Trade. + + Inputs (input is a JSON string): + nftMint: string, the mint address of the NFT (required) + price: number, price in SOL (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + // Validate NFT ownership first + const nftAccount = + await this.solanaKit.connection.getTokenAccountsByOwner( + this.solanaKit.wallet_address, + { mint: new PublicKey(parsedInput.nftMint) }, + ); + + if (nftAccount.value.length === 0) { + return JSON.stringify({ + status: "error", + message: + "NFT not found in wallet. Please make sure you own this NFT.", + code: "NFT_NOT_FOUND", + }); + } + + const tx = await this.solanaKit.tensorListNFT( + new PublicKey(parsedInput.nftMint), + parsedInput.price, + ); + + return JSON.stringify({ + status: "success", + message: "NFT listed for sale successfully", + transaction: tx, + price: parsedInput.price, + nftMint: parsedInput.nftMint, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} + +export class SolanaCancelNFTListingTool extends Tool { + name = "solana_cancel_nft_listing"; + description = `Cancel an NFT listing on Tensor Trade. + + Inputs (input is a JSON string): + nftMint: string, the mint address of the NFT (required)`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + const tx = await this.solanaKit.tensorCancelListing( + new PublicKey(parsedInput.nftMint), + ); + + return JSON.stringify({ + status: "success", + message: "NFT listing cancelled successfully", + transaction: tx, + nftMint: parsedInput.nftMint, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/langchain/tiplink/index.ts b/src/langchain/tiplink/index.ts new file mode 100644 index 00000000..e60779c2 --- /dev/null +++ b/src/langchain/tiplink/index.ts @@ -0,0 +1,50 @@ +import { PublicKey } from "@solana/web3.js"; +import { Tool } from "langchain/tools"; +import { SolanaAgentKit } from "../../agent"; + +export class SolanaTipLinkTool extends Tool { + name = "solana_tiplink"; + description = `Create a TipLink for transferring SOL or SPL tokens. + Input is a JSON string with: + - amount: number (required) - Amount to transfer + - splmintAddress: string (optional) - SPL token mint address`; + + constructor(private solanaKit: SolanaAgentKit) { + super(); + } + + protected async _call(input: string): Promise { + try { + const parsedInput = JSON.parse(input); + + if (!parsedInput.amount) { + throw new Error("Amount is required"); + } + + const amount = parseFloat(parsedInput.amount); + const splmintAddress = parsedInput.splmintAddress + ? new PublicKey(parsedInput.splmintAddress) + : undefined; + + const { url, signature } = await this.solanaKit.createTiplink( + amount, + splmintAddress, + ); + + return JSON.stringify({ + status: "success", + url, + signature, + amount, + tokenType: splmintAddress ? "SPL" : "SOL", + message: `TipLink created successfully`, + }); + } catch (error: any) { + return JSON.stringify({ + status: "error", + message: error.message, + code: error.code || "UNKNOWN_ERROR", + }); + } + } +} diff --git a/src/tools/create_3land_collectible.ts b/src/tools/3land/create_3land_collectible.ts similarity index 100% rename from src/tools/create_3land_collectible.ts rename to src/tools/3land/create_3land_collectible.ts diff --git a/src/tools/adrena_perp_trading.ts b/src/tools/adrena/adrena_perp_trading.ts similarity index 98% rename from src/tools/adrena_perp_trading.ts rename to src/tools/adrena/adrena_perp_trading.ts index 8c472164..ec6e8f1a 100644 --- a/src/tools/adrena_perp_trading.ts +++ b/src/tools/adrena/adrena_perp_trading.ts @@ -3,13 +3,13 @@ import { SystemProgram, TransactionInstruction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; -import { TOKENS, DEFAULT_OPTIONS } from "../constants"; +import { SolanaAgentKit } from "../../index"; +import { TOKENS, DEFAULT_OPTIONS } from "../../constants"; import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { BN } from "@coral-xyz/anchor"; -import AdrenaClient from "../utils/AdrenaClient"; -import { sendTx } from "../utils/send_tx"; +import AdrenaClient from "../../utils/AdrenaClient"; +import { sendTx } from "../../utils/send_tx"; const PRICE_DECIMALS = 10; const ADRENA_PROGRAM_ID = new PublicKey( diff --git a/src/tools/create_image.ts b/src/tools/agent/create_image.ts similarity index 95% rename from src/tools/create_image.ts rename to src/tools/agent/create_image.ts index 106f3c27..91d5913f 100644 --- a/src/tools/create_image.ts +++ b/src/tools/agent/create_image.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import OpenAI from "openai"; /** diff --git a/src/tools/get_wallet_address.ts b/src/tools/agent/get_wallet_address.ts similarity index 81% rename from src/tools/get_wallet_address.ts rename to src/tools/agent/get_wallet_address.ts index bf3c763d..c302a865 100644 --- a/src/tools/get_wallet_address.ts +++ b/src/tools/agent/get_wallet_address.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; /** * Get the agents wallet address diff --git a/src/tools/get_main_all_domains_domain.ts b/src/tools/bonfida/get_main_all_domains_domain.ts similarity index 100% rename from src/tools/get_main_all_domains_domain.ts rename to src/tools/bonfida/get_main_all_domains_domain.ts diff --git a/src/tools/get_primary_domain.ts b/src/tools/bonfida/get_primary_domain.ts similarity index 96% rename from src/tools/get_primary_domain.ts rename to src/tools/bonfida/get_primary_domain.ts index 8e53f1d4..ac276b63 100644 --- a/src/tools/get_primary_domain.ts +++ b/src/tools/bonfida/get_primary_domain.ts @@ -1,6 +1,6 @@ import { getPrimaryDomain as _getPrimaryDomain } from "@bonfida/spl-name-service"; import { PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Retrieves the primary .sol domain associated with a given Solana public key. diff --git a/src/tools/register_domain.ts b/src/tools/bonfida/register_domain.ts similarity index 94% rename from src/tools/register_domain.ts rename to src/tools/bonfida/register_domain.ts index 13480011..1857c215 100644 --- a/src/tools/register_domain.ts +++ b/src/tools/bonfida/register_domain.ts @@ -1,8 +1,8 @@ import { registerDomainNameV2 } from "@bonfida/spl-name-service"; import { Transaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { TOKENS } from "../constants"; +import { TOKENS } from "../../constants"; /** * Register a .sol domain name using Bonfida Name Service diff --git a/src/tools/resolve_sol_domain.ts b/src/tools/bonfida/resolve_sol_domain.ts similarity index 95% rename from src/tools/resolve_sol_domain.ts rename to src/tools/bonfida/resolve_sol_domain.ts index 32b090b2..9f87295d 100644 --- a/src/tools/resolve_sol_domain.ts +++ b/src/tools/bonfida/resolve_sol_domain.ts @@ -1,6 +1,6 @@ import { resolve } from "@bonfida/spl-name-service"; import { PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Resolves a .sol domain to a Solana PublicKey. diff --git a/src/tools/flash_close_trade.ts b/src/tools/flash/flash_close_trade.ts similarity index 96% rename from src/tools/flash_close_trade.ts rename to src/tools/flash/flash_close_trade.ts index c30d0b65..cdd2b4f4 100644 --- a/src/tools/flash_close_trade.ts +++ b/src/tools/flash/flash_close_trade.ts @@ -1,7 +1,7 @@ import { ComputeBudgetProgram } from "@solana/web3.js"; import { PoolConfig, Side } from "flash-sdk"; import { BN } from "@coral-xyz/anchor"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { CLOSE_POSITION_CU, marketSdkInfo, @@ -10,8 +10,8 @@ import { fetchOraclePrice, createPerpClient, get_flash_privilege, -} from "../utils/flashUtils"; -import { FlashCloseTradeParams } from "../types"; +} from "../../utils/flashUtils"; +import { FlashCloseTradeParams } from "../../types"; /** * Closes an existing position on Flash.Trade diff --git a/src/tools/flash_open_trade.ts b/src/tools/flash/flash_open_trade.ts similarity index 98% rename from src/tools/flash_open_trade.ts rename to src/tools/flash/flash_open_trade.ts index 6a646dcd..5af7c604 100644 --- a/src/tools/flash_open_trade.ts +++ b/src/tools/flash/flash_open_trade.ts @@ -8,7 +8,7 @@ import { Custody, } from "flash-sdk"; import { BN } from "@coral-xyz/anchor"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { ALL_TOKENS, marketSdkInfo, @@ -18,8 +18,8 @@ import { fetchOraclePrice, createPerpClient, get_flash_privilege, -} from "../utils/flashUtils"; -import { FlashTradeParams } from "../types"; +} from "../../utils/flashUtils"; +import { FlashTradeParams } from "../../types"; /** * Opens a new position on Flash.Trade diff --git a/src/tools/create_gibwork_task.ts b/src/tools/gibwork/create_gibwork_task.ts similarity index 95% rename from src/tools/create_gibwork_task.ts rename to src/tools/gibwork/create_gibwork_task.ts index 40ff3c38..9f34b61b 100644 --- a/src/tools/create_gibwork_task.ts +++ b/src/tools/gibwork/create_gibwork_task.ts @@ -1,6 +1,7 @@ import { VersionedTransaction } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js"; -import { GibworkCreateTaskReponse, SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../agent"; +import { GibworkCreateTaskReponse } from "../../types"; /** * Create an new task on Gibwork diff --git a/src/tools/index.ts b/src/tools/index.ts index 2363e3ab..7aaf0064 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,52 +1,52 @@ -export * from "./adrena_perp_trading"; -export * from "./create_gibwork_task"; -export * from "./create_image"; -export * from "./create_tiplinks"; -export * from "./deploy_collection"; -export * from "./deploy_token"; -export * from "./fetch_price"; -export * from "./get_all_domains_tlds"; -export * from "./get_all_registered_all_domains"; -export * from "./get_balance"; -export * from "./get_balance_other"; -export * from "./get_main_all_domains_domain"; -export * from "./get_owned_all_domains"; -export * from "./get_owned_domains_for_tld"; -export * from "./get_primary_domain"; -export * from "./get_token_data"; -export * from "./get_tps"; -export * from "./get_wallet_address"; -export * from "./launch_pumpfun_token"; -export * from "./lend"; -export * from "./manifest_trade"; -export * from "./mint_nft"; -export * from "./openbook_create_market"; -export * from "./orca_close_position"; -export * from "./orca_create_clmm"; -export * from "./orca_create_single_sided_liquidity_pool"; -export * from "./orca_fetch_positions"; -export * from "./orca_open_centered_position_with_liquidity"; -export * from "./orca_open_single_sided_position"; -export * from "./pyth_fetch_price"; -export * from "./raydium_create_ammV4"; -export * from "./raydium_create_clmm"; -export * from "./raydium_create_cpmm"; -export * from "./register_domain"; -export * from "./request_faucet_funds"; -export * from "./resolve_domain"; -export * from "./resolve_sol_domain"; -export * from "./rock_paper_scissor"; -export * from "./rugcheck"; -export * from "./send_compressed_airdrop"; -export * from "./stake_with_jup"; -export * from "./stake_with_solayer"; -export * from "./tensor_trade"; +export * from "./adrena/adrena_perp_trading"; +export * from "./gibwork/create_gibwork_task"; +export * from "./agent/create_image"; +export * from "./tiplink/create_tiplinks"; +export * from "./metaplex/deploy_collection"; +export * from "./metaplex/deploy_token"; +export * from "./jupiter/fetch_price"; +export * from "./onsol_labs/get_all_domains_tlds"; +export * from "./onsol_labs/get_all_registered_all_domains"; +export * from "./solana_native/get_balance"; +export * from "./solana_native/get_balance_other"; +export * from "./bonfida/get_main_all_domains_domain"; +export * from "./onsol_labs/get_owned_all_domains"; +export * from "./onsol_labs/get_owned_domains_for_tld"; +export * from "./bonfida/get_primary_domain"; +export * from "./jupiter/get_token_data"; +export * from "./solana_native/get_tps"; +export * from "./agent/get_wallet_address"; +export * from "./pumpfun/launch_pumpfun_token"; +export * from "./lulo/lend"; +export * from "./manifest/manifest_trade"; +export * from "./metaplex/mint_nft"; +export * from "./raydium/openbook_create_market"; +export * from "./orca/orca_close_position"; +export * from "./orca/orca_create_clmm"; +export * from "./orca/orca_create_single_sided_liquidity_pool"; +export * from "./orca/orca_fetch_positions"; +export * from "./orca/orca_open_centered_position_with_liquidity"; +export * from "./orca/orca_open_single_sided_position"; +export * from "./pyth/pyth_fetch_price"; +export * from "./raydium/raydium_create_ammV4"; +export * from "./raydium/raydium_create_clmm"; +export * from "./raydium/raydium_create_cpmm"; +export * from "./bonfida/register_domain"; +export * from "./solana_native/request_faucet_funds"; +export * from "./onsol_labs/resolve_domain"; +export * from "./bonfida/resolve_sol_domain"; +export * from "./send_arcade/rock_paper_scissor"; +export * from "./rugcheck/rugcheck"; +export * from "./light_protocol/send_compressed_airdrop"; +export * from "./jupiter/stake_with_jup"; +export * from "./solayer/stake_with_solayer"; +export * from "./tensor/tensor_trade"; -export * from "./close_empty_token_accounts"; +export * from "./solana_native/close_empty_token_accounts"; -export * from "./trade"; -export * from "./transfer"; -export * from "./flash_open_trade"; -export * from "./flash_close_trade"; +export * from "./jupiter/trade"; +export * from "./solana_native/transfer"; +export * from "./flash/flash_open_trade"; +export * from "./flash/flash_close_trade"; -export * from "./create_3land_collectible"; +export * from "./3land/create_3land_collectible"; diff --git a/src/tools/fetch_price.ts b/src/tools/jupiter/fetch_price.ts similarity index 100% rename from src/tools/fetch_price.ts rename to src/tools/jupiter/fetch_price.ts diff --git a/src/tools/get_token_data.ts b/src/tools/jupiter/get_token_data.ts similarity index 97% rename from src/tools/get_token_data.ts rename to src/tools/jupiter/get_token_data.ts index 434aa9a0..c4ec2ef1 100644 --- a/src/tools/get_token_data.ts +++ b/src/tools/jupiter/get_token_data.ts @@ -1,5 +1,5 @@ import { PublicKey } from "@solana/web3.js"; -import { JupiterTokenData } from "../types"; +import { JupiterTokenData } from "../../types"; export async function getTokenDataByAddress( mint: PublicKey, diff --git a/src/tools/stake_with_jup.ts b/src/tools/jupiter/stake_with_jup.ts similarity index 97% rename from src/tools/stake_with_jup.ts rename to src/tools/jupiter/stake_with_jup.ts index c05915b8..1db0955a 100644 --- a/src/tools/stake_with_jup.ts +++ b/src/tools/jupiter/stake_with_jup.ts @@ -1,5 +1,5 @@ import { VersionedTransaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Stake SOL with Jup validator diff --git a/src/tools/trade.ts b/src/tools/jupiter/trade.ts similarity index 97% rename from src/tools/trade.ts rename to src/tools/jupiter/trade.ts index 4e11712c..f4b27761 100644 --- a/src/tools/trade.ts +++ b/src/tools/jupiter/trade.ts @@ -1,11 +1,11 @@ import { VersionedTransaction, PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { TOKENS, DEFAULT_OPTIONS, JUP_API, JUP_REFERRAL_ADDRESS, -} from "../constants"; +} from "../../constants"; import { getMint } from "@solana/spl-token"; /** * Swap tokens using Jupiter Exchange diff --git a/src/tools/send_compressed_airdrop.ts b/src/tools/light_protocol/send_compressed_airdrop.ts similarity index 99% rename from src/tools/send_compressed_airdrop.ts rename to src/tools/light_protocol/send_compressed_airdrop.ts index 871c810d..4d01ed6c 100644 --- a/src/tools/send_compressed_airdrop.ts +++ b/src/tools/light_protocol/send_compressed_airdrop.ts @@ -5,7 +5,7 @@ import { PublicKey, TransactionInstruction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { buildAndSignTx, calculateComputeUnitPrice, diff --git a/src/tools/lend.ts b/src/tools/lulo/lend.ts similarity index 97% rename from src/tools/lend.ts rename to src/tools/lulo/lend.ts index 732f00c3..9a6644cf 100644 --- a/src/tools/lend.ts +++ b/src/tools/lulo/lend.ts @@ -1,5 +1,5 @@ import { VersionedTransaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Lend tokens for yields using Lulo diff --git a/src/tools/manifest_trade.ts b/src/tools/manifest/manifest_trade.ts similarity index 99% rename from src/tools/manifest_trade.ts rename to src/tools/manifest/manifest_trade.ts index e65aef71..9ef1fb3b 100644 --- a/src/tools/manifest_trade.ts +++ b/src/tools/manifest/manifest_trade.ts @@ -11,7 +11,7 @@ import { Transaction, TransactionInstruction, } from "@solana/web3.js"; -import { BatchOrderPattern, OrderParams, SolanaAgentKit } from "../index"; +import { BatchOrderPattern, OrderParams, SolanaAgentKit } from "../../index"; export async function manifestCreateMarket( agent: SolanaAgentKit, diff --git a/src/tools/deploy_collection.ts b/src/tools/metaplex/deploy_collection.ts similarity index 94% rename from src/tools/deploy_collection.ts rename to src/tools/metaplex/deploy_collection.ts index 10fef9de..0b981bee 100644 --- a/src/tools/deploy_collection.ts +++ b/src/tools/metaplex/deploy_collection.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { generateSigner, keypairIdentity, @@ -9,7 +9,7 @@ import { mplCore, ruleSet, } from "@metaplex-foundation/mpl-core"; -import { CollectionOptions, CollectionDeployment } from "../types"; +import { CollectionOptions, CollectionDeployment } from "../../types"; import { fromWeb3JsKeypair, toWeb3JsPublicKey, diff --git a/src/tools/deploy_token.ts b/src/tools/metaplex/deploy_token.ts similarity index 97% rename from src/tools/deploy_token.ts rename to src/tools/metaplex/deploy_token.ts index 798e0200..0f787432 100644 --- a/src/tools/deploy_token.ts +++ b/src/tools/metaplex/deploy_token.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { PublicKey } from "@solana/web3.js"; import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; import { generateSigner, keypairIdentity } from "@metaplex-foundation/umi"; diff --git a/src/tools/mint_nft.ts b/src/tools/metaplex/mint_nft.ts similarity index 95% rename from src/tools/mint_nft.ts rename to src/tools/metaplex/mint_nft.ts index 4c25b914..dd6b68c3 100644 --- a/src/tools/mint_nft.ts +++ b/src/tools/metaplex/mint_nft.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { generateSigner, keypairIdentity } from "@metaplex-foundation/umi"; import { create, mplCore } from "@metaplex-foundation/mpl-core"; import { fetchCollection } from "@metaplex-foundation/mpl-core"; @@ -9,7 +9,7 @@ import { toWeb3JsPublicKey, } from "@metaplex-foundation/umi-web3js-adapters"; import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { MintCollectionNFTResponse } from "../types"; +import { MintCollectionNFTResponse } from "../../types"; /** * Mint a new NFT as part of an existing collection diff --git a/src/tools/get_all_domains_tlds.ts b/src/tools/onsol_labs/get_all_domains_tlds.ts similarity index 91% rename from src/tools/get_all_domains_tlds.ts rename to src/tools/onsol_labs/get_all_domains_tlds.ts index 4d2fcbd1..2b84c2ab 100644 --- a/src/tools/get_all_domains_tlds.ts +++ b/src/tools/onsol_labs/get_all_domains_tlds.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { getAllTld } from "@onsol/tldparser"; /** diff --git a/src/tools/get_all_registered_all_domains.ts b/src/tools/onsol_labs/get_all_registered_all_domains.ts similarity index 95% rename from src/tools/get_all_registered_all_domains.ts rename to src/tools/onsol_labs/get_all_registered_all_domains.ts index 019a5ea6..1e5cd0e1 100644 --- a/src/tools/get_all_registered_all_domains.ts +++ b/src/tools/onsol_labs/get_all_registered_all_domains.ts @@ -1,5 +1,5 @@ import { getAllDomains } from "@bonfida/spl-name-service"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { PublicKey } from "@solana/web3.js"; import { getAllDomainsTLDs } from "./get_all_domains_tlds"; diff --git a/src/tools/get_owned_all_domains.ts b/src/tools/onsol_labs/get_owned_all_domains.ts similarity index 94% rename from src/tools/get_owned_all_domains.ts rename to src/tools/onsol_labs/get_owned_all_domains.ts index aa52e1e5..87fda7c3 100644 --- a/src/tools/get_owned_all_domains.ts +++ b/src/tools/onsol_labs/get_owned_all_domains.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { PublicKey } from "@solana/web3.js"; import { TldParser } from "@onsol/tldparser"; diff --git a/src/tools/get_owned_domains_for_tld.ts b/src/tools/onsol_labs/get_owned_domains_for_tld.ts similarity index 94% rename from src/tools/get_owned_domains_for_tld.ts rename to src/tools/onsol_labs/get_owned_domains_for_tld.ts index c3fde6a8..347a1806 100644 --- a/src/tools/get_owned_domains_for_tld.ts +++ b/src/tools/onsol_labs/get_owned_domains_for_tld.ts @@ -1,5 +1,5 @@ import { TldParser } from "@onsol/tldparser"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; /** * Get all domains owned by an address for a specific TLD * @param agent SolanaAgentKit instance diff --git a/src/tools/resolve_domain.ts b/src/tools/onsol_labs/resolve_domain.ts similarity index 94% rename from src/tools/resolve_domain.ts rename to src/tools/onsol_labs/resolve_domain.ts index 6de2206f..aa403370 100644 --- a/src/tools/resolve_domain.ts +++ b/src/tools/onsol_labs/resolve_domain.ts @@ -1,5 +1,5 @@ import { TldParser } from "@onsol/tldparser"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { PublicKey } from "@solana/web3.js"; /** diff --git a/src/tools/orca_close_position.ts b/src/tools/orca/orca_close_position.ts similarity index 96% rename from src/tools/orca_close_position.ts rename to src/tools/orca/orca_close_position.ts index 44756924..0cf758a9 100644 --- a/src/tools/orca_close_position.ts +++ b/src/tools/orca/orca_close_position.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { ORCA_WHIRLPOOL_PROGRAM_ID, @@ -12,7 +12,7 @@ import { buildWhirlpoolClient, PDAUtil, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { Percentage } from "@orca-so/common-sdk"; /** diff --git a/src/tools/orca_create_clmm.ts b/src/tools/orca/orca_create_clmm.ts similarity index 98% rename from src/tools/orca_create_clmm.ts rename to src/tools/orca/orca_create_clmm.ts index 9fcdc33f..4d3bb503 100644 --- a/src/tools/orca_create_clmm.ts +++ b/src/tools/orca/orca_create_clmm.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -14,7 +14,7 @@ import { PoolUtil, buildWhirlpoolClient, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { FEE_TIERS } from "./orca_create_single_sided_liquidity_pool"; /** diff --git a/src/tools/orca_create_single_sided_liquidity_pool.ts b/src/tools/orca/orca_create_single_sided_liquidity_pool.ts similarity index 99% rename from src/tools/orca_create_single_sided_liquidity_pool.ts rename to src/tools/orca/orca_create_single_sided_liquidity_pool.ts index 26792b8a..c05a148f 100644 --- a/src/tools/orca_create_single_sided_liquidity_pool.ts +++ b/src/tools/orca/orca_create_single_sided_liquidity_pool.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { BN, Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -36,7 +36,7 @@ import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, } from "@solana/spl-token"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; /** * Maps fee tier bps to their corresponding tick spacing values in the Orca Whirlpool protocol. diff --git a/src/tools/orca_fetch_positions.ts b/src/tools/orca/orca_fetch_positions.ts similarity index 98% rename from src/tools/orca_fetch_positions.ts rename to src/tools/orca/orca_fetch_positions.ts index f90b8a02..edeba5ae 100644 --- a/src/tools/orca_fetch_positions.ts +++ b/src/tools/orca/orca_fetch_positions.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { ORCA_WHIRLPOOL_PROGRAM_ID, diff --git a/src/tools/orca_open_centered_position_with_liquidity.ts b/src/tools/orca/orca_open_centered_position_with_liquidity.ts similarity index 98% rename from src/tools/orca_open_centered_position_with_liquidity.ts rename to src/tools/orca/orca_open_centered_position_with_liquidity.ts index 63a89729..0fea787b 100644 --- a/src/tools/orca_open_centered_position_with_liquidity.ts +++ b/src/tools/orca/orca_open_centered_position_with_liquidity.ts @@ -5,7 +5,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -18,7 +18,7 @@ import { NO_TOKEN_EXTENSION_CONTEXT, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { Percentage } from "@orca-so/common-sdk"; import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token"; diff --git a/src/tools/orca_open_single_sided_position.ts b/src/tools/orca/orca_open_single_sided_position.ts similarity index 98% rename from src/tools/orca_open_single_sided_position.ts rename to src/tools/orca/orca_open_single_sided_position.ts index 741069a3..daaec600 100644 --- a/src/tools/orca_open_single_sided_position.ts +++ b/src/tools/orca/orca_open_single_sided_position.ts @@ -4,7 +4,7 @@ import { TransactionMessage, VersionedTransaction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { Wallet } from "@coral-xyz/anchor"; import { Decimal } from "decimal.js"; import { @@ -16,7 +16,7 @@ import { TokenExtensionContextForPool, NO_TOKEN_EXTENSION_CONTEXT, } from "@orca-so/whirlpools-sdk"; -import { sendTx } from "../utils/send_tx"; +import { sendTx } from "../../utils/send_tx"; import { Percentage } from "@orca-so/common-sdk"; import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token"; diff --git a/src/tools/launch_pumpfun_token.ts b/src/tools/pumpfun/launch_pumpfun_token.ts similarity index 97% rename from src/tools/launch_pumpfun_token.ts rename to src/tools/pumpfun/launch_pumpfun_token.ts index 08fd3bf7..3c66cea7 100644 --- a/src/tools/launch_pumpfun_token.ts +++ b/src/tools/pumpfun/launch_pumpfun_token.ts @@ -1,10 +1,7 @@ // src/tools/launch_pumpfun_token.ts import { VersionedTransaction, Keypair } from "@solana/web3.js"; -import { - PumpfunLaunchResponse, - PumpFunTokenOptions, - SolanaAgentKit, -} from "../index"; +import { SolanaAgentKit } from "../../agent"; +import { PumpFunTokenOptions, PumpfunLaunchResponse } from "../../types"; async function uploadMetadata( tokenName: string, diff --git a/src/tools/pyth_fetch_price.ts b/src/tools/pyth/pyth_fetch_price.ts similarity index 98% rename from src/tools/pyth_fetch_price.ts rename to src/tools/pyth/pyth_fetch_price.ts index 0946af45..ef5b6faa 100644 --- a/src/tools/pyth_fetch_price.ts +++ b/src/tools/pyth/pyth_fetch_price.ts @@ -1,5 +1,5 @@ import BN from "bn.js"; -import { PythPriceFeedIDItem } from "../types"; +import { PythPriceFeedIDItem } from "../../types"; /** * Fetch the price feed ID for a given token symbol from Pyth diff --git a/src/tools/openbook_create_market.ts b/src/tools/raydium/openbook_create_market.ts similarity index 96% rename from src/tools/openbook_create_market.ts rename to src/tools/raydium/openbook_create_market.ts index c7c12aab..1702ba33 100644 --- a/src/tools/openbook_create_market.ts +++ b/src/tools/raydium/openbook_create_market.ts @@ -5,7 +5,7 @@ import { } from "@raydium-io/raydium-sdk-v2"; import { MintLayout, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function openbookCreateMarket( agent: SolanaAgentKit, diff --git a/src/tools/raydium_create_ammV4.ts b/src/tools/raydium/raydium_create_ammV4.ts similarity index 97% rename from src/tools/raydium_create_ammV4.ts rename to src/tools/raydium/raydium_create_ammV4.ts index 98f641e9..1b5ce71b 100644 --- a/src/tools/raydium_create_ammV4.ts +++ b/src/tools/raydium/raydium_create_ammV4.ts @@ -9,7 +9,7 @@ import { import { MintLayout, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function raydiumCreateAmmV4( agent: SolanaAgentKit, diff --git a/src/tools/raydium_create_clmm.ts b/src/tools/raydium/raydium_create_clmm.ts similarity index 97% rename from src/tools/raydium_create_clmm.ts rename to src/tools/raydium/raydium_create_clmm.ts index 7d049d47..611c2f1f 100644 --- a/src/tools/raydium_create_clmm.ts +++ b/src/tools/raydium/raydium_create_clmm.ts @@ -7,7 +7,7 @@ import { MintLayout } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import Decimal from "decimal.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function raydiumCreateClmm( agent: SolanaAgentKit, diff --git a/src/tools/raydium_create_cpmm.ts b/src/tools/raydium/raydium_create_cpmm.ts similarity index 97% rename from src/tools/raydium_create_cpmm.ts rename to src/tools/raydium/raydium_create_cpmm.ts index 35c702d1..59f1124e 100644 --- a/src/tools/raydium_create_cpmm.ts +++ b/src/tools/raydium/raydium_create_cpmm.ts @@ -7,7 +7,7 @@ import { import { MintLayout } from "@solana/spl-token"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function raydiumCreateCpmm( agent: SolanaAgentKit, diff --git a/src/tools/rugcheck.ts b/src/tools/rugcheck/rugcheck.ts similarity index 97% rename from src/tools/rugcheck.ts rename to src/tools/rugcheck/rugcheck.ts index 11d533de..923c0f58 100644 --- a/src/tools/rugcheck.ts +++ b/src/tools/rugcheck/rugcheck.ts @@ -1,4 +1,4 @@ -import { TokenCheck } from "../types"; +import { TokenCheck } from "../../types"; const BASE_URL = "https://api.rugcheck.xyz/v1"; diff --git a/src/tools/rock_paper_scissor.ts b/src/tools/send_arcade/rock_paper_scissor.ts similarity index 98% rename from src/tools/rock_paper_scissor.ts rename to src/tools/send_arcade/rock_paper_scissor.ts index 8a0603e6..f2a48c25 100644 --- a/src/tools/rock_paper_scissor.ts +++ b/src/tools/send_arcade/rock_paper_scissor.ts @@ -1,5 +1,5 @@ import { sendAndConfirmTransaction, Transaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; export async function rock_paper_scissor( agent: SolanaAgentKit, diff --git a/src/tools/close_empty_token_accounts.ts b/src/tools/solana_native/close_empty_token_accounts.ts similarity index 98% rename from src/tools/close_empty_token_accounts.ts rename to src/tools/solana_native/close_empty_token_accounts.ts index 9a102dbd..a424b96a 100644 --- a/src/tools/close_empty_token_accounts.ts +++ b/src/tools/solana_native/close_empty_token_accounts.ts @@ -3,7 +3,7 @@ import { Transaction, TransactionInstruction, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../agent"; +import { SolanaAgentKit } from "../../agent"; import { AccountLayout, createCloseAccountInstruction, diff --git a/src/tools/get_balance.ts b/src/tools/solana_native/get_balance.ts similarity index 94% rename from src/tools/get_balance.ts rename to src/tools/solana_native/get_balance.ts index a1e37361..36dbd36e 100644 --- a/src/tools/get_balance.ts +++ b/src/tools/solana_native/get_balance.ts @@ -1,5 +1,5 @@ import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Get the balance of SOL or an SPL token for the agent's wallet diff --git a/src/tools/get_balance_other.ts b/src/tools/solana_native/get_balance_other.ts similarity index 97% rename from src/tools/get_balance_other.ts rename to src/tools/solana_native/get_balance_other.ts index 84c1c323..32df37cb 100644 --- a/src/tools/get_balance_other.ts +++ b/src/tools/solana_native/get_balance_other.ts @@ -3,7 +3,7 @@ import { ParsedAccountData, PublicKey, } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Get the balance of SOL or an SPL token for the specified wallet address (other than the agent's wallet) diff --git a/src/tools/get_tps.ts b/src/tools/solana_native/get_tps.ts similarity index 90% rename from src/tools/get_tps.ts rename to src/tools/solana_native/get_tps.ts index 7314ce3f..1c29a792 100644 --- a/src/tools/get_tps.ts +++ b/src/tools/solana_native/get_tps.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; export async function getTPS(agent: SolanaAgentKit): Promise { const perfSamples = await agent.connection.getRecentPerformanceSamples(); diff --git a/src/tools/request_faucet_funds.ts b/src/tools/solana_native/request_faucet_funds.ts similarity index 93% rename from src/tools/request_faucet_funds.ts rename to src/tools/solana_native/request_faucet_funds.ts index bde8eed1..3ce9111d 100644 --- a/src/tools/request_faucet_funds.ts +++ b/src/tools/solana_native/request_faucet_funds.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { LAMPORTS_PER_SOL } from "@solana/web3.js"; /** diff --git a/src/tools/transfer.ts b/src/tools/solana_native/transfer.ts similarity index 97% rename from src/tools/transfer.ts rename to src/tools/solana_native/transfer.ts index 9e11dd74..04473d17 100644 --- a/src/tools/transfer.ts +++ b/src/tools/solana_native/transfer.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import { LAMPORTS_PER_SOL } from "@solana/web3.js"; import { diff --git a/src/tools/stake_with_solayer.ts b/src/tools/solayer/stake_with_solayer.ts similarity index 97% rename from src/tools/stake_with_solayer.ts rename to src/tools/solayer/stake_with_solayer.ts index e2ef643e..edbb8ff6 100644 --- a/src/tools/stake_with_solayer.ts +++ b/src/tools/solayer/stake_with_solayer.ts @@ -1,5 +1,5 @@ import { VersionedTransaction } from "@solana/web3.js"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; /** * Stake SOL with Solayer diff --git a/src/tools/squads_multisig/deposit_to_multisig.ts b/src/tools/squads_multisig/deposit_to_multisig.ts index 11a2582f..e2b23adb 100644 --- a/src/tools/squads_multisig/deposit_to_multisig.ts +++ b/src/tools/squads_multisig/deposit_to_multisig.ts @@ -54,7 +54,7 @@ export async function deposit_to_multisig( mint, agent.wallet_address, ); - let transaction = new Transaction(); + const transaction = new Transaction(); const toAta = await getAssociatedTokenAddress(mint, to, true); const toTokenAccountInfo = await agent.connection.getAccountInfo(toAta); // Create associated token account if it doesn't exist diff --git a/src/tools/tensor_trade.ts b/src/tools/tensor/tensor_trade.ts similarity index 98% rename from src/tools/tensor_trade.ts rename to src/tools/tensor/tensor_trade.ts index 4025ac32..b96069b6 100644 --- a/src/tools/tensor_trade.ts +++ b/src/tools/tensor/tensor_trade.ts @@ -1,4 +1,4 @@ -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; import { TensorSwapSDK } from "@tensor-oss/tensorswap-sdk"; import { PublicKey, Transaction } from "@solana/web3.js"; import { AnchorProvider, Wallet } from "@coral-xyz/anchor"; diff --git a/src/tools/create_tiplinks.ts b/src/tools/tiplink/create_tiplinks.ts similarity index 98% rename from src/tools/create_tiplinks.ts rename to src/tools/tiplink/create_tiplinks.ts index 20348ad4..f38dbc19 100644 --- a/src/tools/create_tiplinks.ts +++ b/src/tools/tiplink/create_tiplinks.ts @@ -13,7 +13,7 @@ import { getMint, createAssociatedTokenAccountInstruction, } from "@solana/spl-token"; -import { SolanaAgentKit } from "../index"; +import { SolanaAgentKit } from "../../index"; const MINIMUM_SOL_BALANCE = 0.003 * LAMPORTS_PER_SOL; diff --git a/src/utils/actionExecutor.ts b/src/utils/actionExecutor.ts index ed2bd901..66d4a400 100644 --- a/src/utils/actionExecutor.ts +++ b/src/utils/actionExecutor.ts @@ -10,7 +10,9 @@ export function findAction(query: string): Action | undefined { return Object.values(ACTIONS).find( (action) => action.name.toLowerCase() === normalizedQuery || - action.similes.some((simile) => simile.toLowerCase() === normalizedQuery), + action.similes.some( + (simile: any) => simile.toLowerCase() === normalizedQuery, + ), ); }