@spicenet-io/spiceflow-core 0.3.14 → 0.3.15

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.cjs CHANGED
@@ -23,14 +23,11 @@ __export(index_exports, {
23
23
  ChainBatchHashAbi: () => ChainBatchHashAbi,
24
24
  DELEGATE_ABI: () => DELEGATE_ABI,
25
25
  ERC20_ABI: () => ERC20_ABI,
26
+ ESCROW_ADDRESS: () => ESCROW_ADDRESS,
26
27
  HttpError: () => HttpError,
27
28
  IntentHashAbi: () => IntentHashAbi,
28
29
  NATIVE_TOKEN_ADDRESS: () => NATIVE_TOKEN_ADDRESS,
29
30
  SPICENET_NATIVE_CHAIN_ID: () => SPICENET_NATIVE_CHAIN_ID,
30
- SPICE_COMBINED_FEE_RECIPIENT: () => SPICE_COMBINED_FEE_RECIPIENT,
31
- SPICE_GAS_FEE_RECIPIENT: () => SPICE_GAS_FEE_RECIPIENT,
32
- SPICE_PLATFORM_FEE_RECIPIENT: () => SPICE_PLATFORM_FEE_RECIPIENT,
33
- SPICE_SOLVER_ADDRESS: () => SPICE_SOLVER_ADDRESS,
34
31
  STARKNET_MAINNET_CHAIN_ID: () => STARKNET_MAINNET_CHAIN_ID,
35
32
  SpiceFlowCore: () => SpiceFlowCore,
36
33
  TOKENS: () => TOKENS,
@@ -52,8 +49,6 @@ __export(index_exports, {
52
49
  getDeployment: () => getDeployment,
53
50
  getEquivalenceGroup: () => getEquivalenceGroup,
54
51
  getEquivalentAddresses: () => getEquivalentAddresses,
55
- getEscrowContract: () => getEscrowContract,
56
- getEscrowContractAddress: () => getEscrowContractAddress,
57
52
  getIntentHash: () => getIntentHash,
58
53
  getIntentStepStatus: () => getIntentStepStatus,
59
54
  getMainnetChains: () => getMainnetChains,
@@ -75,9 +70,6 @@ __export(index_exports, {
75
70
  requireTokenBySymbol: () => requireTokenBySymbol,
76
71
  requireViemChain: () => requireViemChain,
77
72
  resolveTokenRef: () => resolveTokenRef,
78
- spicenetAbi: () => spicenetAbi,
79
- spicenetEscrowAbi: () => spicenetEscrowAbi,
80
- spicenetWalletManagerAbi: () => spicenetEscrowAbi,
81
73
  submitTransaction: () => submitTransaction,
82
74
  truncateAddress: () => truncateAddress,
83
75
  uniV3QuoterV2Abi: () => uniV3QuoterV2Abi,
@@ -125,7 +117,7 @@ function getIntentHash(signatureType, nbf, exp, chainBatches) {
125
117
  );
126
118
  }
127
119
  async function getAccountNonce(address, publicClient) {
128
- return await publicClient.getTransactionCount({ address });
120
+ return await publicClient.getTransactionCount({ address, blockTag: "pending" });
129
121
  }
130
122
  async function getRecentBlock(publicClient) {
131
123
  return await publicClient.getBlockNumber();
@@ -750,8 +742,9 @@ var CHAINS = {
750
742
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
751
743
  delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
752
744
  blockExplorer: "https://etherscan.io",
753
- rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
754
- logo: logo_eth
745
+ rpcUrl: "https://eth.llamarpc.com",
746
+ logo: logo_eth,
747
+ moralisId: "0x1"
755
748
  },
756
749
  8453: {
757
750
  id: 8453,
@@ -760,10 +753,10 @@ var CHAINS = {
760
753
  network: "mainnet",
761
754
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
762
755
  delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
763
- escrowContract: "0xd3F8f177BB3d7dfD883d7c232f3093EdD61C3De9",
764
756
  blockExplorer: "https://basescan.org",
765
- rpcUrl: "https://base-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
766
- logo: logo_base
757
+ rpcUrl: "https://mainnet.base.org",
758
+ logo: logo_base,
759
+ moralisId: "0x2105"
767
760
  },
768
761
  42161: {
769
762
  id: 42161,
@@ -772,10 +765,10 @@ var CHAINS = {
772
765
  network: "mainnet",
773
766
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
774
767
  delegateContract: "0x262E1A689555dA5209113A056d0d164EF8355395",
775
- escrowContract: "0x47d6DB10d99b1E0A074B1467407C7A53B68e1147",
776
768
  blockExplorer: "https://arbiscan.io",
777
- rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
778
- logo: logo_arb
769
+ rpcUrl: "https://arb1.arbitrum.io/rpc",
770
+ logo: logo_arb,
771
+ moralisId: "0xa4b1"
779
772
  },
780
773
  4114: {
781
774
  id: 4114,
@@ -784,9 +777,8 @@ var CHAINS = {
784
777
  network: "mainnet",
785
778
  nativeCurrency: { name: "Citrea Bitcoin", symbol: "cBTC", decimals: 18 },
786
779
  delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
787
- escrowContract: "0x3677113f10d82acFEeDd22dF5c7cFD58736111ee",
788
780
  blockExplorer: "https://explorer.mainnet.citrea.xyz",
789
- rpcUrl: "https://citrea-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
781
+ rpcUrl: "https://rpc.mainnet.citrea.xyz",
790
782
  logo: logo_citrea,
791
783
  wrappedNativeTokenAddress: "0x3100000000000000000000000000000000000006"
792
784
  },
@@ -832,7 +824,6 @@ var CHAINS = {
832
824
  network: "testnet",
833
825
  nativeCurrency: { name: "cBTC", symbol: "cBTC", decimals: 18 },
834
826
  delegateContract: "0x347056dd1CB95ae850192e3fC6FA995537A3A091",
835
- escrowContract: "0xDf5616Fe65f103972c25EF596C6386904E5CbC8f",
836
827
  blockExplorer: "https://explorer.testnet.citrea.xyz",
837
828
  rpcUrl: "https://rpc.testnet.citrea.xyz",
838
829
  logo: logo_citrea,
@@ -965,9 +956,6 @@ function getAllChainsByNetwork(network) {
965
956
  function getDelegateContract(chainId) {
966
957
  return CHAINS[chainId]?.delegateContract;
967
958
  }
968
- function getEscrowContract(chainId) {
969
- return CHAINS[chainId]?.escrowContract;
970
- }
971
959
  function toViemChain(meta) {
972
960
  if (meta.chainType === "starknet") return void 0;
973
961
  return (0, import_viem2.defineChain)({
@@ -1011,13 +999,7 @@ var STARKNET_MAINNET_CHAIN_ID = 23448594291968336;
1011
999
  // src/utils.ts
1012
1000
  var NATIVE_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
1013
1001
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
1014
- function getEscrowContractAddress(chainId) {
1015
- const escrow = getEscrowContract(chainId);
1016
- if (!escrow) {
1017
- throw new Error(`Escrow contract not configured for chain ${chainId}`);
1018
- }
1019
- return escrow;
1020
- }
1002
+ var ESCROW_ADDRESS = "0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2";
1021
1003
  function isNativeToken(address) {
1022
1004
  const lower = address.toLowerCase();
1023
1005
  return lower === "0x0" || lower === "0x0000000000000000000000000000000000000000" || lower === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
@@ -1428,1226 +1410,64 @@ var uniV3SwapRouterAbi = [
1428
1410
  }
1429
1411
  ];
1430
1412
 
1431
- // src/abis/spicenet.ts
1432
- var spicenetAbi = [
1433
- {
1434
- type: "function",
1435
- name: "closeRebalancingRequest",
1436
- inputs: [
1437
- {
1438
- name: "args",
1439
- type: "tuple",
1440
- internalType: "struct Spicenet.CloseRebalancingRequestArgs",
1441
- components: [
1442
- {
1443
- name: "idempotenceKey",
1444
- type: "bytes32",
1445
- internalType: "bytes32"
1446
- },
1447
- {
1448
- name: "repaymentChainTokenAmount",
1449
- type: "uint256",
1450
- internalType: "uint256"
1451
- }
1452
- ]
1453
- }
1454
- ],
1455
- outputs: [],
1456
- stateMutability: "nonpayable"
1457
- },
1458
- {
1459
- type: "function",
1460
- name: "createWithdrawalRequest",
1461
- inputs: [
1462
- {
1463
- name: "request",
1464
- type: "tuple",
1465
- internalType: "struct Spicenet.CreateWithdrawalRequestArgs",
1466
- components: [
1467
- {
1468
- name: "chainId",
1469
- type: "string",
1470
- internalType: "string"
1471
- },
1472
- {
1473
- name: "idempotenceKey",
1474
- type: "bytes32",
1475
- internalType: "bytes32"
1476
- },
1477
- {
1478
- name: "nbf",
1479
- type: "uint256",
1480
- internalType: "uint256"
1481
- },
1482
- {
1483
- name: "exp",
1484
- type: "uint256",
1485
- internalType: "uint256"
1486
- },
1487
- {
1488
- name: "metadata",
1489
- type: "string",
1490
- internalType: "string"
1491
- },
1492
- {
1493
- name: "transfers",
1494
- type: "tuple[]",
1495
- internalType: "struct Spicenet.CreateTokenTransfer[]",
1496
- components: [
1497
- {
1498
- name: "token",
1499
- type: "string",
1500
- internalType: "string"
1501
- },
1502
- {
1503
- name: "to",
1504
- type: "string",
1505
- internalType: "string"
1506
- },
1507
- {
1508
- name: "amount",
1509
- type: "uint256",
1510
- internalType: "uint256"
1511
- }
1512
- ]
1513
- }
1514
- ]
1515
- }
1516
- ],
1517
- outputs: [],
1518
- stateMutability: "nonpayable"
1519
- },
1520
- {
1521
- type: "function",
1522
- name: "createRebalancingRequest",
1523
- inputs: [
1524
- {
1525
- name: "request",
1526
- type: "tuple",
1527
- internalType: "struct Spicenet.CreateRebalancingRequestArgs",
1528
- components: [
1529
- {
1530
- name: "idempotenceKey",
1531
- type: "bytes32",
1532
- internalType: "bytes32"
1533
- },
1534
- {
1535
- name: "nbf",
1536
- type: "uint256",
1537
- internalType: "uint256"
1538
- },
1539
- {
1540
- name: "exp",
1541
- type: "uint256",
1542
- internalType: "uint256"
1543
- },
1544
- {
1545
- name: "metadata",
1546
- type: "string",
1547
- internalType: "string"
1548
- },
1549
- {
1550
- name: "recipient",
1551
- type: "string",
1552
- internalType: "string"
1553
- },
1554
- {
1555
- name: "fromChainToken",
1556
- type: "string",
1557
- internalType: "string"
1558
- },
1559
- {
1560
- name: "fromChainTokenAmount",
1561
- type: "uint256",
1562
- internalType: "uint256"
1563
- },
1564
- {
1565
- name: "toChainToken",
1566
- type: "string",
1567
- internalType: "string"
1568
- },
1569
- {
1570
- name: "toChainTokenAmountMin",
1571
- type: "uint256",
1572
- internalType: "uint256"
1573
- }
1574
- ]
1575
- }
1576
- ],
1577
- outputs: [],
1578
- stateMutability: "nonpayable"
1579
- }
1580
- ];
1581
-
1582
- // src/abis/spicenetEscrow.ts
1583
- var spicenetEscrowAbi = [
1584
- {
1585
- type: "constructor",
1586
- inputs: [],
1587
- stateMutability: "nonpayable"
1588
- },
1589
- {
1590
- type: "receive",
1591
- stateMutability: "payable"
1592
- },
1593
- {
1594
- type: "function",
1595
- name: "DEFAULT_ADMIN_ROLE",
1596
- inputs: [],
1597
- outputs: [
1598
- {
1599
- name: "",
1600
- type: "bytes32",
1601
- internalType: "bytes32"
1602
- }
1603
- ],
1604
- stateMutability: "view"
1605
- },
1606
- {
1607
- type: "function",
1608
- name: "PAUSER_ROLE",
1609
- inputs: [],
1610
- outputs: [
1611
- {
1612
- name: "",
1613
- type: "bytes32",
1614
- internalType: "bytes32"
1615
- }
1616
- ],
1617
- stateMutability: "view"
1618
- },
1619
- {
1620
- type: "function",
1621
- name: "RELAYER_ROLE",
1622
- inputs: [],
1623
- outputs: [
1624
- {
1625
- name: "",
1626
- type: "bytes32",
1627
- internalType: "bytes32"
1628
- }
1629
- ],
1630
- stateMutability: "view"
1631
- },
1632
- {
1633
- type: "function",
1634
- name: "UNPAUSER_ROLE",
1635
- inputs: [],
1636
- outputs: [
1637
- {
1638
- name: "",
1639
- type: "bytes32",
1640
- internalType: "bytes32"
1641
- }
1642
- ],
1643
- stateMutability: "view"
1644
- },
1645
- {
1646
- type: "function",
1647
- name: "UPGRADER_ROLE",
1648
- inputs: [],
1649
- outputs: [
1650
- {
1651
- name: "",
1652
- type: "bytes32",
1653
- internalType: "bytes32"
1654
- }
1655
- ],
1656
- stateMutability: "view"
1657
- },
1658
- {
1659
- type: "function",
1660
- name: "UPGRADE_INTERFACE_VERSION",
1661
- inputs: [],
1662
- outputs: [
1663
- {
1664
- name: "",
1665
- type: "string",
1666
- internalType: "string"
1667
- }
1668
- ],
1669
- stateMutability: "view"
1670
- },
1671
- {
1672
- type: "function",
1673
- name: "adminProcessWithdrawalRequestEvents",
1674
- inputs: [
1675
- {
1676
- name: "requests",
1677
- type: "tuple[]",
1678
- internalType: "struct ISpicenetEscrow.WithdrawalRequest[]",
1679
- components: [
1680
- {
1681
- name: "idempotenceKey",
1682
- type: "bytes32",
1683
- internalType: "bytes32"
1684
- },
1685
- {
1686
- name: "forUser",
1687
- type: "string",
1688
- internalType: "string"
1689
- },
1690
- {
1691
- name: "nbf",
1692
- type: "uint256",
1693
- internalType: "uint256"
1694
- },
1695
- {
1696
- name: "exp",
1697
- type: "uint256",
1698
- internalType: "uint256"
1699
- },
1700
- {
1701
- name: "metadata",
1702
- type: "string",
1703
- internalType: "string"
1704
- },
1705
- {
1706
- name: "transfers",
1707
- type: "tuple[]",
1708
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
1709
- components: [
1710
- {
1711
- name: "token",
1712
- type: "address",
1713
- internalType: "address"
1714
- },
1715
- {
1716
- name: "to",
1717
- type: "address",
1718
- internalType: "address"
1719
- },
1720
- {
1721
- name: "amount",
1722
- type: "uint256",
1723
- internalType: "uint256"
1724
- }
1725
- ]
1726
- }
1727
- ]
1728
- }
1729
- ],
1730
- outputs: [],
1731
- stateMutability: "nonpayable"
1732
- },
1733
- {
1734
- type: "function",
1735
- name: "adminSetWithdrawalInfos",
1736
- inputs: [
1737
- {
1738
- name: "idempotenceKeys",
1739
- type: "bytes32[]",
1740
- internalType: "bytes32[]"
1741
- },
1742
- {
1743
- name: "withdrawalInfos",
1744
- type: "tuple[]",
1745
- internalType: "struct ISpicenetEscrow.WithdrawalInfo[]",
1746
- components: [
1747
- {
1748
- name: "forUser",
1749
- type: "string",
1750
- internalType: "string"
1751
- },
1752
- {
1753
- name: "blockNumber",
1754
- type: "uint256",
1755
- internalType: "uint256"
1756
- },
1757
- {
1758
- name: "nbf",
1759
- type: "uint256",
1760
- internalType: "uint256"
1761
- },
1762
- {
1763
- name: "exp",
1764
- type: "uint256",
1765
- internalType: "uint256"
1766
- },
1767
- {
1768
- name: "metadata",
1769
- type: "string",
1770
- internalType: "string"
1771
- }
1772
- ]
1773
- }
1774
- ],
1775
- outputs: [],
1776
- stateMutability: "nonpayable"
1777
- },
1778
- {
1779
- type: "function",
1780
- name: "adminWithdraw",
1781
- inputs: [
1782
- {
1783
- name: "transfers",
1784
- type: "tuple[]",
1785
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
1786
- components: [
1787
- {
1788
- name: "token",
1789
- type: "address",
1790
- internalType: "address"
1791
- },
1792
- {
1793
- name: "to",
1794
- type: "address",
1795
- internalType: "address"
1796
- },
1413
+ // src/swap.ts
1414
+ var import_viem3 = require("viem");
1415
+ function applySlippage(amount, slippage = 0.03) {
1416
+ const slippageBps = BigInt(Math.floor((1 - slippage) * 1e4));
1417
+ return amount * slippageBps / 10000n;
1418
+ }
1419
+ function buildUniV3SwapCalls(params) {
1420
+ const {
1421
+ tokenIn,
1422
+ tokenOut,
1423
+ amountIn,
1424
+ amountOutMinimum,
1425
+ fee,
1426
+ recipient,
1427
+ config
1428
+ } = params;
1429
+ return [
1430
+ {
1431
+ to: tokenIn,
1432
+ value: 0n,
1433
+ data: (0, import_viem3.encodeFunctionData)({
1434
+ abi: import_viem3.erc20Abi,
1435
+ functionName: "approve",
1436
+ args: [config.swapRouter, amountIn]
1437
+ })
1438
+ },
1439
+ {
1440
+ to: config.swapRouter,
1441
+ value: 0n,
1442
+ data: (0, import_viem3.encodeFunctionData)({
1443
+ abi: uniV3SwapRouterAbi,
1444
+ functionName: "exactInputSingle",
1445
+ args: [
1797
1446
  {
1798
- name: "amount",
1799
- type: "uint256",
1800
- internalType: "uint256"
1801
- }
1802
- ]
1803
- }
1804
- ],
1805
- outputs: [],
1806
- stateMutability: "nonpayable"
1807
- },
1808
- {
1809
- type: "function",
1810
- name: "getRoleAdmin",
1811
- inputs: [
1812
- {
1813
- name: "role",
1814
- type: "bytes32",
1815
- internalType: "bytes32"
1816
- }
1817
- ],
1818
- outputs: [
1819
- {
1820
- name: "",
1821
- type: "bytes32",
1822
- internalType: "bytes32"
1823
- }
1824
- ],
1825
- stateMutability: "view"
1826
- },
1827
- {
1828
- type: "function",
1829
- name: "getRoleMember",
1830
- inputs: [
1831
- {
1832
- name: "role",
1833
- type: "bytes32",
1834
- internalType: "bytes32"
1835
- },
1836
- {
1837
- name: "index",
1838
- type: "uint256",
1839
- internalType: "uint256"
1840
- }
1841
- ],
1842
- outputs: [
1843
- {
1844
- name: "",
1845
- type: "address",
1846
- internalType: "address"
1847
- }
1848
- ],
1849
- stateMutability: "view"
1850
- },
1851
- {
1852
- type: "function",
1853
- name: "getRoleMemberCount",
1854
- inputs: [
1855
- {
1856
- name: "role",
1857
- type: "bytes32",
1858
- internalType: "bytes32"
1859
- }
1860
- ],
1861
- outputs: [
1862
- {
1863
- name: "",
1864
- type: "uint256",
1865
- internalType: "uint256"
1866
- }
1867
- ],
1868
- stateMutability: "view"
1869
- },
1870
- {
1871
- type: "function",
1872
- name: "getRoleMembers",
1873
- inputs: [
1874
- {
1875
- name: "role",
1876
- type: "bytes32",
1877
- internalType: "bytes32"
1878
- }
1879
- ],
1880
- outputs: [
1881
- {
1882
- name: "",
1883
- type: "address[]",
1884
- internalType: "address[]"
1885
- }
1886
- ],
1887
- stateMutability: "view"
1888
- },
1889
- {
1890
- type: "function",
1891
- name: "getWithdrawalInfo",
1892
- inputs: [
1893
- {
1894
- name: "idempotenceKey",
1895
- type: "bytes32",
1896
- internalType: "bytes32"
1897
- }
1898
- ],
1899
- outputs: [
1900
- {
1901
- name: "",
1902
- type: "tuple",
1903
- internalType: "struct ISpicenetEscrow.WithdrawalInfo",
1904
- components: [
1905
- {
1906
- name: "forUser",
1907
- type: "string",
1908
- internalType: "string"
1909
- },
1910
- {
1911
- name: "blockNumber",
1912
- type: "uint256",
1913
- internalType: "uint256"
1914
- },
1915
- {
1916
- name: "nbf",
1917
- type: "uint256",
1918
- internalType: "uint256"
1919
- },
1920
- {
1921
- name: "exp",
1922
- type: "uint256",
1923
- internalType: "uint256"
1924
- },
1925
- {
1926
- name: "metadata",
1927
- type: "string",
1928
- internalType: "string"
1929
- }
1930
- ]
1931
- }
1932
- ],
1933
- stateMutability: "view"
1934
- },
1935
- {
1936
- type: "function",
1937
- name: "grantRole",
1938
- inputs: [
1939
- {
1940
- name: "role",
1941
- type: "bytes32",
1942
- internalType: "bytes32"
1943
- },
1944
- {
1945
- name: "account",
1946
- type: "address",
1947
- internalType: "address"
1948
- }
1949
- ],
1950
- outputs: [],
1951
- stateMutability: "nonpayable"
1952
- },
1953
- {
1954
- type: "function",
1955
- name: "hasRole",
1956
- inputs: [
1957
- {
1958
- name: "role",
1959
- type: "bytes32",
1960
- internalType: "bytes32"
1961
- },
1962
- {
1963
- name: "account",
1964
- type: "address",
1965
- internalType: "address"
1966
- }
1967
- ],
1968
- outputs: [
1969
- {
1970
- name: "",
1971
- type: "bool",
1972
- internalType: "bool"
1973
- }
1974
- ],
1975
- stateMutability: "view"
1976
- },
1977
- {
1978
- type: "function",
1979
- name: "initialize",
1980
- inputs: [
1981
- {
1982
- name: "defaultAdmin",
1983
- type: "address",
1984
- internalType: "address"
1985
- }
1986
- ],
1987
- outputs: [],
1988
- stateMutability: "nonpayable"
1989
- },
1990
- {
1991
- type: "function",
1992
- name: "pause",
1993
- inputs: [],
1994
- outputs: [],
1995
- stateMutability: "nonpayable"
1996
- },
1997
- {
1998
- type: "function",
1999
- name: "paused",
2000
- inputs: [],
2001
- outputs: [
2002
- {
2003
- name: "",
2004
- type: "bool",
2005
- internalType: "bool"
2006
- }
2007
- ],
2008
- stateMutability: "view"
2009
- },
2010
- {
2011
- type: "function",
2012
- name: "processWithdrawal",
2013
- inputs: [
2014
- {
2015
- name: "request",
2016
- type: "tuple",
2017
- internalType: "struct ISpicenetEscrow.WithdrawalRequest",
2018
- components: [
2019
- {
2020
- name: "idempotenceKey",
2021
- type: "bytes32",
2022
- internalType: "bytes32"
2023
- },
2024
- {
2025
- name: "forUser",
2026
- type: "string",
2027
- internalType: "string"
2028
- },
2029
- {
2030
- name: "nbf",
2031
- type: "uint256",
2032
- internalType: "uint256"
2033
- },
2034
- {
2035
- name: "exp",
2036
- type: "uint256",
2037
- internalType: "uint256"
2038
- },
2039
- {
2040
- name: "metadata",
2041
- type: "string",
2042
- internalType: "string"
2043
- },
2044
- {
2045
- name: "transfers",
2046
- type: "tuple[]",
2047
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
2048
- components: [
2049
- {
2050
- name: "token",
2051
- type: "address",
2052
- internalType: "address"
2053
- },
2054
- {
2055
- name: "to",
2056
- type: "address",
2057
- internalType: "address"
2058
- },
2059
- {
2060
- name: "amount",
2061
- type: "uint256",
2062
- internalType: "uint256"
2063
- }
2064
- ]
2065
- }
2066
- ]
2067
- }
2068
- ],
2069
- outputs: [],
2070
- stateMutability: "nonpayable"
2071
- },
2072
- {
2073
- type: "function",
2074
- name: "proxiableUUID",
2075
- inputs: [],
2076
- outputs: [
2077
- {
2078
- name: "",
2079
- type: "bytes32",
2080
- internalType: "bytes32"
2081
- }
2082
- ],
2083
- stateMutability: "view"
2084
- },
2085
- {
2086
- type: "function",
2087
- name: "renounceRole",
2088
- inputs: [
2089
- {
2090
- name: "role",
2091
- type: "bytes32",
2092
- internalType: "bytes32"
2093
- },
2094
- {
2095
- name: "callerConfirmation",
2096
- type: "address",
2097
- internalType: "address"
2098
- }
2099
- ],
2100
- outputs: [],
2101
- stateMutability: "nonpayable"
2102
- },
2103
- {
2104
- type: "function",
2105
- name: "revokeRole",
2106
- inputs: [
2107
- {
2108
- name: "role",
2109
- type: "bytes32",
2110
- internalType: "bytes32"
2111
- },
2112
- {
2113
- name: "account",
2114
- type: "address",
2115
- internalType: "address"
2116
- }
2117
- ],
2118
- outputs: [],
2119
- stateMutability: "nonpayable"
2120
- },
2121
- {
2122
- type: "function",
2123
- name: "supportsInterface",
2124
- inputs: [
2125
- {
2126
- name: "interfaceId",
2127
- type: "bytes4",
2128
- internalType: "bytes4"
2129
- }
2130
- ],
2131
- outputs: [
2132
- {
2133
- name: "",
2134
- type: "bool",
2135
- internalType: "bool"
2136
- }
2137
- ],
2138
- stateMutability: "view"
2139
- },
2140
- {
2141
- type: "function",
2142
- name: "unpause",
2143
- inputs: [],
2144
- outputs: [],
2145
- stateMutability: "nonpayable"
2146
- },
2147
- {
2148
- type: "function",
2149
- name: "upgradeToAndCall",
2150
- inputs: [
2151
- {
2152
- name: "newImplementation",
2153
- type: "address",
2154
- internalType: "address"
2155
- },
2156
- {
2157
- name: "data",
2158
- type: "bytes",
2159
- internalType: "bytes"
2160
- }
2161
- ],
2162
- outputs: [],
2163
- stateMutability: "payable"
2164
- },
2165
- {
2166
- type: "event",
2167
- name: "Initialized",
2168
- inputs: [
2169
- {
2170
- name: "version",
2171
- type: "uint64",
2172
- indexed: false,
2173
- internalType: "uint64"
2174
- }
2175
- ],
2176
- anonymous: false
2177
- },
2178
- {
2179
- type: "event",
2180
- name: "NativeTransfer",
2181
- inputs: [
2182
- {
2183
- name: "from",
2184
- type: "address",
2185
- indexed: true,
2186
- internalType: "address"
2187
- },
2188
- {
2189
- name: "to",
2190
- type: "address",
2191
- indexed: true,
2192
- internalType: "address"
2193
- },
2194
- {
2195
- name: "value",
2196
- type: "uint256",
2197
- indexed: false,
2198
- internalType: "uint256"
2199
- }
2200
- ],
2201
- anonymous: false
2202
- },
2203
- {
2204
- type: "event",
2205
- name: "Paused",
2206
- inputs: [
2207
- {
2208
- name: "account",
2209
- type: "address",
2210
- indexed: false,
2211
- internalType: "address"
2212
- }
2213
- ],
2214
- anonymous: false
2215
- },
2216
- {
2217
- type: "event",
2218
- name: "RoleAdminChanged",
2219
- inputs: [
2220
- {
2221
- name: "role",
2222
- type: "bytes32",
2223
- indexed: true,
2224
- internalType: "bytes32"
2225
- },
2226
- {
2227
- name: "previousAdminRole",
2228
- type: "bytes32",
2229
- indexed: true,
2230
- internalType: "bytes32"
2231
- },
2232
- {
2233
- name: "newAdminRole",
2234
- type: "bytes32",
2235
- indexed: true,
2236
- internalType: "bytes32"
2237
- }
2238
- ],
2239
- anonymous: false
2240
- },
2241
- {
2242
- type: "event",
2243
- name: "RoleGranted",
2244
- inputs: [
2245
- {
2246
- name: "role",
2247
- type: "bytes32",
2248
- indexed: true,
2249
- internalType: "bytes32"
2250
- },
2251
- {
2252
- name: "account",
2253
- type: "address",
2254
- indexed: true,
2255
- internalType: "address"
2256
- },
2257
- {
2258
- name: "sender",
2259
- type: "address",
2260
- indexed: true,
2261
- internalType: "address"
2262
- }
2263
- ],
2264
- anonymous: false
2265
- },
2266
- {
2267
- type: "event",
2268
- name: "RoleRevoked",
2269
- inputs: [
2270
- {
2271
- name: "role",
2272
- type: "bytes32",
2273
- indexed: true,
2274
- internalType: "bytes32"
2275
- },
2276
- {
2277
- name: "account",
2278
- type: "address",
2279
- indexed: true,
2280
- internalType: "address"
2281
- },
2282
- {
2283
- name: "sender",
2284
- type: "address",
2285
- indexed: true,
2286
- internalType: "address"
2287
- }
2288
- ],
2289
- anonymous: false
2290
- },
2291
- {
2292
- type: "event",
2293
- name: "Unpaused",
2294
- inputs: [
2295
- {
2296
- name: "account",
2297
- type: "address",
2298
- indexed: false,
2299
- internalType: "address"
2300
- }
2301
- ],
2302
- anonymous: false
2303
- },
2304
- {
2305
- type: "event",
2306
- name: "Upgraded",
2307
- inputs: [
2308
- {
2309
- name: "implementation",
2310
- type: "address",
2311
- indexed: true,
2312
- internalType: "address"
2313
- }
2314
- ],
2315
- anonymous: false
2316
- },
2317
- {
2318
- type: "event",
2319
- name: "WithdrawalProcessed",
2320
- inputs: [
2321
- {
2322
- name: "idempotenceKey",
2323
- type: "bytes32",
2324
- indexed: true,
2325
- internalType: "bytes32"
2326
- },
2327
- {
2328
- name: "forUser",
2329
- type: "string",
2330
- indexed: true,
2331
- internalType: "string"
2332
- },
2333
- {
2334
- name: "request",
2335
- type: "tuple",
2336
- indexed: false,
2337
- internalType: "struct ISpicenetEscrow.WithdrawalRequest",
2338
- components: [
2339
- {
2340
- name: "idempotenceKey",
2341
- type: "bytes32",
2342
- internalType: "bytes32"
2343
- },
2344
- {
2345
- name: "forUser",
2346
- type: "string",
2347
- internalType: "string"
2348
- },
2349
- {
2350
- name: "nbf",
2351
- type: "uint256",
2352
- internalType: "uint256"
2353
- },
2354
- {
2355
- name: "exp",
2356
- type: "uint256",
2357
- internalType: "uint256"
2358
- },
2359
- {
2360
- name: "metadata",
2361
- type: "string",
2362
- internalType: "string"
2363
- },
2364
- {
2365
- name: "transfers",
2366
- type: "tuple[]",
2367
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
2368
- components: [
2369
- {
2370
- name: "token",
2371
- type: "address",
2372
- internalType: "address"
2373
- },
2374
- {
2375
- name: "to",
2376
- type: "address",
2377
- internalType: "address"
2378
- },
2379
- {
2380
- name: "amount",
2381
- type: "uint256",
2382
- internalType: "uint256"
2383
- }
2384
- ]
2385
- }
2386
- ]
2387
- }
2388
- ],
2389
- anonymous: false
2390
- },
2391
- {
2392
- type: "error",
2393
- name: "AccessControlBadConfirmation",
2394
- inputs: []
2395
- },
2396
- {
2397
- type: "error",
2398
- name: "AccessControlUnauthorizedAccount",
2399
- inputs: [
2400
- {
2401
- name: "account",
2402
- type: "address",
2403
- internalType: "address"
2404
- },
2405
- {
2406
- name: "neededRole",
2407
- type: "bytes32",
2408
- internalType: "bytes32"
2409
- }
2410
- ]
2411
- },
2412
- {
2413
- type: "error",
2414
- name: "AddressEmptyCode",
2415
- inputs: [
2416
- {
2417
- name: "target",
2418
- type: "address",
2419
- internalType: "address"
2420
- }
2421
- ]
2422
- },
2423
- {
2424
- type: "error",
2425
- name: "ERC1967InvalidImplementation",
2426
- inputs: [
2427
- {
2428
- name: "implementation",
2429
- type: "address",
2430
- internalType: "address"
2431
- }
2432
- ]
2433
- },
2434
- {
2435
- type: "error",
2436
- name: "ERC1967NonPayable",
2437
- inputs: []
2438
- },
2439
- {
2440
- type: "error",
2441
- name: "EnforcedPause",
2442
- inputs: []
2443
- },
2444
- {
2445
- type: "error",
2446
- name: "ExpectedPause",
2447
- inputs: []
2448
- },
2449
- {
2450
- type: "error",
2451
- name: "FailedCall",
2452
- inputs: []
2453
- },
2454
- {
2455
- type: "error",
2456
- name: "InsufficientBalance",
2457
- inputs: [
2458
- {
2459
- name: "balance",
2460
- type: "uint256",
2461
- internalType: "uint256"
2462
- },
2463
- {
2464
- name: "needed",
2465
- type: "uint256",
2466
- internalType: "uint256"
2467
- }
2468
- ]
2469
- },
2470
- {
2471
- type: "error",
2472
- name: "InvalidInitialization",
2473
- inputs: []
2474
- },
2475
- {
2476
- type: "error",
2477
- name: "NotInitializing",
2478
- inputs: []
2479
- },
2480
- {
2481
- type: "error",
2482
- name: "SafeERC20FailedOperation",
2483
- inputs: [
2484
- {
2485
- name: "token",
2486
- type: "address",
2487
- internalType: "address"
2488
- }
2489
- ]
2490
- },
2491
- {
2492
- type: "error",
2493
- name: "UUPSUnauthorizedCallContext",
2494
- inputs: []
2495
- },
2496
- {
2497
- type: "error",
2498
- name: "UUPSUnsupportedProxiableUUID",
2499
- inputs: [
2500
- {
2501
- name: "slot",
2502
- type: "bytes32",
2503
- internalType: "bytes32"
2504
- }
2505
- ]
2506
- },
2507
- {
2508
- type: "error",
2509
- name: "WithdrawalAlreadyProcessed",
2510
- inputs: [
2511
- {
2512
- name: "idempotenceKey",
2513
- type: "bytes32",
2514
- internalType: "bytes32"
2515
- },
2516
- {
2517
- name: "withdrawalInfo",
2518
- type: "tuple",
2519
- internalType: "struct ISpicenetEscrow.WithdrawalInfo",
2520
- components: [
2521
- {
2522
- name: "forUser",
2523
- type: "string",
2524
- internalType: "string"
2525
- },
2526
- {
2527
- name: "blockNumber",
2528
- type: "uint256",
2529
- internalType: "uint256"
2530
- },
2531
- {
2532
- name: "nbf",
2533
- type: "uint256",
2534
- internalType: "uint256"
2535
- },
2536
- {
2537
- name: "exp",
2538
- type: "uint256",
2539
- internalType: "uint256"
2540
- },
2541
- {
2542
- name: "metadata",
2543
- type: "string",
2544
- internalType: "string"
2545
- }
2546
- ]
2547
- }
2548
- ]
2549
- },
2550
- {
2551
- type: "error",
2552
- name: "WithdrawalRequestExpired",
2553
- inputs: [
2554
- {
2555
- name: "currentTime",
2556
- type: "uint256",
2557
- internalType: "uint256"
2558
- },
2559
- {
2560
- name: "exp",
2561
- type: "uint256",
2562
- internalType: "uint256"
2563
- }
2564
- ]
2565
- },
2566
- {
2567
- type: "error",
2568
- name: "WithdrawalRequestTooEarly",
2569
- inputs: [
2570
- {
2571
- name: "currentTime",
2572
- type: "uint256",
2573
- internalType: "uint256"
2574
- },
2575
- {
2576
- name: "nbf",
2577
- type: "uint256",
2578
- internalType: "uint256"
2579
- }
2580
- ]
2581
- }
2582
- ];
2583
-
2584
- // src/swap.ts
2585
- var import_viem3 = require("viem");
2586
- function applySlippage(amount, slippage = 0.03) {
2587
- const slippageBps = BigInt(Math.floor((1 - slippage) * 1e4));
2588
- return amount * slippageBps / 10000n;
2589
- }
2590
- function buildUniV3SwapCalls(params) {
2591
- const {
2592
- tokenIn,
2593
- tokenOut,
2594
- amountIn,
2595
- amountOutMinimum,
2596
- fee,
2597
- recipient,
2598
- config
2599
- } = params;
2600
- return [
2601
- {
2602
- to: tokenIn,
2603
- value: 0n,
2604
- data: (0, import_viem3.encodeFunctionData)({
2605
- abi: import_viem3.erc20Abi,
2606
- functionName: "approve",
2607
- args: [config.swapRouter, amountIn]
2608
- })
2609
- },
2610
- {
2611
- to: config.swapRouter,
2612
- value: 0n,
2613
- data: (0, import_viem3.encodeFunctionData)({
2614
- abi: uniV3SwapRouterAbi,
2615
- functionName: "exactInputSingle",
2616
- args: [
2617
- {
2618
- tokenIn,
2619
- tokenOut,
2620
- fee,
2621
- recipient,
2622
- amountIn,
2623
- amountOutMinimum,
2624
- sqrtPriceLimitX96: 0n
1447
+ tokenIn,
1448
+ tokenOut,
1449
+ fee,
1450
+ recipient,
1451
+ amountIn,
1452
+ amountOutMinimum,
1453
+ sqrtPriceLimitX96: 0n
2625
1454
  }
2626
1455
  ]
2627
1456
  })
2628
1457
  }
2629
1458
  ];
2630
1459
  }
2631
-
2632
- // src/constants.ts
2633
- var SPICE_SOLVER_ADDRESS = "0x111115763723B53395308eC4c9AB9d5FB0844cae";
2634
- var SPICE_GAS_FEE_RECIPIENT = "0x737680c45F88A8b1b389e354dde11419f89BAdd6";
2635
- var SPICE_PLATFORM_FEE_RECIPIENT = "0xa4bB4c1D188B94c0cF691Dad213dE24169fA0A50";
2636
- var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
2637
1460
  // Annotate the CommonJS export names for ESM import in node:
2638
1461
  0 && (module.exports = {
2639
1462
  CHAINS,
2640
1463
  ChainBatchHashAbi,
2641
1464
  DELEGATE_ABI,
2642
1465
  ERC20_ABI,
1466
+ ESCROW_ADDRESS,
2643
1467
  HttpError,
2644
1468
  IntentHashAbi,
2645
1469
  NATIVE_TOKEN_ADDRESS,
2646
1470
  SPICENET_NATIVE_CHAIN_ID,
2647
- SPICE_COMBINED_FEE_RECIPIENT,
2648
- SPICE_GAS_FEE_RECIPIENT,
2649
- SPICE_PLATFORM_FEE_RECIPIENT,
2650
- SPICE_SOLVER_ADDRESS,
2651
1471
  STARKNET_MAINNET_CHAIN_ID,
2652
1472
  SpiceFlowCore,
2653
1473
  TOKENS,
@@ -2669,8 +1489,6 @@ var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
2669
1489
  getDeployment,
2670
1490
  getEquivalenceGroup,
2671
1491
  getEquivalentAddresses,
2672
- getEscrowContract,
2673
- getEscrowContractAddress,
2674
1492
  getIntentHash,
2675
1493
  getIntentStepStatus,
2676
1494
  getMainnetChains,
@@ -2692,9 +1510,6 @@ var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
2692
1510
  requireTokenBySymbol,
2693
1511
  requireViemChain,
2694
1512
  resolveTokenRef,
2695
- spicenetAbi,
2696
- spicenetEscrowAbi,
2697
- spicenetWalletManagerAbi,
2698
1513
  submitTransaction,
2699
1514
  truncateAddress,
2700
1515
  uniV3QuoterV2Abi,