@funkit/fun-relay 2.2.0-next.5 → 2.2.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/dist/index.js CHANGED
@@ -51,7 +51,8 @@ __export(index_exports, {
51
51
  initDynamicRouting: () => initDynamicRouting,
52
52
  initializeRelayClient: () => initializeRelayClient,
53
53
  isRelayExecutionTerminalStatus: () => isRelayExecutionTerminalStatus,
54
- parseRelayFees: () => parseRelayFees
54
+ parseRelayFees: () => parseRelayFees,
55
+ shouldResetApproval: () => shouldResetApproval
55
56
  });
56
57
  module.exports = __toCommonJS(index_exports);
57
58
 
@@ -145,90 +146,6 @@ function getRelayClient() {
145
146
 
146
147
  // src/execution.ts
147
148
  var import_relay_sdk3 = require("@relayprotocol/relay-sdk");
148
-
149
- // src/utils.ts
150
- function convertFunToRelayTokenAddress(address, chainId) {
151
- if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {
152
- switch (chainId) {
153
- case FUN_HYPERCORE_CHAIN_ID_NUMBER:
154
- return RELAY_NATIVE_TOKEN_HYPERCORE;
155
- case RELAY_BITCOIN_CHAIN_ID_NUMBER:
156
- return RELAY_NATIVE_TOKEN_BITCOIN;
157
- // TODO: is it correct to assume chainId here is relay chain id?
158
- case RELAY_SOLANA_CHAIN_ID_NUMBER:
159
- case FUN_SOLANA_CHAIN_ID_NUMBER:
160
- return RELAY_NATIVE_TOKEN_SOLANA;
161
- case RELAY_LIGHTER_CHAIN_ID_NUMBER:
162
- return RELAY_LIGHTER_USDC_PERPS;
163
- default:
164
- return RELAY_NATIVE_TOKEN;
165
- }
166
- }
167
- if (RELAY_LIGHTER_CHAIN_ID_NUMBER === chainId) {
168
- const relayAddress = RELAY_LIGHTER_FUN_ADDRESS_MAP[address.toLowerCase()];
169
- if (relayAddress) {
170
- return relayAddress;
171
- }
172
- }
173
- return address;
174
- }
175
- function convertFunToRelayChainId(chainId) {
176
- if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {
177
- return RELAY_SOLANA_CHAIN_ID_NUMBER;
178
- }
179
- return chainId;
180
- }
181
- function getRelayExecutionRefundState(info) {
182
- switch (info.status) {
183
- case "refund" /* REFUND */:
184
- return "REFUNDED" /* REFUNDED */;
185
- default:
186
- return void 0;
187
- }
188
- }
189
- function getRelayExecutionState(info) {
190
- switch (info.status) {
191
- case "success" /* SUCCESS */:
192
- return "COMPLETED" /* COMPLETED */;
193
- case "failure" /* FAILURE */:
194
- case "refund" /* REFUND */:
195
- return "CHECKOUT_ERROR" /* CHECKOUT_ERROR */;
196
- default:
197
- return "PENDING_RECEIVAL" /* PENDING_RECEIVAL */;
198
- }
199
- }
200
- function isRelayExecutionTerminalStatus(info) {
201
- return RELAY_TERMINAL_STATUSES.includes(info.status);
202
- }
203
- function jsonStringifyWithBigIntSanitization(serializable) {
204
- return JSON.stringify(
205
- serializable,
206
- (_, value) => typeof value === "bigint" ? `0x${value.toString(16)}` : value
207
- // return everything else unchanged
208
- );
209
- }
210
- function indexBy(items, getKey) {
211
- const indexedItems = {};
212
- for (const item of items) {
213
- const key = getKey(item);
214
- if (!key) {
215
- continue;
216
- }
217
- indexedItems[key] = item;
218
- }
219
- return indexedItems;
220
- }
221
- function filterNullishHeaders(params) {
222
- const result = {};
223
- for (const [key, value] of Object.entries(params)) {
224
- if (value != null) {
225
- result[key] = value;
226
- }
227
- }
228
- return result;
229
- }
230
-
231
- // src/execution.ts
232
149
  function getTxHash({
233
150
  logger,
234
151
  transactionType,
@@ -379,18 +296,6 @@ async function executeRelayQuote({
379
296
  ) {
380
297
  logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes);
381
298
  isTransactionConfirmed = true;
382
- const firstStep = relayQuote.steps[0];
383
- const firstItem = firstStep?.items[0];
384
- if (firstStep?.requestId && firstItem) {
385
- manuallyRegisterIndex(logger, {
386
- requestId: firstStep.requestId,
387
- chainId: firstItem.data.chainId,
388
- tx: jsonStringifyWithBigIntSanitization({
389
- ...firstItem.data,
390
- txHash
391
- })
392
- });
393
- }
394
299
  try {
395
300
  await onTransactionConfirmed?.(txHash);
396
301
  } catch (e) {
@@ -404,42 +309,6 @@ async function executeRelayQuote({
404
309
  }
405
310
  });
406
311
  }
407
- async function manuallyRegisterIndex(logger, registerRequest) {
408
- const logPrefix = "manuallyRegisterIndex";
409
- const stringifiedRequest = JSON.stringify(registerRequest);
410
- const url = `${import_relay_sdk3.MAINNET_RELAY_API}/transactions/single`;
411
- try {
412
- logger.info(`${logPrefix}:onManuallyRegisterIndex`, {
413
- params: stringifiedRequest
414
- });
415
- const response = await fetch(url, {
416
- method: "POST",
417
- body: JSON.stringify(registerRequest)
418
- });
419
- if (!response.ok) {
420
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
421
- message: "Error !response.ok - request to manually register index",
422
- response: JSON.stringify(response),
423
- params: stringifiedRequest
424
- });
425
- return;
426
- }
427
- const data = await response.json();
428
- if (data.message !== "Success") {
429
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
430
- message: `Data.message is not of type Success - ${data.message}`,
431
- response: JSON.stringify(response),
432
- params: stringifiedRequest
433
- });
434
- }
435
- return;
436
- } catch (err) {
437
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
438
- message: `Error sending request to register index at ${url}: ${JSON.stringify(err?.message)}`,
439
- params: stringifiedRequest
440
- });
441
- }
442
- }
443
312
  async function getRelayExecutionInfo(requestId, apiKey) {
444
313
  const url = `${import_relay_sdk3.MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`;
445
314
  const response = await fetch(url, {
@@ -524,6 +393,83 @@ function parseRelayFees({
524
393
 
525
394
  // src/price.ts
526
395
  var import_relay_sdk4 = require("@relayprotocol/relay-sdk");
396
+
397
+ // src/utils.ts
398
+ function convertFunToRelayTokenAddress(address, chainId) {
399
+ if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {
400
+ switch (chainId) {
401
+ case FUN_HYPERCORE_CHAIN_ID_NUMBER:
402
+ return RELAY_NATIVE_TOKEN_HYPERCORE;
403
+ case RELAY_BITCOIN_CHAIN_ID_NUMBER:
404
+ return RELAY_NATIVE_TOKEN_BITCOIN;
405
+ // TODO: is it correct to assume chainId here is relay chain id?
406
+ case RELAY_SOLANA_CHAIN_ID_NUMBER:
407
+ case FUN_SOLANA_CHAIN_ID_NUMBER:
408
+ return RELAY_NATIVE_TOKEN_SOLANA;
409
+ case RELAY_LIGHTER_CHAIN_ID_NUMBER:
410
+ return RELAY_LIGHTER_USDC_PERPS;
411
+ default:
412
+ return RELAY_NATIVE_TOKEN;
413
+ }
414
+ }
415
+ if (RELAY_LIGHTER_CHAIN_ID_NUMBER === chainId) {
416
+ const relayAddress = RELAY_LIGHTER_FUN_ADDRESS_MAP[address.toLowerCase()];
417
+ if (relayAddress) {
418
+ return relayAddress;
419
+ }
420
+ }
421
+ return address;
422
+ }
423
+ function convertFunToRelayChainId(chainId) {
424
+ if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {
425
+ return RELAY_SOLANA_CHAIN_ID_NUMBER;
426
+ }
427
+ return chainId;
428
+ }
429
+ function getRelayExecutionRefundState(info) {
430
+ switch (info.status) {
431
+ case "refund" /* REFUND */:
432
+ return "REFUNDED" /* REFUNDED */;
433
+ default:
434
+ return void 0;
435
+ }
436
+ }
437
+ function getRelayExecutionState(info) {
438
+ switch (info.status) {
439
+ case "success" /* SUCCESS */:
440
+ return "COMPLETED" /* COMPLETED */;
441
+ case "failure" /* FAILURE */:
442
+ case "refund" /* REFUND */:
443
+ return "CHECKOUT_ERROR" /* CHECKOUT_ERROR */;
444
+ default:
445
+ return "PENDING_RECEIVAL" /* PENDING_RECEIVAL */;
446
+ }
447
+ }
448
+ function isRelayExecutionTerminalStatus(info) {
449
+ return RELAY_TERMINAL_STATUSES.includes(info.status);
450
+ }
451
+ function indexBy(items, getKey) {
452
+ const indexedItems = {};
453
+ for (const item of items) {
454
+ const key = getKey(item);
455
+ if (!key) {
456
+ continue;
457
+ }
458
+ indexedItems[key] = item;
459
+ }
460
+ return indexedItems;
461
+ }
462
+ function filterNullishHeaders(params) {
463
+ const result = {};
464
+ for (const [key, value] of Object.entries(params)) {
465
+ if (value != null) {
466
+ result[key] = value;
467
+ }
468
+ }
469
+ return result;
470
+ }
471
+
472
+ // src/price.ts
527
473
  async function getRelayAssetPriceInfo({
528
474
  chainId,
529
475
  address,
@@ -872,8 +818,8 @@ function getTronWallet(walletAddress, tronWeb) {
872
818
  }
873
819
 
874
820
  // src/dynamicRoutes/lighter.ts
875
- var import_viem4 = require("viem");
876
- var import_chains2 = require("viem/chains");
821
+ var import_viem5 = require("viem");
822
+ var import_chains3 = require("viem/chains");
877
823
 
878
824
  // src/dynamicRoutes/abi.ts
879
825
  var UNWRAP_AND_CALL_ABI = [
@@ -1316,7 +1262,7 @@ var ASSET_LOGO_SRCS = {
1316
1262
  IMX: "https://sdk-cdn.fun.xyz/images/imx.svg",
1317
1263
  INJ: "https://sdk-cdn.fun.xyz/images/inj.svg",
1318
1264
  LDO: "https://sdk-cdn.fun.xyz/images/ldo.svg",
1319
- LINK: "https://sdk-cdn.fun.xyz/images/link.svg",
1265
+ LINK: "https://sdk-cdn.fun.xyz/images/link.png",
1320
1266
  LUCK: "https://sdk-cdn.fun.xyz/images/luck.png",
1321
1267
  MATIC: "https://sdk-cdn.fun.xyz/images/matic.svg",
1322
1268
  MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
@@ -1334,7 +1280,7 @@ var ASSET_LOGO_SRCS = {
1334
1280
  SOL: "https://sdk-cdn.fun.xyz/images/sol.svg",
1335
1281
  SUSDS: "https://sdk-cdn.fun.xyz/images/susds.svg",
1336
1282
  TYBG: "https://sdk-cdn.fun.xyz/images/tybg.png",
1337
- UNI: "https://sdk-cdn.fun.xyz/images/uni.svg",
1283
+ UNI: "https://sdk-cdn.fun.xyz/images/uni.png",
1338
1284
  USDC: "https://sdk-cdn.fun.xyz/images/usdc.svg",
1339
1285
  "USDC.E": "https://sdk-cdn.fun.xyz/images/usdc.svg",
1340
1286
  USDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
@@ -1375,7 +1321,8 @@ var ASSET_LOGO_SRCS = {
1375
1321
  MON: "https://sdk-cdn.fun.xyz/images/monad.svg",
1376
1322
  WMON: "https://sdk-cdn.fun.xyz/images/wmon.svg",
1377
1323
  AUSD: "https://sdk-cdn.fun.xyz/images/ausd.svg",
1378
- SUSHI: "https://sdk-cdn.fun.xyz/images/sushi.svg"
1324
+ SUSHI: "https://sdk-cdn.fun.xyz/images/sushi.svg",
1325
+ SKY: "https://sdk-cdn.fun.xyz/images/sky.svg"
1379
1326
  };
1380
1327
 
1381
1328
  // src/dynamicRoutes/consts.ts
@@ -1389,6 +1336,25 @@ var tokenAddresses = {
1389
1336
  },
1390
1337
  USDC: {
1391
1338
  [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
1339
+ },
1340
+ // LIT is currently unused
1341
+ LIT: {
1342
+ [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x232CE3bd40fCd6f80f3d55A522d03f25Df784Ee2")
1343
+ },
1344
+ LINK: {
1345
+ [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x514910771AF9Ca656af840dff83E8264EcF986CA")
1346
+ },
1347
+ UNI: {
1348
+ [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984")
1349
+ },
1350
+ AAVE: {
1351
+ [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9")
1352
+ },
1353
+ SKY: {
1354
+ [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x56072C95FAA701256059aa122697B133aDEd9279")
1355
+ },
1356
+ LDO: {
1357
+ [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32")
1392
1358
  }
1393
1359
  };
1394
1360
  var UNWRAP_AND_CALL_ADDRESS = {
@@ -1403,6 +1369,8 @@ var LIGHTER_DEPOSIT_ADDRESS = (0, import_viem2.getAddress)(
1403
1369
  var MATCH_ALL_CONDITION = "*";
1404
1370
 
1405
1371
  // src/dynamicRoutes/utils.ts
1372
+ var import_viem4 = require("viem");
1373
+ var import_chains2 = require("viem/chains");
1406
1374
  var createPath = (config) => {
1407
1375
  return config;
1408
1376
  };
@@ -1485,6 +1453,35 @@ var initDynamicRouting = (dynamicRoutes, dynamicRoutingConfig) => {
1485
1453
  );
1486
1454
  return indexedDynamicRoutingConfig;
1487
1455
  };
1456
+ var MAX_APPROVAL = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
1457
+ var getApprovalCalldata = ({
1458
+ tokenAddress,
1459
+ spenderAddress,
1460
+ amount
1461
+ }) => {
1462
+ return {
1463
+ contractAbi: import_viem4.erc20Abi,
1464
+ contractAddress: tokenAddress,
1465
+ functionName: "approve",
1466
+ functionArgs: [spenderAddress, amount]
1467
+ };
1468
+ };
1469
+ var getResetApprovalCalldata = ({
1470
+ tokenAddress,
1471
+ spenderAddress
1472
+ }) => {
1473
+ return getApprovalCalldata({
1474
+ tokenAddress,
1475
+ spenderAddress,
1476
+ amount: "0"
1477
+ });
1478
+ };
1479
+ var RESET_APPROVAL_TOKENS = [tokenAddresses.LDO[import_chains2.mainnet.id]].map(
1480
+ (address) => address.toLowerCase()
1481
+ );
1482
+ var shouldResetApproval = (tokenAddress) => {
1483
+ return RESET_APPROVAL_TOKENS.includes(tokenAddress.toLowerCase());
1484
+ };
1488
1485
 
1489
1486
  // src/dynamicRoutes/lighter.ts
1490
1487
  var NATIVE_TOKEN = FUNKIT_NATIVE_TOKEN;
@@ -1493,23 +1490,40 @@ var RELAY_LIGHTER_ETH_SPOT_ADDRESS = "0x0000000000000000000000000000000000000001
1493
1490
  var RELAY_LIGHTER_USDC_PERPS_ADDRESS = "0x0000000000000000000000000000000000000000";
1494
1491
  var TICK_SIZE_FOR_ASSET_INDEX = {
1495
1492
  [3 /* USDC */]: BigInt(1),
1496
- [1 /* ETH */]: BigInt(10 ** 10)
1493
+ [1 /* ETH */]: BigInt(10 ** 10),
1494
+ [2 /* LIT */]: BigInt(10 ** 10),
1495
+ [5 /* LINK */]: BigInt(10 ** 10),
1496
+ [6 /* UNI */]: BigInt(10 ** 10),
1497
+ [7 /* AAVE */]: BigInt(10 ** 10),
1498
+ [8 /* SKY */]: BigInt(10 ** 10),
1499
+ [9 /* LDO */]: BigInt(10 ** 10)
1497
1500
  };
1498
1501
  var DEPOSIT_TOKEN_FOR_ASSET_INDEX = {
1499
- [3 /* USDC */]: tokenAddresses.USDC[import_chains2.mainnet.id],
1500
- [1 /* ETH */]: NATIVE_TOKEN
1502
+ [3 /* USDC */]: tokenAddresses.USDC[import_chains3.mainnet.id],
1503
+ [1 /* ETH */]: NATIVE_TOKEN,
1504
+ [2 /* LIT */]: tokenAddresses.LIT[import_chains3.mainnet.id],
1505
+ [5 /* LINK */]: tokenAddresses.LINK[import_chains3.mainnet.id],
1506
+ [6 /* UNI */]: tokenAddresses.UNI[import_chains3.mainnet.id],
1507
+ [7 /* AAVE */]: tokenAddresses.AAVE[import_chains3.mainnet.id],
1508
+ [8 /* SKY */]: tokenAddresses.SKY[import_chains3.mainnet.id],
1509
+ [9 /* LDO */]: tokenAddresses.LDO[import_chains3.mainnet.id]
1501
1510
  };
1502
1511
  var USDC_PERPS_SYMBOL = "USDC (Perps)";
1503
1512
  var ETH_SPOT_SYMBOL = "ETH (Spot)";
1513
+ var LINK_SPOT_SYMBOL = "LINK (Spot)";
1514
+ var UNI_SPOT_SYMBOL = "UNI (Spot)";
1515
+ var AAVE_SPOT_SYMBOL = "AAVE (Spot)";
1516
+ var SKY_SPOT_SYMBOL = "SKY (Spot)";
1517
+ var LDO_SPOT_SYMBOL = "LDO (Spot)";
1504
1518
  var generateLighterMainnetDepositActions = ({
1505
1519
  address,
1506
1520
  assetIndex,
1507
1521
  routeType
1508
1522
  }) => {
1509
- const depositSelector = (0, import_viem4.toFunctionSelector)(
1523
+ const depositSelector = (0, import_viem5.toFunctionSelector)(
1510
1524
  "deposit(address,uint16,uint8,uint256)"
1511
1525
  );
1512
- const encodedLighterParams = (0, import_viem4.encodeAbiParameters)(
1526
+ const encodedLighterParams = (0, import_viem5.encodeAbiParameters)(
1513
1527
  [
1514
1528
  { type: "address" },
1515
1529
  { type: "uint16" },
@@ -1518,12 +1532,12 @@ var generateLighterMainnetDepositActions = ({
1518
1532
  ],
1519
1533
  [address, assetIndex, routeType, AMOUNT_PLACEHOLDER]
1520
1534
  );
1521
- const lighterDepositCalldata = (0, import_viem4.concat)([depositSelector, encodedLighterParams]);
1535
+ const lighterDepositCalldata = (0, import_viem5.concat)([depositSelector, encodedLighterParams]);
1522
1536
  const depositToken = DEPOSIT_TOKEN_FOR_ASSET_INDEX[assetIndex];
1523
1537
  const tickSize = TICK_SIZE_FOR_ASSET_INDEX[assetIndex];
1524
1538
  const dustRecipient = address;
1525
1539
  if (depositToken === NATIVE_TOKEN) {
1526
- const vaultWrapperCalldata = (0, import_viem4.encodeFunctionData)({
1540
+ const vaultWrapperCalldata = (0, import_viem5.encodeFunctionData)({
1527
1541
  abi: VAULT_DEPOSITOR_ABI,
1528
1542
  functionName: "depositWithTick",
1529
1543
  args: [
@@ -1543,22 +1557,18 @@ var generateLighterMainnetDepositActions = ({
1543
1557
  });
1544
1558
  return [
1545
1559
  // Step 1: Approve WETH to UnwrapWETHAndCall
1546
- {
1547
- contractAbi: import_viem3.erc20Abi,
1548
- contractAddress: tokenAddresses.WETH[import_chains2.mainnet.id],
1549
- functionName: "approve",
1550
- functionArgs: [
1551
- UNWRAP_AND_CALL_ADDRESS[import_chains2.mainnet.id],
1552
- "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
1553
- ]
1554
- },
1560
+ getApprovalCalldata({
1561
+ tokenAddress: tokenAddresses.WETH[import_chains3.mainnet.id],
1562
+ spenderAddress: UNWRAP_AND_CALL_ADDRESS[import_chains3.mainnet.id],
1563
+ amount: MAX_APPROVAL
1564
+ }),
1555
1565
  // Step 2: UnwrapWETHAndCall pulls WETH, unwraps to ETH, sends to VaultWrapper, calls deposit
1556
1566
  {
1557
1567
  contractAbi: UNWRAP_AND_CALL_ABI,
1558
- contractAddress: UNWRAP_AND_CALL_ADDRESS[import_chains2.mainnet.id],
1568
+ contractAddress: UNWRAP_AND_CALL_ADDRESS[import_chains3.mainnet.id],
1559
1569
  functionName: "unwrapAndCall",
1560
1570
  functionArgs: [
1561
- VAULT_DEPOSITOR_ADDRESS[import_chains2.mainnet.id],
1571
+ VAULT_DEPOSITOR_ADDRESS[import_chains3.mainnet.id],
1562
1572
  // target (VaultWrapper)
1563
1573
  vaultWrapperCalldata
1564
1574
  // VaultWrapper.deposit() calldata
@@ -1566,52 +1576,53 @@ var generateLighterMainnetDepositActions = ({
1566
1576
  }
1567
1577
  ];
1568
1578
  }
1569
- if (depositToken === tokenAddresses.USDC[import_chains2.mainnet.id]) {
1570
- return [
1571
- // Step 1: Approve USDC to VaultDepositor
1572
- {
1573
- contractAbi: import_viem3.erc20Abi,
1574
- contractAddress: tokenAddresses.USDC[import_chains2.mainnet.id],
1575
- functionName: "approve",
1576
- functionArgs: [
1577
- VAULT_DEPOSITOR_ADDRESS[import_chains2.mainnet.id],
1578
- "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
1579
- // Max approval
1580
- ]
1581
- },
1582
- // Step 2: VaultDepositor pulls USDC and calls Lighter deposit
1583
- {
1584
- contractAbi: VAULT_DEPOSITOR_ABI,
1585
- contractAddress: VAULT_DEPOSITOR_ADDRESS[import_chains2.mainnet.id],
1586
- functionName: "depositWithTick",
1587
- functionArgs: [
1588
- tokenAddresses.USDC[import_chains2.mainnet.id],
1589
- // token (USDC)
1590
- LIGHTER_DEPOSIT_ADDRESS,
1591
- // vault (Lighter deposit contract)
1592
- lighterDepositCalldata,
1593
- // callData
1594
- 0n,
1595
- // minAmountOut
1596
- tickSize,
1597
- // tickSize
1598
- dustRecipient
1599
- // dustRecipient
1600
- ]
1601
- }
1602
- ];
1603
- }
1579
+ const resetApprovalNeeded = shouldResetApproval(depositToken);
1580
+ return [
1581
+ // Special handling of LDO token as it requires approval reset before approval can be set to a new value due to non-standard implementation of the approve function.
1582
+ ...resetApprovalNeeded ? [
1583
+ getResetApprovalCalldata({
1584
+ tokenAddress: depositToken,
1585
+ spenderAddress: VAULT_DEPOSITOR_ADDRESS[import_chains3.mainnet.id]
1586
+ })
1587
+ ] : [],
1588
+ // Step 1: Approve deposit token to VaultDepositor
1589
+ getApprovalCalldata({
1590
+ tokenAddress: depositToken,
1591
+ spenderAddress: VAULT_DEPOSITOR_ADDRESS[import_chains3.mainnet.id],
1592
+ amount: MAX_APPROVAL
1593
+ }),
1594
+ // Step 2: VaultDepositor pulls deposit token and calls Lighter deposit
1595
+ {
1596
+ contractAbi: VAULT_DEPOSITOR_ABI,
1597
+ contractAddress: VAULT_DEPOSITOR_ADDRESS[import_chains3.mainnet.id],
1598
+ functionName: "depositWithTick",
1599
+ functionArgs: [
1600
+ depositToken,
1601
+ // token (deposit token)
1602
+ LIGHTER_DEPOSIT_ADDRESS,
1603
+ // vault (Lighter deposit contract)
1604
+ lighterDepositCalldata,
1605
+ // callData
1606
+ 0n,
1607
+ // minAmountOut
1608
+ tickSize,
1609
+ // tickSize
1610
+ dustRecipient
1611
+ // dustRecipient
1612
+ ]
1613
+ }
1614
+ ];
1604
1615
  };
1605
1616
  var LIGHTER_USDC_PERPS_FUN_MAINNET_DEPOSIT = createPath({
1606
- targetChain: import_chains2.mainnet.id.toString(),
1607
- targetAsset: tokenAddresses.USDC[import_chains2.mainnet.id],
1617
+ targetChain: import_chains3.mainnet.id.toString(),
1618
+ targetAsset: tokenAddresses.USDC[import_chains3.mainnet.id],
1608
1619
  targetAssetTicker: USDC_PERPS_SYMBOL,
1609
1620
  iconSrc: ASSET_LOGO_SRCS.USDC,
1610
1621
  generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1611
1622
  if (!outputConfig) {
1612
1623
  return [];
1613
1624
  }
1614
- if (outputConfig.targetChain !== import_chains2.mainnet.id.toString()) {
1625
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1615
1626
  return [];
1616
1627
  }
1617
1628
  return generateLighterMainnetDepositActions({
@@ -1622,15 +1633,15 @@ var LIGHTER_USDC_PERPS_FUN_MAINNET_DEPOSIT = createPath({
1622
1633
  }
1623
1634
  });
1624
1635
  var LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1625
- targetChain: import_chains2.mainnet.id.toString(),
1626
- targetAsset: tokenAddresses.WETH[import_chains2.mainnet.id],
1636
+ targetChain: import_chains3.mainnet.id.toString(),
1637
+ targetAsset: tokenAddresses.WETH[import_chains3.mainnet.id],
1627
1638
  targetAssetTicker: ETH_SPOT_SYMBOL,
1628
1639
  iconSrc: ASSET_LOGO_SRCS.ETH,
1629
1640
  generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1630
1641
  if (!outputConfig) {
1631
1642
  return [];
1632
1643
  }
1633
- if (outputConfig.targetChain !== import_chains2.mainnet.id.toString()) {
1644
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1634
1645
  return [];
1635
1646
  }
1636
1647
  return generateLighterMainnetDepositActions({
@@ -1640,6 +1651,101 @@ var LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1640
1651
  });
1641
1652
  }
1642
1653
  });
1654
+ var LIGHTER_LINK_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1655
+ targetChain: import_chains3.mainnet.id.toString(),
1656
+ targetAsset: tokenAddresses.LINK[import_chains3.mainnet.id],
1657
+ targetAssetTicker: LINK_SPOT_SYMBOL,
1658
+ iconSrc: ASSET_LOGO_SRCS.LINK,
1659
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1660
+ if (!outputConfig) {
1661
+ return [];
1662
+ }
1663
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1664
+ return [];
1665
+ }
1666
+ return generateLighterMainnetDepositActions({
1667
+ address,
1668
+ assetIndex: 5 /* LINK */,
1669
+ routeType: 1 /* Spot */
1670
+ });
1671
+ }
1672
+ });
1673
+ var LIGHTER_SKY_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1674
+ targetChain: import_chains3.mainnet.id.toString(),
1675
+ targetAsset: tokenAddresses.SKY[import_chains3.mainnet.id],
1676
+ targetAssetTicker: SKY_SPOT_SYMBOL,
1677
+ iconSrc: ASSET_LOGO_SRCS.SKY,
1678
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1679
+ if (!outputConfig) {
1680
+ return [];
1681
+ }
1682
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1683
+ return [];
1684
+ }
1685
+ return generateLighterMainnetDepositActions({
1686
+ address,
1687
+ assetIndex: 8 /* SKY */,
1688
+ routeType: 1 /* Spot */
1689
+ });
1690
+ }
1691
+ });
1692
+ var LIGHTER_UNI_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1693
+ targetChain: import_chains3.mainnet.id.toString(),
1694
+ targetAsset: tokenAddresses.UNI[import_chains3.mainnet.id],
1695
+ targetAssetTicker: UNI_SPOT_SYMBOL,
1696
+ iconSrc: ASSET_LOGO_SRCS.UNI,
1697
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1698
+ if (!outputConfig) {
1699
+ return [];
1700
+ }
1701
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1702
+ return [];
1703
+ }
1704
+ return generateLighterMainnetDepositActions({
1705
+ address,
1706
+ assetIndex: 6 /* UNI */,
1707
+ routeType: 1 /* Spot */
1708
+ });
1709
+ }
1710
+ });
1711
+ var LIGHTER_AAVE_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1712
+ targetChain: import_chains3.mainnet.id.toString(),
1713
+ targetAsset: tokenAddresses.AAVE[import_chains3.mainnet.id],
1714
+ targetAssetTicker: AAVE_SPOT_SYMBOL,
1715
+ iconSrc: ASSET_LOGO_SRCS.AAVE,
1716
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1717
+ if (!outputConfig) {
1718
+ return [];
1719
+ }
1720
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1721
+ return [];
1722
+ }
1723
+ return generateLighterMainnetDepositActions({
1724
+ address,
1725
+ assetIndex: 7 /* AAVE */,
1726
+ routeType: 1 /* Spot */
1727
+ });
1728
+ }
1729
+ });
1730
+ var LIGHTER_LDO_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1731
+ targetChain: import_chains3.mainnet.id.toString(),
1732
+ targetAsset: tokenAddresses.LDO[import_chains3.mainnet.id],
1733
+ targetAssetTicker: LDO_SPOT_SYMBOL,
1734
+ iconSrc: ASSET_LOGO_SRCS.LDO,
1735
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1736
+ if (!outputConfig) {
1737
+ return [];
1738
+ }
1739
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1740
+ return [];
1741
+ }
1742
+ return generateLighterMainnetDepositActions({
1743
+ address,
1744
+ assetIndex: 9 /* LDO */,
1745
+ routeType: 1 /* Spot */
1746
+ });
1747
+ }
1748
+ });
1643
1749
  var LIGHTER_DYNAMIC_ROUTES = [
1644
1750
  createRoute({
1645
1751
  id: "LIGHTER_ETH_SPOT",
@@ -1682,6 +1788,37 @@ var LIGHTER_DYNAMIC_ROUTES = [
1682
1788
  paths: {
1683
1789
  FUN_MAINNET_DEPOSIT: LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT
1684
1790
  }
1791
+ }),
1792
+ // LINK, UNI, AAVE, SKY, LDO tokens
1793
+ createRoute({
1794
+ id: "LIGHTER_LINK_SPOT_NEW_USER",
1795
+ paths: {
1796
+ FUN_MAINNET_DEPOSIT: LIGHTER_LINK_SPOT_FUN_MAINNET_DEPOSIT
1797
+ }
1798
+ }),
1799
+ createRoute({
1800
+ id: "LIGHTER_SKY_SPOT_NEW_USER",
1801
+ paths: {
1802
+ FUN_MAINNET_DEPOSIT: LIGHTER_SKY_SPOT_FUN_MAINNET_DEPOSIT
1803
+ }
1804
+ }),
1805
+ createRoute({
1806
+ id: "LIGHTER_UNI_SPOT_NEW_USER",
1807
+ paths: {
1808
+ FUN_MAINNET_DEPOSIT: LIGHTER_UNI_SPOT_FUN_MAINNET_DEPOSIT
1809
+ }
1810
+ }),
1811
+ createRoute({
1812
+ id: "LIGHTER_AAVE_SPOT_NEW_USER",
1813
+ paths: {
1814
+ FUN_MAINNET_DEPOSIT: LIGHTER_AAVE_SPOT_FUN_MAINNET_DEPOSIT
1815
+ }
1816
+ }),
1817
+ createRoute({
1818
+ id: "LIGHTER_LDO_SPOT_NEW_USER",
1819
+ paths: {
1820
+ FUN_MAINNET_DEPOSIT: LIGHTER_LDO_SPOT_FUN_MAINNET_DEPOSIT
1821
+ }
1685
1822
  })
1686
1823
  ];
1687
1824