@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.js CHANGED
@@ -37,7 +37,7 @@ function getIntentHash(signatureType, nbf, exp, chainBatches) {
37
37
  );
38
38
  }
39
39
  async function getAccountNonce(address, publicClient) {
40
- return await publicClient.getTransactionCount({ address });
40
+ return await publicClient.getTransactionCount({ address, blockTag: "pending" });
41
41
  }
42
42
  async function getRecentBlock(publicClient) {
43
43
  return await publicClient.getBlockNumber();
@@ -662,8 +662,9 @@ var CHAINS = {
662
662
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
663
663
  delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
664
664
  blockExplorer: "https://etherscan.io",
665
- rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
666
- logo: logo_eth
665
+ rpcUrl: "https://eth.llamarpc.com",
666
+ logo: logo_eth,
667
+ moralisId: "0x1"
667
668
  },
668
669
  8453: {
669
670
  id: 8453,
@@ -672,10 +673,10 @@ var CHAINS = {
672
673
  network: "mainnet",
673
674
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
674
675
  delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
675
- escrowContract: "0xd3F8f177BB3d7dfD883d7c232f3093EdD61C3De9",
676
676
  blockExplorer: "https://basescan.org",
677
- rpcUrl: "https://base-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
678
- logo: logo_base
677
+ rpcUrl: "https://mainnet.base.org",
678
+ logo: logo_base,
679
+ moralisId: "0x2105"
679
680
  },
680
681
  42161: {
681
682
  id: 42161,
@@ -684,10 +685,10 @@ var CHAINS = {
684
685
  network: "mainnet",
685
686
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
686
687
  delegateContract: "0x262E1A689555dA5209113A056d0d164EF8355395",
687
- escrowContract: "0x47d6DB10d99b1E0A074B1467407C7A53B68e1147",
688
688
  blockExplorer: "https://arbiscan.io",
689
- rpcUrl: "https://arb-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
690
- logo: logo_arb
689
+ rpcUrl: "https://arb1.arbitrum.io/rpc",
690
+ logo: logo_arb,
691
+ moralisId: "0xa4b1"
691
692
  },
692
693
  4114: {
693
694
  id: 4114,
@@ -696,9 +697,8 @@ var CHAINS = {
696
697
  network: "mainnet",
697
698
  nativeCurrency: { name: "Citrea Bitcoin", symbol: "cBTC", decimals: 18 },
698
699
  delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
699
- escrowContract: "0x3677113f10d82acFEeDd22dF5c7cFD58736111ee",
700
700
  blockExplorer: "https://explorer.mainnet.citrea.xyz",
701
- rpcUrl: "https://citrea-mainnet.g.alchemy.com/v2/7SgOekVydB9TOyNk3NKj8",
701
+ rpcUrl: "https://rpc.mainnet.citrea.xyz",
702
702
  logo: logo_citrea,
703
703
  wrappedNativeTokenAddress: "0x3100000000000000000000000000000000000006"
704
704
  },
@@ -744,7 +744,6 @@ var CHAINS = {
744
744
  network: "testnet",
745
745
  nativeCurrency: { name: "cBTC", symbol: "cBTC", decimals: 18 },
746
746
  delegateContract: "0x347056dd1CB95ae850192e3fC6FA995537A3A091",
747
- escrowContract: "0xDf5616Fe65f103972c25EF596C6386904E5CbC8f",
748
747
  blockExplorer: "https://explorer.testnet.citrea.xyz",
749
748
  rpcUrl: "https://rpc.testnet.citrea.xyz",
750
749
  logo: logo_citrea,
@@ -877,9 +876,6 @@ function getAllChainsByNetwork(network) {
877
876
  function getDelegateContract(chainId) {
878
877
  return CHAINS[chainId]?.delegateContract;
879
878
  }
880
- function getEscrowContract(chainId) {
881
- return CHAINS[chainId]?.escrowContract;
882
- }
883
879
  function toViemChain(meta) {
884
880
  if (meta.chainType === "starknet") return void 0;
885
881
  return defineChain({
@@ -923,13 +919,7 @@ var STARKNET_MAINNET_CHAIN_ID = 23448594291968336;
923
919
  // src/utils.ts
924
920
  var NATIVE_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
925
921
  var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
926
- function getEscrowContractAddress(chainId) {
927
- const escrow = getEscrowContract(chainId);
928
- if (!escrow) {
929
- throw new Error(`Escrow contract not configured for chain ${chainId}`);
930
- }
931
- return escrow;
932
- }
922
+ var ESCROW_ADDRESS = "0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2";
933
923
  function isNativeToken(address) {
934
924
  const lower = address.toLowerCase();
935
925
  return lower === "0x0" || lower === "0x0000000000000000000000000000000000000000" || lower === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
@@ -1340,1225 +1330,63 @@ var uniV3SwapRouterAbi = [
1340
1330
  }
1341
1331
  ];
1342
1332
 
1343
- // src/abis/spicenet.ts
1344
- var spicenetAbi = [
1345
- {
1346
- type: "function",
1347
- name: "closeRebalancingRequest",
1348
- inputs: [
1349
- {
1350
- name: "args",
1351
- type: "tuple",
1352
- internalType: "struct Spicenet.CloseRebalancingRequestArgs",
1353
- components: [
1354
- {
1355
- name: "idempotenceKey",
1356
- type: "bytes32",
1357
- internalType: "bytes32"
1358
- },
1359
- {
1360
- name: "repaymentChainTokenAmount",
1361
- type: "uint256",
1362
- internalType: "uint256"
1363
- }
1364
- ]
1365
- }
1366
- ],
1367
- outputs: [],
1368
- stateMutability: "nonpayable"
1369
- },
1370
- {
1371
- type: "function",
1372
- name: "createWithdrawalRequest",
1373
- inputs: [
1374
- {
1375
- name: "request",
1376
- type: "tuple",
1377
- internalType: "struct Spicenet.CreateWithdrawalRequestArgs",
1378
- components: [
1379
- {
1380
- name: "chainId",
1381
- type: "string",
1382
- internalType: "string"
1383
- },
1384
- {
1385
- name: "idempotenceKey",
1386
- type: "bytes32",
1387
- internalType: "bytes32"
1388
- },
1389
- {
1390
- name: "nbf",
1391
- type: "uint256",
1392
- internalType: "uint256"
1393
- },
1394
- {
1395
- name: "exp",
1396
- type: "uint256",
1397
- internalType: "uint256"
1398
- },
1399
- {
1400
- name: "metadata",
1401
- type: "string",
1402
- internalType: "string"
1403
- },
1404
- {
1405
- name: "transfers",
1406
- type: "tuple[]",
1407
- internalType: "struct Spicenet.CreateTokenTransfer[]",
1408
- components: [
1409
- {
1410
- name: "token",
1411
- type: "string",
1412
- internalType: "string"
1413
- },
1414
- {
1415
- name: "to",
1416
- type: "string",
1417
- internalType: "string"
1418
- },
1419
- {
1420
- name: "amount",
1421
- type: "uint256",
1422
- internalType: "uint256"
1423
- }
1424
- ]
1425
- }
1426
- ]
1427
- }
1428
- ],
1429
- outputs: [],
1430
- stateMutability: "nonpayable"
1431
- },
1432
- {
1433
- type: "function",
1434
- name: "createRebalancingRequest",
1435
- inputs: [
1436
- {
1437
- name: "request",
1438
- type: "tuple",
1439
- internalType: "struct Spicenet.CreateRebalancingRequestArgs",
1440
- components: [
1441
- {
1442
- name: "idempotenceKey",
1443
- type: "bytes32",
1444
- internalType: "bytes32"
1445
- },
1446
- {
1447
- name: "nbf",
1448
- type: "uint256",
1449
- internalType: "uint256"
1450
- },
1451
- {
1452
- name: "exp",
1453
- type: "uint256",
1454
- internalType: "uint256"
1455
- },
1456
- {
1457
- name: "metadata",
1458
- type: "string",
1459
- internalType: "string"
1460
- },
1461
- {
1462
- name: "recipient",
1463
- type: "string",
1464
- internalType: "string"
1465
- },
1466
- {
1467
- name: "fromChainToken",
1468
- type: "string",
1469
- internalType: "string"
1470
- },
1471
- {
1472
- name: "fromChainTokenAmount",
1473
- type: "uint256",
1474
- internalType: "uint256"
1475
- },
1476
- {
1477
- name: "toChainToken",
1478
- type: "string",
1479
- internalType: "string"
1480
- },
1481
- {
1482
- name: "toChainTokenAmountMin",
1483
- type: "uint256",
1484
- internalType: "uint256"
1485
- }
1486
- ]
1487
- }
1488
- ],
1489
- outputs: [],
1490
- stateMutability: "nonpayable"
1491
- }
1492
- ];
1493
-
1494
- // src/abis/spicenetEscrow.ts
1495
- var spicenetEscrowAbi = [
1496
- {
1497
- type: "constructor",
1498
- inputs: [],
1499
- stateMutability: "nonpayable"
1500
- },
1501
- {
1502
- type: "receive",
1503
- stateMutability: "payable"
1504
- },
1505
- {
1506
- type: "function",
1507
- name: "DEFAULT_ADMIN_ROLE",
1508
- inputs: [],
1509
- outputs: [
1510
- {
1511
- name: "",
1512
- type: "bytes32",
1513
- internalType: "bytes32"
1514
- }
1515
- ],
1516
- stateMutability: "view"
1517
- },
1518
- {
1519
- type: "function",
1520
- name: "PAUSER_ROLE",
1521
- inputs: [],
1522
- outputs: [
1523
- {
1524
- name: "",
1525
- type: "bytes32",
1526
- internalType: "bytes32"
1527
- }
1528
- ],
1529
- stateMutability: "view"
1530
- },
1531
- {
1532
- type: "function",
1533
- name: "RELAYER_ROLE",
1534
- inputs: [],
1535
- outputs: [
1536
- {
1537
- name: "",
1538
- type: "bytes32",
1539
- internalType: "bytes32"
1540
- }
1541
- ],
1542
- stateMutability: "view"
1543
- },
1544
- {
1545
- type: "function",
1546
- name: "UNPAUSER_ROLE",
1547
- inputs: [],
1548
- outputs: [
1549
- {
1550
- name: "",
1551
- type: "bytes32",
1552
- internalType: "bytes32"
1553
- }
1554
- ],
1555
- stateMutability: "view"
1556
- },
1557
- {
1558
- type: "function",
1559
- name: "UPGRADER_ROLE",
1560
- inputs: [],
1561
- outputs: [
1562
- {
1563
- name: "",
1564
- type: "bytes32",
1565
- internalType: "bytes32"
1566
- }
1567
- ],
1568
- stateMutability: "view"
1569
- },
1570
- {
1571
- type: "function",
1572
- name: "UPGRADE_INTERFACE_VERSION",
1573
- inputs: [],
1574
- outputs: [
1575
- {
1576
- name: "",
1577
- type: "string",
1578
- internalType: "string"
1579
- }
1580
- ],
1581
- stateMutability: "view"
1582
- },
1583
- {
1584
- type: "function",
1585
- name: "adminProcessWithdrawalRequestEvents",
1586
- inputs: [
1587
- {
1588
- name: "requests",
1589
- type: "tuple[]",
1590
- internalType: "struct ISpicenetEscrow.WithdrawalRequest[]",
1591
- components: [
1592
- {
1593
- name: "idempotenceKey",
1594
- type: "bytes32",
1595
- internalType: "bytes32"
1596
- },
1597
- {
1598
- name: "forUser",
1599
- type: "string",
1600
- internalType: "string"
1601
- },
1602
- {
1603
- name: "nbf",
1604
- type: "uint256",
1605
- internalType: "uint256"
1606
- },
1607
- {
1608
- name: "exp",
1609
- type: "uint256",
1610
- internalType: "uint256"
1611
- },
1612
- {
1613
- name: "metadata",
1614
- type: "string",
1615
- internalType: "string"
1616
- },
1617
- {
1618
- name: "transfers",
1619
- type: "tuple[]",
1620
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
1621
- components: [
1622
- {
1623
- name: "token",
1624
- type: "address",
1625
- internalType: "address"
1626
- },
1627
- {
1628
- name: "to",
1629
- type: "address",
1630
- internalType: "address"
1631
- },
1632
- {
1633
- name: "amount",
1634
- type: "uint256",
1635
- internalType: "uint256"
1636
- }
1637
- ]
1638
- }
1639
- ]
1640
- }
1641
- ],
1642
- outputs: [],
1643
- stateMutability: "nonpayable"
1644
- },
1645
- {
1646
- type: "function",
1647
- name: "adminSetWithdrawalInfos",
1648
- inputs: [
1649
- {
1650
- name: "idempotenceKeys",
1651
- type: "bytes32[]",
1652
- internalType: "bytes32[]"
1653
- },
1654
- {
1655
- name: "withdrawalInfos",
1656
- type: "tuple[]",
1657
- internalType: "struct ISpicenetEscrow.WithdrawalInfo[]",
1658
- components: [
1659
- {
1660
- name: "forUser",
1661
- type: "string",
1662
- internalType: "string"
1663
- },
1664
- {
1665
- name: "blockNumber",
1666
- type: "uint256",
1667
- internalType: "uint256"
1668
- },
1669
- {
1670
- name: "nbf",
1671
- type: "uint256",
1672
- internalType: "uint256"
1673
- },
1674
- {
1675
- name: "exp",
1676
- type: "uint256",
1677
- internalType: "uint256"
1678
- },
1679
- {
1680
- name: "metadata",
1681
- type: "string",
1682
- internalType: "string"
1683
- }
1684
- ]
1685
- }
1686
- ],
1687
- outputs: [],
1688
- stateMutability: "nonpayable"
1689
- },
1690
- {
1691
- type: "function",
1692
- name: "adminWithdraw",
1693
- inputs: [
1694
- {
1695
- name: "transfers",
1696
- type: "tuple[]",
1697
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
1698
- components: [
1699
- {
1700
- name: "token",
1701
- type: "address",
1702
- internalType: "address"
1703
- },
1704
- {
1705
- name: "to",
1706
- type: "address",
1707
- internalType: "address"
1708
- },
1333
+ // src/swap.ts
1334
+ import { encodeFunctionData, erc20Abi } from "viem";
1335
+ function applySlippage(amount, slippage = 0.03) {
1336
+ const slippageBps = BigInt(Math.floor((1 - slippage) * 1e4));
1337
+ return amount * slippageBps / 10000n;
1338
+ }
1339
+ function buildUniV3SwapCalls(params) {
1340
+ const {
1341
+ tokenIn,
1342
+ tokenOut,
1343
+ amountIn,
1344
+ amountOutMinimum,
1345
+ fee,
1346
+ recipient,
1347
+ config
1348
+ } = params;
1349
+ return [
1350
+ {
1351
+ to: tokenIn,
1352
+ value: 0n,
1353
+ data: encodeFunctionData({
1354
+ abi: erc20Abi,
1355
+ functionName: "approve",
1356
+ args: [config.swapRouter, amountIn]
1357
+ })
1358
+ },
1359
+ {
1360
+ to: config.swapRouter,
1361
+ value: 0n,
1362
+ data: encodeFunctionData({
1363
+ abi: uniV3SwapRouterAbi,
1364
+ functionName: "exactInputSingle",
1365
+ args: [
1709
1366
  {
1710
- name: "amount",
1711
- type: "uint256",
1712
- internalType: "uint256"
1713
- }
1714
- ]
1715
- }
1716
- ],
1717
- outputs: [],
1718
- stateMutability: "nonpayable"
1719
- },
1720
- {
1721
- type: "function",
1722
- name: "getRoleAdmin",
1723
- inputs: [
1724
- {
1725
- name: "role",
1726
- type: "bytes32",
1727
- internalType: "bytes32"
1728
- }
1729
- ],
1730
- outputs: [
1731
- {
1732
- name: "",
1733
- type: "bytes32",
1734
- internalType: "bytes32"
1735
- }
1736
- ],
1737
- stateMutability: "view"
1738
- },
1739
- {
1740
- type: "function",
1741
- name: "getRoleMember",
1742
- inputs: [
1743
- {
1744
- name: "role",
1745
- type: "bytes32",
1746
- internalType: "bytes32"
1747
- },
1748
- {
1749
- name: "index",
1750
- type: "uint256",
1751
- internalType: "uint256"
1752
- }
1753
- ],
1754
- outputs: [
1755
- {
1756
- name: "",
1757
- type: "address",
1758
- internalType: "address"
1759
- }
1760
- ],
1761
- stateMutability: "view"
1762
- },
1763
- {
1764
- type: "function",
1765
- name: "getRoleMemberCount",
1766
- inputs: [
1767
- {
1768
- name: "role",
1769
- type: "bytes32",
1770
- internalType: "bytes32"
1771
- }
1772
- ],
1773
- outputs: [
1774
- {
1775
- name: "",
1776
- type: "uint256",
1777
- internalType: "uint256"
1778
- }
1779
- ],
1780
- stateMutability: "view"
1781
- },
1782
- {
1783
- type: "function",
1784
- name: "getRoleMembers",
1785
- inputs: [
1786
- {
1787
- name: "role",
1788
- type: "bytes32",
1789
- internalType: "bytes32"
1790
- }
1791
- ],
1792
- outputs: [
1793
- {
1794
- name: "",
1795
- type: "address[]",
1796
- internalType: "address[]"
1797
- }
1798
- ],
1799
- stateMutability: "view"
1800
- },
1801
- {
1802
- type: "function",
1803
- name: "getWithdrawalInfo",
1804
- inputs: [
1805
- {
1806
- name: "idempotenceKey",
1807
- type: "bytes32",
1808
- internalType: "bytes32"
1809
- }
1810
- ],
1811
- outputs: [
1812
- {
1813
- name: "",
1814
- type: "tuple",
1815
- internalType: "struct ISpicenetEscrow.WithdrawalInfo",
1816
- components: [
1817
- {
1818
- name: "forUser",
1819
- type: "string",
1820
- internalType: "string"
1821
- },
1822
- {
1823
- name: "blockNumber",
1824
- type: "uint256",
1825
- internalType: "uint256"
1826
- },
1827
- {
1828
- name: "nbf",
1829
- type: "uint256",
1830
- internalType: "uint256"
1831
- },
1832
- {
1833
- name: "exp",
1834
- type: "uint256",
1835
- internalType: "uint256"
1836
- },
1837
- {
1838
- name: "metadata",
1839
- type: "string",
1840
- internalType: "string"
1841
- }
1842
- ]
1843
- }
1844
- ],
1845
- stateMutability: "view"
1846
- },
1847
- {
1848
- type: "function",
1849
- name: "grantRole",
1850
- inputs: [
1851
- {
1852
- name: "role",
1853
- type: "bytes32",
1854
- internalType: "bytes32"
1855
- },
1856
- {
1857
- name: "account",
1858
- type: "address",
1859
- internalType: "address"
1860
- }
1861
- ],
1862
- outputs: [],
1863
- stateMutability: "nonpayable"
1864
- },
1865
- {
1866
- type: "function",
1867
- name: "hasRole",
1868
- inputs: [
1869
- {
1870
- name: "role",
1871
- type: "bytes32",
1872
- internalType: "bytes32"
1873
- },
1874
- {
1875
- name: "account",
1876
- type: "address",
1877
- internalType: "address"
1878
- }
1879
- ],
1880
- outputs: [
1881
- {
1882
- name: "",
1883
- type: "bool",
1884
- internalType: "bool"
1885
- }
1886
- ],
1887
- stateMutability: "view"
1888
- },
1889
- {
1890
- type: "function",
1891
- name: "initialize",
1892
- inputs: [
1893
- {
1894
- name: "defaultAdmin",
1895
- type: "address",
1896
- internalType: "address"
1897
- }
1898
- ],
1899
- outputs: [],
1900
- stateMutability: "nonpayable"
1901
- },
1902
- {
1903
- type: "function",
1904
- name: "pause",
1905
- inputs: [],
1906
- outputs: [],
1907
- stateMutability: "nonpayable"
1908
- },
1909
- {
1910
- type: "function",
1911
- name: "paused",
1912
- inputs: [],
1913
- outputs: [
1914
- {
1915
- name: "",
1916
- type: "bool",
1917
- internalType: "bool"
1918
- }
1919
- ],
1920
- stateMutability: "view"
1921
- },
1922
- {
1923
- type: "function",
1924
- name: "processWithdrawal",
1925
- inputs: [
1926
- {
1927
- name: "request",
1928
- type: "tuple",
1929
- internalType: "struct ISpicenetEscrow.WithdrawalRequest",
1930
- components: [
1931
- {
1932
- name: "idempotenceKey",
1933
- type: "bytes32",
1934
- internalType: "bytes32"
1935
- },
1936
- {
1937
- name: "forUser",
1938
- type: "string",
1939
- internalType: "string"
1940
- },
1941
- {
1942
- name: "nbf",
1943
- type: "uint256",
1944
- internalType: "uint256"
1945
- },
1946
- {
1947
- name: "exp",
1948
- type: "uint256",
1949
- internalType: "uint256"
1950
- },
1951
- {
1952
- name: "metadata",
1953
- type: "string",
1954
- internalType: "string"
1955
- },
1956
- {
1957
- name: "transfers",
1958
- type: "tuple[]",
1959
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
1960
- components: [
1961
- {
1962
- name: "token",
1963
- type: "address",
1964
- internalType: "address"
1965
- },
1966
- {
1967
- name: "to",
1968
- type: "address",
1969
- internalType: "address"
1970
- },
1971
- {
1972
- name: "amount",
1973
- type: "uint256",
1974
- internalType: "uint256"
1975
- }
1976
- ]
1977
- }
1978
- ]
1979
- }
1980
- ],
1981
- outputs: [],
1982
- stateMutability: "nonpayable"
1983
- },
1984
- {
1985
- type: "function",
1986
- name: "proxiableUUID",
1987
- inputs: [],
1988
- outputs: [
1989
- {
1990
- name: "",
1991
- type: "bytes32",
1992
- internalType: "bytes32"
1993
- }
1994
- ],
1995
- stateMutability: "view"
1996
- },
1997
- {
1998
- type: "function",
1999
- name: "renounceRole",
2000
- inputs: [
2001
- {
2002
- name: "role",
2003
- type: "bytes32",
2004
- internalType: "bytes32"
2005
- },
2006
- {
2007
- name: "callerConfirmation",
2008
- type: "address",
2009
- internalType: "address"
2010
- }
2011
- ],
2012
- outputs: [],
2013
- stateMutability: "nonpayable"
2014
- },
2015
- {
2016
- type: "function",
2017
- name: "revokeRole",
2018
- inputs: [
2019
- {
2020
- name: "role",
2021
- type: "bytes32",
2022
- internalType: "bytes32"
2023
- },
2024
- {
2025
- name: "account",
2026
- type: "address",
2027
- internalType: "address"
2028
- }
2029
- ],
2030
- outputs: [],
2031
- stateMutability: "nonpayable"
2032
- },
2033
- {
2034
- type: "function",
2035
- name: "supportsInterface",
2036
- inputs: [
2037
- {
2038
- name: "interfaceId",
2039
- type: "bytes4",
2040
- internalType: "bytes4"
2041
- }
2042
- ],
2043
- outputs: [
2044
- {
2045
- name: "",
2046
- type: "bool",
2047
- internalType: "bool"
2048
- }
2049
- ],
2050
- stateMutability: "view"
2051
- },
2052
- {
2053
- type: "function",
2054
- name: "unpause",
2055
- inputs: [],
2056
- outputs: [],
2057
- stateMutability: "nonpayable"
2058
- },
2059
- {
2060
- type: "function",
2061
- name: "upgradeToAndCall",
2062
- inputs: [
2063
- {
2064
- name: "newImplementation",
2065
- type: "address",
2066
- internalType: "address"
2067
- },
2068
- {
2069
- name: "data",
2070
- type: "bytes",
2071
- internalType: "bytes"
2072
- }
2073
- ],
2074
- outputs: [],
2075
- stateMutability: "payable"
2076
- },
2077
- {
2078
- type: "event",
2079
- name: "Initialized",
2080
- inputs: [
2081
- {
2082
- name: "version",
2083
- type: "uint64",
2084
- indexed: false,
2085
- internalType: "uint64"
2086
- }
2087
- ],
2088
- anonymous: false
2089
- },
2090
- {
2091
- type: "event",
2092
- name: "NativeTransfer",
2093
- inputs: [
2094
- {
2095
- name: "from",
2096
- type: "address",
2097
- indexed: true,
2098
- internalType: "address"
2099
- },
2100
- {
2101
- name: "to",
2102
- type: "address",
2103
- indexed: true,
2104
- internalType: "address"
2105
- },
2106
- {
2107
- name: "value",
2108
- type: "uint256",
2109
- indexed: false,
2110
- internalType: "uint256"
2111
- }
2112
- ],
2113
- anonymous: false
2114
- },
2115
- {
2116
- type: "event",
2117
- name: "Paused",
2118
- inputs: [
2119
- {
2120
- name: "account",
2121
- type: "address",
2122
- indexed: false,
2123
- internalType: "address"
2124
- }
2125
- ],
2126
- anonymous: false
2127
- },
2128
- {
2129
- type: "event",
2130
- name: "RoleAdminChanged",
2131
- inputs: [
2132
- {
2133
- name: "role",
2134
- type: "bytes32",
2135
- indexed: true,
2136
- internalType: "bytes32"
2137
- },
2138
- {
2139
- name: "previousAdminRole",
2140
- type: "bytes32",
2141
- indexed: true,
2142
- internalType: "bytes32"
2143
- },
2144
- {
2145
- name: "newAdminRole",
2146
- type: "bytes32",
2147
- indexed: true,
2148
- internalType: "bytes32"
2149
- }
2150
- ],
2151
- anonymous: false
2152
- },
2153
- {
2154
- type: "event",
2155
- name: "RoleGranted",
2156
- inputs: [
2157
- {
2158
- name: "role",
2159
- type: "bytes32",
2160
- indexed: true,
2161
- internalType: "bytes32"
2162
- },
2163
- {
2164
- name: "account",
2165
- type: "address",
2166
- indexed: true,
2167
- internalType: "address"
2168
- },
2169
- {
2170
- name: "sender",
2171
- type: "address",
2172
- indexed: true,
2173
- internalType: "address"
2174
- }
2175
- ],
2176
- anonymous: false
2177
- },
2178
- {
2179
- type: "event",
2180
- name: "RoleRevoked",
2181
- inputs: [
2182
- {
2183
- name: "role",
2184
- type: "bytes32",
2185
- indexed: true,
2186
- internalType: "bytes32"
2187
- },
2188
- {
2189
- name: "account",
2190
- type: "address",
2191
- indexed: true,
2192
- internalType: "address"
2193
- },
2194
- {
2195
- name: "sender",
2196
- type: "address",
2197
- indexed: true,
2198
- internalType: "address"
2199
- }
2200
- ],
2201
- anonymous: false
2202
- },
2203
- {
2204
- type: "event",
2205
- name: "Unpaused",
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: "Upgraded",
2219
- inputs: [
2220
- {
2221
- name: "implementation",
2222
- type: "address",
2223
- indexed: true,
2224
- internalType: "address"
2225
- }
2226
- ],
2227
- anonymous: false
2228
- },
2229
- {
2230
- type: "event",
2231
- name: "WithdrawalProcessed",
2232
- inputs: [
2233
- {
2234
- name: "idempotenceKey",
2235
- type: "bytes32",
2236
- indexed: true,
2237
- internalType: "bytes32"
2238
- },
2239
- {
2240
- name: "forUser",
2241
- type: "string",
2242
- indexed: true,
2243
- internalType: "string"
2244
- },
2245
- {
2246
- name: "request",
2247
- type: "tuple",
2248
- indexed: false,
2249
- internalType: "struct ISpicenetEscrow.WithdrawalRequest",
2250
- components: [
2251
- {
2252
- name: "idempotenceKey",
2253
- type: "bytes32",
2254
- internalType: "bytes32"
2255
- },
2256
- {
2257
- name: "forUser",
2258
- type: "string",
2259
- internalType: "string"
2260
- },
2261
- {
2262
- name: "nbf",
2263
- type: "uint256",
2264
- internalType: "uint256"
2265
- },
2266
- {
2267
- name: "exp",
2268
- type: "uint256",
2269
- internalType: "uint256"
2270
- },
2271
- {
2272
- name: "metadata",
2273
- type: "string",
2274
- internalType: "string"
2275
- },
2276
- {
2277
- name: "transfers",
2278
- type: "tuple[]",
2279
- internalType: "struct ISpicenetEscrow.TokenTransfer[]",
2280
- components: [
2281
- {
2282
- name: "token",
2283
- type: "address",
2284
- internalType: "address"
2285
- },
2286
- {
2287
- name: "to",
2288
- type: "address",
2289
- internalType: "address"
2290
- },
2291
- {
2292
- name: "amount",
2293
- type: "uint256",
2294
- internalType: "uint256"
2295
- }
2296
- ]
2297
- }
2298
- ]
2299
- }
2300
- ],
2301
- anonymous: false
2302
- },
2303
- {
2304
- type: "error",
2305
- name: "AccessControlBadConfirmation",
2306
- inputs: []
2307
- },
2308
- {
2309
- type: "error",
2310
- name: "AccessControlUnauthorizedAccount",
2311
- inputs: [
2312
- {
2313
- name: "account",
2314
- type: "address",
2315
- internalType: "address"
2316
- },
2317
- {
2318
- name: "neededRole",
2319
- type: "bytes32",
2320
- internalType: "bytes32"
2321
- }
2322
- ]
2323
- },
2324
- {
2325
- type: "error",
2326
- name: "AddressEmptyCode",
2327
- inputs: [
2328
- {
2329
- name: "target",
2330
- type: "address",
2331
- internalType: "address"
2332
- }
2333
- ]
2334
- },
2335
- {
2336
- type: "error",
2337
- name: "ERC1967InvalidImplementation",
2338
- inputs: [
2339
- {
2340
- name: "implementation",
2341
- type: "address",
2342
- internalType: "address"
2343
- }
2344
- ]
2345
- },
2346
- {
2347
- type: "error",
2348
- name: "ERC1967NonPayable",
2349
- inputs: []
2350
- },
2351
- {
2352
- type: "error",
2353
- name: "EnforcedPause",
2354
- inputs: []
2355
- },
2356
- {
2357
- type: "error",
2358
- name: "ExpectedPause",
2359
- inputs: []
2360
- },
2361
- {
2362
- type: "error",
2363
- name: "FailedCall",
2364
- inputs: []
2365
- },
2366
- {
2367
- type: "error",
2368
- name: "InsufficientBalance",
2369
- inputs: [
2370
- {
2371
- name: "balance",
2372
- type: "uint256",
2373
- internalType: "uint256"
2374
- },
2375
- {
2376
- name: "needed",
2377
- type: "uint256",
2378
- internalType: "uint256"
2379
- }
2380
- ]
2381
- },
2382
- {
2383
- type: "error",
2384
- name: "InvalidInitialization",
2385
- inputs: []
2386
- },
2387
- {
2388
- type: "error",
2389
- name: "NotInitializing",
2390
- inputs: []
2391
- },
2392
- {
2393
- type: "error",
2394
- name: "SafeERC20FailedOperation",
2395
- inputs: [
2396
- {
2397
- name: "token",
2398
- type: "address",
2399
- internalType: "address"
2400
- }
2401
- ]
2402
- },
2403
- {
2404
- type: "error",
2405
- name: "UUPSUnauthorizedCallContext",
2406
- inputs: []
2407
- },
2408
- {
2409
- type: "error",
2410
- name: "UUPSUnsupportedProxiableUUID",
2411
- inputs: [
2412
- {
2413
- name: "slot",
2414
- type: "bytes32",
2415
- internalType: "bytes32"
2416
- }
2417
- ]
2418
- },
2419
- {
2420
- type: "error",
2421
- name: "WithdrawalAlreadyProcessed",
2422
- inputs: [
2423
- {
2424
- name: "idempotenceKey",
2425
- type: "bytes32",
2426
- internalType: "bytes32"
2427
- },
2428
- {
2429
- name: "withdrawalInfo",
2430
- type: "tuple",
2431
- internalType: "struct ISpicenetEscrow.WithdrawalInfo",
2432
- components: [
2433
- {
2434
- name: "forUser",
2435
- type: "string",
2436
- internalType: "string"
2437
- },
2438
- {
2439
- name: "blockNumber",
2440
- type: "uint256",
2441
- internalType: "uint256"
2442
- },
2443
- {
2444
- name: "nbf",
2445
- type: "uint256",
2446
- internalType: "uint256"
2447
- },
2448
- {
2449
- name: "exp",
2450
- type: "uint256",
2451
- internalType: "uint256"
2452
- },
2453
- {
2454
- name: "metadata",
2455
- type: "string",
2456
- internalType: "string"
2457
- }
2458
- ]
2459
- }
2460
- ]
2461
- },
2462
- {
2463
- type: "error",
2464
- name: "WithdrawalRequestExpired",
2465
- inputs: [
2466
- {
2467
- name: "currentTime",
2468
- type: "uint256",
2469
- internalType: "uint256"
2470
- },
2471
- {
2472
- name: "exp",
2473
- type: "uint256",
2474
- internalType: "uint256"
2475
- }
2476
- ]
2477
- },
2478
- {
2479
- type: "error",
2480
- name: "WithdrawalRequestTooEarly",
2481
- inputs: [
2482
- {
2483
- name: "currentTime",
2484
- type: "uint256",
2485
- internalType: "uint256"
2486
- },
2487
- {
2488
- name: "nbf",
2489
- type: "uint256",
2490
- internalType: "uint256"
2491
- }
2492
- ]
2493
- }
2494
- ];
2495
-
2496
- // src/swap.ts
2497
- import { encodeFunctionData, erc20Abi } from "viem";
2498
- function applySlippage(amount, slippage = 0.03) {
2499
- const slippageBps = BigInt(Math.floor((1 - slippage) * 1e4));
2500
- return amount * slippageBps / 10000n;
2501
- }
2502
- function buildUniV3SwapCalls(params) {
2503
- const {
2504
- tokenIn,
2505
- tokenOut,
2506
- amountIn,
2507
- amountOutMinimum,
2508
- fee,
2509
- recipient,
2510
- config
2511
- } = params;
2512
- return [
2513
- {
2514
- to: tokenIn,
2515
- value: 0n,
2516
- data: encodeFunctionData({
2517
- abi: erc20Abi,
2518
- functionName: "approve",
2519
- args: [config.swapRouter, amountIn]
2520
- })
2521
- },
2522
- {
2523
- to: config.swapRouter,
2524
- value: 0n,
2525
- data: encodeFunctionData({
2526
- abi: uniV3SwapRouterAbi,
2527
- functionName: "exactInputSingle",
2528
- args: [
2529
- {
2530
- tokenIn,
2531
- tokenOut,
2532
- fee,
2533
- recipient,
2534
- amountIn,
2535
- amountOutMinimum,
2536
- sqrtPriceLimitX96: 0n
1367
+ tokenIn,
1368
+ tokenOut,
1369
+ fee,
1370
+ recipient,
1371
+ amountIn,
1372
+ amountOutMinimum,
1373
+ sqrtPriceLimitX96: 0n
2537
1374
  }
2538
1375
  ]
2539
1376
  })
2540
1377
  }
2541
1378
  ];
2542
1379
  }
2543
-
2544
- // src/constants.ts
2545
- var SPICE_SOLVER_ADDRESS = "0x111115763723B53395308eC4c9AB9d5FB0844cae";
2546
- var SPICE_GAS_FEE_RECIPIENT = "0x737680c45F88A8b1b389e354dde11419f89BAdd6";
2547
- var SPICE_PLATFORM_FEE_RECIPIENT = "0xa4bB4c1D188B94c0cF691Dad213dE24169fA0A50";
2548
- var SPICE_COMBINED_FEE_RECIPIENT = SPICE_GAS_FEE_RECIPIENT;
2549
1380
  export {
2550
1381
  CHAINS,
2551
1382
  ChainBatchHashAbi,
2552
1383
  DELEGATE_ABI,
2553
1384
  ERC20_ABI,
1385
+ ESCROW_ADDRESS,
2554
1386
  HttpError,
2555
1387
  IntentHashAbi,
2556
1388
  NATIVE_TOKEN_ADDRESS,
2557
1389
  SPICENET_NATIVE_CHAIN_ID,
2558
- SPICE_COMBINED_FEE_RECIPIENT,
2559
- SPICE_GAS_FEE_RECIPIENT,
2560
- SPICE_PLATFORM_FEE_RECIPIENT,
2561
- SPICE_SOLVER_ADDRESS,
2562
1390
  STARKNET_MAINNET_CHAIN_ID,
2563
1391
  SpiceFlowCore,
2564
1392
  TOKENS,
@@ -2580,8 +1408,6 @@ export {
2580
1408
  getDeployment,
2581
1409
  getEquivalenceGroup,
2582
1410
  getEquivalentAddresses,
2583
- getEscrowContract,
2584
- getEscrowContractAddress,
2585
1411
  getIntentHash,
2586
1412
  getIntentStepStatus,
2587
1413
  getMainnetChains,
@@ -2603,9 +1429,6 @@ export {
2603
1429
  requireTokenBySymbol,
2604
1430
  requireViemChain,
2605
1431
  resolveTokenRef,
2606
- spicenetAbi,
2607
- spicenetEscrowAbi,
2608
- spicenetEscrowAbi as spicenetWalletManagerAbi,
2609
1432
  submitTransaction,
2610
1433
  truncateAddress,
2611
1434
  uniV3QuoterV2Abi,