@1llet.xyz/erc4337-gasless-sdk 0.4.54 → 0.4.56
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/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +159 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -366,9 +366,13 @@ interface CircleInformation {
|
|
|
366
366
|
cCTPInformation?: CCTPInformation;
|
|
367
367
|
aproxFromFee: number;
|
|
368
368
|
}
|
|
369
|
+
interface StargateInformation {
|
|
370
|
+
support: boolean;
|
|
371
|
+
}
|
|
369
372
|
interface CrossChainInformation {
|
|
370
373
|
circleInformation?: CircleInformation;
|
|
371
374
|
nearIntentInformation: NearIntentInformation | null;
|
|
375
|
+
stargateInformation?: StargateInformation;
|
|
372
376
|
}
|
|
373
377
|
interface EvmInformation {
|
|
374
378
|
chain: any;
|
|
@@ -389,6 +393,7 @@ interface Asset {
|
|
|
389
393
|
decimals: number;
|
|
390
394
|
address?: Address$1 | string;
|
|
391
395
|
coingeckoId?: string;
|
|
396
|
+
supportsStargate?: boolean;
|
|
392
397
|
}
|
|
393
398
|
interface ChainConfig {
|
|
394
399
|
assets: Asset[];
|
package/dist/index.d.ts
CHANGED
|
@@ -366,9 +366,13 @@ interface CircleInformation {
|
|
|
366
366
|
cCTPInformation?: CCTPInformation;
|
|
367
367
|
aproxFromFee: number;
|
|
368
368
|
}
|
|
369
|
+
interface StargateInformation {
|
|
370
|
+
support: boolean;
|
|
371
|
+
}
|
|
369
372
|
interface CrossChainInformation {
|
|
370
373
|
circleInformation?: CircleInformation;
|
|
371
374
|
nearIntentInformation: NearIntentInformation | null;
|
|
375
|
+
stargateInformation?: StargateInformation;
|
|
372
376
|
}
|
|
373
377
|
interface EvmInformation {
|
|
374
378
|
chain: any;
|
|
@@ -389,6 +393,7 @@ interface Asset {
|
|
|
389
393
|
decimals: number;
|
|
390
394
|
address?: Address$1 | string;
|
|
391
395
|
coingeckoId?: string;
|
|
396
|
+
supportsStargate?: boolean;
|
|
392
397
|
}
|
|
393
398
|
interface ChainConfig {
|
|
394
399
|
assets: Asset[];
|
package/dist/index.js
CHANGED
|
@@ -233,14 +233,9 @@ var init_facilitator = __esm({
|
|
|
233
233
|
chainId: 100,
|
|
234
234
|
chain: chains.gnosis,
|
|
235
235
|
usdc: "0x2a22f9c3b48403ebD92cF06fF916b322a30dB834",
|
|
236
|
-
// EURe (or USDC on Gnosis? The user is swapping USDT -> USDC, wait. The user log says GNOSIS -> Optimism (USDT -> USDC).
|
|
237
|
-
// For verification, we just need RPC. The 'usdc' field is for CCTP, but verify logic just needs `rpcUrl`.
|
|
238
|
-
// I will populate others as placeholders if unknown.
|
|
239
236
|
usdcName: "USDC",
|
|
240
|
-
// Placeholder
|
|
241
237
|
usdcVersion: "2",
|
|
242
238
|
domain: 0,
|
|
243
|
-
// Placeholder
|
|
244
239
|
tokenMessenger: "0x0000000000000000000000000000000000000000",
|
|
245
240
|
messageTransmitter: "0x0000000000000000000000000000000000000000",
|
|
246
241
|
rpcUrl: "https://rpc.gnosischain.com"
|
|
@@ -252,8 +247,8 @@ var init_facilitator = __esm({
|
|
|
252
247
|
usdcName: "USD Coin",
|
|
253
248
|
usdcVersion: "2",
|
|
254
249
|
domain: 3,
|
|
255
|
-
tokenMessenger: "
|
|
256
|
-
messageTransmitter: "
|
|
250
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
251
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
257
252
|
rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN"
|
|
258
253
|
},
|
|
259
254
|
Polygon: {
|
|
@@ -263,10 +258,53 @@ var init_facilitator = __esm({
|
|
|
263
258
|
usdcName: "USD Coin",
|
|
264
259
|
usdcVersion: "2",
|
|
265
260
|
domain: 7,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
messageTransmitter: "0x0000000000000000000000000000000000000000",
|
|
261
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
262
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
269
263
|
rpcUrl: "https://polygon-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN"
|
|
264
|
+
},
|
|
265
|
+
Unichain: {
|
|
266
|
+
chainId: chains.unichain.id,
|
|
267
|
+
chain: chains.unichain,
|
|
268
|
+
usdc: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
|
|
269
|
+
usdcName: "USD Coin",
|
|
270
|
+
usdcVersion: "2",
|
|
271
|
+
domain: 10,
|
|
272
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
273
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
274
|
+
rpcUrl: chains.unichain.rpcUrls.default.http[0]
|
|
275
|
+
},
|
|
276
|
+
Avalanche: {
|
|
277
|
+
chainId: chains.avalanche.id,
|
|
278
|
+
chain: chains.avalanche,
|
|
279
|
+
usdc: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
280
|
+
usdcName: "USD Coin",
|
|
281
|
+
usdcVersion: "2",
|
|
282
|
+
domain: 1,
|
|
283
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
284
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
285
|
+
rpcUrl: chains.avalanche.rpcUrls.default.http[0]
|
|
286
|
+
},
|
|
287
|
+
Worldchain: {
|
|
288
|
+
chainId: chains.worldchain.id,
|
|
289
|
+
chain: chains.worldchain,
|
|
290
|
+
usdc: "0x79A02482A880bCe3F13E09da970dC34dB4cD24D1",
|
|
291
|
+
usdcName: "USD Coin",
|
|
292
|
+
usdcVersion: "2",
|
|
293
|
+
domain: 13,
|
|
294
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
295
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
296
|
+
rpcUrl: chains.worldchain.rpcUrls.default.http[0]
|
|
297
|
+
},
|
|
298
|
+
Monad: {
|
|
299
|
+
chainId: chains.monad.id,
|
|
300
|
+
chain: chains.monad,
|
|
301
|
+
usdc: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
302
|
+
usdcName: "USD Coin",
|
|
303
|
+
usdcVersion: "2",
|
|
304
|
+
domain: 15,
|
|
305
|
+
tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
|
|
306
|
+
messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
|
|
307
|
+
rpcUrl: chains.monad.rpcUrls.default.http[0]
|
|
270
308
|
}
|
|
271
309
|
};
|
|
272
310
|
}
|
|
@@ -1055,7 +1093,8 @@ var BASE = {
|
|
|
1055
1093
|
name: "USDC",
|
|
1056
1094
|
decimals: 6,
|
|
1057
1095
|
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
1058
|
-
coingeckoId: "usd-coin"
|
|
1096
|
+
coingeckoId: "usd-coin",
|
|
1097
|
+
supportsStargate: true
|
|
1059
1098
|
},
|
|
1060
1099
|
{
|
|
1061
1100
|
name: "ETH",
|
|
@@ -1098,6 +1137,9 @@ var BASE = {
|
|
|
1098
1137
|
}
|
|
1099
1138
|
],
|
|
1100
1139
|
needMemo: false
|
|
1140
|
+
},
|
|
1141
|
+
stargateInformation: {
|
|
1142
|
+
support: true
|
|
1101
1143
|
}
|
|
1102
1144
|
}
|
|
1103
1145
|
};
|
|
@@ -1302,7 +1344,8 @@ var AVALANCHE = {
|
|
|
1302
1344
|
name: "USDC",
|
|
1303
1345
|
decimals: 6,
|
|
1304
1346
|
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
1305
|
-
coingeckoId: "usd-coin"
|
|
1347
|
+
coingeckoId: "usd-coin",
|
|
1348
|
+
supportsStargate: true
|
|
1306
1349
|
},
|
|
1307
1350
|
{
|
|
1308
1351
|
name: "AVAX",
|
|
@@ -1356,6 +1399,9 @@ var AVALANCHE = {
|
|
|
1356
1399
|
}
|
|
1357
1400
|
],
|
|
1358
1401
|
needMemo: false
|
|
1402
|
+
},
|
|
1403
|
+
stargateInformation: {
|
|
1404
|
+
support: true
|
|
1359
1405
|
}
|
|
1360
1406
|
}
|
|
1361
1407
|
};
|
|
@@ -2472,11 +2518,107 @@ async function getNearSimulation(sourceChain, destChain, amount, destToken, sour
|
|
|
2472
2518
|
}
|
|
2473
2519
|
}
|
|
2474
2520
|
|
|
2521
|
+
// src/services/stargate.ts
|
|
2522
|
+
var STARGATE_API_URL = "https://stargate.finance/api/v1/quotes";
|
|
2523
|
+
var StargateStrategy = class {
|
|
2524
|
+
constructor() {
|
|
2525
|
+
this.name = "StargateFinance";
|
|
2526
|
+
}
|
|
2527
|
+
canHandle(context) {
|
|
2528
|
+
const { sourceChain, destChain, sourceToken } = context;
|
|
2529
|
+
if (sourceChain === "Base" && destChain === "Avalanche" && sourceToken === "USDC") {
|
|
2530
|
+
return true;
|
|
2531
|
+
}
|
|
2532
|
+
const sourceConfig = NETWORKS[sourceChain];
|
|
2533
|
+
const destConfig = NETWORKS[destChain];
|
|
2534
|
+
if (!sourceConfig || !destConfig) return false;
|
|
2535
|
+
const sourceStargate = sourceConfig.crossChainInformation.stargateInformation?.support;
|
|
2536
|
+
const destStargate = destConfig.crossChainInformation.stargateInformation?.support;
|
|
2537
|
+
if (!sourceStargate || !destStargate) return false;
|
|
2538
|
+
const sourceAsset = sourceConfig.assets.find((a) => a.name === (sourceToken || "USDC"));
|
|
2539
|
+
const destAsset = destConfig.assets.find((a) => a.name === (context.destToken || "USDC"));
|
|
2540
|
+
return !!(sourceAsset?.supportsStargate && destAsset?.supportsStargate);
|
|
2541
|
+
}
|
|
2542
|
+
async execute(context) {
|
|
2543
|
+
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress } = context;
|
|
2544
|
+
console.log(`[StargateStrategy] Executing ${sourceChain} -> ${destChain} for ${amount} ${sourceToken}`);
|
|
2545
|
+
const sourceConfig = NETWORKS[sourceChain];
|
|
2546
|
+
const destConfig = NETWORKS[destChain];
|
|
2547
|
+
if (!sourceConfig || !destConfig) {
|
|
2548
|
+
return { success: false, errorReason: "Invalid chain configuration" };
|
|
2549
|
+
}
|
|
2550
|
+
const sourceAsset = sourceConfig.assets.find((a) => a.name === (sourceToken || "USDC"));
|
|
2551
|
+
const destAsset = destConfig.assets.find((a) => a.name === (destToken || "USDC"));
|
|
2552
|
+
if (!sourceAsset || !destAsset) {
|
|
2553
|
+
return { success: false, errorReason: "Invalid asset configuration" };
|
|
2554
|
+
}
|
|
2555
|
+
const decimals = sourceAsset.decimals;
|
|
2556
|
+
const amountAtomic = Math.floor(parseFloat(amount) * Math.pow(10, decimals)).toString();
|
|
2557
|
+
const minAmountAtomic = Math.floor(parseFloat(amountAtomic) * 0.995).toString();
|
|
2558
|
+
const srcChainKey = sourceChain.toLowerCase();
|
|
2559
|
+
const dstChainKey = destChain.toLowerCase();
|
|
2560
|
+
const url = new URL(STARGATE_API_URL);
|
|
2561
|
+
url.searchParams.append("srcToken", sourceAsset.address);
|
|
2562
|
+
url.searchParams.append("dstToken", destAsset.address);
|
|
2563
|
+
url.searchParams.append("srcAddress", senderAddress || recipient);
|
|
2564
|
+
url.searchParams.append("dstAddress", recipient);
|
|
2565
|
+
url.searchParams.append("srcChainKey", srcChainKey);
|
|
2566
|
+
url.searchParams.append("dstChainKey", dstChainKey);
|
|
2567
|
+
url.searchParams.append("srcAmount", amountAtomic);
|
|
2568
|
+
url.searchParams.append("dstAmountMin", minAmountAtomic);
|
|
2569
|
+
console.log(`[StargateStrategy] Fetching quote from: ${url.toString()}`);
|
|
2570
|
+
try {
|
|
2571
|
+
const response = await fetch(url.toString());
|
|
2572
|
+
const data = await response.json();
|
|
2573
|
+
if (!response.ok) {
|
|
2574
|
+
console.error("[StargateStrategy] API Error:", data);
|
|
2575
|
+
return { success: false, errorReason: `Stargate API Error: ${JSON.stringify(data)}` };
|
|
2576
|
+
}
|
|
2577
|
+
console.log("[StargateStrategy] Quote received:", JSON.stringify(data, null, 2));
|
|
2578
|
+
const quotes = data.quotes || [];
|
|
2579
|
+
if (quotes.length === 0) {
|
|
2580
|
+
return { success: false, errorReason: "No routes found from Stargate API" };
|
|
2581
|
+
}
|
|
2582
|
+
const selectedQuote = quotes.find((q) => q.route === "stargate/v2/taxi") || quotes[0];
|
|
2583
|
+
console.log(`[StargateStrategy] Selected Route: ${selectedQuote.route}`);
|
|
2584
|
+
const bridgeStep = selectedQuote.steps.find((s) => s.type === "bridge");
|
|
2585
|
+
if (!bridgeStep || !bridgeStep.transaction) {
|
|
2586
|
+
return { success: false, errorReason: "No bridge transaction found in quote" };
|
|
2587
|
+
}
|
|
2588
|
+
const txData = bridgeStep.transaction;
|
|
2589
|
+
const approvalTx = selectedQuote.steps.find((s) => s.type === "approve")?.transaction;
|
|
2590
|
+
return {
|
|
2591
|
+
success: true,
|
|
2592
|
+
transactionHash: "PENDING_USER_SIGNATURE",
|
|
2593
|
+
netAmount: amount,
|
|
2594
|
+
data: {
|
|
2595
|
+
strategy: "Stargate",
|
|
2596
|
+
quote: selectedQuote,
|
|
2597
|
+
// Normalized Transaction Data for execution
|
|
2598
|
+
txTarget: txData.to,
|
|
2599
|
+
txData: txData.data,
|
|
2600
|
+
txValue: txData.value,
|
|
2601
|
+
// Metadata
|
|
2602
|
+
approvalRequired: approvalTx ? {
|
|
2603
|
+
target: approvalTx.to,
|
|
2604
|
+
data: approvalTx.data,
|
|
2605
|
+
value: approvalTx.value
|
|
2606
|
+
} : null
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
} catch (e) {
|
|
2610
|
+
console.error("[StargateStrategy] Execution Error:", e);
|
|
2611
|
+
return { success: false, errorReason: e.message };
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2475
2616
|
// src/services/TransferManager.ts
|
|
2476
2617
|
var TransferManager = class {
|
|
2477
2618
|
constructor() {
|
|
2478
2619
|
this.strategies = [
|
|
2479
2620
|
new CCTPStrategy(),
|
|
2621
|
+
new StargateStrategy(),
|
|
2480
2622
|
new NearStrategy()
|
|
2481
2623
|
];
|
|
2482
2624
|
}
|
|
@@ -2495,6 +2637,11 @@ var TransferManager = class {
|
|
|
2495
2637
|
};
|
|
2496
2638
|
}
|
|
2497
2639
|
const strategies = this.strategies;
|
|
2640
|
+
const stargateStrategy = strategies.find((s) => s instanceof StargateStrategy);
|
|
2641
|
+
if (stargateStrategy && stargateStrategy.canHandle(context)) {
|
|
2642
|
+
console.log(`[TransferManager] Routing to: ${stargateStrategy.name} (Stargate)`);
|
|
2643
|
+
return stargateStrategy.execute(context);
|
|
2644
|
+
}
|
|
2498
2645
|
const cctpStrategy = strategies.find((s) => s instanceof CCTPStrategy);
|
|
2499
2646
|
if (cctpStrategy && cctpStrategy.canHandle(context)) {
|
|
2500
2647
|
console.log(`[TransferManager] Routing to: ${cctpStrategy.name} (CCTP)`);
|