@funkit/fun-relay 2.2.0-next.6 → 2.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @funkit/fun-relay
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3e40d89: feat(connect,fun-relay): add LIT spot asset
8
+
9
+ ## 2.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - c289ca6: feat(fun-relay): require api key for relay to prevent rate limiting
14
+ feat(connect): pass pseudo api key to fun-relay
15
+ - aa767b0: feat: add tron adapter
16
+
17
+ ### Patch Changes
18
+
19
+ - 173d602: chore(fun-relay): dynamic routes
20
+ - 3601d23: feat(fun-relay): support for more lighter addresses
21
+ - 320236b: refactor: refactor approval calldata generation
22
+ - 52406e3: feat(connect,fun-relay): add new lighter spot assets
23
+ - e009c8d: Fix USDC_PERPS icon displaying ETH logo instead of USDC logo
24
+ - 7312429: adopt checkedIndexedAccess for safety
25
+ - 2f57830: feat: implemented revoke/reset approval mechanics for tokens with non-standard approval implementation
26
+ - 0152e69: chore(fun-relay): expose `RelayExecute` type
27
+ - fd5fe29: fix(fun-relay): add protocolVersion to tests
28
+ - ab9c1e9: chore: update assets
29
+ - 85ab331: remove unused manual register indexing
30
+ - 9257a9b: remove tick size read in connect
31
+ - d4b9ea5: feat(fun-relay): add new lighter routes
32
+ - dc9cc8c: add relay request id to error message
33
+
3
34
  ## 2.2.0-next.6
4
35
 
5
36
  ### Patch Changes
package/dist/index.js CHANGED
@@ -146,90 +146,6 @@ function getRelayClient() {
146
146
 
147
147
  // src/execution.ts
148
148
  var import_relay_sdk3 = require("@relayprotocol/relay-sdk");
149
-
150
- // src/utils.ts
151
- function convertFunToRelayTokenAddress(address, chainId) {
152
- if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {
153
- switch (chainId) {
154
- case FUN_HYPERCORE_CHAIN_ID_NUMBER:
155
- return RELAY_NATIVE_TOKEN_HYPERCORE;
156
- case RELAY_BITCOIN_CHAIN_ID_NUMBER:
157
- return RELAY_NATIVE_TOKEN_BITCOIN;
158
- // TODO: is it correct to assume chainId here is relay chain id?
159
- case RELAY_SOLANA_CHAIN_ID_NUMBER:
160
- case FUN_SOLANA_CHAIN_ID_NUMBER:
161
- return RELAY_NATIVE_TOKEN_SOLANA;
162
- case RELAY_LIGHTER_CHAIN_ID_NUMBER:
163
- return RELAY_LIGHTER_USDC_PERPS;
164
- default:
165
- return RELAY_NATIVE_TOKEN;
166
- }
167
- }
168
- if (RELAY_LIGHTER_CHAIN_ID_NUMBER === chainId) {
169
- const relayAddress = RELAY_LIGHTER_FUN_ADDRESS_MAP[address.toLowerCase()];
170
- if (relayAddress) {
171
- return relayAddress;
172
- }
173
- }
174
- return address;
175
- }
176
- function convertFunToRelayChainId(chainId) {
177
- if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {
178
- return RELAY_SOLANA_CHAIN_ID_NUMBER;
179
- }
180
- return chainId;
181
- }
182
- function getRelayExecutionRefundState(info) {
183
- switch (info.status) {
184
- case "refund" /* REFUND */:
185
- return "REFUNDED" /* REFUNDED */;
186
- default:
187
- return void 0;
188
- }
189
- }
190
- function getRelayExecutionState(info) {
191
- switch (info.status) {
192
- case "success" /* SUCCESS */:
193
- return "COMPLETED" /* COMPLETED */;
194
- case "failure" /* FAILURE */:
195
- case "refund" /* REFUND */:
196
- return "CHECKOUT_ERROR" /* CHECKOUT_ERROR */;
197
- default:
198
- return "PENDING_RECEIVAL" /* PENDING_RECEIVAL */;
199
- }
200
- }
201
- function isRelayExecutionTerminalStatus(info) {
202
- return RELAY_TERMINAL_STATUSES.includes(info.status);
203
- }
204
- function jsonStringifyWithBigIntSanitization(serializable) {
205
- return JSON.stringify(
206
- serializable,
207
- (_, value) => typeof value === "bigint" ? `0x${value.toString(16)}` : value
208
- // return everything else unchanged
209
- );
210
- }
211
- function indexBy(items, getKey) {
212
- const indexedItems = {};
213
- for (const item of items) {
214
- const key = getKey(item);
215
- if (!key) {
216
- continue;
217
- }
218
- indexedItems[key] = item;
219
- }
220
- return indexedItems;
221
- }
222
- function filterNullishHeaders(params) {
223
- const result = {};
224
- for (const [key, value] of Object.entries(params)) {
225
- if (value != null) {
226
- result[key] = value;
227
- }
228
- }
229
- return result;
230
- }
231
-
232
- // src/execution.ts
233
149
  function getTxHash({
234
150
  logger,
235
151
  transactionType,
@@ -380,18 +296,6 @@ async function executeRelayQuote({
380
296
  ) {
381
297
  logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes);
382
298
  isTransactionConfirmed = true;
383
- const firstStep = relayQuote.steps[0];
384
- const firstItem = firstStep?.items[0];
385
- if (firstStep?.requestId && firstItem) {
386
- manuallyRegisterIndex(logger, {
387
- requestId: firstStep.requestId,
388
- chainId: firstItem.data.chainId,
389
- tx: jsonStringifyWithBigIntSanitization({
390
- ...firstItem.data,
391
- txHash
392
- })
393
- });
394
- }
395
299
  try {
396
300
  await onTransactionConfirmed?.(txHash);
397
301
  } catch (e) {
@@ -405,42 +309,6 @@ async function executeRelayQuote({
405
309
  }
406
310
  });
407
311
  }
408
- async function manuallyRegisterIndex(logger, registerRequest) {
409
- const logPrefix = "manuallyRegisterIndex";
410
- const stringifiedRequest = JSON.stringify(registerRequest);
411
- const url = `${import_relay_sdk3.MAINNET_RELAY_API}/transactions/single`;
412
- try {
413
- logger.info(`${logPrefix}:onManuallyRegisterIndex`, {
414
- params: stringifiedRequest
415
- });
416
- const response = await fetch(url, {
417
- method: "POST",
418
- body: JSON.stringify(registerRequest)
419
- });
420
- if (!response.ok) {
421
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
422
- message: "Error !response.ok - request to manually register index",
423
- response: JSON.stringify(response),
424
- params: stringifiedRequest
425
- });
426
- return;
427
- }
428
- const data = await response.json();
429
- if (data.message !== "Success") {
430
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
431
- message: `Data.message is not of type Success - ${data.message}`,
432
- response: JSON.stringify(response),
433
- params: stringifiedRequest
434
- });
435
- }
436
- return;
437
- } catch (err) {
438
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
439
- message: `Error sending request to register index at ${url}: ${JSON.stringify(err?.message)}`,
440
- params: stringifiedRequest
441
- });
442
- }
443
- }
444
312
  async function getRelayExecutionInfo(requestId, apiKey) {
445
313
  const url = `${import_relay_sdk3.MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`;
446
314
  const response = await fetch(url, {
@@ -525,6 +393,83 @@ function parseRelayFees({
525
393
 
526
394
  // src/price.ts
527
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
528
473
  async function getRelayAssetPriceInfo({
529
474
  chainId,
530
475
  address,
@@ -1377,7 +1322,8 @@ var ASSET_LOGO_SRCS = {
1377
1322
  WMON: "https://sdk-cdn.fun.xyz/images/wmon.svg",
1378
1323
  AUSD: "https://sdk-cdn.fun.xyz/images/ausd.svg",
1379
1324
  SUSHI: "https://sdk-cdn.fun.xyz/images/sushi.svg",
1380
- SKY: "https://sdk-cdn.fun.xyz/images/sky.svg"
1325
+ SKY: "https://sdk-cdn.fun.xyz/images/sky.svg",
1326
+ LIT: "https://sdk-cdn.fun.xyz/images/lit.svg"
1381
1327
  };
1382
1328
 
1383
1329
  // src/dynamicRoutes/consts.ts
@@ -1392,7 +1338,6 @@ var tokenAddresses = {
1392
1338
  USDC: {
1393
1339
  [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
1394
1340
  },
1395
- // LIT is currently unused
1396
1341
  LIT: {
1397
1342
  [import_chains.mainnet.id]: (0, import_viem2.getAddress)("0x232CE3bd40fCd6f80f3d55A522d03f25Df784Ee2")
1398
1343
  },
@@ -1570,6 +1515,7 @@ var UNI_SPOT_SYMBOL = "UNI (Spot)";
1570
1515
  var AAVE_SPOT_SYMBOL = "AAVE (Spot)";
1571
1516
  var SKY_SPOT_SYMBOL = "SKY (Spot)";
1572
1517
  var LDO_SPOT_SYMBOL = "LDO (Spot)";
1518
+ var LIT_SPOT_SYMBOL = "LIT (Spot)";
1573
1519
  var generateLighterMainnetDepositActions = ({
1574
1520
  address,
1575
1521
  assetIndex,
@@ -1706,6 +1652,25 @@ var LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1706
1652
  });
1707
1653
  }
1708
1654
  });
1655
+ var LIGHTER_LIT_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1656
+ targetChain: import_chains3.mainnet.id.toString(),
1657
+ targetAsset: tokenAddresses.LIT[import_chains3.mainnet.id],
1658
+ targetAssetTicker: LIT_SPOT_SYMBOL,
1659
+ iconSrc: ASSET_LOGO_SRCS.LIT,
1660
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1661
+ if (!outputConfig) {
1662
+ return [];
1663
+ }
1664
+ if (outputConfig.targetChain !== import_chains3.mainnet.id.toString()) {
1665
+ return [];
1666
+ }
1667
+ return generateLighterMainnetDepositActions({
1668
+ address,
1669
+ assetIndex: 2 /* LIT */,
1670
+ routeType: 1 /* Spot */
1671
+ });
1672
+ }
1673
+ });
1709
1674
  var LIGHTER_LINK_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1710
1675
  targetChain: import_chains3.mainnet.id.toString(),
1711
1676
  targetAsset: tokenAddresses.LINK[import_chains3.mainnet.id],
@@ -1845,6 +1810,12 @@ var LIGHTER_DYNAMIC_ROUTES = [
1845
1810
  }
1846
1811
  }),
1847
1812
  // LINK, UNI, AAVE, SKY, LDO tokens
1813
+ createRoute({
1814
+ id: "LIGHTER_LIT_SPOT_NEW_USER",
1815
+ paths: {
1816
+ FUN_MAINNET_DEPOSIT: LIGHTER_LIT_SPOT_FUN_MAINNET_DEPOSIT
1817
+ }
1818
+ }),
1848
1819
  createRoute({
1849
1820
  id: "LIGHTER_LINK_SPOT_NEW_USER",
1850
1821
  paths: {