mint.club-cli 1.0.0
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 +43 -0
- package/dist/abi/bond.d.ts +244 -0
- package/dist/abi/bond.js +323 -0
- package/dist/abi/bond.js.map +1 -0
- package/dist/abi/zap-v2.d.ts +93 -0
- package/dist/abi/zap-v2.js +121 -0
- package/dist/abi/zap-v2.js.map +1 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +38 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/buy.d.ts +2 -0
- package/dist/commands/buy.js +77 -0
- package/dist/commands/buy.js.map +1 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.js +85 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/info.d.ts +19 -0
- package/dist/commands/info.js +139 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/sell.d.ts +2 -0
- package/dist/commands/sell.js +77 -0
- package/dist/commands/sell.js.map +1 -0
- package/dist/commands/zap-buy.d.ts +2 -0
- package/dist/commands/zap-buy.js +93 -0
- package/dist/commands/zap-buy.js.map +1 -0
- package/dist/commands/zap-sell.d.ts +2 -0
- package/dist/commands/zap-sell.js +89 -0
- package/dist/commands/zap-sell.js.map +1 -0
- package/dist/config/chains.d.ts +782 -0
- package/dist/config/chains.js +260 -0
- package/dist/config/chains.js.map +1 -0
- package/dist/config/contracts.d.ts +44 -0
- package/dist/config/contracts.js +59 -0
- package/dist/config/contracts.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/format.d.ts +26 -0
- package/dist/utils/format.js +54 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/swap.d.ts +8 -0
- package/dist/utils/swap.js +48 -0
- package/dist/utils/swap.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare const MCV2_ZAP_V2_ABI: readonly [{
|
|
2
|
+
readonly type: "function";
|
|
3
|
+
readonly name: "zapMint";
|
|
4
|
+
readonly inputs: readonly [{
|
|
5
|
+
readonly name: "token";
|
|
6
|
+
readonly type: "address";
|
|
7
|
+
readonly internalType: "address";
|
|
8
|
+
}, {
|
|
9
|
+
readonly name: "inputToken";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
readonly internalType: "address";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "inputAmount";
|
|
14
|
+
readonly type: "uint256";
|
|
15
|
+
readonly internalType: "uint256";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "minTokensOut";
|
|
18
|
+
readonly type: "uint256";
|
|
19
|
+
readonly internalType: "uint256";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "commands";
|
|
22
|
+
readonly type: "bytes";
|
|
23
|
+
readonly internalType: "bytes";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "inputs";
|
|
26
|
+
readonly type: "bytes[]";
|
|
27
|
+
readonly internalType: "bytes[]";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "deadline";
|
|
30
|
+
readonly type: "uint256";
|
|
31
|
+
readonly internalType: "uint256";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "receiver";
|
|
34
|
+
readonly type: "address";
|
|
35
|
+
readonly internalType: "address";
|
|
36
|
+
}];
|
|
37
|
+
readonly outputs: readonly [{
|
|
38
|
+
readonly name: "tokensReceived";
|
|
39
|
+
readonly type: "uint256";
|
|
40
|
+
readonly internalType: "uint256";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "reserveUsed";
|
|
43
|
+
readonly type: "uint256";
|
|
44
|
+
readonly internalType: "uint256";
|
|
45
|
+
}];
|
|
46
|
+
readonly stateMutability: "payable";
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "function";
|
|
49
|
+
readonly name: "zapBurn";
|
|
50
|
+
readonly inputs: readonly [{
|
|
51
|
+
readonly name: "token";
|
|
52
|
+
readonly type: "address";
|
|
53
|
+
readonly internalType: "address";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "tokensToBurn";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
readonly internalType: "uint256";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "outputToken";
|
|
60
|
+
readonly type: "address";
|
|
61
|
+
readonly internalType: "address";
|
|
62
|
+
}, {
|
|
63
|
+
readonly name: "minOutputAmount";
|
|
64
|
+
readonly type: "uint256";
|
|
65
|
+
readonly internalType: "uint256";
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "commands";
|
|
68
|
+
readonly type: "bytes";
|
|
69
|
+
readonly internalType: "bytes";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "inputs";
|
|
72
|
+
readonly type: "bytes[]";
|
|
73
|
+
readonly internalType: "bytes[]";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "deadline";
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
readonly internalType: "uint256";
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "receiver";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
readonly internalType: "address";
|
|
82
|
+
}];
|
|
83
|
+
readonly outputs: readonly [{
|
|
84
|
+
readonly name: "outputAmount";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
readonly internalType: "uint256";
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "reserveReceived";
|
|
89
|
+
readonly type: "uint256";
|
|
90
|
+
readonly internalType: "uint256";
|
|
91
|
+
}];
|
|
92
|
+
readonly stateMutability: "nonpayable";
|
|
93
|
+
}];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export const MCV2_ZAP_V2_ABI = [
|
|
2
|
+
{
|
|
3
|
+
"type": "function",
|
|
4
|
+
"name": "zapMint",
|
|
5
|
+
"inputs": [
|
|
6
|
+
{
|
|
7
|
+
"name": "token",
|
|
8
|
+
"type": "address",
|
|
9
|
+
"internalType": "address"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "inputToken",
|
|
13
|
+
"type": "address",
|
|
14
|
+
"internalType": "address"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "inputAmount",
|
|
18
|
+
"type": "uint256",
|
|
19
|
+
"internalType": "uint256"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "minTokensOut",
|
|
23
|
+
"type": "uint256",
|
|
24
|
+
"internalType": "uint256"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "commands",
|
|
28
|
+
"type": "bytes",
|
|
29
|
+
"internalType": "bytes"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "inputs",
|
|
33
|
+
"type": "bytes[]",
|
|
34
|
+
"internalType": "bytes[]"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "deadline",
|
|
38
|
+
"type": "uint256",
|
|
39
|
+
"internalType": "uint256"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "receiver",
|
|
43
|
+
"type": "address",
|
|
44
|
+
"internalType": "address"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"outputs": [
|
|
48
|
+
{
|
|
49
|
+
"name": "tokensReceived",
|
|
50
|
+
"type": "uint256",
|
|
51
|
+
"internalType": "uint256"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "reserveUsed",
|
|
55
|
+
"type": "uint256",
|
|
56
|
+
"internalType": "uint256"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"stateMutability": "payable"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "function",
|
|
63
|
+
"name": "zapBurn",
|
|
64
|
+
"inputs": [
|
|
65
|
+
{
|
|
66
|
+
"name": "token",
|
|
67
|
+
"type": "address",
|
|
68
|
+
"internalType": "address"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "tokensToBurn",
|
|
72
|
+
"type": "uint256",
|
|
73
|
+
"internalType": "uint256"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "outputToken",
|
|
77
|
+
"type": "address",
|
|
78
|
+
"internalType": "address"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "minOutputAmount",
|
|
82
|
+
"type": "uint256",
|
|
83
|
+
"internalType": "uint256"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "commands",
|
|
87
|
+
"type": "bytes",
|
|
88
|
+
"internalType": "bytes"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "inputs",
|
|
92
|
+
"type": "bytes[]",
|
|
93
|
+
"internalType": "bytes[]"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "deadline",
|
|
97
|
+
"type": "uint256",
|
|
98
|
+
"internalType": "uint256"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "receiver",
|
|
102
|
+
"type": "address",
|
|
103
|
+
"internalType": "address"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"outputs": [
|
|
107
|
+
{
|
|
108
|
+
"name": "outputAmount",
|
|
109
|
+
"type": "uint256",
|
|
110
|
+
"internalType": "uint256"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "reserveReceived",
|
|
114
|
+
"type": "uint256",
|
|
115
|
+
"internalType": "uint256"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"stateMutability": "nonpayable"
|
|
119
|
+
}
|
|
120
|
+
];
|
|
121
|
+
//# sourceMappingURL=zap-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zap-v2.js","sourceRoot":"","sources":["../../src/abi/zap-v2.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B;QACE,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE;YACR;gBACE,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE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iBAAiB;gBACzB,MAAM,EAAE,SAAS;gBACjB,cAAc,EAAE,SAAS;aAC1B;YACD;gBACE,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,OAAO;gBACf,cAAc,EAAE,OAAO;aACxB;YACD;gBACE,MAAM,EAAE,QAAQ;gBAChB,MAAM,EAAE,SAAS;gBACjB,cAAc,EAAE,SAAS;aAC1B;YACD;gBACE,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,SAAS;gBACjB,cAAc,EAAE,SAAS;aAC1B;YACD;gBACE,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,SAAS;gBACjB,cAAc,EAAE,SAAS;aAC1B;SACF;QACD,SAAS,EAAE;YACT;gBACE,MAAM,EAAE,cAAc;gBACtB,MAAM,EAAE,SAAS;gBACjB,cAAc,EAAE,SAAS;aAC1B;YACD;gBACE,MAAM,EAAE,iBAAiB;gBACzB,MAAM,EAAE,SAAS;gBACjB,cAAc,EAAE,SAAS;aAC1B;SACF;QACD,iBAAiB,EAAE,YAAY;KAChC;CACO,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Transport, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
import { type SupportedChain } from './config/chains.js';
|
|
3
|
+
export declare function createTransport(chain: SupportedChain): Transport;
|
|
4
|
+
export declare function getPublicClient(chain: SupportedChain): PublicClient;
|
|
5
|
+
export declare function getWalletClient(chain: SupportedChain, privateKey: `0x${string}`): WalletClient;
|
|
6
|
+
export declare function validateChain(chain: string): SupportedChain;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createPublicClient, createWalletClient, http, fallback } from 'viem';
|
|
2
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
|
+
import { supportedChains, chainRpcs } from './config/chains.js';
|
|
4
|
+
export function createTransport(chain) {
|
|
5
|
+
const rpcUrls = chainRpcs[chain];
|
|
6
|
+
const transports = rpcUrls.map(url => http(url, {
|
|
7
|
+
retryCount: 0,
|
|
8
|
+
timeout: 2000,
|
|
9
|
+
batch: true
|
|
10
|
+
}));
|
|
11
|
+
return fallback(transports, { rank: false });
|
|
12
|
+
}
|
|
13
|
+
export function getPublicClient(chain) {
|
|
14
|
+
const chainConfig = supportedChains[chain];
|
|
15
|
+
const transport = createTransport(chain);
|
|
16
|
+
return createPublicClient({
|
|
17
|
+
chain: chainConfig,
|
|
18
|
+
transport,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function getWalletClient(chain, privateKey) {
|
|
22
|
+
const chainConfig = supportedChains[chain];
|
|
23
|
+
const transport = createTransport(chain);
|
|
24
|
+
const account = privateKeyToAccount(privateKey);
|
|
25
|
+
return createWalletClient({
|
|
26
|
+
account,
|
|
27
|
+
chain: chainConfig,
|
|
28
|
+
transport,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function validateChain(chain) {
|
|
32
|
+
if (!(chain in supportedChains)) {
|
|
33
|
+
const supportedList = Object.keys(supportedChains).join(', ');
|
|
34
|
+
throw new Error(`Unsupported chain: ${chain}. Supported chains: ${supportedList}`);
|
|
35
|
+
}
|
|
36
|
+
return chain;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAE,QAAQ,EAAgD,MAAM,MAAM,CAAC;AAC5H,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAuB,MAAM,oBAAoB,CAAC;AAErF,MAAM,UAAU,eAAe,CAAC,KAAqB;IACnD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CACnC,IAAI,CAAC,GAAG,EAAE;QACR,UAAU,EAAE,CAAC;QACb,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,IAAI;KACZ,CAAC,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAqB;IACnD,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAEzC,OAAO,kBAAkB,CAAC;QACxB,KAAK,EAAE,WAAW;QAClB,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAqB,EAAE,UAAyB;IAC9E,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAEhD,OAAO,kBAAkB,CAAC;QACxB,OAAO;QACP,KAAK,EAAE,WAAW;QAClB,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,IAAI,CAAC,CAAC,KAAK,IAAI,eAAe,CAAC,EAAE,CAAC;QAChC,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,uBAAuB,aAAa,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,KAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { getPublicClient, getWalletClient } from '../client.js';
|
|
2
|
+
import { getBondAddress } from '../config/contracts.js';
|
|
3
|
+
import { MCV2_BOND_ABI } from '../abi/bond.js';
|
|
4
|
+
import { formatAmount, parseAmount, formatTxHash } from '../utils/format.js';
|
|
5
|
+
export async function buyCommand(tokenAddress, amount, maxCost, chain, privateKey) {
|
|
6
|
+
try {
|
|
7
|
+
console.log(`🛒 Buying ${amount} tokens of ${tokenAddress} on ${chain}...`);
|
|
8
|
+
const publicClient = getPublicClient(chain);
|
|
9
|
+
const walletClient = getWalletClient(chain, privateKey);
|
|
10
|
+
const bondAddress = getBondAddress(chain);
|
|
11
|
+
const tokensToMint = parseAmount(amount);
|
|
12
|
+
// Get the required reserve amount
|
|
13
|
+
console.log('💰 Calculating required reserve amount...');
|
|
14
|
+
const [reserveAmount, royalty] = await publicClient.readContract({
|
|
15
|
+
address: bondAddress,
|
|
16
|
+
abi: MCV2_BOND_ABI,
|
|
17
|
+
functionName: 'getReserveForToken',
|
|
18
|
+
args: [tokenAddress, tokensToMint],
|
|
19
|
+
});
|
|
20
|
+
const totalCost = reserveAmount + royalty;
|
|
21
|
+
console.log(` Reserve needed: ${formatAmount(reserveAmount)}`);
|
|
22
|
+
console.log(` Royalty: ${formatAmount(royalty)}`);
|
|
23
|
+
console.log(` Total cost: ${formatAmount(totalCost)}`);
|
|
24
|
+
// Check max cost if provided
|
|
25
|
+
if (maxCost) {
|
|
26
|
+
const maxCostWei = parseAmount(maxCost);
|
|
27
|
+
if (totalCost > maxCostWei) {
|
|
28
|
+
throw new Error(`Cost ${formatAmount(totalCost)} exceeds max cost ${formatAmount(maxCostWei)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Simulate the transaction first
|
|
32
|
+
console.log('🔍 Simulating transaction...');
|
|
33
|
+
await publicClient.simulateContract({
|
|
34
|
+
account: walletClient.account,
|
|
35
|
+
address: bondAddress,
|
|
36
|
+
abi: MCV2_BOND_ABI,
|
|
37
|
+
functionName: 'mint',
|
|
38
|
+
args: [
|
|
39
|
+
tokenAddress,
|
|
40
|
+
tokensToMint,
|
|
41
|
+
totalCost, // Use total cost as max to ensure it doesn't revert
|
|
42
|
+
walletClient.account.address,
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
// Execute the transaction
|
|
46
|
+
console.log('📤 Sending transaction...');
|
|
47
|
+
const hash = await walletClient.writeContract({
|
|
48
|
+
address: bondAddress,
|
|
49
|
+
abi: MCV2_BOND_ABI,
|
|
50
|
+
functionName: 'mint',
|
|
51
|
+
args: [
|
|
52
|
+
tokenAddress,
|
|
53
|
+
tokensToMint,
|
|
54
|
+
totalCost,
|
|
55
|
+
walletClient.account.address,
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
console.log(` Transaction hash: ${formatTxHash(hash)}`);
|
|
59
|
+
// Wait for confirmation
|
|
60
|
+
console.log('⏳ Waiting for confirmation...');
|
|
61
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
62
|
+
if (receipt.status === 'success') {
|
|
63
|
+
console.log('✅ Transaction confirmed!');
|
|
64
|
+
console.log(` Bought: ${amount} tokens`);
|
|
65
|
+
console.log(` Cost: ${formatAmount(totalCost)} reserve tokens`);
|
|
66
|
+
console.log(` Block: ${receipt.blockNumber}`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.log('❌ Transaction failed');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error('❌ Error:', error instanceof Error ? error.message : error);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=buy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buy.js","sourceRoot":"","sources":["../../src/commands/buy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YA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AAS,CAAC,iBAAiB,CAAC,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;IAEH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { SupportedChain } from '../config/chains.js';
|
|
2
|
+
export declare function createCommand(name: string, symbol: string, reserveToken: string, maxSupply: string, steps: string, chain: SupportedChain, privateKey: `0x${string}`, mintRoyalty?: number, burnRoyalty?: number): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { getPublicClient, getWalletClient } from '../client.js';
|
|
2
|
+
import { getBondAddress } from '../config/contracts.js';
|
|
3
|
+
import { MCV2_BOND_ABI } from '../abi/bond.js';
|
|
4
|
+
import { formatAmount, parseAmount, parseStepsInput, formatTxHash } from '../utils/format.js';
|
|
5
|
+
export async function createCommand(name, symbol, reserveToken, maxSupply, steps, chain, privateKey, mintRoyalty = 0, burnRoyalty = 0) {
|
|
6
|
+
try {
|
|
7
|
+
console.log(`🚀 Creating token "${name}" (${symbol}) on ${chain}...`);
|
|
8
|
+
const publicClient = getPublicClient(chain);
|
|
9
|
+
const walletClient = getWalletClient(chain, privateKey);
|
|
10
|
+
const bondAddress = getBondAddress(chain);
|
|
11
|
+
// Parse inputs
|
|
12
|
+
const maxSupplyWei = parseAmount(maxSupply);
|
|
13
|
+
const { stepRanges, stepPrices } = parseStepsInput(steps);
|
|
14
|
+
console.log(` Name: ${name}`);
|
|
15
|
+
console.log(` Symbol: ${symbol}`);
|
|
16
|
+
console.log(` Reserve Token: ${reserveToken}`);
|
|
17
|
+
console.log(` Max Supply: ${maxSupply}`);
|
|
18
|
+
console.log(` Mint Royalty: ${mintRoyalty / 100}%`);
|
|
19
|
+
console.log(` Burn Royalty: ${burnRoyalty / 100}%`);
|
|
20
|
+
console.log(` Steps: ${stepRanges.length} configured`);
|
|
21
|
+
// Get creation fee
|
|
22
|
+
console.log('💰 Checking creation fee...');
|
|
23
|
+
const creationFee = await publicClient.readContract({
|
|
24
|
+
address: bondAddress,
|
|
25
|
+
abi: MCV2_BOND_ABI,
|
|
26
|
+
functionName: 'creationFee',
|
|
27
|
+
});
|
|
28
|
+
console.log(` Creation fee: ${formatAmount(creationFee)} ETH`);
|
|
29
|
+
// Prepare parameters
|
|
30
|
+
const tokenParam = {
|
|
31
|
+
name,
|
|
32
|
+
symbol,
|
|
33
|
+
};
|
|
34
|
+
const bondParam = {
|
|
35
|
+
mintRoyalty: mintRoyalty,
|
|
36
|
+
burnRoyalty: burnRoyalty,
|
|
37
|
+
reserveToken: reserveToken,
|
|
38
|
+
maxSupply: maxSupplyWei,
|
|
39
|
+
stepRanges: stepRanges,
|
|
40
|
+
stepPrices: stepPrices,
|
|
41
|
+
};
|
|
42
|
+
// Simulate the transaction first
|
|
43
|
+
console.log('🔍 Simulating transaction...');
|
|
44
|
+
const { result } = await publicClient.simulateContract({
|
|
45
|
+
account: walletClient.account,
|
|
46
|
+
address: bondAddress,
|
|
47
|
+
abi: MCV2_BOND_ABI,
|
|
48
|
+
functionName: 'createToken',
|
|
49
|
+
args: [tokenParam, bondParam],
|
|
50
|
+
value: creationFee,
|
|
51
|
+
});
|
|
52
|
+
console.log(` Expected token address: ${result}`);
|
|
53
|
+
// Execute the transaction
|
|
54
|
+
console.log('📤 Sending transaction...');
|
|
55
|
+
const hash = await walletClient.writeContract({
|
|
56
|
+
address: bondAddress,
|
|
57
|
+
abi: MCV2_BOND_ABI,
|
|
58
|
+
functionName: 'createToken',
|
|
59
|
+
args: [tokenParam, bondParam],
|
|
60
|
+
value: creationFee,
|
|
61
|
+
});
|
|
62
|
+
console.log(` Transaction hash: ${formatTxHash(hash)}`);
|
|
63
|
+
// Wait for confirmation
|
|
64
|
+
console.log('⏳ Waiting for confirmation...');
|
|
65
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
66
|
+
if (receipt.status === 'success') {
|
|
67
|
+
console.log('✅ Token created successfully!');
|
|
68
|
+
console.log(` Token Address: ${result}`);
|
|
69
|
+
console.log(` Name: ${name} (${symbol})`);
|
|
70
|
+
console.log(` Block: ${receipt.blockNumber}`);
|
|
71
|
+
// Show helpful next steps
|
|
72
|
+
console.log('\n🔗 Next steps:');
|
|
73
|
+
console.log(` View info: mintclub info ${result} --chain ${chain}`);
|
|
74
|
+
console.log(` Buy tokens: mintclub buy ${result} --amount 1 --chain ${chain}`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log('❌ Transaction failed');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error('❌ Error:', error instanceof Error ? error.message : error);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG9F,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,MAAc,EACd,YAAoB,EACpB,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I,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,qBAAqB,MAAM,EAAE,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;YAEhD,0BAA0B;YAC1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,+BAA+B,MAAM,YAAY,KAAK,EAAE,CAAC,CAAC;YACtE,OAAO,CAAC,GAAG,CAAC,+BAA+B,MAAM,uBAAuB,KAAK,EAAE,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;IAEH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SupportedChain } from '../config/chains.js';
|
|
2
|
+
export declare function getTokenInfo(tokenAddress: `0x${string}`, chain: SupportedChain): Promise<{
|
|
3
|
+
name: string;
|
|
4
|
+
symbol: string;
|
|
5
|
+
address: `0x${string}`;
|
|
6
|
+
creator: `0x${string}`;
|
|
7
|
+
reserveToken: `0x${string}`;
|
|
8
|
+
reserveBalance: bigint;
|
|
9
|
+
currentSupply: bigint;
|
|
10
|
+
maxSupply: bigint;
|
|
11
|
+
mintRoyalty: number;
|
|
12
|
+
burnRoyalty: number;
|
|
13
|
+
createdAt: number;
|
|
14
|
+
steps: readonly {
|
|
15
|
+
rangeTo: bigint;
|
|
16
|
+
price: bigint;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
export declare function infoCommand(tokenAddress: string, chain: SupportedChain): Promise<void>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { getPublicClient } from '../client.js';
|
|
2
|
+
import { getBondAddress } from '../config/contracts.js';
|
|
3
|
+
import { MCV2_BOND_ABI } from '../abi/bond.js';
|
|
4
|
+
import { formatTokenInfo, formatAmount } from '../utils/format.js';
|
|
5
|
+
// ERC20 ABI for name, symbol, totalSupply, decimals
|
|
6
|
+
const ERC20_ABI = [
|
|
7
|
+
{
|
|
8
|
+
type: 'function',
|
|
9
|
+
name: 'name',
|
|
10
|
+
inputs: [],
|
|
11
|
+
outputs: [{ name: '', type: 'string', internalType: 'string' }],
|
|
12
|
+
stateMutability: 'view',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'function',
|
|
16
|
+
name: 'symbol',
|
|
17
|
+
inputs: [],
|
|
18
|
+
outputs: [{ name: '', type: 'string', internalType: 'string' }],
|
|
19
|
+
stateMutability: 'view',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'function',
|
|
23
|
+
name: 'totalSupply',
|
|
24
|
+
inputs: [],
|
|
25
|
+
outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
|
|
26
|
+
stateMutability: 'view',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'function',
|
|
30
|
+
name: 'decimals',
|
|
31
|
+
inputs: [],
|
|
32
|
+
outputs: [{ name: '', type: 'uint8', internalType: 'uint8' }],
|
|
33
|
+
stateMutability: 'view',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
export async function getTokenInfo(tokenAddress, chain) {
|
|
37
|
+
const client = getPublicClient(chain);
|
|
38
|
+
const bondAddress = getBondAddress(chain);
|
|
39
|
+
try {
|
|
40
|
+
// Get token basic info
|
|
41
|
+
const [name, symbol, totalSupply, decimals] = await client.multicall({
|
|
42
|
+
contracts: [
|
|
43
|
+
{
|
|
44
|
+
address: tokenAddress,
|
|
45
|
+
abi: ERC20_ABI,
|
|
46
|
+
functionName: 'name',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
address: tokenAddress,
|
|
50
|
+
abi: ERC20_ABI,
|
|
51
|
+
functionName: 'symbol',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
address: tokenAddress,
|
|
55
|
+
abi: ERC20_ABI,
|
|
56
|
+
functionName: 'totalSupply',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
address: tokenAddress,
|
|
60
|
+
abi: ERC20_ABI,
|
|
61
|
+
functionName: 'decimals',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
// Get bond info
|
|
66
|
+
const [bondInfo, maxSupply, steps] = await client.multicall({
|
|
67
|
+
contracts: [
|
|
68
|
+
{
|
|
69
|
+
address: bondAddress,
|
|
70
|
+
abi: MCV2_BOND_ABI,
|
|
71
|
+
functionName: 'tokenBond',
|
|
72
|
+
args: [tokenAddress],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
address: bondAddress,
|
|
76
|
+
abi: MCV2_BOND_ABI,
|
|
77
|
+
functionName: 'maxSupply',
|
|
78
|
+
args: [tokenAddress],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
address: bondAddress,
|
|
82
|
+
abi: MCV2_BOND_ABI,
|
|
83
|
+
functionName: 'getSteps',
|
|
84
|
+
args: [tokenAddress],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
if (bondInfo.status === 'failure') {
|
|
89
|
+
throw new Error('Token not found or not a Mint Club token');
|
|
90
|
+
}
|
|
91
|
+
const tokenInfo = {
|
|
92
|
+
name: name.result || 'Unknown',
|
|
93
|
+
symbol: symbol.result || 'Unknown',
|
|
94
|
+
address: tokenAddress,
|
|
95
|
+
creator: bondInfo.result[0],
|
|
96
|
+
reserveToken: bondInfo.result[4],
|
|
97
|
+
reserveBalance: bondInfo.result[5],
|
|
98
|
+
currentSupply: totalSupply.result || 0n,
|
|
99
|
+
maxSupply: maxSupply.result || 0n,
|
|
100
|
+
mintRoyalty: bondInfo.result[1],
|
|
101
|
+
burnRoyalty: bondInfo.result[2],
|
|
102
|
+
createdAt: Number(bondInfo.result[3]),
|
|
103
|
+
steps: steps.result || [],
|
|
104
|
+
};
|
|
105
|
+
return tokenInfo;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw new Error(`Failed to fetch token info: ${error instanceof Error ? error.message : error}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export async function infoCommand(tokenAddress, chain) {
|
|
112
|
+
try {
|
|
113
|
+
console.log(`🔍 Fetching token info for ${tokenAddress} on ${chain}...`);
|
|
114
|
+
const tokenInfo = await getTokenInfo(tokenAddress, chain);
|
|
115
|
+
console.log('\n' + formatTokenInfo(tokenInfo));
|
|
116
|
+
// Show current price if there's supply
|
|
117
|
+
if (tokenInfo.currentSupply > 0n && tokenInfo.steps.length > 0) {
|
|
118
|
+
const client = getPublicClient(chain);
|
|
119
|
+
const bondAddress = getBondAddress(chain);
|
|
120
|
+
try {
|
|
121
|
+
const [reserveFor1Token] = await client.readContract({
|
|
122
|
+
address: bondAddress,
|
|
123
|
+
abi: MCV2_BOND_ABI,
|
|
124
|
+
functionName: 'getReserveForToken',
|
|
125
|
+
args: [tokenAddress, 1n * (10n ** 18n)], // 1 token with 18 decimals
|
|
126
|
+
});
|
|
127
|
+
console.log(`\n💱 Current Price: ${formatAmount(reserveFor1Token)} reserve tokens per 1 ${tokenInfo.symbol}`);
|
|
128
|
+
}
|
|
129
|
+
catch (priceError) {
|
|
130
|
+
console.log('\n⚠️ Could not fetch current price');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error('❌ Error:', error instanceof Error ? error.message : error);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGnE,oDAAoD;AACpD,MAAM,SAAS,GAAG;IAChB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;QAC/D,eAAe,EAAE,MAAM;KACxB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;QAC/D,eAAe,EAAE,MAAM;KACxB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;KACxB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,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