@infiniteezverse/monskills-ezpath 0.1.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/.well-known/agent.json +241 -0
- package/.well-known/openapi.json +310 -0
- package/ARENA.md +551 -0
- package/DEPLOYMENT.md +460 -0
- package/LAUNCH.md +345 -0
- package/LICENSE +24 -0
- package/MANIFEST.md +356 -0
- package/MONAD.md +375 -0
- package/QUICKSTART.md +378 -0
- package/README.md +88 -0
- package/X402_IMPLEMENTATION.md +468 -0
- package/dist/agents/arena-agent.d.ts +166 -0
- package/dist/agents/arena-agent.d.ts.map +1 -0
- package/dist/agents/arena-agent.js +267 -0
- package/dist/agents/arena-agent.js.map +1 -0
- package/dist/agents/bankroll-manager.d.ts +114 -0
- package/dist/agents/bankroll-manager.d.ts.map +1 -0
- package/dist/agents/bankroll-manager.js +293 -0
- package/dist/agents/bankroll-manager.js.map +1 -0
- package/dist/agents/index.d.ts +9 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +29 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/strategy.d.ts +48 -0
- package/dist/agents/strategy.d.ts.map +1 -0
- package/dist/agents/strategy.js +265 -0
- package/dist/agents/strategy.js.map +1 -0
- package/dist/agents/types.d.ts +197 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +7 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/config/monad.d.ts +175 -0
- package/dist/config/monad.d.ts.map +1 -0
- package/dist/config/monad.js +222 -0
- package/dist/config/monad.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +153 -0
- package/dist/index.js.map +1 -0
- package/dist/payments/eip3009.d.ts +210 -0
- package/dist/payments/eip3009.d.ts.map +1 -0
- package/dist/payments/eip3009.js +261 -0
- package/dist/payments/eip3009.js.map +1 -0
- package/dist/payments/index.d.ts +8 -0
- package/dist/payments/index.d.ts.map +1 -0
- package/dist/payments/index.js +25 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/payments/quote-execution.d.ts +76 -0
- package/dist/payments/quote-execution.d.ts.map +1 -0
- package/dist/payments/quote-execution.js +285 -0
- package/dist/payments/quote-execution.js.map +1 -0
- package/dist/types/ezpath.d.ts +65 -0
- package/dist/types/ezpath.d.ts.map +1 -0
- package/dist/types/ezpath.js +7 -0
- package/dist/types/ezpath.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Quote Execution with X402 Payment
|
|
4
|
+
* Handles the complete flow: probe → payment signing → retry → settlement
|
|
5
|
+
*
|
|
6
|
+
* Flow:
|
|
7
|
+
* 1. GET /api/v1/quote → HTTP 402 Payment Required
|
|
8
|
+
* 2. Extract toll address and payment amount from 402 response
|
|
9
|
+
* 3. Create EIP-3009 TransferWithAuthorization message
|
|
10
|
+
* 4. Sign message with agent's private key
|
|
11
|
+
* 5. Retry GET /api/v1/quote with X-Payment header
|
|
12
|
+
* 6. Return settlement transaction and quote data
|
|
13
|
+
*/
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.QuoteExecutor = void 0;
|
|
19
|
+
const axios_1 = __importDefault(require("axios"));
|
|
20
|
+
const eip3009_1 = require("./eip3009");
|
|
21
|
+
/**
|
|
22
|
+
* Quote Executor
|
|
23
|
+
* Handles quotes with optional X402 payment
|
|
24
|
+
*/
|
|
25
|
+
class QuoteExecutor {
|
|
26
|
+
constructor(ezPathUrl = 'https://ezpath.myezverse.xyz', options) {
|
|
27
|
+
this.maxRetries = 3;
|
|
28
|
+
this.retryDelayMs = 1000;
|
|
29
|
+
this.ezPathUrl = ezPathUrl;
|
|
30
|
+
if (options?.maxRetries)
|
|
31
|
+
this.maxRetries = options.maxRetries;
|
|
32
|
+
if (options?.retryDelayMs)
|
|
33
|
+
this.retryDelayMs = options.retryDelayMs;
|
|
34
|
+
if (options?.signingFunction)
|
|
35
|
+
this.signingFunction = options.signingFunction;
|
|
36
|
+
if (options?.agentAddress)
|
|
37
|
+
this.agentAddress = options.agentAddress;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Execute quote with optional X402 payment
|
|
41
|
+
*/
|
|
42
|
+
async executeQuote(request, paymentSigningFunction) {
|
|
43
|
+
let retries = 0;
|
|
44
|
+
const maxRetries = this.maxRetries;
|
|
45
|
+
const agentAddress = this.agentAddress || '0x0000000000000000000000000000000000000000';
|
|
46
|
+
try {
|
|
47
|
+
// Step 1: Initial probe (no payment)
|
|
48
|
+
console.log('[EZ-Path] Probing endpoint...');
|
|
49
|
+
const probeResponse = await this.makeQuoteRequest(request);
|
|
50
|
+
// Check for 402 Payment Required
|
|
51
|
+
if (probeResponse.status === 402) {
|
|
52
|
+
const paymentRequired = probeResponse.data;
|
|
53
|
+
console.log('[EZ-Path] Payment required (HTTP 402)');
|
|
54
|
+
// Extract payment information
|
|
55
|
+
const feeUSD = paymentRequired.unlock_fee_usd || 0.03;
|
|
56
|
+
const feeAtomic = getTierBasedAmount(feeUSD);
|
|
57
|
+
const tier = (0, eip3009_1.getTierByAmount)(feeAtomic);
|
|
58
|
+
console.log(`[X402] Tier: ${tier}, Fee: $${feeUSD} USDC (${feeAtomic.toString()} atomic)`);
|
|
59
|
+
// Step 2: Create authorization message
|
|
60
|
+
const authMessage = (0, eip3009_1.createAuthorizationMessage)(agentAddress, eip3009_1.TOLL_ADDRESS, feeAtomic, 300 // 5 minute validity
|
|
61
|
+
);
|
|
62
|
+
console.log(`[X402] Authorization created`);
|
|
63
|
+
console.log(` Valid: ${new Date(authMessage.validAfter * 1000).toISOString()}`);
|
|
64
|
+
console.log(` Expires: ${new Date(authMessage.validBefore * 1000).toISOString()}`);
|
|
65
|
+
console.log(` Nonce: ${authMessage.nonce}`);
|
|
66
|
+
// Validate message before signing
|
|
67
|
+
const validation = validateAuthorizationMessage(authMessage);
|
|
68
|
+
if (!validation.valid) {
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
error: `Invalid authorization message: ${validation.error}`,
|
|
72
|
+
paymentRequired: true,
|
|
73
|
+
estimatedFee: {
|
|
74
|
+
usd: feeUSD,
|
|
75
|
+
atomic: feeAtomic.toString(),
|
|
76
|
+
token: 'USDC',
|
|
77
|
+
},
|
|
78
|
+
retries,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Step 3: Sign the message
|
|
82
|
+
let signature;
|
|
83
|
+
const signingFn = paymentSigningFunction || this.signingFunction;
|
|
84
|
+
if (!signingFn) {
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
error: 'No signing function provided. Cannot sign X402 payment.',
|
|
88
|
+
paymentRequired: true,
|
|
89
|
+
estimatedFee: {
|
|
90
|
+
usd: feeUSD,
|
|
91
|
+
atomic: feeAtomic.toString(),
|
|
92
|
+
token: 'USDC',
|
|
93
|
+
},
|
|
94
|
+
retries,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
console.log('[X402] Signing authorization...');
|
|
99
|
+
signature = await signingFn(authMessage);
|
|
100
|
+
console.log(`[X402] Signature: ${signature.substring(0, 20)}...`);
|
|
101
|
+
}
|
|
102
|
+
catch (signError) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
error: `Failed to sign X402 payment: ${String(signError)}`,
|
|
106
|
+
paymentRequired: true,
|
|
107
|
+
estimatedFee: {
|
|
108
|
+
usd: feeUSD,
|
|
109
|
+
atomic: feeAtomic.toString(),
|
|
110
|
+
token: 'USDC',
|
|
111
|
+
},
|
|
112
|
+
retries,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// Step 4: Create X402 payment header
|
|
116
|
+
const paymentSignature = {
|
|
117
|
+
signature,
|
|
118
|
+
authorization: authMessage,
|
|
119
|
+
quote_issued_at: Math.floor(Date.now() / 1000),
|
|
120
|
+
};
|
|
121
|
+
const xPaymentHeader = (0, eip3009_1.createX402PaymentHeader)(paymentSignature);
|
|
122
|
+
// Step 5: Retry with payment header
|
|
123
|
+
console.log('[X402] Retrying quote with payment...');
|
|
124
|
+
let paidResponse = await this.makeQuoteRequest(request, xPaymentHeader);
|
|
125
|
+
retries++;
|
|
126
|
+
// Retry logic for transient failures
|
|
127
|
+
while (paidResponse.status !== 200 && retries < maxRetries) {
|
|
128
|
+
console.log(`[X402] Attempt ${retries}: Got ${paidResponse.status}, retrying in ${this.retryDelayMs}ms...`);
|
|
129
|
+
await this.delay(this.retryDelayMs);
|
|
130
|
+
paidResponse = await this.makeQuoteRequest(request, xPaymentHeader);
|
|
131
|
+
retries++;
|
|
132
|
+
}
|
|
133
|
+
// Check final response
|
|
134
|
+
if (paidResponse.status === 200) {
|
|
135
|
+
const data = paidResponse.data;
|
|
136
|
+
console.log(`[EZ-Path] ✅ Quote successful`);
|
|
137
|
+
console.log(` Buy amount: ${data.buyAmount}`);
|
|
138
|
+
console.log(` Best engine: ${data.routingEngine}`);
|
|
139
|
+
console.log(` Settlement TX: ${data.settlement_tx || 'pending'}`);
|
|
140
|
+
return {
|
|
141
|
+
success: true,
|
|
142
|
+
data: {
|
|
143
|
+
status: data.status,
|
|
144
|
+
request_id: data.request_id,
|
|
145
|
+
sellToken: data.sellToken,
|
|
146
|
+
buyToken: data.buyToken,
|
|
147
|
+
sellAmount: data.sellAmount,
|
|
148
|
+
buyAmount: data.buyAmount,
|
|
149
|
+
price: data.price,
|
|
150
|
+
sources: data.sources || [],
|
|
151
|
+
routingEngine: data.routingEngine || 'unknown',
|
|
152
|
+
tier: tier,
|
|
153
|
+
settlement_tx: data.settlement_tx,
|
|
154
|
+
},
|
|
155
|
+
paymentSignature,
|
|
156
|
+
retries,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: `Quote failed after ${retries} attempts: ${paidResponse.status}`,
|
|
163
|
+
retries,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else if (probeResponse.status === 200) {
|
|
168
|
+
// No payment required, return quote directly
|
|
169
|
+
const data = probeResponse.data;
|
|
170
|
+
console.log('[EZ-Path] ✅ Quote successful (no payment required)');
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
data: {
|
|
174
|
+
status: data.status,
|
|
175
|
+
request_id: data.request_id,
|
|
176
|
+
sellToken: data.sellToken,
|
|
177
|
+
buyToken: data.buyToken,
|
|
178
|
+
sellAmount: data.sellAmount,
|
|
179
|
+
buyAmount: data.buyAmount,
|
|
180
|
+
price: data.price,
|
|
181
|
+
sources: data.sources || [],
|
|
182
|
+
routingEngine: data.routingEngine || 'unknown',
|
|
183
|
+
tier: 'basic',
|
|
184
|
+
},
|
|
185
|
+
retries,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
return {
|
|
190
|
+
success: false,
|
|
191
|
+
error: `Unexpected status: ${probeResponse.status}`,
|
|
192
|
+
retries,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
198
|
+
console.error(`[EZ-Path] Error: ${message}`);
|
|
199
|
+
return {
|
|
200
|
+
success: false,
|
|
201
|
+
error: `Request failed: ${message}`,
|
|
202
|
+
retries,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Make quote request (internal)
|
|
208
|
+
*/
|
|
209
|
+
async makeQuoteRequest(request, xPaymentHeader) {
|
|
210
|
+
const params = new URLSearchParams({
|
|
211
|
+
chain: request.chain || 'base',
|
|
212
|
+
sellToken: request.sellToken,
|
|
213
|
+
buyToken: request.buyToken,
|
|
214
|
+
sellAmount: request.sellAmount,
|
|
215
|
+
});
|
|
216
|
+
if (request.slippagePercentage !== undefined) {
|
|
217
|
+
params.append('slippagePercentage', request.slippagePercentage.toString());
|
|
218
|
+
}
|
|
219
|
+
const headers = {
|
|
220
|
+
'Content-Type': 'application/json',
|
|
221
|
+
};
|
|
222
|
+
if (xPaymentHeader) {
|
|
223
|
+
headers['X-Payment'] = xPaymentHeader;
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
const response = await axios_1.default.get(`${this.ezPathUrl}/api/v1/quote?${params}`, {
|
|
227
|
+
headers,
|
|
228
|
+
timeout: 10000,
|
|
229
|
+
validateStatus: () => true, // Accept all statuses
|
|
230
|
+
});
|
|
231
|
+
return response;
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Delay utility
|
|
239
|
+
*/
|
|
240
|
+
delay(ms) {
|
|
241
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.QuoteExecutor = QuoteExecutor;
|
|
245
|
+
/**
|
|
246
|
+
* Get tier-based payment amount
|
|
247
|
+
*/
|
|
248
|
+
function getTierBasedAmount(feeUSD) {
|
|
249
|
+
// Map USD fee to atomic USDC (6 decimals)
|
|
250
|
+
const atomic = Math.round(feeUSD * 1e6);
|
|
251
|
+
return BigInt(atomic);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Validate authorization message
|
|
255
|
+
*/
|
|
256
|
+
function validateAuthorizationMessage(message) {
|
|
257
|
+
const now = Math.floor(Date.now() / 1000);
|
|
258
|
+
if (message.validBefore < now) {
|
|
259
|
+
return {
|
|
260
|
+
valid: false,
|
|
261
|
+
error: 'Authorization expired',
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (!message.from.startsWith('0x') || message.from.length !== 42) {
|
|
265
|
+
return {
|
|
266
|
+
valid: false,
|
|
267
|
+
error: 'Invalid from address',
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
if (!message.to.startsWith('0x') || message.to.length !== 42) {
|
|
271
|
+
return {
|
|
272
|
+
valid: false,
|
|
273
|
+
error: 'Invalid to address',
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
if (!message.nonce.startsWith('0x') || message.nonce.length !== 66) {
|
|
277
|
+
return {
|
|
278
|
+
valid: false,
|
|
279
|
+
error: 'Invalid nonce',
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
return { valid: true };
|
|
283
|
+
}
|
|
284
|
+
exports.default = QuoteExecutor;
|
|
285
|
+
//# sourceMappingURL=quote-execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote-execution.js","sourceRoot":"","sources":["../../src/payments/quote-execution.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;AAEH,kDAA0B;AAC1B,uCAKmB;AAiCnB;;;GAGG;AACH,MAAa,aAAa;IAOxB,YACE,YAAoB,8BAA8B,EAClD,OAKC;QAVK,eAAU,GAAW,CAAC,CAAC;QACvB,iBAAY,GAAW,IAAI,CAAC;QAWlC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,OAAO,EAAE,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAC9D,IAAI,OAAO,EAAE,YAAY;YAAE,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACpE,IAAI,OAAO,EAAE,eAAe;YAAE,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC7E,IAAI,OAAO,EAAE,YAAY;YAAE,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,OAA2B,EAC3B,sBAAmF;QAE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C,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACjE,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,sBAAsB;SAC9B,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC7D,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,oBAAoB;SAC5B,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACnE,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,eAAe;SACvB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EZ-Path Quote Types
|
|
3
|
+
* Matches the EZ-Path API response schema
|
|
4
|
+
*/
|
|
5
|
+
export interface EZPathQuoteRequest {
|
|
6
|
+
chain: 'base' | 'monad' | 'arbitrum' | 'optimism' | 'polygon';
|
|
7
|
+
sellToken: string;
|
|
8
|
+
buyToken: string;
|
|
9
|
+
sellAmount: string;
|
|
10
|
+
slippagePercentage?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface EZPathSource {
|
|
13
|
+
name: string;
|
|
14
|
+
buyAmount: string;
|
|
15
|
+
gasEstimate?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EZPathQuoteResponse {
|
|
18
|
+
status: 'ok' | 'payment_required' | 'bad_request' | 'internal_error';
|
|
19
|
+
request_id: string;
|
|
20
|
+
sellToken: string;
|
|
21
|
+
buyToken: string;
|
|
22
|
+
sellAmount: string;
|
|
23
|
+
buyAmount: string;
|
|
24
|
+
price: string;
|
|
25
|
+
sources: EZPathSource[];
|
|
26
|
+
routingEngine: string;
|
|
27
|
+
tier: 'basic' | 'resilient' | 'institutional';
|
|
28
|
+
settlement_tx?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface EZPathPaymentRequired {
|
|
31
|
+
status: 'payment_required';
|
|
32
|
+
x402Version: number;
|
|
33
|
+
accepts: Array<{
|
|
34
|
+
scheme: string;
|
|
35
|
+
network: string;
|
|
36
|
+
maxAmountRequired: string;
|
|
37
|
+
resource: string;
|
|
38
|
+
description: string;
|
|
39
|
+
mimeType: string;
|
|
40
|
+
payTo: string;
|
|
41
|
+
maxTimeoutSeconds: number;
|
|
42
|
+
asset: string;
|
|
43
|
+
extra: Record<string, any>;
|
|
44
|
+
}>;
|
|
45
|
+
unlock_fee_usd: number;
|
|
46
|
+
request_id: string;
|
|
47
|
+
tiers: Record<string, {
|
|
48
|
+
min_atomic: string;
|
|
49
|
+
min_usdc: number;
|
|
50
|
+
description: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export type EZPathResponse = EZPathQuoteResponse | EZPathPaymentRequired;
|
|
54
|
+
export interface QuoteResult {
|
|
55
|
+
success: boolean;
|
|
56
|
+
data?: EZPathQuoteResponse;
|
|
57
|
+
error?: string;
|
|
58
|
+
paymentRequired?: boolean;
|
|
59
|
+
estimatedFee?: {
|
|
60
|
+
usd: number;
|
|
61
|
+
atomic: string;
|
|
62
|
+
token: 'USDC';
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ezpath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ezpath.d.ts","sourceRoot":"","sources":["../../src/types/ezpath.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,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ACvB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ;AAED,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AAEzE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ezpath.js","sourceRoot":"","sources":["../../src/types/ezpath.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@infiniteezverse/monskills-ezpath",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MONSKILLS skill for EZ-Path DEX price quotes on Monad, Base, and other EVM chains",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"test:watch": "jest --watch",
|
|
11
|
+
"test:coverage": "jest --coverage",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"lint": "eslint src/**/*.ts",
|
|
14
|
+
"publish:npm": "npm run build && npm publish --access=public"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"monskills",
|
|
18
|
+
"monad",
|
|
19
|
+
"dex",
|
|
20
|
+
"ezpath",
|
|
21
|
+
"agent",
|
|
22
|
+
"skill",
|
|
23
|
+
"defi"
|
|
24
|
+
],
|
|
25
|
+
"author": "infiniteezverse",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"axios": "^1.6.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.0.0",
|
|
32
|
+
"typescript": "^5.0.0",
|
|
33
|
+
"jest": "^29.0.0",
|
|
34
|
+
"@types/jest": "^29.0.0",
|
|
35
|
+
"ts-jest": "^29.0.0"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/infiniteezverse/monskills-ezpath.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://skills.devnads.com"
|
|
42
|
+
}
|