@coinbase/agentkit 0.0.0-nightly-20250328174338
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +827 -0
- package/dist/action-providers/across/acrossActionProvider.d.ts +50 -0
- package/dist/action-providers/across/acrossActionProvider.js +333 -0
- package/dist/action-providers/across/acrossActionProvider.test.d.ts +1 -0
- package/dist/action-providers/across/acrossActionProvider.test.js +391 -0
- package/dist/action-providers/across/constants.d.ts +1 -0
- package/dist/action-providers/across/constants.js +2 -0
- package/dist/action-providers/across/index.d.ts +1 -0
- package/dist/action-providers/across/index.js +17 -0
- package/dist/action-providers/across/schemas.d.ts +36 -0
- package/dist/action-providers/across/schemas.js +46 -0
- package/dist/action-providers/across/utils.d.ts +7 -0
- package/dist/action-providers/across/utils.js +25 -0
- package/dist/action-providers/actionDecorator.d.ts +69 -0
- package/dist/action-providers/actionDecorator.js +96 -0
- package/dist/action-providers/actionProvider.d.ts +48 -0
- package/dist/action-providers/actionProvider.js +62 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.d.ts +55 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.js +173 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.d.ts +1 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.js +131 -0
- package/dist/action-providers/alchemy/index.d.ts +2 -0
- package/dist/action-providers/alchemy/index.js +18 -0
- package/dist/action-providers/alchemy/schemas.d.ts +41 -0
- package/dist/action-providers/alchemy/schemas.js +34 -0
- package/dist/action-providers/allora/alloraActionProvider.d.ts +44 -0
- package/dist/action-providers/allora/alloraActionProvider.js +195 -0
- package/dist/action-providers/allora/alloraActionProvider.test.d.ts +1 -0
- package/dist/action-providers/allora/alloraActionProvider.test.js +109 -0
- package/dist/action-providers/allora/index.d.ts +2 -0
- package/dist/action-providers/allora/index.js +18 -0
- package/dist/action-providers/allora/schemas.d.ts +28 -0
- package/dist/action-providers/allora/schemas.js +30 -0
- package/dist/action-providers/basename/basenameActionProvider.d.ts +30 -0
- package/dist/action-providers/basename/basenameActionProvider.js +109 -0
- package/dist/action-providers/basename/basenameActionProvider.test.d.ts +1 -0
- package/dist/action-providers/basename/basenameActionProvider.test.js +146 -0
- package/dist/action-providers/basename/constants.d.ts +52 -0
- package/dist/action-providers/basename/constants.js +81 -0
- package/dist/action-providers/basename/index.d.ts +2 -0
- package/dist/action-providers/basename/index.js +18 -0
- package/dist/action-providers/basename/schemas.d.ts +14 -0
- package/dist/action-providers/basename/schemas.js +14 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +43 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.js +128 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.test.d.ts +1 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +146 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.d.ts +58 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.js +224 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.test.d.ts +1 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.test.js +267 -0
- package/dist/action-providers/cdp/constants.d.ts +31 -0
- package/dist/action-providers/cdp/constants.js +34 -0
- package/dist/action-providers/cdp/index.d.ts +3 -0
- package/dist/action-providers/cdp/index.js +19 -0
- package/dist/action-providers/cdp/schemas.d.ts +91 -0
- package/dist/action-providers/cdp/schemas.js +77 -0
- package/dist/action-providers/compound/compoundActionProvider.d.ts +67 -0
- package/dist/action-providers/compound/compoundActionProvider.js +365 -0
- package/dist/action-providers/compound/compoundActionProvider.test.d.ts +1 -0
- package/dist/action-providers/compound/compoundActionProvider.test.js +353 -0
- package/dist/action-providers/compound/constants.d.ts +180 -0
- package/dist/action-providers/compound/constants.js +129 -0
- package/dist/action-providers/compound/index.d.ts +1 -0
- package/dist/action-providers/compound/index.js +17 -0
- package/dist/action-providers/compound/schemas.d.ts +57 -0
- package/dist/action-providers/compound/schemas.js +58 -0
- package/dist/action-providers/compound/utils.d.ts +95 -0
- package/dist/action-providers/compound/utils.js +353 -0
- package/dist/action-providers/customActionProvider.d.ts +30 -0
- package/dist/action-providers/customActionProvider.js +66 -0
- package/dist/action-providers/defillama/constants.d.ts +8 -0
- package/dist/action-providers/defillama/constants.js +11 -0
- package/dist/action-providers/defillama/defillamaActionProvider.d.ts +54 -0
- package/dist/action-providers/defillama/defillamaActionProvider.js +180 -0
- package/dist/action-providers/defillama/defillamaActionProvider.test.d.ts +1 -0
- package/dist/action-providers/defillama/defillamaActionProvider.test.js +114 -0
- package/dist/action-providers/defillama/index.d.ts +1 -0
- package/dist/action-providers/defillama/index.js +17 -0
- package/dist/action-providers/defillama/schemas.d.ts +34 -0
- package/dist/action-providers/defillama/schemas.js +34 -0
- package/dist/action-providers/defillama/types.d.ts +73 -0
- package/dist/action-providers/defillama/types.js +2 -0
- package/dist/action-providers/defillama/utils.d.ts +10 -0
- package/dist/action-providers/defillama/utils.js +87 -0
- package/dist/action-providers/defillama/utils.test.d.ts +1 -0
- package/dist/action-providers/defillama/utils.test.js +124 -0
- package/dist/action-providers/erc20/constants.d.ts +137 -0
- package/dist/action-providers/erc20/constants.js +202 -0
- package/dist/action-providers/erc20/erc20ActionProvider.d.ts +38 -0
- package/dist/action-providers/erc20/erc20ActionProvider.js +142 -0
- package/dist/action-providers/erc20/erc20ActionProvider.test.d.ts +1 -0
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +131 -0
- package/dist/action-providers/erc20/index.d.ts +1 -0
- package/dist/action-providers/erc20/index.js +17 -0
- package/dist/action-providers/erc20/schemas.d.ts +27 -0
- package/dist/action-providers/erc20/schemas.js +26 -0
- package/dist/action-providers/erc721/constants.d.ts +232 -0
- package/dist/action-providers/erc721/constants.js +298 -0
- package/dist/action-providers/erc721/erc721ActionProvider.d.ts +46 -0
- package/dist/action-providers/erc721/erc721ActionProvider.js +164 -0
- package/dist/action-providers/erc721/erc721ActionProvider.test.d.ts +1 -0
- package/dist/action-providers/erc721/erc721ActionProvider.test.js +137 -0
- package/dist/action-providers/erc721/index.d.ts +1 -0
- package/dist/action-providers/erc721/index.js +17 -0
- package/dist/action-providers/erc721/schemas.d.ts +46 -0
- package/dist/action-providers/erc721/schemas.js +44 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.d.ts +57 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.js +142 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.test.js +151 -0
- package/dist/action-providers/farcaster/index.d.ts +2 -0
- package/dist/action-providers/farcaster/index.js +18 -0
- package/dist/action-providers/farcaster/schemas.d.ts +15 -0
- package/dist/action-providers/farcaster/schemas.js +20 -0
- package/dist/action-providers/index.d.ts +24 -0
- package/dist/action-providers/index.js +40 -0
- package/dist/action-providers/jupiter/index.d.ts +1 -0
- package/dist/action-providers/jupiter/index.js +17 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.d.ts +36 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.js +115 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.test.js +146 -0
- package/dist/action-providers/jupiter/schemas.d.ts +20 -0
- package/dist/action-providers/jupiter/schemas.js +20 -0
- package/dist/action-providers/messari/constants.d.ts +17 -0
- package/dist/action-providers/messari/constants.js +20 -0
- package/dist/action-providers/messari/index.d.ts +5 -0
- package/dist/action-providers/messari/index.js +21 -0
- package/dist/action-providers/messari/messariActionProvider.d.ts +42 -0
- package/dist/action-providers/messari/messariActionProvider.js +128 -0
- package/dist/action-providers/messari/messariActionProvider.test.d.ts +1 -0
- package/dist/action-providers/messari/messariActionProvider.test.js +152 -0
- package/dist/action-providers/messari/schemas.d.ts +11 -0
- package/dist/action-providers/messari/schemas.js +16 -0
- package/dist/action-providers/messari/types.d.ts +40 -0
- package/dist/action-providers/messari/types.js +2 -0
- package/dist/action-providers/messari/utils.d.ts +22 -0
- package/dist/action-providers/messari/utils.js +65 -0
- package/dist/action-providers/moonwell/constants.d.ts +78 -0
- package/dist/action-providers/moonwell/constants.js +111 -0
- package/dist/action-providers/moonwell/index.d.ts +1 -0
- package/dist/action-providers/moonwell/index.js +5 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.d.ts +39 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.js +249 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.test.d.ts +1 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.test.js +455 -0
- package/dist/action-providers/moonwell/schemas.d.ts +30 -0
- package/dist/action-providers/moonwell/schemas.js +39 -0
- package/dist/action-providers/morpho/constants.d.ts +16 -0
- package/dist/action-providers/morpho/constants.js +27 -0
- package/dist/action-providers/morpho/index.d.ts +2 -0
- package/dist/action-providers/morpho/index.js +18 -0
- package/dist/action-providers/morpho/morphoActionProvider.d.ts +39 -0
- package/dist/action-providers/morpho/morphoActionProvider.js +154 -0
- package/dist/action-providers/morpho/morphoActionProvider.test.d.ts +1 -0
- package/dist/action-providers/morpho/morphoActionProvider.test.js +128 -0
- package/dist/action-providers/morpho/schemas.d.ts +36 -0
- package/dist/action-providers/morpho/schemas.js +47 -0
- package/dist/action-providers/opensea/index.d.ts +1 -0
- package/dist/action-providers/opensea/index.js +17 -0
- package/dist/action-providers/opensea/openseaActionProvider.d.ts +59 -0
- package/dist/action-providers/opensea/openseaActionProvider.js +146 -0
- package/dist/action-providers/opensea/openseaActionProvider.test.d.ts +1 -0
- package/dist/action-providers/opensea/openseaActionProvider.test.js +201 -0
- package/dist/action-providers/opensea/schemas.d.ts +30 -0
- package/dist/action-providers/opensea/schemas.js +33 -0
- package/dist/action-providers/opensea/utils.d.ts +12 -0
- package/dist/action-providers/opensea/utils.js +47 -0
- package/dist/action-providers/pyth/index.d.ts +2 -0
- package/dist/action-providers/pyth/index.js +18 -0
- package/dist/action-providers/pyth/pythActionProvider.d.ts +33 -0
- package/dist/action-providers/pyth/pythActionProvider.js +121 -0
- package/dist/action-providers/pyth/pythActionProvider.test.d.ts +1 -0
- package/dist/action-providers/pyth/pythActionProvider.test.js +113 -0
- package/dist/action-providers/pyth/schemas.d.ts +21 -0
- package/dist/action-providers/pyth/schemas.js +20 -0
- package/dist/action-providers/spl/index.d.ts +1 -0
- package/dist/action-providers/spl/index.js +17 -0
- package/dist/action-providers/spl/schemas.d.ts +30 -0
- package/dist/action-providers/spl/schemas.js +26 -0
- package/dist/action-providers/spl/splActionProvider.d.ts +45 -0
- package/dist/action-providers/spl/splActionProvider.js +173 -0
- package/dist/action-providers/spl/splActionProvider.test.d.ts +1 -0
- package/dist/action-providers/spl/splActionProvider.test.js +300 -0
- package/dist/action-providers/twitter/index.d.ts +2 -0
- package/dist/action-providers/twitter/index.js +18 -0
- package/dist/action-providers/twitter/schemas.d.ts +38 -0
- package/dist/action-providers/twitter/schemas.js +44 -0
- package/dist/action-providers/twitter/twitterActionProvider.d.ts +82 -0
- package/dist/action-providers/twitter/twitterActionProvider.js +204 -0
- package/dist/action-providers/twitter/twitterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/twitter/twitterActionProvider.test.js +185 -0
- package/dist/action-providers/wallet/index.d.ts +1 -0
- package/dist/action-providers/wallet/index.js +17 -0
- package/dist/action-providers/wallet/schemas.d.ts +19 -0
- package/dist/action-providers/wallet/schemas.js +19 -0
- package/dist/action-providers/wallet/walletActionProvider.d.ts +44 -0
- package/dist/action-providers/wallet/walletActionProvider.js +140 -0
- package/dist/action-providers/wallet/walletActionProvider.test.d.ts +1 -0
- package/dist/action-providers/wallet/walletActionProvider.test.js +194 -0
- package/dist/action-providers/weth/constants.d.ts +19 -0
- package/dist/action-providers/weth/constants.js +29 -0
- package/dist/action-providers/weth/index.d.ts +1 -0
- package/dist/action-providers/weth/index.js +17 -0
- package/dist/action-providers/weth/schemas.d.ts +8 -0
- package/dist/action-providers/weth/schemas.js +10 -0
- package/dist/action-providers/weth/wethActionProvider.d.ts +30 -0
- package/dist/action-providers/weth/wethActionProvider.js +89 -0
- package/dist/action-providers/weth/wethActionProvider.test.d.ts +1 -0
- package/dist/action-providers/weth/wethActionProvider.test.js +92 -0
- package/dist/action-providers/wow/constants.d.ts +15 -0
- package/dist/action-providers/wow/constants.js +844 -0
- package/dist/action-providers/wow/index.d.ts +2 -0
- package/dist/action-providers/wow/index.js +18 -0
- package/dist/action-providers/wow/schemas.d.ts +43 -0
- package/dist/action-providers/wow/schemas.js +47 -0
- package/dist/action-providers/wow/uniswap/constants.d.ts +3 -0
- package/dist/action-providers/wow/uniswap/constants.js +100 -0
- package/dist/action-providers/wow/uniswap/utils.d.ts +82 -0
- package/dist/action-providers/wow/uniswap/utils.js +226 -0
- package/dist/action-providers/wow/utils.d.ts +27 -0
- package/dist/action-providers/wow/utils.js +63 -0
- package/dist/action-providers/wow/wowActionProvider.d.ts +46 -0
- package/dist/action-providers/wow/wowActionProvider.js +223 -0
- package/dist/action-providers/wow/wowActionProvider.test.d.ts +1 -0
- package/dist/action-providers/wow/wowActionProvider.test.js +291 -0
- package/dist/agentkit.d.ts +44 -0
- package/dist/agentkit.js +68 -0
- package/dist/analytics/index.d.ts +1 -0
- package/dist/analytics/index.js +17 -0
- package/dist/analytics/sendAnalyticsEvent.d.ts +31 -0
- package/dist/analytics/sendAnalyticsEvent.js +52 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/network/index.d.ts +3 -0
- package/dist/network/index.js +19 -0
- package/dist/network/network.d.ts +20 -0
- package/dist/network/network.js +86 -0
- package/dist/network/svm.d.ts +15 -0
- package/dist/network/svm.js +38 -0
- package/dist/network/types.d.ts +17 -0
- package/dist/network/types.js +2 -0
- package/dist/utils.d.ts +22 -0
- package/dist/utils.js +57 -0
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +50 -0
- package/dist/wallet-providers/cdpWalletProvider.d.ts +246 -0
- package/dist/wallet-providers/cdpWalletProvider.js +421 -0
- package/dist/wallet-providers/cdpWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/cdpWalletProvider.test.js +701 -0
- package/dist/wallet-providers/evmWalletProvider.d.ts +51 -0
- package/dist/wallet-providers/evmWalletProvider.js +14 -0
- package/dist/wallet-providers/evmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/evmWalletProvider.test.js +56 -0
- package/dist/wallet-providers/index.d.ts +10 -0
- package/dist/wallet-providers/index.js +26 -0
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +55 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +140 -0
- package/dist/wallet-providers/privyEvmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/privyEvmWalletProvider.test.js +331 -0
- package/dist/wallet-providers/privyShared.d.ts +40 -0
- package/dist/wallet-providers/privyShared.js +49 -0
- package/dist/wallet-providers/privySvmWalletProvider.d.ts +128 -0
- package/dist/wallet-providers/privySvmWalletProvider.js +212 -0
- package/dist/wallet-providers/privySvmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/privySvmWalletProvider.test.js +310 -0
- package/dist/wallet-providers/privyWalletProvider.d.ts +35 -0
- package/dist/wallet-providers/privyWalletProvider.js +39 -0
- package/dist/wallet-providers/privyWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/privyWalletProvider.test.js +124 -0
- package/dist/wallet-providers/smartWalletProvider.d.ts +177 -0
- package/dist/wallet-providers/smartWalletProvider.js +303 -0
- package/dist/wallet-providers/smartWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/smartWalletProvider.test.js +388 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +143 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.js +280 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +218 -0
- package/dist/wallet-providers/svmWalletProvider.d.ts +56 -0
- package/dist/wallet-providers/svmWalletProvider.js +13 -0
- package/dist/wallet-providers/svmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/svmWalletProvider.test.js +55 -0
- package/dist/wallet-providers/viemWalletProvider.d.ts +103 -0
- package/dist/wallet-providers/viemWalletProvider.js +206 -0
- package/dist/wallet-providers/viemWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/viemWalletProvider.test.js +338 -0
- package/dist/wallet-providers/walletProvider.d.ts +48 -0
- package/dist/wallet-providers/walletProvider.js +41 -0
- package/dist/wallet-providers/walletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/walletProvider.test.js +103 -0
- package/package.json +83 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./schemas"), exports);
|
|
18
|
+
__exportStar(require("./wowActionProvider"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Input schema for buying WOW tokens.
|
|
4
|
+
*/
|
|
5
|
+
export declare const WowBuyTokenInput: z.ZodObject<{
|
|
6
|
+
contractAddress: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
7
|
+
amountEthInWei: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
contractAddress: `0x${string}`;
|
|
10
|
+
amountEthInWei: string;
|
|
11
|
+
}, {
|
|
12
|
+
contractAddress: `0x${string}`;
|
|
13
|
+
amountEthInWei: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Input schema for creating WOW tokens.
|
|
17
|
+
*/
|
|
18
|
+
export declare const WowCreateTokenInput: z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
symbol: z.ZodString;
|
|
21
|
+
tokenUri: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
symbol: string;
|
|
24
|
+
name: string;
|
|
25
|
+
tokenUri?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
symbol: string;
|
|
28
|
+
name: string;
|
|
29
|
+
tokenUri?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Input schema for selling WOW tokens.
|
|
33
|
+
*/
|
|
34
|
+
export declare const WowSellTokenInput: z.ZodObject<{
|
|
35
|
+
contractAddress: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
36
|
+
amountTokensInWei: z.ZodString;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
contractAddress: `0x${string}`;
|
|
39
|
+
amountTokensInWei: string;
|
|
40
|
+
}, {
|
|
41
|
+
contractAddress: `0x${string}`;
|
|
42
|
+
amountTokensInWei: string;
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WowSellTokenInput = exports.WowCreateTokenInput = exports.WowBuyTokenInput = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const ethereumAddress = zod_1.z.custom(val => typeof val === "string" && (0, viem_1.isAddress)(val), "Invalid address");
|
|
7
|
+
/**
|
|
8
|
+
* Input schema for buying WOW tokens.
|
|
9
|
+
*/
|
|
10
|
+
exports.WowBuyTokenInput = zod_1.z
|
|
11
|
+
.object({
|
|
12
|
+
contractAddress: ethereumAddress.describe("The WOW token contract address"),
|
|
13
|
+
amountEthInWei: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d+$/, "Must be a valid wei amount")
|
|
16
|
+
.describe("Amount of ETH to spend (in wei)"),
|
|
17
|
+
})
|
|
18
|
+
.strip()
|
|
19
|
+
.describe("Instructions for buying WOW tokens");
|
|
20
|
+
/**
|
|
21
|
+
* Input schema for creating WOW tokens.
|
|
22
|
+
*/
|
|
23
|
+
exports.WowCreateTokenInput = zod_1.z
|
|
24
|
+
.object({
|
|
25
|
+
name: zod_1.z.string().min(1).describe("The name of the token to create, e.g. WowCoin"),
|
|
26
|
+
symbol: zod_1.z.string().min(1).describe("The symbol of the token to create, e.g. WOW"),
|
|
27
|
+
tokenUri: zod_1.z
|
|
28
|
+
.string()
|
|
29
|
+
.url()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("The URI of the token metadata to store on IPFS, e.g. ipfs://QmY1GqprFYvojCcUEKgqHeDj9uhZD9jmYGrQTfA9vAE78J"),
|
|
32
|
+
})
|
|
33
|
+
.strip()
|
|
34
|
+
.describe("Instructions for creating a WOW token");
|
|
35
|
+
/**
|
|
36
|
+
* Input schema for selling WOW tokens.
|
|
37
|
+
*/
|
|
38
|
+
exports.WowSellTokenInput = zod_1.z
|
|
39
|
+
.object({
|
|
40
|
+
contractAddress: ethereumAddress.describe("The WOW token contract address, such as `0x036CbD53842c5426634e7929541eC2318f3dCF7e`"),
|
|
41
|
+
amountTokensInWei: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.regex(/^\d+$/, "Must be a valid wei amount")
|
|
44
|
+
.describe("Amount of tokens to sell (in wei), meaning 1 is 1 wei or 0.000000000000000001 of the token"),
|
|
45
|
+
})
|
|
46
|
+
.strip()
|
|
47
|
+
.describe("Instructions for selling WOW tokens");
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNISWAP_V3_ABI = exports.UNISWAP_QUOTER_ABI = void 0;
|
|
4
|
+
exports.UNISWAP_QUOTER_ABI = [
|
|
5
|
+
{
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
components: [
|
|
9
|
+
{ internalType: "address", name: "tokenIn", type: "address" },
|
|
10
|
+
{ internalType: "address", name: "tokenOut", type: "address" },
|
|
11
|
+
{ internalType: "uint256", name: "amountIn", type: "uint256" },
|
|
12
|
+
{ internalType: "uint24", name: "fee", type: "uint24" },
|
|
13
|
+
{ internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" },
|
|
14
|
+
],
|
|
15
|
+
internalType: "struct IQuoterV2.QuoteExactInputSingleParams",
|
|
16
|
+
name: "params",
|
|
17
|
+
type: "tuple",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
name: "quoteExactInputSingle",
|
|
21
|
+
outputs: [
|
|
22
|
+
{ internalType: "uint256", name: "amountOut", type: "uint256" },
|
|
23
|
+
{ internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" },
|
|
24
|
+
{ internalType: "uint32", name: "initializedTicksCrossed", type: "uint32" },
|
|
25
|
+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
|
|
26
|
+
],
|
|
27
|
+
stateMutability: "nonpayable",
|
|
28
|
+
type: "function",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
inputs: [
|
|
32
|
+
{
|
|
33
|
+
components: [
|
|
34
|
+
{ internalType: "address", name: "tokenIn", type: "address" },
|
|
35
|
+
{ internalType: "address", name: "tokenOut", type: "address" },
|
|
36
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
37
|
+
{ internalType: "uint24", name: "fee", type: "uint24" },
|
|
38
|
+
{ internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" },
|
|
39
|
+
],
|
|
40
|
+
internalType: "struct IQuoterV2.QuoteExactOutputSingleParams",
|
|
41
|
+
name: "params",
|
|
42
|
+
type: "tuple",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
name: "quoteExactOutputSingle",
|
|
46
|
+
outputs: [
|
|
47
|
+
{ internalType: "uint256", name: "amountIn", type: "uint256" },
|
|
48
|
+
{ internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" },
|
|
49
|
+
{ internalType: "uint32", name: "initializedTicksCrossed", type: "uint32" },
|
|
50
|
+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
|
|
51
|
+
],
|
|
52
|
+
stateMutability: "nonpayable",
|
|
53
|
+
type: "function",
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
exports.UNISWAP_V3_ABI = [
|
|
57
|
+
{
|
|
58
|
+
inputs: [],
|
|
59
|
+
name: "fee",
|
|
60
|
+
outputs: [{ internalType: "uint24", name: "", type: "uint24" }],
|
|
61
|
+
stateMutability: "view",
|
|
62
|
+
type: "function",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
inputs: [],
|
|
66
|
+
name: "liquidity",
|
|
67
|
+
outputs: [{ internalType: "uint128", name: "", type: "uint128" }],
|
|
68
|
+
stateMutability: "view",
|
|
69
|
+
type: "function",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
inputs: [],
|
|
73
|
+
name: "slot0",
|
|
74
|
+
outputs: [
|
|
75
|
+
{ internalType: "uint160", name: "sqrtPriceX96", type: "uint160" },
|
|
76
|
+
{ internalType: "int24", name: "tick", type: "int24" },
|
|
77
|
+
{ internalType: "uint16", name: "observationIndex", type: "uint16" },
|
|
78
|
+
{ internalType: "uint16", name: "observationCardinality", type: "uint16" },
|
|
79
|
+
{ internalType: "uint16", name: "observationCardinalityNext", type: "uint16" },
|
|
80
|
+
{ internalType: "uint8", name: "feeProtocol", type: "uint8" },
|
|
81
|
+
{ internalType: "bool", name: "unlocked", type: "bool" },
|
|
82
|
+
],
|
|
83
|
+
stateMutability: "view",
|
|
84
|
+
type: "function",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
inputs: [],
|
|
88
|
+
name: "token0",
|
|
89
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
90
|
+
stateMutability: "view",
|
|
91
|
+
type: "function",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
inputs: [],
|
|
95
|
+
name: "token1",
|
|
96
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
97
|
+
stateMutability: "view",
|
|
98
|
+
type: "function",
|
|
99
|
+
},
|
|
100
|
+
];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { EvmWalletProvider } from "../../../wallet-providers";
|
|
2
|
+
export interface PriceInfo {
|
|
3
|
+
eth: string;
|
|
4
|
+
usd: number;
|
|
5
|
+
}
|
|
6
|
+
export interface Balance {
|
|
7
|
+
erc20z: string;
|
|
8
|
+
weth: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Price {
|
|
11
|
+
perToken: PriceInfo;
|
|
12
|
+
total: PriceInfo;
|
|
13
|
+
}
|
|
14
|
+
export interface Quote {
|
|
15
|
+
amountIn: number;
|
|
16
|
+
amountOut: number;
|
|
17
|
+
balance: Balance | null;
|
|
18
|
+
fee: number | null;
|
|
19
|
+
error: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface PoolInfo {
|
|
22
|
+
token0: string;
|
|
23
|
+
balance0: number;
|
|
24
|
+
token1: string;
|
|
25
|
+
balance1: number;
|
|
26
|
+
fee: number;
|
|
27
|
+
liquidity: number;
|
|
28
|
+
sqrtPriceX96: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a PriceInfo object from wei amount and ETH price.
|
|
32
|
+
*
|
|
33
|
+
* @param weiAmount - Amount in wei
|
|
34
|
+
* @param ethPriceInUsd - Current ETH price in USD
|
|
35
|
+
* @returns A PriceInfo object containing the amount in ETH and USD
|
|
36
|
+
*/
|
|
37
|
+
export declare function createPriceInfo(weiAmount: string, ethPriceInUsd: number): PriceInfo;
|
|
38
|
+
/**
|
|
39
|
+
* Gets pool info for a given uniswap v3 pool address.
|
|
40
|
+
*
|
|
41
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
42
|
+
* @param poolAddress - Uniswap v3 pool address
|
|
43
|
+
* @returns A PoolInfo object containing pool details
|
|
44
|
+
*/
|
|
45
|
+
export declare function getPoolInfo(wallet: EvmWalletProvider, poolAddress: string): Promise<PoolInfo>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets exact input quote from Uniswap.
|
|
48
|
+
*
|
|
49
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
50
|
+
* @param tokenIn - Token address to swap from
|
|
51
|
+
* @param tokenOut - Token address to swap to
|
|
52
|
+
* @param amountIn - Amount of tokens to swap (in Wei)
|
|
53
|
+
* @param fee - Fee for the swap
|
|
54
|
+
* @returns Amount of tokens to receive (in Wei)
|
|
55
|
+
*/
|
|
56
|
+
export declare function exactInputSingle(wallet: EvmWalletProvider, tokenIn: string, tokenOut: string, amountIn: string, fee: string): Promise<number>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets Uniswap quote for buying or selling tokens.
|
|
59
|
+
*
|
|
60
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
61
|
+
* @param tokenAddress - Token address
|
|
62
|
+
* @param amount - Amount of tokens (in Wei)
|
|
63
|
+
* @param quoteType - 'buy' or 'sell'
|
|
64
|
+
* @returns A Quote object containing quote details
|
|
65
|
+
*/
|
|
66
|
+
export declare function getUniswapQuote(wallet: EvmWalletProvider, tokenAddress: string, amount: number, quoteType: "buy" | "sell"): Promise<Quote>;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if a token has graduated from the Zora Wow protocol.
|
|
69
|
+
*
|
|
70
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
71
|
+
* @param tokenAddress - Token address
|
|
72
|
+
* @returns True if the token has graduated, false otherwise
|
|
73
|
+
*/
|
|
74
|
+
export declare function getHasGraduated(wallet: EvmWalletProvider, tokenAddress: string): Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetches the uniswap v3 pool address for a given token.
|
|
77
|
+
*
|
|
78
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
79
|
+
* @param tokenAddress - The address of the token contract
|
|
80
|
+
* @returns The uniswap v3 pool address associated with the token
|
|
81
|
+
*/
|
|
82
|
+
export declare function getPoolAddress(wallet: EvmWalletProvider, tokenAddress: string): Promise<string>;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPriceInfo = createPriceInfo;
|
|
4
|
+
exports.getPoolInfo = getPoolInfo;
|
|
5
|
+
exports.exactInputSingle = exactInputSingle;
|
|
6
|
+
exports.getUniswapQuote = getUniswapQuote;
|
|
7
|
+
exports.getHasGraduated = getHasGraduated;
|
|
8
|
+
exports.getPoolAddress = getPoolAddress;
|
|
9
|
+
const viem_1 = require("viem");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const constants_2 = require("./constants");
|
|
12
|
+
/**
|
|
13
|
+
* Creates a PriceInfo object from wei amount and ETH price.
|
|
14
|
+
*
|
|
15
|
+
* @param weiAmount - Amount in wei
|
|
16
|
+
* @param ethPriceInUsd - Current ETH price in USD
|
|
17
|
+
* @returns A PriceInfo object containing the amount in ETH and USD
|
|
18
|
+
*/
|
|
19
|
+
function createPriceInfo(weiAmount, ethPriceInUsd) {
|
|
20
|
+
const amountInEth = (0, viem_1.formatEther)(BigInt(weiAmount));
|
|
21
|
+
const usd = Number(amountInEth) * ethPriceInUsd;
|
|
22
|
+
return {
|
|
23
|
+
eth: weiAmount,
|
|
24
|
+
usd,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets pool info for a given uniswap v3 pool address.
|
|
29
|
+
*
|
|
30
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
31
|
+
* @param poolAddress - Uniswap v3 pool address
|
|
32
|
+
* @returns A PoolInfo object containing pool details
|
|
33
|
+
*/
|
|
34
|
+
async function getPoolInfo(wallet, poolAddress) {
|
|
35
|
+
try {
|
|
36
|
+
const results = await Promise.all([
|
|
37
|
+
wallet.readContract({
|
|
38
|
+
address: poolAddress,
|
|
39
|
+
functionName: "token0",
|
|
40
|
+
args: [],
|
|
41
|
+
abi: constants_2.UNISWAP_V3_ABI,
|
|
42
|
+
}),
|
|
43
|
+
wallet.readContract({
|
|
44
|
+
address: poolAddress,
|
|
45
|
+
functionName: "token1",
|
|
46
|
+
args: [],
|
|
47
|
+
abi: constants_2.UNISWAP_V3_ABI,
|
|
48
|
+
}),
|
|
49
|
+
wallet.readContract({
|
|
50
|
+
address: poolAddress,
|
|
51
|
+
functionName: "fee",
|
|
52
|
+
args: [],
|
|
53
|
+
abi: constants_2.UNISWAP_V3_ABI,
|
|
54
|
+
}),
|
|
55
|
+
wallet.readContract({
|
|
56
|
+
address: poolAddress,
|
|
57
|
+
functionName: "liquidity",
|
|
58
|
+
args: [],
|
|
59
|
+
abi: constants_2.UNISWAP_V3_ABI,
|
|
60
|
+
}),
|
|
61
|
+
wallet.readContract({
|
|
62
|
+
address: poolAddress,
|
|
63
|
+
functionName: "slot0",
|
|
64
|
+
args: [],
|
|
65
|
+
abi: constants_2.UNISWAP_V3_ABI,
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
68
|
+
const [token0Result, token1Result, fee, liquidity, slot0] = results;
|
|
69
|
+
const [balance0, balance1] = await Promise.all([
|
|
70
|
+
wallet.readContract({
|
|
71
|
+
address: token0Result,
|
|
72
|
+
functionName: "balanceOf",
|
|
73
|
+
args: [poolAddress],
|
|
74
|
+
abi: constants_1.WOW_ABI,
|
|
75
|
+
}),
|
|
76
|
+
wallet.readContract({
|
|
77
|
+
address: token1Result,
|
|
78
|
+
functionName: "balanceOf",
|
|
79
|
+
args: [poolAddress],
|
|
80
|
+
abi: constants_1.WOW_ABI,
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
return {
|
|
84
|
+
token0: token0Result,
|
|
85
|
+
balance0: Number(balance0),
|
|
86
|
+
token1: token1Result,
|
|
87
|
+
balance1: Number(balance1),
|
|
88
|
+
fee: Number(fee),
|
|
89
|
+
liquidity: Number(liquidity),
|
|
90
|
+
sqrtPriceX96: Number(slot0[0]),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw new Error(`Failed to fetch pool information: ${error}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets exact input quote from Uniswap.
|
|
99
|
+
*
|
|
100
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
101
|
+
* @param tokenIn - Token address to swap from
|
|
102
|
+
* @param tokenOut - Token address to swap to
|
|
103
|
+
* @param amountIn - Amount of tokens to swap (in Wei)
|
|
104
|
+
* @param fee - Fee for the swap
|
|
105
|
+
* @returns Amount of tokens to receive (in Wei)
|
|
106
|
+
*/
|
|
107
|
+
async function exactInputSingle(wallet, tokenIn, tokenOut, amountIn, fee) {
|
|
108
|
+
try {
|
|
109
|
+
const networkId = wallet.getNetwork().networkId;
|
|
110
|
+
const amount = await wallet.readContract({
|
|
111
|
+
address: constants_1.ADDRESSES[networkId].UniswapQuoter,
|
|
112
|
+
functionName: "quoteExactInputSingle",
|
|
113
|
+
args: [
|
|
114
|
+
{
|
|
115
|
+
tokenIn: (0, viem_1.getAddress)(tokenIn),
|
|
116
|
+
tokenOut: (0, viem_1.getAddress)(tokenOut),
|
|
117
|
+
fee,
|
|
118
|
+
amountIn,
|
|
119
|
+
sqrtPriceLimitX96: 0,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
abi: constants_2.UNISWAP_QUOTER_ABI,
|
|
123
|
+
});
|
|
124
|
+
return Number(amount);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error("Quoter error:", error);
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Gets Uniswap quote for buying or selling tokens.
|
|
133
|
+
*
|
|
134
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
135
|
+
* @param tokenAddress - Token address
|
|
136
|
+
* @param amount - Amount of tokens (in Wei)
|
|
137
|
+
* @param quoteType - 'buy' or 'sell'
|
|
138
|
+
* @returns A Quote object containing quote details
|
|
139
|
+
*/
|
|
140
|
+
async function getUniswapQuote(wallet, tokenAddress, amount, quoteType) {
|
|
141
|
+
let pool = null;
|
|
142
|
+
let tokens = null;
|
|
143
|
+
let balances = null;
|
|
144
|
+
let quoteResult = null;
|
|
145
|
+
const utilization = 0;
|
|
146
|
+
const networkId = wallet.getNetwork().networkId;
|
|
147
|
+
const poolAddress = await getPoolAddress(wallet, tokenAddress);
|
|
148
|
+
const invalidPoolError = !poolAddress ? "Invalid pool address" : null;
|
|
149
|
+
try {
|
|
150
|
+
pool = await getPoolInfo(wallet, poolAddress);
|
|
151
|
+
const { token0, token1, balance0, balance1, fee } = pool;
|
|
152
|
+
tokens = [token0, token1];
|
|
153
|
+
balances = [balance0, balance1];
|
|
154
|
+
const isToken0Weth = token0.toLowerCase() === constants_1.ADDRESSES[networkId].WETH.toLowerCase();
|
|
155
|
+
const tokenIn = (quoteType === "buy" && isToken0Weth) || (quoteType === "sell" && !isToken0Weth)
|
|
156
|
+
? token0
|
|
157
|
+
: token1;
|
|
158
|
+
const [tokenOut, balanceOut] = tokenIn === token0 ? [token1, balance1] : [token0, balance0];
|
|
159
|
+
const isInsufficientLiquidity = quoteType === "buy" && amount > balanceOut;
|
|
160
|
+
if (!isInsufficientLiquidity) {
|
|
161
|
+
quoteResult = await exactInputSingle(wallet, tokenIn, tokenOut, String(amount), String(fee));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
console.error("Error fetching quote:", error);
|
|
166
|
+
}
|
|
167
|
+
const insufficientLiquidity = (quoteType === "sell" && pool && !quoteResult) || false;
|
|
168
|
+
let errorMsg = null;
|
|
169
|
+
if (!pool) {
|
|
170
|
+
errorMsg = "Failed fetching pool";
|
|
171
|
+
}
|
|
172
|
+
else if (insufficientLiquidity) {
|
|
173
|
+
errorMsg = "Insufficient liquidity";
|
|
174
|
+
}
|
|
175
|
+
else if (!quoteResult && utilization >= 0.9) {
|
|
176
|
+
errorMsg = "Price impact too high";
|
|
177
|
+
}
|
|
178
|
+
else if (!quoteResult) {
|
|
179
|
+
errorMsg = "Failed fetching quote";
|
|
180
|
+
}
|
|
181
|
+
const balanceResult = tokens && balances
|
|
182
|
+
? {
|
|
183
|
+
erc20z: String(balances[tokens[0].toLowerCase() === constants_1.ADDRESSES[networkId].WETH.toLowerCase() ? 1 : 0]),
|
|
184
|
+
weth: String(balances[tokens[0].toLowerCase() === constants_1.ADDRESSES[networkId].WETH.toLowerCase() ? 0 : 1]),
|
|
185
|
+
}
|
|
186
|
+
: null;
|
|
187
|
+
return {
|
|
188
|
+
amountIn: Number(amount),
|
|
189
|
+
amountOut: quoteResult || 0,
|
|
190
|
+
balance: balanceResult,
|
|
191
|
+
fee: pool?.fee ? pool.fee / 1000000 : null,
|
|
192
|
+
error: invalidPoolError || errorMsg,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Checks if a token has graduated from the Zora Wow protocol.
|
|
197
|
+
*
|
|
198
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
199
|
+
* @param tokenAddress - Token address
|
|
200
|
+
* @returns True if the token has graduated, false otherwise
|
|
201
|
+
*/
|
|
202
|
+
async function getHasGraduated(wallet, tokenAddress) {
|
|
203
|
+
const marketType = await wallet.readContract({
|
|
204
|
+
address: tokenAddress,
|
|
205
|
+
functionName: "marketType",
|
|
206
|
+
args: [],
|
|
207
|
+
abi: constants_1.WOW_ABI,
|
|
208
|
+
});
|
|
209
|
+
return marketType === 1;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Fetches the uniswap v3 pool address for a given token.
|
|
213
|
+
*
|
|
214
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
215
|
+
* @param tokenAddress - The address of the token contract
|
|
216
|
+
* @returns The uniswap v3 pool address associated with the token
|
|
217
|
+
*/
|
|
218
|
+
async function getPoolAddress(wallet, tokenAddress) {
|
|
219
|
+
const poolAddress = await wallet.readContract({
|
|
220
|
+
address: tokenAddress,
|
|
221
|
+
functionName: "poolAddress",
|
|
222
|
+
args: [],
|
|
223
|
+
abi: constants_1.WOW_ABI,
|
|
224
|
+
});
|
|
225
|
+
return poolAddress;
|
|
226
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EvmWalletProvider } from "../../wallet-providers";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current supply of a token.
|
|
4
|
+
*
|
|
5
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
6
|
+
* @param tokenAddress - Address of the token contract
|
|
7
|
+
* @returns The current token supply
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCurrentSupply(wallet: EvmWalletProvider, tokenAddress: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets quote for buying tokens.
|
|
12
|
+
*
|
|
13
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
14
|
+
* @param tokenAddress - Address of the token contract
|
|
15
|
+
* @param amountEthInWei - Amount of ETH to buy (in wei)
|
|
16
|
+
* @returns The buy quote amount
|
|
17
|
+
*/
|
|
18
|
+
export declare function getBuyQuote(wallet: EvmWalletProvider, tokenAddress: string, amountEthInWei: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets quote for selling tokens.
|
|
21
|
+
*
|
|
22
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
23
|
+
* @param tokenAddress - Address of the token contract
|
|
24
|
+
* @param amountTokensInWei - Amount of tokens to sell (in wei)
|
|
25
|
+
* @returns The sell quote amount
|
|
26
|
+
*/
|
|
27
|
+
export declare function getSellQuote(wallet: EvmWalletProvider, tokenAddress: string, amountTokensInWei: string): Promise<string>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrentSupply = getCurrentSupply;
|
|
4
|
+
exports.getBuyQuote = getBuyQuote;
|
|
5
|
+
exports.getSellQuote = getSellQuote;
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const utils_1 = require("./uniswap/utils");
|
|
8
|
+
/**
|
|
9
|
+
* Gets the current supply of a token.
|
|
10
|
+
*
|
|
11
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
12
|
+
* @param tokenAddress - Address of the token contract
|
|
13
|
+
* @returns The current token supply
|
|
14
|
+
*/
|
|
15
|
+
async function getCurrentSupply(wallet, tokenAddress) {
|
|
16
|
+
const supply = await wallet.readContract({
|
|
17
|
+
address: tokenAddress,
|
|
18
|
+
abi: constants_1.WOW_ABI,
|
|
19
|
+
functionName: "totalSupply",
|
|
20
|
+
args: [],
|
|
21
|
+
});
|
|
22
|
+
return supply;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets quote for buying tokens.
|
|
26
|
+
*
|
|
27
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
28
|
+
* @param tokenAddress - Address of the token contract
|
|
29
|
+
* @param amountEthInWei - Amount of ETH to buy (in wei)
|
|
30
|
+
* @returns The buy quote amount
|
|
31
|
+
*/
|
|
32
|
+
async function getBuyQuote(wallet, tokenAddress, amountEthInWei) {
|
|
33
|
+
const hasGraduated = await (0, utils_1.getHasGraduated)(wallet, tokenAddress);
|
|
34
|
+
const tokenQuote = (hasGraduated
|
|
35
|
+
? (await (0, utils_1.getUniswapQuote)(wallet, tokenAddress, Number(amountEthInWei), "buy")).amountOut
|
|
36
|
+
: await wallet.readContract({
|
|
37
|
+
address: tokenAddress,
|
|
38
|
+
abi: constants_1.WOW_ABI,
|
|
39
|
+
functionName: "getEthBuyQuote",
|
|
40
|
+
args: [amountEthInWei],
|
|
41
|
+
}));
|
|
42
|
+
return tokenQuote.toString();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets quote for selling tokens.
|
|
46
|
+
*
|
|
47
|
+
* @param wallet - The wallet provider to use for contract calls
|
|
48
|
+
* @param tokenAddress - Address of the token contract
|
|
49
|
+
* @param amountTokensInWei - Amount of tokens to sell (in wei)
|
|
50
|
+
* @returns The sell quote amount
|
|
51
|
+
*/
|
|
52
|
+
async function getSellQuote(wallet, tokenAddress, amountTokensInWei) {
|
|
53
|
+
const hasGraduated = await (0, utils_1.getHasGraduated)(wallet, tokenAddress);
|
|
54
|
+
const tokenQuote = (hasGraduated
|
|
55
|
+
? (await (0, utils_1.getUniswapQuote)(wallet, tokenAddress, Number(amountTokensInWei), "sell")).amountOut
|
|
56
|
+
: await wallet.readContract({
|
|
57
|
+
address: tokenAddress,
|
|
58
|
+
abi: constants_1.WOW_ABI,
|
|
59
|
+
functionName: "getTokenSellQuote",
|
|
60
|
+
args: [amountTokensInWei],
|
|
61
|
+
}));
|
|
62
|
+
return tokenQuote.toString();
|
|
63
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ActionProvider } from "../actionProvider";
|
|
3
|
+
import { EvmWalletProvider } from "../../wallet-providers";
|
|
4
|
+
import { Network } from "../../network";
|
|
5
|
+
import { WowBuyTokenInput, WowCreateTokenInput, WowSellTokenInput } from "./schemas";
|
|
6
|
+
/**
|
|
7
|
+
* WowActionProvider is an action provider for Wow protocol interactions.
|
|
8
|
+
*/
|
|
9
|
+
export declare class WowActionProvider extends ActionProvider<EvmWalletProvider> {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for the WowActionProvider class.
|
|
12
|
+
*/
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Buys a Zora Wow ERC20 memecoin with ETH.
|
|
16
|
+
*
|
|
17
|
+
* @param walletProvider - The wallet to create the token from.
|
|
18
|
+
* @param args - The input arguments for the action.
|
|
19
|
+
* @returns A message containing the token purchase details.
|
|
20
|
+
*/
|
|
21
|
+
buyToken(walletProvider: EvmWalletProvider, args: z.infer<typeof WowBuyTokenInput>): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Zora Wow ERC20 memecoin.
|
|
24
|
+
*
|
|
25
|
+
* @param wallet - The wallet to create the token from.
|
|
26
|
+
* @param args - The input arguments for the action.
|
|
27
|
+
* @returns A message containing the token creation details.
|
|
28
|
+
*/
|
|
29
|
+
createToken(wallet: EvmWalletProvider, args: z.infer<typeof WowCreateTokenInput>): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Sells WOW tokens for ETH.
|
|
32
|
+
*
|
|
33
|
+
* @param walletProvider - The wallet to sell the tokens from.
|
|
34
|
+
* @param args - The input arguments for the action.
|
|
35
|
+
* @returns A message confirming the sale with the transaction hash.
|
|
36
|
+
*/
|
|
37
|
+
sellToken(walletProvider: EvmWalletProvider, args: z.infer<typeof WowSellTokenInput>): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if the Wow action provider supports the given network.
|
|
40
|
+
*
|
|
41
|
+
* @param network - The network to check.
|
|
42
|
+
* @returns True if the Wow action provider supports the network, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
supportsNetwork: (network: Network) => boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare const wowActionProvider: () => WowActionProvider;
|