@coinbase/agentkit 0.10.0 → 0.10.2
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 +195 -23
- package/dist/action-providers/across/acrossActionProvider.js +3 -3
- package/dist/action-providers/across/schemas.d.ts +1 -1
- package/dist/action-providers/baseAccount/baseAccountActionProvider.d.ts +46 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.js +404 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.test.d.ts +1 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.test.js +325 -0
- package/dist/action-providers/baseAccount/index.d.ts +2 -0
- package/dist/action-providers/baseAccount/index.js +18 -0
- package/dist/action-providers/baseAccount/schemas.d.ts +43 -0
- package/dist/action-providers/baseAccount/schemas.js +62 -0
- package/dist/action-providers/baseAccount/types.d.ts +17 -0
- package/dist/action-providers/baseAccount/types.js +2 -0
- package/dist/action-providers/baseAccount/utils.d.ts +14 -0
- package/dist/action-providers/baseAccount/utils.js +57 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +3 -12
- package/dist/action-providers/cdp/cdpApiActionProvider.js +2 -81
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +0 -125
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +18 -3
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +224 -23
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +280 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +17 -2
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +224 -18
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +267 -1
- package/dist/action-providers/cdp/schemas.d.ts +12 -12
- package/dist/action-providers/cdp/schemas.js +17 -5
- package/dist/action-providers/cdp/swapUtils.d.ts +23 -0
- package/dist/action-providers/cdp/swapUtils.js +106 -0
- package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
- package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
- package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
- package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
- package/dist/action-providers/clanker/index.d.ts +2 -0
- package/dist/action-providers/clanker/index.js +18 -0
- package/dist/action-providers/clanker/schemas.d.ts +56 -0
- package/dist/action-providers/clanker/schemas.js +47 -0
- package/dist/action-providers/clanker/utils.d.ts +9 -0
- package/dist/action-providers/clanker/utils.js +23 -0
- package/dist/action-providers/compound/constants.d.ts +1 -1
- package/dist/action-providers/compound/constants.js +2 -2
- package/dist/action-providers/erc20/constants.d.ts +35 -135
- package/dist/action-providers/erc20/constants.js +37 -189
- package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
- package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
- package/dist/action-providers/erc20/schemas.d.ts +25 -12
- package/dist/action-providers/erc20/schemas.js +34 -6
- package/dist/action-providers/erc20/utils.d.ts +19 -0
- package/dist/action-providers/erc20/utils.js +54 -0
- package/dist/action-providers/flaunch/client_utils.d.ts +25 -0
- package/dist/action-providers/flaunch/client_utils.js +62 -0
- package/dist/action-providers/flaunch/constants.d.ts +42 -21
- package/dist/action-providers/flaunch/constants.js +113 -38
- package/dist/action-providers/flaunch/flaunchActionProvider.d.ts +4 -43
- package/dist/action-providers/flaunch/flaunchActionProvider.js +133 -209
- package/dist/action-providers/flaunch/flaunchActionProvider.test.js +113 -13
- package/dist/action-providers/flaunch/metadata_utils.d.ts +12 -0
- package/dist/action-providers/flaunch/metadata_utils.js +216 -0
- package/dist/action-providers/flaunch/schemas.d.ts +39 -3
- package/dist/action-providers/flaunch/schemas.js +62 -10
- package/dist/action-providers/flaunch/{utils.d.ts → swap_utils.d.ts} +17 -19
- package/dist/action-providers/flaunch/{utils.js → swap_utils.js} +137 -172
- package/dist/action-providers/index.d.ts +4 -0
- package/dist/action-providers/index.js +4 -0
- package/dist/action-providers/jupiter/schemas.d.ts +1 -1
- package/dist/action-providers/moonwell/schemas.d.ts +2 -2
- package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
- package/dist/action-providers/morpho/schemas.d.ts +2 -2
- package/dist/action-providers/pyth/pythActionProvider.d.ts +2 -2
- package/dist/action-providers/pyth/pythActionProvider.js +83 -26
- package/dist/action-providers/pyth/pythActionProvider.test.js +179 -23
- package/dist/action-providers/pyth/schemas.d.ts +6 -0
- package/dist/action-providers/pyth/schemas.js +9 -1
- package/dist/action-providers/superfluid/constants.d.ts +814 -0
- package/dist/action-providers/superfluid/constants.js +2826 -0
- package/dist/action-providers/superfluid/graphQueries/endpoints.d.ts +2 -0
- package/dist/action-providers/superfluid/graphQueries/endpoints.js +5 -0
- package/dist/action-providers/superfluid/graphQueries/queries.d.ts +1 -0
- package/dist/action-providers/superfluid/graphQueries/queries.js +35 -0
- package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.d.ts +8 -0
- package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +24 -0
- package/dist/action-providers/superfluid/graphQueries/types.d.ts +27 -0
- package/dist/action-providers/superfluid/graphQueries/types.js +2 -0
- package/dist/action-providers/superfluid/index.d.ts +7 -0
- package/dist/action-providers/superfluid/index.js +23 -0
- package/dist/action-providers/superfluid/schemas.d.ts +86 -0
- package/dist/action-providers/superfluid/schemas.js +103 -0
- package/dist/action-providers/superfluid/superfluidActionProvider.d.ts +20 -0
- package/dist/action-providers/superfluid/superfluidActionProvider.js +36 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.d.ts +46 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.js +143 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.js +92 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.d.ts +27 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.js +71 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.js +57 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.d.ts +56 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.js +191 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.js +80 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.d.ts +30 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +109 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.js +75 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.d.ts +32 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +101 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.d.ts +1 -0
- package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +85 -0
- package/dist/action-providers/superfluid/utils/parseLogs.d.ts +19 -0
- package/dist/action-providers/superfluid/utils/parseLogs.js +81 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +4 -16
- package/dist/action-providers/truemarkets/truemarketsActionProvider.js +20 -41
- package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +11 -33
- package/dist/action-providers/wallet/walletActionProvider.js +24 -10
- package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
- package/dist/action-providers/x402/schemas.d.ts +7 -0
- package/dist/action-providers/x402/schemas.js +11 -1
- package/dist/action-providers/x402/utils.d.ts +55 -0
- package/dist/action-providers/x402/utils.js +160 -0
- package/dist/action-providers/x402/x402ActionProvider.d.ts +9 -9
- package/dist/action-providers/x402/x402ActionProvider.js +158 -39
- package/dist/action-providers/x402/x402ActionProvider.test.js +116 -10
- package/dist/action-providers/zeroX/index.d.ts +1 -0
- package/dist/action-providers/zeroX/index.js +17 -0
- package/dist/action-providers/zeroX/schemas.d.ts +51 -0
- package/dist/action-providers/zeroX/schemas.js +82 -0
- package/dist/action-providers/zeroX/utils.d.ts +23 -0
- package/dist/action-providers/zeroX/utils.js +106 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.d.ts +57 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.js +407 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.test.d.ts +1 -0
- package/dist/action-providers/zeroX/zeroXActionProvider.test.js +445 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.js +43 -13
- package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +27 -2
- package/dist/wallet-providers/cdpEvmWalletProvider.js +54 -36
- package/dist/wallet-providers/cdpEvmWalletProvider.test.js +7 -0
- package/dist/wallet-providers/cdpShared.d.ts +5 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +29 -3
- package/dist/wallet-providers/cdpSmartWalletProvider.js +66 -25
- package/dist/wallet-providers/cdpSmartWalletProvider.test.js +6 -10
- package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
- package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
- package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
- package/dist/wallet-providers/evmWalletProvider.d.ts +13 -2
- package/dist/wallet-providers/evmWalletProvider.js +4 -0
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +18 -2
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +23 -2
- package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +19 -2
- package/dist/wallet-providers/legacyCdpWalletProvider.js +27 -2
- package/dist/wallet-providers/legacyCdpWalletProvider.test.js +6 -0
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +17 -2
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +39 -3
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +2 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +2 -1
- package/dist/wallet-providers/privyEvmWalletProvider.test.js +12 -1
- package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
- package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
- package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
- package/dist/wallet-providers/viemWalletProvider.d.ts +20 -3
- package/dist/wallet-providers/viemWalletProvider.js +33 -4
- package/dist/wallet-providers/viemWalletProvider.test.js +27 -6
- package/dist/wallet-providers/walletProvider.d.ts +1 -1
- package/dist/wallet-providers/zeroDevWalletProvider.d.ts +17 -2
- package/dist/wallet-providers/zeroDevWalletProvider.js +26 -5
- package/dist/wallet-providers/zeroDevWalletProvider.test.js +12 -2
- package/package.json +8 -4
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Flaunch Action Provider
|
|
4
|
-
*
|
|
5
|
-
* This file contains the implementation of the FlaunchActionProvider,
|
|
6
|
-
* which provides actions for flaunch operations.
|
|
7
|
-
*
|
|
8
|
-
* @module flaunch
|
|
9
|
-
*/
|
|
10
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -26,7 +18,9 @@ const wallet_providers_1 = require("../../wallet-providers");
|
|
|
26
18
|
const viem_1 = require("viem");
|
|
27
19
|
const chains_1 = require("viem/chains");
|
|
28
20
|
const schemas_1 = require("./schemas");
|
|
29
|
-
const
|
|
21
|
+
const metadata_utils_1 = require("./metadata_utils");
|
|
22
|
+
const client_utils_1 = require("./client_utils");
|
|
23
|
+
const swap_utils_1 = require("./swap_utils");
|
|
30
24
|
const constants_1 = require("./constants");
|
|
31
25
|
const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
|
|
32
26
|
/**
|
|
@@ -34,33 +28,21 @@ const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
|
|
|
34
28
|
*
|
|
35
29
|
* @description
|
|
36
30
|
* This provider is designed to work with EvmWalletProvider for blockchain interactions.
|
|
37
|
-
* It supports all evm networks.
|
|
38
31
|
*/
|
|
39
32
|
class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
40
33
|
/**
|
|
41
34
|
* Constructor for the FlaunchActionProvider.
|
|
42
35
|
*
|
|
43
|
-
* @param config - The configuration options for the FlaunchActionProvider.
|
|
44
36
|
*/
|
|
45
|
-
constructor(
|
|
37
|
+
constructor() {
|
|
46
38
|
super("flaunch", []);
|
|
47
|
-
const pinataJwt = config.pinataJwt || process.env.PINATA_JWT;
|
|
48
|
-
if (!pinataJwt) {
|
|
49
|
-
throw new Error("PINATA_JWT is not configured.");
|
|
50
|
-
}
|
|
51
|
-
this.pinataJwt = pinataJwt;
|
|
52
39
|
}
|
|
53
40
|
/**
|
|
54
|
-
*
|
|
55
|
-
* Replace or modify this with your actual action.
|
|
56
|
-
*
|
|
57
|
-
* @description
|
|
58
|
-
* This is a template action that demonstrates the basic structure.
|
|
59
|
-
* Replace it with your actual implementation.
|
|
41
|
+
* Launches a new memecoin using the flaunch protocol.
|
|
60
42
|
*
|
|
61
43
|
* @param walletProvider - The wallet provider instance for blockchain interactions
|
|
62
44
|
* @param args - Arguments defined by FlaunchSchema
|
|
63
|
-
* @returns A promise that resolves to a string describing the
|
|
45
|
+
* @returns A promise that resolves to a string describing the transaction result
|
|
64
46
|
*/
|
|
65
47
|
async flaunch(walletProvider, args) {
|
|
66
48
|
try {
|
|
@@ -70,11 +52,34 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
70
52
|
if (!chainId || !networkId) {
|
|
71
53
|
throw new Error("Chain ID is not set.");
|
|
72
54
|
}
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
// Validate that premineAmount does not exceed fairLaunchPercent
|
|
56
|
+
if (args.preminePercent > args.fairLaunchPercent) {
|
|
57
|
+
throw new Error(`premineAmount (${args.preminePercent}%) cannot exceed fairLaunchPercent (${args.fairLaunchPercent}%)`);
|
|
58
|
+
}
|
|
59
|
+
// Prepare launch parameters
|
|
60
|
+
const initialMCapInUSDCWei = (0, viem_1.parseUnits)(args.initialMarketCapUSD.toString(), 6);
|
|
61
|
+
const initialPriceParams = (0, viem_1.encodeAbiParameters)([{ type: "uint256" }], [initialMCapInUSDCWei]);
|
|
62
|
+
const fairLaunchInBps = BigInt(args.fairLaunchPercent * 100);
|
|
63
|
+
// Convert premine percentage to token amount and calculate ETH required
|
|
64
|
+
const premineAmount = (constants_1.TOTAL_SUPPLY * BigInt(Math.floor(args.preminePercent * 100))) / 10000n;
|
|
65
|
+
const ethRequired = args.preminePercent > 0
|
|
66
|
+
? await (0, client_utils_1.ethRequiredToFlaunch)(walletProvider, {
|
|
67
|
+
premineAmount,
|
|
68
|
+
initialPriceParams,
|
|
69
|
+
slippagePercent: 5,
|
|
70
|
+
})
|
|
71
|
+
: 0n;
|
|
72
|
+
// Check ETH balance
|
|
73
|
+
if (ethRequired > 0n) {
|
|
74
|
+
const ethBalance = await walletProvider.getBalance();
|
|
75
|
+
if (ethBalance < ethRequired) {
|
|
76
|
+
throw new Error(`Insufficient ETH balance. Required: ${(0, viem_1.formatEther)(ethRequired)} ETH, Available: ${(0, viem_1.formatEther)(ethBalance)} ETH`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Upload image & token uri to ipfs
|
|
80
|
+
const tokenUri = await (0, metadata_utils_1.generateTokenUri)(args.name, args.symbol, {
|
|
76
81
|
metadata: {
|
|
77
|
-
|
|
82
|
+
image: args.image,
|
|
78
83
|
description: args.description,
|
|
79
84
|
websiteUrl: args.websiteUrl,
|
|
80
85
|
discordUrl: args.discordUrl,
|
|
@@ -82,42 +87,92 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
82
87
|
telegramUrl: args.telegramUrl,
|
|
83
88
|
},
|
|
84
89
|
});
|
|
90
|
+
// Fee split configuration
|
|
91
|
+
const creatorFeeAllocationInBps = args.creatorFeeAllocationPercent * 100;
|
|
92
|
+
let creatorShare = 10000000n;
|
|
93
|
+
let recipientShares = [];
|
|
94
|
+
if (args.creatorSplitPercent !== undefined && args.splitReceivers !== undefined) {
|
|
95
|
+
const VALID_SHARE_TOTAL = 10000000n; // 5 decimals as BigInt, 100 * 10^5
|
|
96
|
+
creatorShare = (BigInt(args.creatorSplitPercent) * VALID_SHARE_TOTAL) / 100n;
|
|
97
|
+
recipientShares = args.splitReceivers.map(receiver => {
|
|
98
|
+
return {
|
|
99
|
+
recipient: receiver.address,
|
|
100
|
+
share: (BigInt(receiver.percent) * VALID_SHARE_TOTAL) / 100n,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
const totalRecipientShares = recipientShares.reduce((acc, curr) => acc + curr.share, 0n);
|
|
104
|
+
const totalRecipientPercent = (totalRecipientShares * 100n) / VALID_SHARE_TOTAL;
|
|
105
|
+
// Check that recipient shares add up to 100%
|
|
106
|
+
if (totalRecipientPercent !== 100n) {
|
|
107
|
+
throw new Error(`Recipient shares must add up to exactly 100%, but they add up to ${totalRecipientPercent}%`);
|
|
108
|
+
}
|
|
109
|
+
const remainderShares = VALID_SHARE_TOTAL - totalRecipientShares;
|
|
110
|
+
creatorShare += remainderShares;
|
|
111
|
+
}
|
|
112
|
+
const initializeData = (0, viem_1.encodeAbiParameters)([
|
|
113
|
+
{
|
|
114
|
+
type: "tuple",
|
|
115
|
+
name: "params",
|
|
116
|
+
components: [
|
|
117
|
+
{ type: "uint256", name: "creatorShare" },
|
|
118
|
+
{
|
|
119
|
+
type: "tuple[]",
|
|
120
|
+
name: "recipientShares",
|
|
121
|
+
components: [
|
|
122
|
+
{ type: "address", name: "recipient" },
|
|
123
|
+
{ type: "uint256", name: "share" },
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
], [
|
|
129
|
+
{
|
|
130
|
+
creatorShare,
|
|
131
|
+
recipientShares,
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
const flaunchParams = {
|
|
135
|
+
name: args.name,
|
|
136
|
+
symbol: args.symbol,
|
|
137
|
+
tokenUri,
|
|
138
|
+
initialTokenFairLaunch: (constants_1.TOTAL_SUPPLY * fairLaunchInBps) / 10000n,
|
|
139
|
+
fairLaunchDuration: BigInt(args.fairLaunchDuration * 60),
|
|
140
|
+
premineAmount,
|
|
141
|
+
creator: walletProvider.getAddress(),
|
|
142
|
+
creatorFeeAllocation: creatorFeeAllocationInBps,
|
|
143
|
+
flaunchAt: 0n,
|
|
144
|
+
initialPriceParams,
|
|
145
|
+
feeCalculatorParams: "0x",
|
|
146
|
+
};
|
|
147
|
+
const treasuryManagerParams = {
|
|
148
|
+
manager: constants_1.AddressFeeSplitManagerAddress[chainId],
|
|
149
|
+
initializeData,
|
|
150
|
+
depositData: "0x",
|
|
151
|
+
};
|
|
152
|
+
const whitelistParams = {
|
|
153
|
+
merkleRoot: viem_1.zeroHash,
|
|
154
|
+
merkleIPFSHash: "",
|
|
155
|
+
maxTokens: 0n,
|
|
156
|
+
};
|
|
157
|
+
const airdropParams = {
|
|
158
|
+
airdropIndex: 0n,
|
|
159
|
+
airdropAmount: 0n,
|
|
160
|
+
airdropEndTime: 0n,
|
|
161
|
+
merkleRoot: viem_1.zeroHash,
|
|
162
|
+
merkleIPFSHash: "",
|
|
163
|
+
};
|
|
85
164
|
const data = (0, viem_1.encodeFunctionData)({
|
|
86
|
-
abi: constants_1.
|
|
165
|
+
abi: constants_1.FLAUNCH_ZAP_ABI,
|
|
87
166
|
functionName: "flaunch",
|
|
88
|
-
args: [
|
|
89
|
-
{
|
|
90
|
-
name: args.name,
|
|
91
|
-
symbol: args.symbol,
|
|
92
|
-
tokenUri,
|
|
93
|
-
creator: walletProvider.getAddress(),
|
|
94
|
-
},
|
|
95
|
-
],
|
|
167
|
+
args: [flaunchParams, whitelistParams, airdropParams, treasuryManagerParams],
|
|
96
168
|
});
|
|
97
169
|
const hash = await walletProvider.sendTransaction({
|
|
98
|
-
to: constants_1.
|
|
170
|
+
to: constants_1.FlaunchZapAddress[chainId],
|
|
99
171
|
data,
|
|
172
|
+
value: ethRequired,
|
|
100
173
|
});
|
|
101
174
|
const receipt = await walletProvider.waitForTransactionReceipt(hash);
|
|
102
|
-
const
|
|
103
|
-
.map(log => {
|
|
104
|
-
try {
|
|
105
|
-
if (log.address.toLowerCase() !== constants_1.FlaunchPositionManagerAddress[chainId].toLowerCase()) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
const event = (0, viem_1.decodeEventLog)({
|
|
109
|
-
abi: constants_1.POSITION_MANAGER_ABI,
|
|
110
|
-
data: log.data,
|
|
111
|
-
topics: log.topics,
|
|
112
|
-
});
|
|
113
|
-
return event.eventName === "PoolCreated" ? event.args : null;
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
.filter((event) => event !== null)[0];
|
|
120
|
-
const memecoinAddress = filteredPoolCreatedEvent._memecoin;
|
|
175
|
+
const memecoinAddress = (0, client_utils_1.getMemecoinAddressFromReceipt)(receipt, chainId);
|
|
121
176
|
const chainSlug = Number(chainId) === chains_1.base.id ? "base" : "base-sepolia";
|
|
122
177
|
return `Flaunched\n ${JSON.stringify({
|
|
123
178
|
coinSymbol: `$${args.symbol}`,
|
|
@@ -140,7 +195,7 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
140
195
|
* @returns A promise that resolves to a string describing the transaction result
|
|
141
196
|
*/
|
|
142
197
|
async buyCoinWithETHInput(walletProvider, args) {
|
|
143
|
-
return
|
|
198
|
+
return (0, swap_utils_1.buyFlaunchCoin)(walletProvider, args.coinAddress, "EXACT_IN", { amountIn: args.amountIn }, args.slippagePercent);
|
|
144
199
|
}
|
|
145
200
|
/**
|
|
146
201
|
* Buys a flaunch coin using Coin input.
|
|
@@ -150,7 +205,7 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
150
205
|
* @returns A promise that resolves to a string describing the transaction result
|
|
151
206
|
*/
|
|
152
207
|
async buyCoinWithCoinInput(walletProvider, args) {
|
|
153
|
-
return
|
|
208
|
+
return (0, swap_utils_1.buyFlaunchCoin)(walletProvider, args.coinAddress, "EXACT_OUT", { amountOut: args.amountOut }, args.slippagePercent);
|
|
154
209
|
}
|
|
155
210
|
/**
|
|
156
211
|
* Sells a flaunch coin into ETH.
|
|
@@ -209,11 +264,7 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
209
264
|
signature = await walletProvider.signTypedData(typedData);
|
|
210
265
|
permitSingle = message;
|
|
211
266
|
}
|
|
212
|
-
const
|
|
213
|
-
chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
|
|
214
|
-
transport: (0, viem_1.http)(),
|
|
215
|
-
});
|
|
216
|
-
const quoteResult = await viemPublicClient.simulateContract({
|
|
267
|
+
const quoteResult = await walletProvider.getPublicClient().simulateContract({
|
|
217
268
|
address: constants_1.QuoterAddress[chainId],
|
|
218
269
|
abi: constants_1.QUOTER_ABI,
|
|
219
270
|
functionName: "quoteExactInput",
|
|
@@ -225,7 +276,7 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
225
276
|
{
|
|
226
277
|
fee: 0,
|
|
227
278
|
tickSpacing: 60,
|
|
228
|
-
hooks: constants_1.
|
|
279
|
+
hooks: constants_1.FlaunchPositionManagerV1_1Address[chainId],
|
|
229
280
|
hookData: "0x",
|
|
230
281
|
intermediateCurrency: constants_1.FLETHAddress[chainId],
|
|
231
282
|
},
|
|
@@ -240,9 +291,9 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
240
291
|
},
|
|
241
292
|
],
|
|
242
293
|
});
|
|
243
|
-
const ethOutMin = (0,
|
|
294
|
+
const ethOutMin = (0, swap_utils_1.getAmountWithSlippage)(quoteResult.result[0], // amountOut
|
|
244
295
|
(args.slippagePercent / 100).toFixed(18).toString(), "EXACT_IN");
|
|
245
|
-
const { commands, inputs } = (0,
|
|
296
|
+
const { commands, inputs } = (0, swap_utils_1.memecoinToEthWithPermit2)({
|
|
246
297
|
chainId: Number(chainId),
|
|
247
298
|
memecoin: args.coinAddress,
|
|
248
299
|
amountIn,
|
|
@@ -261,7 +312,7 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
261
312
|
data,
|
|
262
313
|
});
|
|
263
314
|
const receipt = await walletProvider.waitForTransactionReceipt(hash);
|
|
264
|
-
const swapAmounts = (0,
|
|
315
|
+
const swapAmounts = (0, swap_utils_1.getSwapAmountsFromReceipt)({
|
|
265
316
|
receipt,
|
|
266
317
|
coinAddress: args.coinAddress,
|
|
267
318
|
chainId: Number(chainId),
|
|
@@ -288,138 +339,6 @@ class FlaunchActionProvider extends actionProvider_1.ActionProvider {
|
|
|
288
339
|
// all protocol networks
|
|
289
340
|
return network.protocolFamily === "evm" && SUPPORTED_NETWORKS.includes(network.networkId);
|
|
290
341
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Handles the process of buying a flaunch coin with ETH.
|
|
293
|
-
*
|
|
294
|
-
* @param walletProvider - The wallet provider instance
|
|
295
|
-
* @param coinAddress - The address of the flaunch coin
|
|
296
|
-
* @param swapType - The type of swap (EXACT_IN or EXACT_OUT)
|
|
297
|
-
* @param swapParams - Parameters specific to the swap type
|
|
298
|
-
* @param swapParams.amountIn - The amount of ETH to spend (for EXACT_IN)
|
|
299
|
-
* @param swapParams.amountOut - The amount of coins to buy (for EXACT_OUT)
|
|
300
|
-
* @param slippagePercent - The slippage percentage
|
|
301
|
-
* @returns A promise that resolves to a string describing the transaction result
|
|
302
|
-
*/
|
|
303
|
-
async _buyFlaunchCoin(walletProvider, coinAddress, swapType, swapParams, slippagePercent) {
|
|
304
|
-
const network = walletProvider.getNetwork();
|
|
305
|
-
const chainId = network.chainId;
|
|
306
|
-
const networkId = network.networkId;
|
|
307
|
-
if (!chainId || !networkId) {
|
|
308
|
-
throw new Error("Chain ID is not set.");
|
|
309
|
-
}
|
|
310
|
-
try {
|
|
311
|
-
const viemPublicClient = (0, viem_1.createPublicClient)({
|
|
312
|
-
chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
|
|
313
|
-
transport: (0, viem_1.http)(),
|
|
314
|
-
});
|
|
315
|
-
let amountIn;
|
|
316
|
-
let amountOutMin;
|
|
317
|
-
let amountOut;
|
|
318
|
-
let amountInMax;
|
|
319
|
-
if (swapType === "EXACT_IN") {
|
|
320
|
-
amountIn = (0, viem_1.parseEther)(swapParams.amountIn);
|
|
321
|
-
const quoteResult = await viemPublicClient.simulateContract({
|
|
322
|
-
address: constants_1.QuoterAddress[chainId],
|
|
323
|
-
abi: constants_1.QUOTER_ABI,
|
|
324
|
-
functionName: "quoteExactInput",
|
|
325
|
-
args: [
|
|
326
|
-
{
|
|
327
|
-
exactAmount: amountIn,
|
|
328
|
-
exactCurrency: viem_1.zeroAddress, // ETH
|
|
329
|
-
path: [
|
|
330
|
-
{
|
|
331
|
-
fee: 0,
|
|
332
|
-
tickSpacing: 60,
|
|
333
|
-
hookData: "0x",
|
|
334
|
-
hooks: constants_1.FLETHHooksAddress[chainId],
|
|
335
|
-
intermediateCurrency: constants_1.FLETHAddress[chainId],
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
fee: 0,
|
|
339
|
-
tickSpacing: 60,
|
|
340
|
-
hooks: constants_1.FlaunchPositionManagerAddress[chainId],
|
|
341
|
-
hookData: "0x",
|
|
342
|
-
intermediateCurrency: coinAddress,
|
|
343
|
-
},
|
|
344
|
-
],
|
|
345
|
-
},
|
|
346
|
-
],
|
|
347
|
-
});
|
|
348
|
-
amountOutMin = (0, utils_1.getAmountWithSlippage)(quoteResult.result[0], // amountOut
|
|
349
|
-
(slippagePercent / 100).toFixed(18).toString(), swapType);
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
// EXACT_OUT
|
|
353
|
-
amountOut = (0, viem_1.parseEther)(swapParams.amountOut);
|
|
354
|
-
const quoteResult = await viemPublicClient.simulateContract({
|
|
355
|
-
address: constants_1.QuoterAddress[chainId],
|
|
356
|
-
abi: constants_1.QUOTER_ABI,
|
|
357
|
-
functionName: "quoteExactOutput",
|
|
358
|
-
args: [
|
|
359
|
-
{
|
|
360
|
-
path: [
|
|
361
|
-
{
|
|
362
|
-
intermediateCurrency: viem_1.zeroAddress,
|
|
363
|
-
fee: 0,
|
|
364
|
-
tickSpacing: 60,
|
|
365
|
-
hookData: "0x",
|
|
366
|
-
hooks: constants_1.FLETHHooksAddress[chainId],
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
intermediateCurrency: constants_1.FLETHAddress[chainId],
|
|
370
|
-
fee: 0,
|
|
371
|
-
tickSpacing: 60,
|
|
372
|
-
hooks: constants_1.FlaunchPositionManagerAddress[chainId],
|
|
373
|
-
hookData: "0x",
|
|
374
|
-
},
|
|
375
|
-
],
|
|
376
|
-
exactCurrency: coinAddress,
|
|
377
|
-
exactAmount: amountOut,
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
});
|
|
381
|
-
amountInMax = (0, utils_1.getAmountWithSlippage)(quoteResult.result[0], // amountIn
|
|
382
|
-
(slippagePercent / 100).toFixed(18).toString(), swapType);
|
|
383
|
-
}
|
|
384
|
-
const { commands, inputs } = (0, utils_1.ethToMemecoin)({
|
|
385
|
-
sender: walletProvider.getAddress(),
|
|
386
|
-
memecoin: coinAddress,
|
|
387
|
-
chainId: Number(chainId),
|
|
388
|
-
referrer: viem_1.zeroAddress,
|
|
389
|
-
swapType,
|
|
390
|
-
amountIn,
|
|
391
|
-
amountOutMin,
|
|
392
|
-
amountOut,
|
|
393
|
-
amountInMax,
|
|
394
|
-
});
|
|
395
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
396
|
-
abi: constants_1.UNIVERSAL_ROUTER_ABI,
|
|
397
|
-
functionName: "execute",
|
|
398
|
-
args: [commands, inputs],
|
|
399
|
-
});
|
|
400
|
-
const hash = await walletProvider.sendTransaction({
|
|
401
|
-
to: constants_1.UniversalRouterAddress[chainId],
|
|
402
|
-
data,
|
|
403
|
-
value: swapType === "EXACT_IN" ? amountIn : amountInMax,
|
|
404
|
-
});
|
|
405
|
-
const receipt = await walletProvider.waitForTransactionReceipt(hash);
|
|
406
|
-
const swapAmounts = (0, utils_1.getSwapAmountsFromReceipt)({
|
|
407
|
-
receipt,
|
|
408
|
-
coinAddress: coinAddress,
|
|
409
|
-
chainId: Number(chainId),
|
|
410
|
-
});
|
|
411
|
-
const coinSymbol = await walletProvider.readContract({
|
|
412
|
-
address: coinAddress,
|
|
413
|
-
abi: constants_1.ERC20_ABI,
|
|
414
|
-
functionName: "symbol",
|
|
415
|
-
});
|
|
416
|
-
return `Bought ${(0, viem_1.formatEther)(swapAmounts.coinsBought)} $${coinSymbol} for ${(0, viem_1.formatEther)(swapAmounts.ethSold)} ETH\n
|
|
417
|
-
Tx hash: [${hash}](${network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId].blockExplorers?.default.url}/tx/${hash})`;
|
|
418
|
-
}
|
|
419
|
-
catch (error) {
|
|
420
|
-
return `Error buying coin: ${error}`;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
342
|
}
|
|
424
343
|
exports.FlaunchActionProvider = FlaunchActionProvider;
|
|
425
344
|
__decorate([
|
|
@@ -431,16 +350,22 @@ This tool allows launching a new memecoin using the flaunch protocol.
|
|
|
431
350
|
It takes:
|
|
432
351
|
- name: The name of the token
|
|
433
352
|
- symbol: The symbol of the token
|
|
434
|
-
-
|
|
353
|
+
- image: Local image file path or URL to the token image
|
|
435
354
|
- description: Description of the token
|
|
436
|
-
|
|
437
|
-
-
|
|
438
|
-
-
|
|
439
|
-
-
|
|
440
|
-
-
|
|
355
|
+
- fairLaunchPercent: The percentage of tokens for fair launch (defaults to 60%)
|
|
356
|
+
- fairLaunchDuration: The duration of the fair launch in minutes (defaults to 30 minutes)
|
|
357
|
+
- initialMarketCapUSD: The initial market cap in USD (defaults to 10000 USD)
|
|
358
|
+
- preminePercent: The percentage of total supply to premine (defaults to 0%, max is equal to fairLaunchPercent)
|
|
359
|
+
- creatorFeeAllocationPercent: The percentage of fees allocated to creator and optional receivers (defaults to 80%)
|
|
360
|
+
- creatorSplitPercent: The percentage of fees allocated to the creator (defaults to 100%), remainder goes to fee split recipients
|
|
361
|
+
- splitReceivers: Array of fee split recipients with address and percentage (optional)
|
|
362
|
+
- websiteUrl: URL to the token website (optional)
|
|
363
|
+
- discordUrl: URL to the token Discord (optional)
|
|
364
|
+
- twitterUrl: URL to the token Twitter (optional)
|
|
365
|
+
- telegramUrl: URL to the token Telegram (optional)
|
|
441
366
|
|
|
442
367
|
Note:
|
|
443
|
-
-
|
|
368
|
+
- splitReceivers must add up to exactly 100% if provided.
|
|
444
369
|
`,
|
|
445
370
|
schema: schemas_1.FlaunchSchema,
|
|
446
371
|
}),
|
|
@@ -512,8 +437,7 @@ It takes:
|
|
|
512
437
|
/**
|
|
513
438
|
* Factory function to create a new FlaunchActionProvider instance.
|
|
514
439
|
*
|
|
515
|
-
* @param config - Configuration options for the FlaunchActionProvider
|
|
516
440
|
* @returns A new FlaunchActionProvider instance
|
|
517
441
|
*/
|
|
518
|
-
const flaunchActionProvider = (
|
|
442
|
+
const flaunchActionProvider = () => new FlaunchActionProvider();
|
|
519
443
|
exports.flaunchActionProvider = flaunchActionProvider;
|
|
@@ -1,8 +1,42 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
const flaunchActionProvider_1 = require("./flaunchActionProvider");
|
|
4
37
|
const schemas_1 = require("./schemas");
|
|
5
38
|
const viem_1 = require("viem");
|
|
39
|
+
const swapUtils = __importStar(require("./swap_utils"));
|
|
6
40
|
// Mock the actual contract calls with Jest
|
|
7
41
|
jest.mock("viem", () => {
|
|
8
42
|
const originalModule = jest.requireActual("viem");
|
|
@@ -22,27 +56,54 @@ jest.mock("viem", () => {
|
|
|
22
56
|
};
|
|
23
57
|
}),
|
|
24
58
|
parseEther: jest.fn().mockReturnValue(BigInt(100000000000000000)),
|
|
59
|
+
parseUnits: jest.fn().mockReturnValue(BigInt(100000000000000000)),
|
|
60
|
+
encodeAbiParameters: jest.fn().mockReturnValue("0xencoded"),
|
|
61
|
+
encodeFunctionData: jest.fn().mockReturnValue("0xfunctiondata"),
|
|
25
62
|
zeroAddress: "0x0000000000000000000000000000000000000000",
|
|
63
|
+
zeroHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
26
64
|
};
|
|
27
65
|
});
|
|
28
|
-
// Mock the
|
|
29
|
-
jest.mock("./
|
|
66
|
+
// Mock the metadata_utils module
|
|
67
|
+
jest.mock("./metadata_utils", () => ({
|
|
30
68
|
generateTokenUri: jest.fn().mockResolvedValue("ipfs://test-uri"),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
69
|
+
}));
|
|
70
|
+
// Mock the client_utils module
|
|
71
|
+
jest.mock("./client_utils", () => ({
|
|
72
|
+
ethRequiredToFlaunch: jest.fn().mockResolvedValue(BigInt(100000000000000000)),
|
|
73
|
+
getMemecoinAddressFromReceipt: jest
|
|
74
|
+
.fn()
|
|
75
|
+
.mockReturnValue("0x1234567890123456789012345678901234567890"),
|
|
76
|
+
}));
|
|
77
|
+
// Mock the swap_utils module
|
|
78
|
+
jest.mock("./swap_utils", () => ({
|
|
79
|
+
getAmountWithSlippage: jest.fn().mockImplementation(amount => amount),
|
|
35
80
|
memecoinToEthWithPermit2: jest.fn().mockReturnValue({
|
|
36
81
|
commands: "0x02",
|
|
37
82
|
inputs: ["0x5678"],
|
|
38
83
|
}),
|
|
39
|
-
getAmountWithSlippage: jest.fn().mockImplementation(amount => amount),
|
|
40
84
|
getSwapAmountsFromReceipt: jest.fn().mockImplementation(() => ({
|
|
41
85
|
coinsBought: BigInt(1000000000000000000),
|
|
42
86
|
ethSold: BigInt(100000000000000000),
|
|
43
87
|
coinsSold: BigInt(1000000000000000000),
|
|
44
88
|
ethBought: BigInt(100000000000000000),
|
|
45
89
|
})),
|
|
90
|
+
buyFlaunchCoin: jest
|
|
91
|
+
.fn()
|
|
92
|
+
.mockImplementation(async (walletProvider, coinAddress, _swapType, _amount, _slippagePercent) => {
|
|
93
|
+
// Simulate the actual behavior by calling wallet provider methods
|
|
94
|
+
walletProvider.getNetwork();
|
|
95
|
+
const coinSymbol = await walletProvider.readContract({
|
|
96
|
+
address: coinAddress,
|
|
97
|
+
abi: [],
|
|
98
|
+
functionName: "symbol",
|
|
99
|
+
});
|
|
100
|
+
const hash = await walletProvider.sendTransaction({
|
|
101
|
+
to: coinAddress,
|
|
102
|
+
data: "0x",
|
|
103
|
+
});
|
|
104
|
+
await walletProvider.waitForTransactionReceipt(hash);
|
|
105
|
+
return `Bought ${(0, viem_1.formatEther)(BigInt(1000000000000000000))} $${coinSymbol} for ${(0, viem_1.formatEther)(BigInt(100000000000000000))} ETH`;
|
|
106
|
+
}),
|
|
46
107
|
}));
|
|
47
108
|
// Mock the constants used in the test
|
|
48
109
|
jest.mock("./constants", () => {
|
|
@@ -85,7 +146,7 @@ jest.mock("./constants", () => {
|
|
|
85
146
|
};
|
|
86
147
|
});
|
|
87
148
|
describe("FlaunchActionProvider", () => {
|
|
88
|
-
const provider = new flaunchActionProvider_1.FlaunchActionProvider(
|
|
149
|
+
const provider = new flaunchActionProvider_1.FlaunchActionProvider();
|
|
89
150
|
let mockWalletProvider;
|
|
90
151
|
beforeEach(() => {
|
|
91
152
|
mockWalletProvider = {
|
|
@@ -116,6 +177,11 @@ describe("FlaunchActionProvider", () => {
|
|
|
116
177
|
return undefined;
|
|
117
178
|
}),
|
|
118
179
|
signTypedData: jest.fn().mockResolvedValue("0xsignature"),
|
|
180
|
+
getPublicClient: jest.fn().mockReturnValue({
|
|
181
|
+
simulateContract: jest.fn().mockResolvedValue({
|
|
182
|
+
result: [BigInt(1000000000000000000)],
|
|
183
|
+
}),
|
|
184
|
+
}),
|
|
119
185
|
};
|
|
120
186
|
});
|
|
121
187
|
describe("network support", () => {
|
|
@@ -150,9 +216,10 @@ describe("FlaunchActionProvider", () => {
|
|
|
150
216
|
const validInput = {
|
|
151
217
|
name: "Test Token",
|
|
152
218
|
symbol: "TEST",
|
|
153
|
-
|
|
219
|
+
image: "https://example.com/image.png",
|
|
154
220
|
description: "A test token",
|
|
155
221
|
websiteUrl: "https://example.com",
|
|
222
|
+
premineAmount: 5,
|
|
156
223
|
};
|
|
157
224
|
const parseResult = schemas_1.FlaunchSchema.safeParse(validInput);
|
|
158
225
|
expect(parseResult.success).toBe(true);
|
|
@@ -161,8 +228,9 @@ describe("FlaunchActionProvider", () => {
|
|
|
161
228
|
const invalidInput = {
|
|
162
229
|
name: "",
|
|
163
230
|
symbol: "",
|
|
164
|
-
|
|
231
|
+
image: "not-a-url",
|
|
165
232
|
description: "",
|
|
233
|
+
premineAmount: 150, // Invalid: exceeds 100%
|
|
166
234
|
};
|
|
167
235
|
const parseResult = schemas_1.FlaunchSchema.safeParse(invalidInput);
|
|
168
236
|
expect(parseResult.success).toBe(false);
|
|
@@ -200,9 +268,21 @@ describe("FlaunchActionProvider", () => {
|
|
|
200
268
|
const args = {
|
|
201
269
|
name: "Test Token",
|
|
202
270
|
symbol: "TEST",
|
|
203
|
-
|
|
271
|
+
image: "https://example.com/image.png",
|
|
204
272
|
description: "A test token",
|
|
205
273
|
websiteUrl: "https://example.com",
|
|
274
|
+
fairLaunchPercent: 60,
|
|
275
|
+
fairLaunchDuration: 30,
|
|
276
|
+
initialMarketCapUSD: 10000,
|
|
277
|
+
creatorFeeAllocationPercent: 80,
|
|
278
|
+
creatorSplitPercent: 50,
|
|
279
|
+
splitReceivers: [
|
|
280
|
+
{
|
|
281
|
+
address: "0x1234567890123456789012345678901234567890",
|
|
282
|
+
percent: 100,
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
preminePercent: 5,
|
|
206
286
|
};
|
|
207
287
|
const result = await provider.flaunch(mockWalletProvider, args);
|
|
208
288
|
console.log("Test result:", result);
|
|
@@ -212,6 +292,24 @@ describe("FlaunchActionProvider", () => {
|
|
|
212
292
|
expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
|
|
213
293
|
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
|
|
214
294
|
});
|
|
295
|
+
it("should reject premineAmount exceeding fairLaunchPercent", async () => {
|
|
296
|
+
const args = {
|
|
297
|
+
name: "Test Token",
|
|
298
|
+
symbol: "TEST",
|
|
299
|
+
image: "https://example.com/image.png",
|
|
300
|
+
description: "A test token",
|
|
301
|
+
websiteUrl: "https://example.com",
|
|
302
|
+
fairLaunchPercent: 60,
|
|
303
|
+
fairLaunchDuration: 30,
|
|
304
|
+
initialMarketCapUSD: 10000,
|
|
305
|
+
creatorFeeAllocationPercent: 80,
|
|
306
|
+
creatorSplitPercent: 50,
|
|
307
|
+
splitReceivers: [],
|
|
308
|
+
preminePercent: 70, // Invalid: exceeds fairLaunchPercent of 60%
|
|
309
|
+
};
|
|
310
|
+
const result = await provider.flaunch(mockWalletProvider, args);
|
|
311
|
+
expect(result).toContain("premineAmount (70%) cannot exceed fairLaunchPercent (60%)");
|
|
312
|
+
});
|
|
215
313
|
});
|
|
216
314
|
describe("buyCoinWithETHInput action", () => {
|
|
217
315
|
it("should execute buyCoinWithETHInput action with wallet provider", async () => {
|
|
@@ -230,7 +328,8 @@ describe("FlaunchActionProvider", () => {
|
|
|
230
328
|
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
|
|
231
329
|
});
|
|
232
330
|
it("should handle errors in buyCoinWithETHInput", async () => {
|
|
233
|
-
|
|
331
|
+
// Mock buyFlaunchCoin to return an error string
|
|
332
|
+
swapUtils.buyFlaunchCoin.mockResolvedValueOnce("Error buying coin: Transaction failed");
|
|
234
333
|
const args = {
|
|
235
334
|
coinAddress: "0x1234567890123456789012345678901234567890",
|
|
236
335
|
amountIn: "0.1",
|
|
@@ -257,7 +356,8 @@ describe("FlaunchActionProvider", () => {
|
|
|
257
356
|
expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
|
|
258
357
|
});
|
|
259
358
|
it("should handle errors in buyCoinWithCoinInput", async () => {
|
|
260
|
-
|
|
359
|
+
// Mock buyFlaunchCoin to return an error string
|
|
360
|
+
swapUtils.buyFlaunchCoin.mockResolvedValueOnce("Error buying coin: Transaction failed");
|
|
261
361
|
const args = {
|
|
262
362
|
coinAddress: "0x1234567890123456789012345678901234567890",
|
|
263
363
|
amountOut: "1000",
|