@xswap-link/sdk 0.0.13 → 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.
Files changed (81) hide show
  1. package/.github/workflows/main.yml +1 -1
  2. package/.github/workflows/publish.yml +1 -1
  3. package/.prettierrc +7 -0
  4. package/CHANGELOG.md +12 -1
  5. package/README.md +23 -14
  6. package/dist/index.css +1012 -0
  7. package/dist/index.d.mts +209 -52
  8. package/dist/index.d.ts +209 -52
  9. package/dist/index.js +33963 -88
  10. package/dist/index.mjs +33949 -76
  11. package/package.json +8 -2
  12. package/postcss.config.js +3 -0
  13. package/src/components/Alert/index.tsx +9 -0
  14. package/src/components/Skeleton/index.tsx +10 -0
  15. package/src/components/TxConfigForm/Form.tsx +567 -0
  16. package/src/components/TxConfigForm/History.tsx +159 -0
  17. package/src/components/TxConfigForm/HistoryCard.tsx +209 -0
  18. package/src/components/TxConfigForm/TokenPicker.tsx +165 -0
  19. package/src/components/TxConfigForm/index.jsx +100 -0
  20. package/src/components/global.css +34 -0
  21. package/src/components/global.d.ts +6 -0
  22. package/src/components/icons/ArrowRightIcon.tsx +11 -0
  23. package/src/components/icons/ArrowUpRightIcon.tsx +11 -0
  24. package/src/components/icons/CheckIcon.tsx +11 -0
  25. package/src/components/icons/ChevronDownIcon.tsx +15 -0
  26. package/src/components/icons/ChevronUpIcon.tsx +15 -0
  27. package/src/components/icons/CircularProgressIcon.tsx +24 -0
  28. package/src/components/icons/CloseIcon.tsx +15 -0
  29. package/src/components/icons/CoinsIcon.tsx +15 -0
  30. package/src/components/icons/DownArrorIcon.tsx +17 -0
  31. package/src/components/icons/HistoryIcon.tsx +13 -0
  32. package/src/components/icons/HourGlassIcon.tsx +11 -0
  33. package/src/components/icons/PercentageIcon.tsx +29 -0
  34. package/src/components/icons/SearchIcon.tsx +15 -0
  35. package/src/components/icons/XMarkIcon.tsx +11 -0
  36. package/src/components/icons/index.ts +14 -0
  37. package/src/components/index.ts +3 -0
  38. package/src/constants/index.ts +6 -5
  39. package/src/contracts/abi/BatchQuery.json +52 -0
  40. package/src/contracts/abi/index.ts +2 -0
  41. package/src/contracts/addresses.ts +34 -0
  42. package/src/contracts/index.ts +1 -0
  43. package/src/hooks/index.ts +1 -0
  44. package/src/hooks/useDebounce.tsx +21 -0
  45. package/src/index.ts +6 -0
  46. package/src/models/Addresses.ts +12 -0
  47. package/src/models/Route.ts +17 -5
  48. package/src/models/TokenData.ts +45 -0
  49. package/src/models/TransactionHistory.ts +48 -0
  50. package/src/models/XSwapConfig.ts +3 -0
  51. package/src/models/forms/TxConfigFormData.ts +8 -0
  52. package/src/models/forms/index.ts +1 -0
  53. package/src/models/index.ts +6 -6
  54. package/src/models/integrations/GenerateStakingCallsParams.ts +8 -0
  55. package/src/models/integrations/index.ts +1 -0
  56. package/src/models/payloads/GetPricesPayload.ts +4 -0
  57. package/src/models/payloads/GetRoutePayload.ts +1 -3
  58. package/src/models/payloads/GetSwapTxPayload.ts +8 -0
  59. package/src/models/payloads/index.ts +2 -0
  60. package/src/services/api.ts +46 -64
  61. package/src/services/index.ts +1 -0
  62. package/src/services/integrations/customCalls/index.ts +1 -0
  63. package/src/services/integrations/customCalls/staking.ts +83 -0
  64. package/src/services/integrations/index.ts +2 -0
  65. package/src/services/integrations/transactions.ts +30 -0
  66. package/src/utils/contracts.ts +153 -11
  67. package/src/utils/index.ts +49 -1
  68. package/src/utils/numbers.ts +47 -0
  69. package/src/utils/strings.ts +6 -0
  70. package/tailwind.config.js +14 -0
  71. package/test/api.test.ts +1 -1
  72. package/tsconfig.json +10 -1
  73. package/xswap.config.ts +18 -0
  74. package/index.ts +0 -5
  75. package/src/models/ApiOverrides.ts +0 -3
  76. package/src/models/Chain.ts +0 -20
  77. package/src/models/Prices.ts +0 -9
  78. package/src/models/Token.ts +0 -10
  79. package/src/models/XSwapFee.ts +0 -4
  80. package/src/models/XSwapFees.ts +0 -7
  81. package/src/utils/bigNumbers.ts +0 -7
@@ -0,0 +1,11 @@
1
+ export const ArrowUpRightIcon = () => {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ viewBox="0 0 512 512"
6
+ fill="currentColor"
7
+ >
8
+ <path d="M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z" />
9
+ </svg>
10
+ );
11
+ };
@@ -0,0 +1,11 @@
1
+ export const CheckIcon = () => {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ viewBox="0 0 448 512"
6
+ fill="currentColor"
7
+ >
8
+ <path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z" />
9
+ </svg>
10
+ );
11
+ };
@@ -0,0 +1,15 @@
1
+ export const ChevronDownIcon = () => {
2
+ return (
3
+ <svg
4
+ width={16}
5
+ height={16}
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ viewBox="0 0 512 512"
8
+ >
9
+ <path
10
+ fill="currentColor"
11
+ d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
12
+ ></path>
13
+ </svg>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ export const ChevronUpIcon = () => {
2
+ return (
3
+ <svg
4
+ height={16}
5
+ width={16}
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ viewBox="0 0 512 512"
8
+ >
9
+ <path
10
+ fill="currentColor"
11
+ d="M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"
12
+ ></path>
13
+ </svg>
14
+ );
15
+ };
@@ -0,0 +1,24 @@
1
+ export const CircularProgressIcon = () => {
2
+ return (
3
+ <svg
4
+ className="animate-spin -ml-1 mr-3 h-10 w-10 text-white"
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ fill="none"
7
+ viewBox="0 0 24 24"
8
+ >
9
+ <circle
10
+ className="opacity-25"
11
+ cx="12"
12
+ cy="12"
13
+ r="10"
14
+ stroke="currentColor"
15
+ strokeWidth="4"
16
+ ></circle>
17
+ <path
18
+ className="opacity-75"
19
+ fill="currentColor"
20
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
21
+ ></path>
22
+ </svg>
23
+ );
24
+ };
@@ -0,0 +1,15 @@
1
+ export const CloseIcon = () => {
2
+ return (
3
+ <svg
4
+ height={16}
5
+ width={16}
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ viewBox="0 0 10.312 8.319"
8
+ >
9
+ <path
10
+ fill="white"
11
+ d="M6.073 4.078 10.151 0H9.093A1.87 1.87 0 0 0 7.77.548L5.157 3.162 2.543.548A1.87 1.87 0 0 0 1.22 0H.161L4.24 4.078 0 8.318h1.058a1.87 1.87 0 0 0 1.322-.547l2.777-2.777 2.776 2.777a1.869 1.869 0 0 0 1.322.548h1.058Z"
12
+ />
13
+ </svg>
14
+ );
15
+ };
@@ -0,0 +1,15 @@
1
+ export const CoinsIcon = () => {
2
+ return (
3
+ <svg
4
+ width={16}
5
+ height={16}
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ viewBox="0 0 512 512"
8
+ >
9
+ <path
10
+ fill="currentColor"
11
+ d="M512 80c0 18-14.3 34.6-38.4 48c-29.1 16.1-72.5 27.5-122.3 30.9c-3.7-1.8-7.4-3.5-11.3-5C300.6 137.4 248.2 128 192 128c-8.3 0-16.4 .2-24.5 .6l-1.1-.6C142.3 114.6 128 98 128 80c0-44.2 86-80 192-80S512 35.8 512 80zM160.7 161.1c10.2-.7 20.7-1.1 31.3-1.1c62.2 0 117.4 12.3 152.5 31.4C369.3 204.9 384 221.7 384 240c0 4-.7 7.9-2.1 11.7c-4.6 13.2-17 25.3-35 35.5c0 0 0 0 0 0c-.1 .1-.3 .1-.4 .2l0 0 0 0c-.3 .2-.6 .3-.9 .5c-35 19.4-90.8 32-153.6 32c-59.6 0-112.9-11.3-148.2-29.1c-1.9-.9-3.7-1.9-5.5-2.9C14.3 274.6 0 258 0 240c0-34.8 53.4-64.5 128-75.4c10.5-1.5 21.4-2.7 32.7-3.5zM416 240c0-21.9-10.6-39.9-24.1-53.4c28.3-4.4 54.2-11.4 76.2-20.5c16.3-6.8 31.5-15.2 43.9-25.5V176c0 19.3-16.5 37.1-43.8 50.9c-14.6 7.4-32.4 13.7-52.4 18.5c.1-1.8 .2-3.5 .2-5.3zm-32 96c0 18-14.3 34.6-38.4 48c-1.8 1-3.6 1.9-5.5 2.9C304.9 404.7 251.6 416 192 416c-62.8 0-118.6-12.6-153.6-32C14.3 370.6 0 354 0 336V300.6c12.5 10.3 27.6 18.7 43.9 25.5C83.4 342.6 135.8 352 192 352s108.6-9.4 148.1-25.9c7.8-3.2 15.3-6.9 22.4-10.9c6.1-3.4 11.8-7.2 17.2-11.2c1.5-1.1 2.9-2.3 4.3-3.4V304v5.7V336zm32 0V304 278.1c19-4.2 36.5-9.5 52.1-16c16.3-6.8 31.5-15.2 43.9-25.5V272c0 10.5-5 21-14.9 30.9c-16.3 16.3-45 29.7-81.3 38.4c.1-1.7 .2-3.5 .2-5.3zM192 448c56.2 0 108.6-9.4 148.1-25.9c16.3-6.8 31.5-15.2 43.9-25.5V432c0 44.2-86 80-192 80S0 476.2 0 432V396.6c12.5 10.3 27.6 18.7 43.9 25.5C83.4 438.6 135.8 448 192 448z"
12
+ ></path>
13
+ </svg>
14
+ );
15
+ };
@@ -0,0 +1,17 @@
1
+ export const DownArrowIcon = () => {
2
+ return (
3
+ <svg
4
+ width={16}
5
+ height={16}
6
+ viewBox="0 0 16 16"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ >
10
+ <path
11
+ d="M8.00008 9.76921L5.06421 6.83334H10.9359L8.00008 9.76921Z"
12
+ fill="white"
13
+ fillOpacity="0.2"
14
+ />
15
+ </svg>
16
+ );
17
+ };
@@ -0,0 +1,13 @@
1
+ export const HistoryIcon = () => {
2
+ return (
3
+ <svg
4
+ width={12}
5
+ height={12}
6
+ fill="white"
7
+ viewBox="0 0 12 12"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ >
10
+ <path d="M6 12C4.46667 12 3.13056 11.4917 1.99167 10.475C0.852778 9.45833 0.2 8.18889 0.0333333 6.66667H1.4C1.55556 7.82222 2.06944 8.77778 2.94167 9.53333C3.81389 10.2889 4.83333 10.6667 6 10.6667C7.3 10.6667 8.40278 10.2139 9.30833 9.30833C10.2139 8.40278 10.6667 7.3 10.6667 6C10.6667 4.7 10.2139 3.59722 9.30833 2.69167C8.40278 1.78611 7.3 1.33333 6 1.33333C5.23333 1.33333 4.51667 1.51111 3.85 1.86667C3.18333 2.22222 2.62222 2.71111 2.16667 3.33333H4V4.66667H0V0.666667H1.33333V2.23333C1.9 1.52222 2.59167 0.972222 3.40833 0.583333C4.225 0.194444 5.08889 0 6 0C6.83333 0 7.61389 0.158333 8.34167 0.475C9.06944 0.791667 9.70278 1.21944 10.2417 1.75833C10.7806 2.29722 11.2083 2.93056 11.525 3.65833C11.8417 4.38611 12 5.16667 12 6C12 6.83333 11.8417 7.61389 11.525 8.34167C11.2083 9.06944 10.7806 9.70278 10.2417 10.2417C9.70278 10.7806 9.06944 11.2083 8.34167 11.525C7.61389 11.8417 6.83333 12 6 12ZM7.86667 8.8L5.33333 6.26667V2.66667H6.66667V5.73333L8.8 7.86667L7.86667 8.8Z" />
11
+ </svg>
12
+ );
13
+ };
@@ -0,0 +1,11 @@
1
+ export const HourGlassIcon = () => {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ viewBox="0 0 384 512"
6
+ fill="currentColor"
7
+ >
8
+ <path d="M0 32C0 14.3 14.3 0 32 0H64 320h32c17.7 0 32 14.3 32 32s-14.3 32-32 32V75c0 42.4-16.9 83.1-46.9 113.1L237.3 256l67.9 67.9c30 30 46.9 70.7 46.9 113.1v11c17.7 0 32 14.3 32 32s-14.3 32-32 32H320 64 32c-17.7 0-32-14.3-32-32s14.3-32 32-32V437c0-42.4 16.9-83.1 46.9-113.1L146.7 256 78.9 188.1C48.9 158.1 32 117.4 32 75V64C14.3 64 0 49.7 0 32zM96 64V75c0 25.5 10.1 49.9 28.1 67.9L192 210.7l67.9-67.9c18-18 28.1-42.4 28.1-67.9V64H96zm0 384H288V437c0-25.5-10.1-49.9-28.1-67.9L192 301.3l-67.9 67.9c-18 18-28.1 42.4-28.1 67.9v11z" />
9
+ </svg>
10
+ );
11
+ };
@@ -0,0 +1,29 @@
1
+ export const PercentageIcon = () => {
2
+ return (
3
+ <svg
4
+ width="12"
5
+ height="12"
6
+ viewBox="0 0 12 12"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ >
10
+ <path
11
+ d="M3.00008 5.33329C2.35564 5.33329 1.80564 5.10552 1.35008 4.64996C0.894526 4.1944 0.666748 3.6444 0.666748 2.99996C0.666748 2.35551 0.894526 1.80551 1.35008 1.34996C1.80564 0.894404 2.35564 0.666626 3.00008 0.666626C3.64453 0.666626 4.19453 0.894404 4.65008 1.34996C5.10564 1.80551 5.33342 2.35551 5.33342 2.99996C5.33342 3.6444 5.10564 4.1944 4.65008 4.64996C4.19453 5.10552 3.64453 5.33329 3.00008 5.33329ZM3.00008 3.99996C3.27786 3.99996 3.51397 3.90274 3.70841 3.70829C3.90286 3.51385 4.00008 3.27774 4.00008 2.99996C4.00008 2.72218 3.90286 2.48607 3.70841 2.29163C3.51397 2.09718 3.27786 1.99996 3.00008 1.99996C2.7223 1.99996 2.48619 2.09718 2.29175 2.29163C2.0973 2.48607 2.00008 2.72218 2.00008 2.99996C2.00008 3.27774 2.0973 3.51385 2.29175 3.70829C2.48619 3.90274 2.7223 3.99996 3.00008 3.99996ZM9.00008 11.3333C8.35564 11.3333 7.80564 11.1055 7.35008 10.65C6.89453 10.1944 6.66675 9.6444 6.66675 8.99996C6.66675 8.35552 6.89453 7.80552 7.35008 7.34996C7.80564 6.8944 8.35564 6.66663 9.00008 6.66663C9.64453 6.66663 10.1945 6.8944 10.6501 7.34996C11.1056 7.80552 11.3334 8.35552 11.3334 8.99996C11.3334 9.6444 11.1056 10.1944 10.6501 10.65C10.1945 11.1055 9.64453 11.3333 9.00008 11.3333ZM9.00008 9.99996C9.27786 9.99996 9.51397 9.90274 9.70842 9.70829C9.90286 9.51385 10.0001 9.27774 10.0001 8.99996C10.0001 8.72218 9.90286 8.48607 9.70842 8.29163C9.51397 8.09718 9.27786 7.99996 9.00008 7.99996C8.7223 7.99996 8.48619 8.09718 8.29175 8.29163C8.0973 8.48607 8.00008 8.72218 8.00008 8.99996C8.00008 9.27774 8.0973 9.51385 8.29175 9.70829C8.48619 9.90274 8.7223 9.99996 9.00008 9.99996ZM1.60008 11.3333L0.666748 10.4L10.4001 0.666626L11.3334 1.59996L1.60008 11.3333Z"
12
+ fill="url(#paint0_linear_32_1164)"
13
+ />
14
+ <defs>
15
+ <linearGradient
16
+ id="paint0_linear_32_1164"
17
+ x1="0.666748"
18
+ y1="0.666626"
19
+ x2="11.9132"
20
+ y2="1.31767"
21
+ gradientUnits="userSpaceOnUse"
22
+ >
23
+ <stop stopColor="#3681C6" />
24
+ <stop offset="1" stopColor="#2B4A9D" />
25
+ </linearGradient>
26
+ </defs>
27
+ </svg>
28
+ );
29
+ };
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+
3
+ export const SearchIcon = () => {
4
+ return (
5
+ <svg
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ height="24"
8
+ width="24"
9
+ viewBox="0 -960 960 960"
10
+ fill="#ffffffc0"
11
+ >
12
+ <path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z" />
13
+ </svg>
14
+ );
15
+ };
@@ -0,0 +1,11 @@
1
+ export const XMarkIcon = () => {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ viewBox="0 0 384 512"
6
+ fill="current"
7
+ >
8
+ <path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z" />
9
+ </svg>
10
+ );
11
+ };
@@ -0,0 +1,14 @@
1
+ export * from "./ArrowRightIcon";
2
+ export * from "./ArrowUpRightIcon";
3
+ export * from "./CheckIcon";
4
+ export * from "./ChevronDownIcon";
5
+ export * from "./ChevronUpIcon";
6
+ export * from "./CircularProgressIcon";
7
+ export * from "./CloseIcon";
8
+ export * from "./CoinsIcon";
9
+ export * from "./DownArrorIcon";
10
+ export * from "./HistoryIcon";
11
+ export * from "./HourGlassIcon";
12
+ export * from "./SearchIcon";
13
+ export * from "./XMarkIcon";
14
+ export * from "./PercentageIcon";
@@ -0,0 +1,3 @@
1
+ export * from "./Alert";
2
+ export * from "./TxConfigForm";
3
+ export * from "./Skeleton";
@@ -1,7 +1,8 @@
1
- import { Ecosystem } from "../models";
1
+ import { Ecosystem } from "@src/models";
2
2
 
3
- export const DEFAULT_API_URL = "https://xswap.link/api";
4
- export const DEFAULT_DB_ERROR = "No data for provided parameters";
5
3
  export const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
6
- export const DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE = 105;
7
- export const DEFAULT_GAS_LIMIT_MULTIPLIER = 1.2;
4
+ export const NUMBER_INPUT_REGEX = /^[0-9]*[.,]?[0-9]*$/;
5
+ export const SLIPPAGE_PRESETS: number[] = [0.5, 1.5, 3];
6
+ export const FALLBACK_CROSSCHAIN_ESTIMATION_TIME = 30 * 60 * 1000;
7
+ export const BALANCES_CHUNK_SIZE = 500;
8
+ export const BALANCE_DISPLAY_MIN_LIMIT = 0.0001;
@@ -0,0 +1,52 @@
1
+ [
2
+ {
3
+ "inputs": [],
4
+ "name": "MismatchedLength",
5
+ "type": "error"
6
+ },
7
+ {
8
+ "inputs": [
9
+ {
10
+ "internalType": "uint256",
11
+ "name": "index",
12
+ "type": "uint256"
13
+ },
14
+ {
15
+ "internalType": "address",
16
+ "name": "targetAddress",
17
+ "type": "address"
18
+ },
19
+ {
20
+ "internalType": "bytes",
21
+ "name": "calldataBytes",
22
+ "type": "bytes"
23
+ }
24
+ ],
25
+ "name": "QueryFailed",
26
+ "type": "error"
27
+ },
28
+ {
29
+ "inputs": [
30
+ {
31
+ "internalType": "address[]",
32
+ "name": "targetAddresses",
33
+ "type": "address[]"
34
+ },
35
+ {
36
+ "internalType": "bytes[]",
37
+ "name": "calldatas",
38
+ "type": "bytes[]"
39
+ }
40
+ ],
41
+ "name": "batchQuery",
42
+ "outputs": [
43
+ {
44
+ "internalType": "bytes[]",
45
+ "name": "",
46
+ "type": "bytes[]"
47
+ }
48
+ ],
49
+ "stateMutability": "view",
50
+ "type": "function"
51
+ }
52
+ ]
@@ -1,5 +1,7 @@
1
+ import BatchQuery from "./BatchQuery.json";
1
2
  import ERC20 from "./ERC20.json";
2
3
  import XSwapRouter from "./XSwapRouter.json";
3
4
 
5
+ export const BatchQueryAbi = BatchQuery;
4
6
  export const ERC20Abi = ERC20;
5
7
  export const XSwapRouterAbi = XSwapRouter;
@@ -0,0 +1,34 @@
1
+ import { Addresses, ContractName } from "@src/models";
2
+
3
+ export const ADDRESSES: Addresses = {
4
+ // arbitrum
5
+ "42161": {
6
+ [ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
7
+ [ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
8
+ },
9
+ // avalanche
10
+ "43114": {
11
+ [ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
12
+ [ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
13
+ },
14
+ // base
15
+ "8453": {
16
+ [ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
17
+ [ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
18
+ },
19
+ // ethereum
20
+ "1": {
21
+ [ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
22
+ [ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
23
+ },
24
+ // optimism
25
+ "10": {
26
+ [ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
27
+ [ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
28
+ },
29
+ // polygon
30
+ "137": {
31
+ [ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
32
+ [ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
33
+ },
34
+ };
@@ -1 +1,2 @@
1
1
  export * from "./abi";
2
+ export * from "./addresses";
@@ -0,0 +1 @@
1
+ export * from "./useDebounce";
@@ -0,0 +1,21 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ export const useDebounce = (value: string, delay: number) => {
4
+ const timeoutRef = useRef<NodeJS.Timeout | null>(null);
5
+
6
+ useEffect(() => {
7
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
8
+
9
+ timeoutRef.current = setTimeout(() => {
10
+ setValue(value);
11
+ }, delay);
12
+
13
+ return () => {
14
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
15
+ };
16
+ }, [value, delay]);
17
+
18
+ const [debouncedValue, setValue] = useState(value);
19
+
20
+ return debouncedValue;
21
+ };
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./components";
2
+ export * from "./constants";
3
+ export * from "./contracts";
4
+ export * from "./models";
5
+ export * from "./services";
6
+ export * from "./utils";
@@ -0,0 +1,12 @@
1
+ export type Addresses = {
2
+ [chainId: string]: Contracts;
3
+ };
4
+
5
+ export type Contracts = {
6
+ [contractName in ContractName]: string;
7
+ };
8
+
9
+ export enum ContractName {
10
+ BatchQuery = "BatchQuery",
11
+ FeeCollector = "FeeCollector",
12
+ }
@@ -1,13 +1,25 @@
1
1
  import { TransactionRequest } from "@ethersproject/providers";
2
- import { XSwapFees } from "./XSwapFees";
3
2
 
4
3
  export type Route = {
5
4
  estAmountOut: string;
6
5
  minAmountOut: string;
7
- transactions: {
8
- approve?: TransactionRequest;
9
- swap: TransactionRequest;
10
- };
6
+ transactions: Transactions;
11
7
  xSwapFees: XSwapFees;
12
8
  message?: string;
13
9
  };
10
+
11
+ export type Transactions = {
12
+ approve?: TransactionRequest;
13
+ swap: TransactionRequest;
14
+ };
15
+
16
+ export type XSwapFees = {
17
+ ccipFee?: string;
18
+ xSwapFee: XSwapFee;
19
+ expressDeliveryFee?: string;
20
+ };
21
+
22
+ export type XSwapFee = {
23
+ tokenFee: string;
24
+ nativeFee: string;
25
+ };
@@ -0,0 +1,45 @@
1
+ import { Web3Environment } from "./Web3Environment";
2
+ import { BigNumber } from "ethers";
3
+
4
+ export type Chain = {
5
+ ecosystem: string;
6
+ chainId: string;
7
+ name: string;
8
+ displayName: string;
9
+ image: string;
10
+ web3Environment: Web3Environment;
11
+ tokenSymbol: string;
12
+ ccipChainId: string;
13
+ transactionExplorer: string;
14
+ bridgeSupported: boolean;
15
+ swapSupported: boolean;
16
+ tokens: Token[];
17
+ publicRpcUrls: string[];
18
+ privateRpcUrls?: string[];
19
+ scanApiURL?: string;
20
+ };
21
+
22
+ export type Token = {
23
+ address: string;
24
+ name: string;
25
+ symbol: string;
26
+ decimals: number;
27
+ image: string;
28
+ priority: number;
29
+ quickPick?: boolean;
30
+ supported?: boolean;
31
+ };
32
+
33
+ export type Prices = {
34
+ blockchainId: string;
35
+ updatedAt: Date;
36
+ prices: TokenPrices;
37
+ };
38
+
39
+ export type TokenPrices = {
40
+ [tokenAddress: string]: string;
41
+ };
42
+
43
+ export type TokenBalances = {
44
+ [tokenAddress: string]: BigNumber | undefined;
45
+ };
@@ -0,0 +1,48 @@
1
+ type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN";
2
+
3
+ export type TransactionHistory = {
4
+ history: {
5
+ transferId: string;
6
+ transferType: TransferType;
7
+ walletAddress: string;
8
+ // ExecutorRunFailed
9
+ failed: boolean;
10
+ // MessageSent
11
+ source: {
12
+ blockchainId: string;
13
+ transactionHash: string;
14
+ blockTime: Date;
15
+ tokenAmount: string;
16
+ tokenAddress: string;
17
+ transferredTokenAddress: string;
18
+ transferredTokenAmount: string;
19
+ valueForInstantCcipRecieve: string;
20
+ tokenOutAddress: string;
21
+ estimatedAmountOut: string;
22
+ targetBlockchainId: string;
23
+ } | null;
24
+ // MessageReceived
25
+ target: {
26
+ blockchainId: string;
27
+ transactionHash: string;
28
+ blockTime: Date;
29
+ tokenAmount: string;
30
+ tokenAddress: string;
31
+ } | null;
32
+ }[];
33
+ };
34
+
35
+ export type TransactionStatus = "IN_PROGRESS" | "DONE" | "REVERTED";
36
+
37
+ export type Transaction = {
38
+ hash: string;
39
+ timestamp: number;
40
+ sourceChainId: string;
41
+ targetChainId: string;
42
+ amountWei: string;
43
+ tokenAddress: string;
44
+ tokenOutAddress: string | undefined;
45
+ tokenOutAmount: string | undefined;
46
+ estimatedDeliveryTimestamp: number;
47
+ status: TransactionStatus;
48
+ };
@@ -0,0 +1,3 @@
1
+ export type XSwapConfig = {
2
+ apiUrl: string;
3
+ };
@@ -0,0 +1,8 @@
1
+ export type TxConfigFormData = {
2
+ srcChain: string;
3
+ srcToken: string;
4
+ amountIn: string;
5
+ paymentToken: string;
6
+ slippage: number;
7
+ expressDelivery: boolean;
8
+ };
@@ -0,0 +1 @@
1
+ export * from "./TxConfigFormData";
@@ -1,18 +1,18 @@
1
- export * from "./ApiOverrides";
1
+ export * from "./Addresses";
2
+ export * from "./XSwapConfig";
2
3
  export * from "./BridgeToken";
3
- export * from "./Chain";
4
+ export * from "./TokenData";
4
5
  export * from "./CoinTypeAddress";
5
6
  export * from "./CollectFees";
6
7
  export * from "./ContractCall";
7
8
  export * from "./Ecosystem";
8
9
  export * from "./Environment";
10
+ export * from "./forms";
11
+ export * from "./integrations";
9
12
  export * from "./payloads";
10
13
  export * from "./Protocol";
11
14
  export * from "./Route";
12
- export * from "./Token";
13
15
  export * from "./Web3Environment";
14
16
  export * from "./XSwapCallType";
15
- export * from "./XSwapFee";
16
- export * from "./XSwapFees";
17
17
  export * from "./Referral";
18
- export * from "./Prices";
18
+ export * from "./TransactionHistory";
@@ -0,0 +1,8 @@
1
+ export type GenerateStakingCallsParams = {
2
+ token: string;
3
+ staking: string;
4
+ stakingAbi: string;
5
+ stakingFunName: string;
6
+ // eslint-disable-next-line
7
+ stakingFunParams: any[];
8
+ };
@@ -0,0 +1 @@
1
+ export * from "./GenerateStakingCallsParams";
@@ -0,0 +1,4 @@
1
+ export type GetPricesPayload = {
2
+ chainId: string;
3
+ currency?: string;
4
+ };
@@ -1,6 +1,4 @@
1
- import { CoinTypeAddress } from "../CoinTypeAddress";
2
- import { CollectFees } from "../CollectFees";
3
- import { ContractCall } from "../ContractCall";
1
+ import { CoinTypeAddress, CollectFees, ContractCall } from "@src/models";
4
2
 
5
3
  export type GetRoutePayload = {
6
4
  fromChain: string;
@@ -0,0 +1,8 @@
1
+ import { ContractCall } from "@src/models";
2
+
3
+ export type GetSwapTxPayload = {
4
+ dstChain: string;
5
+ dstToken: string;
6
+ customContractCalls?: ContractCall[];
7
+ desc?: string;
8
+ };
@@ -1,2 +1,4 @@
1
1
  export * from "./GetRoutePayload";
2
2
  export * from "./AddReferralPayload";
3
+ export * from "./GetSwapTxPayload";
4
+ export * from "./GetPricesPayload";