@moltlaunch/sdk 2.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/src/types.ts ADDED
@@ -0,0 +1,122 @@
1
+ // MoltLaunch Types
2
+
3
+ export interface AgentProfile {
4
+ name: string;
5
+ symbol: string;
6
+ description: string;
7
+ capabilities: string[];
8
+ apiEndpoint: string;
9
+ githubRepo?: string;
10
+ website?: string;
11
+ twitter?: string;
12
+ telegram?: string;
13
+ logo?: string; // URL or file path
14
+ }
15
+
16
+ export interface LaunchConfig {
17
+ // Token Economics
18
+ totalSupply: number;
19
+ targetRaise: number; // in SOL
20
+ quoteMint?: string; // default SOL
21
+
22
+ // Bonding Curve
23
+ curveType: 'linear' | 'exponential' | 'marketcap' | 'custom';
24
+ initialMarketCap?: number;
25
+ migrationMarketCap?: number;
26
+
27
+ // Migration
28
+ migrationTarget: 'damm-v1' | 'damm-v2';
29
+ migrationFeeOption: 0 | 1 | 2 | 3 | 4 | 5; // 0.25% to 6%
30
+
31
+ // LP Distribution (must total 100%)
32
+ creatorLpPercentage: number;
33
+ platformLpPercentage: number;
34
+ creatorLockedLpPercentage: number;
35
+ platformLockedLpPercentage: number;
36
+
37
+ // Fees
38
+ tradingFeeBps: number; // basis points
39
+ creatorFeeShare: number; // 0-100, percentage of trading fees to creator
40
+
41
+ // Anti-rug features
42
+ vestingEnabled: boolean;
43
+ vestingDurationDays?: number;
44
+ cliffDays?: number;
45
+ }
46
+
47
+ export interface VerificationResult {
48
+ passed: boolean;
49
+ score: number; // 0-100
50
+ checks: {
51
+ apiLiveness: boolean;
52
+ apiResponsive: boolean;
53
+ githubExists: boolean;
54
+ capabilitiesVerified: boolean;
55
+ uniqueIdentity: boolean;
56
+ };
57
+ attestation?: string; // On-chain proof
58
+ timestamp: string;
59
+ }
60
+
61
+ export interface LaunchApplication {
62
+ id: string;
63
+ agent: AgentProfile;
64
+ config: LaunchConfig;
65
+ verification: VerificationResult | null;
66
+ status: 'pending' | 'verifying' | 'verified' | 'rejected' | 'live' | 'graduated';
67
+ createdAt: string;
68
+ updatedAt: string;
69
+ launchAddress?: string;
70
+ tokenMint?: string;
71
+ }
72
+
73
+ export interface LaunchResult {
74
+ success: boolean;
75
+ transactionId?: string;
76
+ poolAddress?: string;
77
+ tokenMint?: string;
78
+ configKey?: string;
79
+ error?: string;
80
+ }
81
+
82
+ export interface SwapParams {
83
+ tokenMint: string;
84
+ amountIn: number;
85
+ isBuy: boolean; // true = buy tokens, false = sell tokens
86
+ slippageBps: number;
87
+ }
88
+
89
+ export interface SwapResult {
90
+ success: boolean;
91
+ transactionId?: string;
92
+ amountIn: number;
93
+ amountOut: number;
94
+ priceImpact: number;
95
+ newPrice: number;
96
+ error?: string;
97
+ }
98
+
99
+ // Meteora DBC Program ID
100
+ export const DBC_PROGRAM_ID = 'dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN';
101
+
102
+ // MoltLaunch Platform Config
103
+ export const MOLTLAUNCH_CONFIG = {
104
+ platformWallet: '82rh4CG9bMfVLFcpWwUXAscVkAgtDqCXgcQ4k2bjuoEx',
105
+ platformFeePercentage: 20, // 20% of trading fees
106
+ minVerificationScore: 60, // minimum score to launch
107
+ defaultLaunchConfig: {
108
+ totalSupply: 1_000_000_000,
109
+ curveType: 'linear' as const,
110
+ migrationTarget: 'damm-v2' as const,
111
+ migrationFeeOption: 2 as const, // 1%
112
+ creatorLpPercentage: 40,
113
+ platformLpPercentage: 50,
114
+ creatorLockedLpPercentage: 5,
115
+ platformLockedLpPercentage: 5,
116
+ tradingFeeBps: 100, // 1%
117
+ creatorFeeShare: 80, // 80/20 split
118
+ vestingEnabled: true,
119
+ vestingDurationDays: 30,
120
+ cliffDays: 7,
121
+ }
122
+ };
@@ -0,0 +1,228 @@
1
+ // Agent Verification Service
2
+ import axios from 'axios';
3
+ import { AgentProfile, VerificationResult } from './types';
4
+
5
+ export class AgentVerifier {
6
+ private timeout: number;
7
+
8
+ constructor(timeout: number = 10000) {
9
+ this.timeout = timeout;
10
+ }
11
+
12
+ /**
13
+ * Verify an agent's liveness and capabilities
14
+ */
15
+ async verify(agent: AgentProfile): Promise<VerificationResult> {
16
+ const checks = {
17
+ apiLiveness: false,
18
+ apiResponsive: false,
19
+ githubExists: false,
20
+ capabilitiesVerified: false,
21
+ uniqueIdentity: false,
22
+ };
23
+
24
+ // 1. API Liveness Check
25
+ try {
26
+ const livenessResult = await this.checkApiLiveness(agent.apiEndpoint);
27
+ checks.apiLiveness = livenessResult.alive;
28
+ checks.apiResponsive = livenessResult.responseTime < 5000;
29
+ } catch (error) {
30
+ console.log('API liveness check failed:', error);
31
+ }
32
+
33
+ // 2. GitHub Check
34
+ if (agent.githubRepo) {
35
+ try {
36
+ checks.githubExists = await this.checkGithubRepo(agent.githubRepo);
37
+ } catch (error) {
38
+ console.log('GitHub check failed:', error);
39
+ }
40
+ }
41
+
42
+ // 3. Capabilities Verification (via API prompt)
43
+ if (checks.apiLiveness) {
44
+ try {
45
+ checks.capabilitiesVerified = await this.verifyCapabilities(
46
+ agent.apiEndpoint,
47
+ agent.capabilities
48
+ );
49
+ } catch (error) {
50
+ console.log('Capability verification failed:', error);
51
+ }
52
+ }
53
+
54
+ // 4. Unique Identity Check (placeholder for SAID/on-chain identity)
55
+ checks.uniqueIdentity = true; // TODO: Integrate with SAID protocol
56
+
57
+ // Calculate score
58
+ const score = this.calculateScore(checks);
59
+ const passed = score >= 60;
60
+
61
+ return {
62
+ passed,
63
+ score,
64
+ checks,
65
+ attestation: passed ? this.generateAttestation(agent, score) : undefined,
66
+ timestamp: new Date().toISOString(),
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Check if agent API is alive and responsive
72
+ */
73
+ private async checkApiLiveness(
74
+ endpoint: string
75
+ ): Promise<{ alive: boolean; responseTime: number }> {
76
+ const start = Date.now();
77
+
78
+ try {
79
+ // Try common health endpoints
80
+ const healthEndpoints = [
81
+ endpoint,
82
+ `${endpoint}/health`,
83
+ `${endpoint}/api/health`,
84
+ `${endpoint}/ping`,
85
+ ];
86
+
87
+ for (const url of healthEndpoints) {
88
+ try {
89
+ const response = await axios.get(url, { timeout: this.timeout });
90
+ if (response.status === 200) {
91
+ return { alive: true, responseTime: Date.now() - start };
92
+ }
93
+ } catch {
94
+ continue;
95
+ }
96
+ }
97
+
98
+ // Try POST with verification prompt
99
+ const response = await axios.post(
100
+ endpoint,
101
+ {
102
+ message: 'MoltLaunch verification ping. Please respond with your agent name.',
103
+ },
104
+ { timeout: this.timeout }
105
+ );
106
+
107
+ return {
108
+ alive: response.status === 200,
109
+ responseTime: Date.now() - start,
110
+ };
111
+ } catch (error) {
112
+ return { alive: false, responseTime: Date.now() - start };
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Check if GitHub repository exists and has recent activity
118
+ */
119
+ private async checkGithubRepo(repoUrl: string): Promise<boolean> {
120
+ try {
121
+ // Extract owner/repo from URL
122
+ const match = repoUrl.match(/github\.com\/([^\/]+)\/([^\/]+)/);
123
+ if (!match) return false;
124
+
125
+ const [, owner, repo] = match;
126
+ const apiUrl = `https://api.github.com/repos/${owner}/${repo.replace('.git', '')}`;
127
+
128
+ const response = await axios.get(apiUrl, {
129
+ timeout: this.timeout,
130
+ headers: { Accept: 'application/vnd.github.v3+json' },
131
+ });
132
+
133
+ // Check for recent activity (updated in last 30 days)
134
+ const updatedAt = new Date(response.data.updated_at);
135
+ const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
136
+
137
+ return response.status === 200 && updatedAt > thirtyDaysAgo;
138
+ } catch {
139
+ return false;
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Verify agent capabilities through API interaction
145
+ */
146
+ private async verifyCapabilities(
147
+ endpoint: string,
148
+ capabilities: string[]
149
+ ): Promise<boolean> {
150
+ const verificationPrompts: Record<string, string> = {
151
+ trading: 'What trading pairs do you support? Respond with a list.',
152
+ analysis: 'Provide a brief market analysis for SOL.',
153
+ automation: 'Describe one automation task you can perform.',
154
+ defi: 'What DeFi protocols do you integrate with?',
155
+ social: 'What social platforms do you monitor?',
156
+ nft: 'What NFT marketplaces do you support?',
157
+ };
158
+
159
+ let verifiedCount = 0;
160
+
161
+ for (const capability of capabilities) {
162
+ const prompt = verificationPrompts[capability.toLowerCase()];
163
+ if (!prompt) continue;
164
+
165
+ try {
166
+ const response = await axios.post(
167
+ endpoint,
168
+ { message: prompt },
169
+ { timeout: this.timeout }
170
+ );
171
+
172
+ // Basic check: response should be non-empty and relevant
173
+ if (
174
+ response.status === 200 &&
175
+ response.data &&
176
+ (typeof response.data === 'string' ? response.data.length > 20 : true)
177
+ ) {
178
+ verifiedCount++;
179
+ }
180
+ } catch {
181
+ continue;
182
+ }
183
+ }
184
+
185
+ // At least 50% of capabilities should be verified
186
+ return capabilities.length > 0 && verifiedCount / capabilities.length >= 0.5;
187
+ }
188
+
189
+ /**
190
+ * Calculate verification score (0-100)
191
+ */
192
+ private calculateScore(checks: VerificationResult['checks']): number {
193
+ const weights = {
194
+ apiLiveness: 30,
195
+ apiResponsive: 20,
196
+ githubExists: 15,
197
+ capabilitiesVerified: 25,
198
+ uniqueIdentity: 10,
199
+ };
200
+
201
+ let score = 0;
202
+ for (const [key, passed] of Object.entries(checks)) {
203
+ if (passed) {
204
+ score += weights[key as keyof typeof weights] || 0;
205
+ }
206
+ }
207
+
208
+ return score;
209
+ }
210
+
211
+ /**
212
+ * Generate verification attestation (placeholder for on-chain)
213
+ */
214
+ private generateAttestation(agent: AgentProfile, score: number): string {
215
+ const data = {
216
+ agentName: agent.name,
217
+ symbol: agent.symbol,
218
+ score,
219
+ verifiedAt: new Date().toISOString(),
220
+ verifier: 'MoltLaunch',
221
+ };
222
+
223
+ // TODO: Create actual on-chain attestation
224
+ return Buffer.from(JSON.stringify(data)).toString('base64');
225
+ }
226
+ }
227
+
228
+ export const verifier = new AgentVerifier();
package/test/basic.js ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Basic SDK tests
3
+ */
4
+
5
+ const { MoltLaunch, getTier, isVerified, DEPLOYMENT } = require('../src/index.js');
6
+
7
+ async function runTests() {
8
+ console.log('=== MoltLaunch SDK Tests ===\n');
9
+
10
+ // Test helper functions
11
+ console.log('1. Testing helper functions...');
12
+ console.assert(getTier(85) === 'excellent', 'getTier(85) should be excellent');
13
+ console.assert(getTier(70) === 'good', 'getTier(70) should be good');
14
+ console.assert(getTier(50) === 'needs_work', 'getTier(50) should be needs_work');
15
+ console.assert(getTier(30) === 'poor', 'getTier(30) should be poor');
16
+ console.assert(isVerified(60) === true, 'isVerified(60) should be true');
17
+ console.assert(isVerified(59) === false, 'isVerified(59) should be false');
18
+ console.log(' ✓ Helper functions work correctly\n');
19
+
20
+ // Test constants
21
+ console.log('2. Testing constants...');
22
+ console.assert(DEPLOYMENT.vm, 'DEPLOYMENT.vm should exist');
23
+ console.assert(DEPLOYMENT.program, 'DEPLOYMENT.program should exist');
24
+ console.log(' ✓ Constants are defined\n');
25
+
26
+ // Test API (if available)
27
+ console.log('3. Testing API connection...');
28
+ const ml = new MoltLaunch();
29
+
30
+ try {
31
+ const healthy = await ml.isHealthy();
32
+ console.log(` API healthy: ${healthy}`);
33
+
34
+ if (healthy) {
35
+ // Test on-chain info
36
+ console.log('\n4. Testing getOnChainInfo...');
37
+ const info = await ml.getOnChainInfo();
38
+ console.log(` Model: ${info.model}`);
39
+ console.log(` Status: ${info.status}`);
40
+ console.log(` VM: ${info.deployment?.vm?.substring(0, 20)}...`);
41
+ console.log(' ✓ On-chain info retrieved\n');
42
+
43
+ // Test verification
44
+ console.log('5. Testing verify...');
45
+ const result = await ml.verify({
46
+ agentId: 'sdk-test-agent-' + Date.now(),
47
+ capabilities: ['testing'],
48
+ documentation: true,
49
+ codeLines: 1000,
50
+ testCoverage: 50
51
+ });
52
+ console.log(` Score: ${result.score}`);
53
+ console.log(` Tier: ${result.tier}`);
54
+ console.log(` Verified: ${result.verified}`);
55
+ console.log(` On-chain: ${result.onChainAI?.enabled}`);
56
+ console.log(' ✓ Verification works\n');
57
+
58
+ // Test status
59
+ console.log('6. Testing getStatus...');
60
+ const status = await ml.getStatus(result.agentId);
61
+ console.log(` Cached: ${status.verified}`);
62
+ console.log(' ✓ Status lookup works\n');
63
+ }
64
+ } catch (error) {
65
+ console.log(` ✗ API test failed: ${error.message}\n`);
66
+ }
67
+
68
+ console.log('=== Tests Complete ===');
69
+ }
70
+
71
+ runTests().catch(console.error);
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "CommonJS",
5
+ "lib": ["ES2022"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "resolveJsonModule": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }