veilix-sdk 0.2.3 → 0.3.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/dist/{VeilixSDK-DL7hvWhB.d.ts → VeilixSDK-BLZZ5yVj.d.ts} +216 -87
- package/dist/{VeilixSDK-CousE3xD.d.cts → VeilixSDK-CpjyQiV7.d.cts} +216 -87
- package/dist/circuits/paths.cjs.map +1 -1
- package/dist/circuits/paths.js.map +1 -1
- package/dist/index.cjs +1406 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -3
- package/dist/index.d.ts +42 -3
- package/dist/index.js +1401 -105
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +1400 -104
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1400 -104
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -65,7 +65,7 @@ function formatBaseUnits(value, decimals) {
|
|
|
65
65
|
|
|
66
66
|
// src/idl/veilix-devnet.json
|
|
67
67
|
var veilix_devnet_default = {
|
|
68
|
-
address: "
|
|
68
|
+
address: "Vxi1QK84Akv4yGngjvkWNmEsK7XpsSrpDaPBoiyXGPG",
|
|
69
69
|
metadata: {
|
|
70
70
|
name: "veilix",
|
|
71
71
|
version: "0.2.0",
|
|
@@ -666,6 +666,38 @@ var veilix_devnet_default = {
|
|
|
666
666
|
{
|
|
667
667
|
name: "system_program",
|
|
668
668
|
address: "11111111111111111111111111111111"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: "event_authority",
|
|
672
|
+
pda: {
|
|
673
|
+
seeds: [
|
|
674
|
+
{
|
|
675
|
+
kind: "const",
|
|
676
|
+
value: [
|
|
677
|
+
95,
|
|
678
|
+
95,
|
|
679
|
+
101,
|
|
680
|
+
118,
|
|
681
|
+
101,
|
|
682
|
+
110,
|
|
683
|
+
116,
|
|
684
|
+
95,
|
|
685
|
+
97,
|
|
686
|
+
117,
|
|
687
|
+
116,
|
|
688
|
+
104,
|
|
689
|
+
111,
|
|
690
|
+
114,
|
|
691
|
+
105,
|
|
692
|
+
116,
|
|
693
|
+
121
|
|
694
|
+
]
|
|
695
|
+
}
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
name: "program"
|
|
669
701
|
}
|
|
670
702
|
],
|
|
671
703
|
args: [
|
|
@@ -728,6 +760,91 @@ var veilix_devnet_default = {
|
|
|
728
760
|
]
|
|
729
761
|
}
|
|
730
762
|
},
|
|
763
|
+
{
|
|
764
|
+
name: "program_data",
|
|
765
|
+
docs: [
|
|
766
|
+
"This program's ProgramData. Only its upgrade authority may initialize the network,",
|
|
767
|
+
"so nobody can claim the config authority between deploy and setup."
|
|
768
|
+
],
|
|
769
|
+
pda: {
|
|
770
|
+
seeds: [
|
|
771
|
+
{
|
|
772
|
+
kind: "const",
|
|
773
|
+
value: [
|
|
774
|
+
7,
|
|
775
|
+
107,
|
|
776
|
+
64,
|
|
777
|
+
50,
|
|
778
|
+
251,
|
|
779
|
+
172,
|
|
780
|
+
47,
|
|
781
|
+
215,
|
|
782
|
+
89,
|
|
783
|
+
179,
|
|
784
|
+
92,
|
|
785
|
+
125,
|
|
786
|
+
67,
|
|
787
|
+
162,
|
|
788
|
+
96,
|
|
789
|
+
45,
|
|
790
|
+
239,
|
|
791
|
+
91,
|
|
792
|
+
223,
|
|
793
|
+
168,
|
|
794
|
+
251,
|
|
795
|
+
138,
|
|
796
|
+
165,
|
|
797
|
+
133,
|
|
798
|
+
253,
|
|
799
|
+
74,
|
|
800
|
+
152,
|
|
801
|
+
142,
|
|
802
|
+
6,
|
|
803
|
+
85,
|
|
804
|
+
93,
|
|
805
|
+
119
|
|
806
|
+
]
|
|
807
|
+
}
|
|
808
|
+
],
|
|
809
|
+
program: {
|
|
810
|
+
kind: "const",
|
|
811
|
+
value: [
|
|
812
|
+
2,
|
|
813
|
+
168,
|
|
814
|
+
246,
|
|
815
|
+
145,
|
|
816
|
+
78,
|
|
817
|
+
136,
|
|
818
|
+
161,
|
|
819
|
+
176,
|
|
820
|
+
226,
|
|
821
|
+
16,
|
|
822
|
+
21,
|
|
823
|
+
62,
|
|
824
|
+
247,
|
|
825
|
+
99,
|
|
826
|
+
174,
|
|
827
|
+
43,
|
|
828
|
+
0,
|
|
829
|
+
194,
|
|
830
|
+
185,
|
|
831
|
+
61,
|
|
832
|
+
22,
|
|
833
|
+
193,
|
|
834
|
+
36,
|
|
835
|
+
210,
|
|
836
|
+
192,
|
|
837
|
+
83,
|
|
838
|
+
122,
|
|
839
|
+
16,
|
|
840
|
+
4,
|
|
841
|
+
128,
|
|
842
|
+
0,
|
|
843
|
+
0
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
},
|
|
731
848
|
{
|
|
732
849
|
name: "system_program",
|
|
733
850
|
address: "11111111111111111111111111111111"
|
|
@@ -1056,6 +1173,31 @@ var veilix_devnet_default = {
|
|
|
1056
1173
|
]
|
|
1057
1174
|
}
|
|
1058
1175
|
},
|
|
1176
|
+
{
|
|
1177
|
+
name: "treasury",
|
|
1178
|
+
docs: [
|
|
1179
|
+
"Holds the SOL pool. Funded with its rent-exempt reserve here so that no withdrawal",
|
|
1180
|
+
"can fail for leaving it below that reserve."
|
|
1181
|
+
],
|
|
1182
|
+
writable: true,
|
|
1183
|
+
pda: {
|
|
1184
|
+
seeds: [
|
|
1185
|
+
{
|
|
1186
|
+
kind: "const",
|
|
1187
|
+
value: [
|
|
1188
|
+
116,
|
|
1189
|
+
114,
|
|
1190
|
+
101,
|
|
1191
|
+
97,
|
|
1192
|
+
115,
|
|
1193
|
+
117,
|
|
1194
|
+
114,
|
|
1195
|
+
121
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
]
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1059
1201
|
{
|
|
1060
1202
|
name: "system_program",
|
|
1061
1203
|
address: "11111111111111111111111111111111"
|
|
@@ -1486,6 +1628,336 @@ var veilix_devnet_default = {
|
|
|
1486
1628
|
}
|
|
1487
1629
|
]
|
|
1488
1630
|
},
|
|
1631
|
+
{
|
|
1632
|
+
name: "swap",
|
|
1633
|
+
docs: [
|
|
1634
|
+
"Private swap. Remaining accounts: the protocol fee wallets for the input asset (SOL",
|
|
1635
|
+
"accounts or their token accounts, in config order), then the DEX instruction's accounts."
|
|
1636
|
+
],
|
|
1637
|
+
discriminator: [
|
|
1638
|
+
248,
|
|
1639
|
+
198,
|
|
1640
|
+
158,
|
|
1641
|
+
145,
|
|
1642
|
+
225,
|
|
1643
|
+
117,
|
|
1644
|
+
135,
|
|
1645
|
+
200
|
|
1646
|
+
],
|
|
1647
|
+
accounts: [
|
|
1648
|
+
{
|
|
1649
|
+
name: "relayer",
|
|
1650
|
+
writable: true,
|
|
1651
|
+
signer: true
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
name: "relayer_account",
|
|
1655
|
+
writable: true,
|
|
1656
|
+
pda: {
|
|
1657
|
+
seeds: [
|
|
1658
|
+
{
|
|
1659
|
+
kind: "const",
|
|
1660
|
+
value: [
|
|
1661
|
+
114,
|
|
1662
|
+
101,
|
|
1663
|
+
108,
|
|
1664
|
+
97,
|
|
1665
|
+
121,
|
|
1666
|
+
101,
|
|
1667
|
+
114
|
|
1668
|
+
]
|
|
1669
|
+
},
|
|
1670
|
+
{
|
|
1671
|
+
kind: "account",
|
|
1672
|
+
path: "relayer_account.owner",
|
|
1673
|
+
account: "RelayerAccount"
|
|
1674
|
+
}
|
|
1675
|
+
]
|
|
1676
|
+
}
|
|
1677
|
+
},
|
|
1678
|
+
{
|
|
1679
|
+
name: "network_state",
|
|
1680
|
+
pda: {
|
|
1681
|
+
seeds: [
|
|
1682
|
+
{
|
|
1683
|
+
kind: "const",
|
|
1684
|
+
value: [
|
|
1685
|
+
99,
|
|
1686
|
+
111,
|
|
1687
|
+
110,
|
|
1688
|
+
102,
|
|
1689
|
+
105,
|
|
1690
|
+
103
|
|
1691
|
+
]
|
|
1692
|
+
}
|
|
1693
|
+
]
|
|
1694
|
+
}
|
|
1695
|
+
},
|
|
1696
|
+
{
|
|
1697
|
+
name: "swap_config",
|
|
1698
|
+
pda: {
|
|
1699
|
+
seeds: [
|
|
1700
|
+
{
|
|
1701
|
+
kind: "const",
|
|
1702
|
+
value: [
|
|
1703
|
+
115,
|
|
1704
|
+
119,
|
|
1705
|
+
97,
|
|
1706
|
+
112,
|
|
1707
|
+
95,
|
|
1708
|
+
99,
|
|
1709
|
+
111,
|
|
1710
|
+
110,
|
|
1711
|
+
102,
|
|
1712
|
+
105,
|
|
1713
|
+
103
|
|
1714
|
+
]
|
|
1715
|
+
}
|
|
1716
|
+
]
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1719
|
+
{
|
|
1720
|
+
name: "tree_in",
|
|
1721
|
+
docs: [
|
|
1722
|
+
"Tree of the asset being spent. The handler checks it is the PDA for its mint."
|
|
1723
|
+
],
|
|
1724
|
+
writable: true
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
name: "tree_out",
|
|
1728
|
+
docs: [
|
|
1729
|
+
"Tree that receives the swapped note."
|
|
1730
|
+
],
|
|
1731
|
+
writable: true
|
|
1732
|
+
},
|
|
1733
|
+
{
|
|
1734
|
+
name: "treasury",
|
|
1735
|
+
writable: true,
|
|
1736
|
+
pda: {
|
|
1737
|
+
seeds: [
|
|
1738
|
+
{
|
|
1739
|
+
kind: "const",
|
|
1740
|
+
value: [
|
|
1741
|
+
116,
|
|
1742
|
+
114,
|
|
1743
|
+
101,
|
|
1744
|
+
97,
|
|
1745
|
+
115,
|
|
1746
|
+
117,
|
|
1747
|
+
114,
|
|
1748
|
+
121
|
|
1749
|
+
]
|
|
1750
|
+
}
|
|
1751
|
+
]
|
|
1752
|
+
}
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
name: "escrow",
|
|
1756
|
+
docs: [
|
|
1757
|
+
"Signs the DEX call. Holds nothing between transactions."
|
|
1758
|
+
],
|
|
1759
|
+
writable: true,
|
|
1760
|
+
pda: {
|
|
1761
|
+
seeds: [
|
|
1762
|
+
{
|
|
1763
|
+
kind: "const",
|
|
1764
|
+
value: [
|
|
1765
|
+
115,
|
|
1766
|
+
119,
|
|
1767
|
+
97,
|
|
1768
|
+
112,
|
|
1769
|
+
95,
|
|
1770
|
+
101,
|
|
1771
|
+
115,
|
|
1772
|
+
99,
|
|
1773
|
+
114,
|
|
1774
|
+
111,
|
|
1775
|
+
119
|
|
1776
|
+
]
|
|
1777
|
+
}
|
|
1778
|
+
]
|
|
1779
|
+
}
|
|
1780
|
+
},
|
|
1781
|
+
{
|
|
1782
|
+
name: "treasury_ata_in",
|
|
1783
|
+
docs: [
|
|
1784
|
+
"Treasury ATA for `mint_in`. `None` when spending SOL."
|
|
1785
|
+
],
|
|
1786
|
+
writable: true,
|
|
1787
|
+
optional: true
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
name: "treasury_ata_out",
|
|
1791
|
+
docs: [
|
|
1792
|
+
"Treasury ATA for `mint_out`. `None` when receiving SOL."
|
|
1793
|
+
],
|
|
1794
|
+
writable: true,
|
|
1795
|
+
optional: true
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
name: "escrow_ata_in",
|
|
1799
|
+
docs: [
|
|
1800
|
+
"Escrow ATA for `mint_in` (wrapped SOL when spending SOL). Must exist: prepend an",
|
|
1801
|
+
"idempotent ATA create. A wrapped-SOL escrow account is closed at the end of the swap."
|
|
1802
|
+
],
|
|
1803
|
+
writable: true
|
|
1804
|
+
},
|
|
1805
|
+
{
|
|
1806
|
+
name: "escrow_ata_out",
|
|
1807
|
+
docs: [
|
|
1808
|
+
"Escrow ATA for `mint_out` (wrapped SOL when receiving SOL). Must exist, as above."
|
|
1809
|
+
],
|
|
1810
|
+
writable: true
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
name: "relayer_ata",
|
|
1814
|
+
docs: [
|
|
1815
|
+
"Relayer ATA for `mint_in`, paid the relayer fee. `None` when spending SOL."
|
|
1816
|
+
],
|
|
1817
|
+
writable: true,
|
|
1818
|
+
optional: true
|
|
1819
|
+
},
|
|
1820
|
+
{
|
|
1821
|
+
name: "nullifier0",
|
|
1822
|
+
writable: true,
|
|
1823
|
+
pda: {
|
|
1824
|
+
seeds: [
|
|
1825
|
+
{
|
|
1826
|
+
kind: "const",
|
|
1827
|
+
value: [
|
|
1828
|
+
110,
|
|
1829
|
+
117,
|
|
1830
|
+
108,
|
|
1831
|
+
108,
|
|
1832
|
+
105,
|
|
1833
|
+
102,
|
|
1834
|
+
105,
|
|
1835
|
+
101,
|
|
1836
|
+
114
|
|
1837
|
+
]
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
kind: "arg",
|
|
1841
|
+
path: "proof.input_nullifiers [0]"
|
|
1842
|
+
}
|
|
1843
|
+
]
|
|
1844
|
+
}
|
|
1845
|
+
},
|
|
1846
|
+
{
|
|
1847
|
+
name: "nullifier1",
|
|
1848
|
+
writable: true,
|
|
1849
|
+
pda: {
|
|
1850
|
+
seeds: [
|
|
1851
|
+
{
|
|
1852
|
+
kind: "const",
|
|
1853
|
+
value: [
|
|
1854
|
+
110,
|
|
1855
|
+
117,
|
|
1856
|
+
108,
|
|
1857
|
+
108,
|
|
1858
|
+
105,
|
|
1859
|
+
102,
|
|
1860
|
+
105,
|
|
1861
|
+
101,
|
|
1862
|
+
114
|
|
1863
|
+
]
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
kind: "arg",
|
|
1867
|
+
path: "proof.input_nullifiers [1]"
|
|
1868
|
+
}
|
|
1869
|
+
]
|
|
1870
|
+
}
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
name: "mint_in",
|
|
1874
|
+
docs: [
|
|
1875
|
+
"Mint of the spent asset (the native mint when spending SOL)."
|
|
1876
|
+
]
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
name: "mint_out",
|
|
1880
|
+
docs: [
|
|
1881
|
+
"Mint of the received asset (the native mint when receiving SOL)."
|
|
1882
|
+
]
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
name: "token_program_in"
|
|
1886
|
+
},
|
|
1887
|
+
{
|
|
1888
|
+
name: "token_program_out"
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
name: "dex_program"
|
|
1892
|
+
},
|
|
1893
|
+
{
|
|
1894
|
+
name: "system_program",
|
|
1895
|
+
address: "11111111111111111111111111111111"
|
|
1896
|
+
},
|
|
1897
|
+
{
|
|
1898
|
+
name: "event_authority",
|
|
1899
|
+
pda: {
|
|
1900
|
+
seeds: [
|
|
1901
|
+
{
|
|
1902
|
+
kind: "const",
|
|
1903
|
+
value: [
|
|
1904
|
+
95,
|
|
1905
|
+
95,
|
|
1906
|
+
101,
|
|
1907
|
+
118,
|
|
1908
|
+
101,
|
|
1909
|
+
110,
|
|
1910
|
+
116,
|
|
1911
|
+
95,
|
|
1912
|
+
97,
|
|
1913
|
+
117,
|
|
1914
|
+
116,
|
|
1915
|
+
104,
|
|
1916
|
+
111,
|
|
1917
|
+
114,
|
|
1918
|
+
105,
|
|
1919
|
+
116,
|
|
1920
|
+
121
|
|
1921
|
+
]
|
|
1922
|
+
}
|
|
1923
|
+
]
|
|
1924
|
+
}
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
name: "program"
|
|
1928
|
+
}
|
|
1929
|
+
],
|
|
1930
|
+
args: [
|
|
1931
|
+
{
|
|
1932
|
+
name: "proof",
|
|
1933
|
+
type: {
|
|
1934
|
+
defined: {
|
|
1935
|
+
name: "TransactionProof"
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
name: "params",
|
|
1941
|
+
type: {
|
|
1942
|
+
defined: {
|
|
1943
|
+
name: "SwapParams"
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
},
|
|
1947
|
+
{
|
|
1948
|
+
name: "encrypted_output1",
|
|
1949
|
+
type: "bytes"
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
name: "encrypted_output2",
|
|
1953
|
+
type: "bytes"
|
|
1954
|
+
},
|
|
1955
|
+
{
|
|
1956
|
+
name: "route_data",
|
|
1957
|
+
type: "bytes"
|
|
1958
|
+
}
|
|
1959
|
+
]
|
|
1960
|
+
},
|
|
1489
1961
|
{
|
|
1490
1962
|
name: "token_deposit",
|
|
1491
1963
|
discriminator: [
|
|
@@ -1712,14 +2184,46 @@ var veilix_devnet_default = {
|
|
|
1712
2184
|
}
|
|
1713
2185
|
},
|
|
1714
2186
|
{
|
|
1715
|
-
name: "mint"
|
|
1716
|
-
},
|
|
1717
|
-
{
|
|
1718
|
-
name: "token_program"
|
|
1719
|
-
},
|
|
1720
|
-
{
|
|
1721
|
-
name: "system_program",
|
|
1722
|
-
address: "11111111111111111111111111111111"
|
|
2187
|
+
name: "mint"
|
|
2188
|
+
},
|
|
2189
|
+
{
|
|
2190
|
+
name: "token_program"
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
name: "system_program",
|
|
2194
|
+
address: "11111111111111111111111111111111"
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
name: "event_authority",
|
|
2198
|
+
pda: {
|
|
2199
|
+
seeds: [
|
|
2200
|
+
{
|
|
2201
|
+
kind: "const",
|
|
2202
|
+
value: [
|
|
2203
|
+
95,
|
|
2204
|
+
95,
|
|
2205
|
+
101,
|
|
2206
|
+
118,
|
|
2207
|
+
101,
|
|
2208
|
+
110,
|
|
2209
|
+
116,
|
|
2210
|
+
95,
|
|
2211
|
+
97,
|
|
2212
|
+
117,
|
|
2213
|
+
116,
|
|
2214
|
+
104,
|
|
2215
|
+
111,
|
|
2216
|
+
114,
|
|
2217
|
+
105,
|
|
2218
|
+
116,
|
|
2219
|
+
121
|
|
2220
|
+
]
|
|
2221
|
+
}
|
|
2222
|
+
]
|
|
2223
|
+
}
|
|
2224
|
+
},
|
|
2225
|
+
{
|
|
2226
|
+
name: "program"
|
|
1723
2227
|
}
|
|
1724
2228
|
],
|
|
1725
2229
|
args: [
|
|
@@ -2086,6 +2590,38 @@ var veilix_devnet_default = {
|
|
|
2086
2590
|
{
|
|
2087
2591
|
name: "system_program",
|
|
2088
2592
|
address: "11111111111111111111111111111111"
|
|
2593
|
+
},
|
|
2594
|
+
{
|
|
2595
|
+
name: "event_authority",
|
|
2596
|
+
pda: {
|
|
2597
|
+
seeds: [
|
|
2598
|
+
{
|
|
2599
|
+
kind: "const",
|
|
2600
|
+
value: [
|
|
2601
|
+
95,
|
|
2602
|
+
95,
|
|
2603
|
+
101,
|
|
2604
|
+
118,
|
|
2605
|
+
101,
|
|
2606
|
+
110,
|
|
2607
|
+
116,
|
|
2608
|
+
95,
|
|
2609
|
+
97,
|
|
2610
|
+
117,
|
|
2611
|
+
116,
|
|
2612
|
+
104,
|
|
2613
|
+
111,
|
|
2614
|
+
114,
|
|
2615
|
+
105,
|
|
2616
|
+
116,
|
|
2617
|
+
121
|
|
2618
|
+
]
|
|
2619
|
+
}
|
|
2620
|
+
]
|
|
2621
|
+
}
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
name: "program"
|
|
2089
2625
|
}
|
|
2090
2626
|
],
|
|
2091
2627
|
args: [
|
|
@@ -2534,6 +3070,83 @@ var veilix_devnet_default = {
|
|
|
2534
3070
|
}
|
|
2535
3071
|
]
|
|
2536
3072
|
},
|
|
3073
|
+
{
|
|
3074
|
+
name: "update_swap_config",
|
|
3075
|
+
docs: [
|
|
3076
|
+
"Replaces the list of DEX programs the swap escrow may call. Config authority only."
|
|
3077
|
+
],
|
|
3078
|
+
discriminator: [
|
|
3079
|
+
123,
|
|
3080
|
+
172,
|
|
3081
|
+
158,
|
|
3082
|
+
60,
|
|
3083
|
+
104,
|
|
3084
|
+
133,
|
|
3085
|
+
39,
|
|
3086
|
+
13
|
|
3087
|
+
],
|
|
3088
|
+
accounts: [
|
|
3089
|
+
{
|
|
3090
|
+
name: "authority",
|
|
3091
|
+
writable: true,
|
|
3092
|
+
signer: true
|
|
3093
|
+
},
|
|
3094
|
+
{
|
|
3095
|
+
name: "network_state",
|
|
3096
|
+
pda: {
|
|
3097
|
+
seeds: [
|
|
3098
|
+
{
|
|
3099
|
+
kind: "const",
|
|
3100
|
+
value: [
|
|
3101
|
+
99,
|
|
3102
|
+
111,
|
|
3103
|
+
110,
|
|
3104
|
+
102,
|
|
3105
|
+
105,
|
|
3106
|
+
103
|
|
3107
|
+
]
|
|
3108
|
+
}
|
|
3109
|
+
]
|
|
3110
|
+
}
|
|
3111
|
+
},
|
|
3112
|
+
{
|
|
3113
|
+
name: "swap_config",
|
|
3114
|
+
writable: true,
|
|
3115
|
+
pda: {
|
|
3116
|
+
seeds: [
|
|
3117
|
+
{
|
|
3118
|
+
kind: "const",
|
|
3119
|
+
value: [
|
|
3120
|
+
115,
|
|
3121
|
+
119,
|
|
3122
|
+
97,
|
|
3123
|
+
112,
|
|
3124
|
+
95,
|
|
3125
|
+
99,
|
|
3126
|
+
111,
|
|
3127
|
+
110,
|
|
3128
|
+
102,
|
|
3129
|
+
105,
|
|
3130
|
+
103
|
|
3131
|
+
]
|
|
3132
|
+
}
|
|
3133
|
+
]
|
|
3134
|
+
}
|
|
3135
|
+
},
|
|
3136
|
+
{
|
|
3137
|
+
name: "system_program",
|
|
3138
|
+
address: "11111111111111111111111111111111"
|
|
3139
|
+
}
|
|
3140
|
+
],
|
|
3141
|
+
args: [
|
|
3142
|
+
{
|
|
3143
|
+
name: "allowed_programs",
|
|
3144
|
+
type: {
|
|
3145
|
+
vec: "pubkey"
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
]
|
|
3149
|
+
},
|
|
2537
3150
|
{
|
|
2538
3151
|
name: "withdraw",
|
|
2539
3152
|
discriminator: [
|
|
@@ -2692,6 +3305,38 @@ var veilix_devnet_default = {
|
|
|
2692
3305
|
{
|
|
2693
3306
|
name: "system_program",
|
|
2694
3307
|
address: "11111111111111111111111111111111"
|
|
3308
|
+
},
|
|
3309
|
+
{
|
|
3310
|
+
name: "event_authority",
|
|
3311
|
+
pda: {
|
|
3312
|
+
seeds: [
|
|
3313
|
+
{
|
|
3314
|
+
kind: "const",
|
|
3315
|
+
value: [
|
|
3316
|
+
95,
|
|
3317
|
+
95,
|
|
3318
|
+
101,
|
|
3319
|
+
118,
|
|
3320
|
+
101,
|
|
3321
|
+
110,
|
|
3322
|
+
116,
|
|
3323
|
+
95,
|
|
3324
|
+
97,
|
|
3325
|
+
117,
|
|
3326
|
+
116,
|
|
3327
|
+
104,
|
|
3328
|
+
111,
|
|
3329
|
+
114,
|
|
3330
|
+
105,
|
|
3331
|
+
116,
|
|
3332
|
+
121
|
|
3333
|
+
]
|
|
3334
|
+
}
|
|
3335
|
+
]
|
|
3336
|
+
}
|
|
3337
|
+
},
|
|
3338
|
+
{
|
|
3339
|
+
name: "program"
|
|
2695
3340
|
}
|
|
2696
3341
|
],
|
|
2697
3342
|
args: [
|
|
@@ -2801,6 +3446,19 @@ var veilix_devnet_default = {
|
|
|
2801
3446
|
20
|
|
2802
3447
|
]
|
|
2803
3448
|
},
|
|
3449
|
+
{
|
|
3450
|
+
name: "SwapConfig",
|
|
3451
|
+
discriminator: [
|
|
3452
|
+
212,
|
|
3453
|
+
45,
|
|
3454
|
+
70,
|
|
3455
|
+
222,
|
|
3456
|
+
245,
|
|
3457
|
+
122,
|
|
3458
|
+
125,
|
|
3459
|
+
166
|
|
3460
|
+
]
|
|
3461
|
+
},
|
|
2804
3462
|
{
|
|
2805
3463
|
name: "TreeAccount",
|
|
2806
3464
|
discriminator: [
|
|
@@ -2842,6 +3500,19 @@ var veilix_devnet_default = {
|
|
|
2842
3500
|
159
|
|
2843
3501
|
]
|
|
2844
3502
|
},
|
|
3503
|
+
{
|
|
3504
|
+
name: "PrivateSwapEvent",
|
|
3505
|
+
discriminator: [
|
|
3506
|
+
150,
|
|
3507
|
+
165,
|
|
3508
|
+
138,
|
|
3509
|
+
189,
|
|
3510
|
+
123,
|
|
3511
|
+
86,
|
|
3512
|
+
117,
|
|
3513
|
+
39
|
|
3514
|
+
]
|
|
3515
|
+
},
|
|
2845
3516
|
{
|
|
2846
3517
|
name: "RelayerCancelled",
|
|
2847
3518
|
discriminator: [
|
|
@@ -3104,6 +3775,56 @@ var veilix_devnet_default = {
|
|
|
3104
3775
|
code: 6033,
|
|
3105
3776
|
name: "FeeRepaymentAccounts",
|
|
3106
3777
|
msg: "Fee repayment accounts do not match earned fees"
|
|
3778
|
+
},
|
|
3779
|
+
{
|
|
3780
|
+
code: 6034,
|
|
3781
|
+
name: "DexProgramNotAllowed",
|
|
3782
|
+
msg: "DEX program is not on the swap allowlist"
|
|
3783
|
+
},
|
|
3784
|
+
{
|
|
3785
|
+
code: 6035,
|
|
3786
|
+
name: "TooManyDexPrograms",
|
|
3787
|
+
msg: "Too many allowlisted DEX programs"
|
|
3788
|
+
},
|
|
3789
|
+
{
|
|
3790
|
+
code: 6036,
|
|
3791
|
+
name: "SlippageExceeded",
|
|
3792
|
+
msg: "Swap output is below the minimum amount"
|
|
3793
|
+
},
|
|
3794
|
+
{
|
|
3795
|
+
code: 6037,
|
|
3796
|
+
name: "SwapInputMismatch",
|
|
3797
|
+
msg: "DEX did not use exactly the escrowed swap input"
|
|
3798
|
+
},
|
|
3799
|
+
{
|
|
3800
|
+
code: 6038,
|
|
3801
|
+
name: "InvalidSwapAccounts",
|
|
3802
|
+
msg: "Swap accounts do not match the trees"
|
|
3803
|
+
},
|
|
3804
|
+
{
|
|
3805
|
+
code: 6039,
|
|
3806
|
+
name: "EscrowTampered",
|
|
3807
|
+
msg: "Swap escrow was modified by the DEX"
|
|
3808
|
+
},
|
|
3809
|
+
{
|
|
3810
|
+
code: 6040,
|
|
3811
|
+
name: "InvalidNoteKey",
|
|
3812
|
+
msg: "Note public key or blinding is not a valid field element"
|
|
3813
|
+
},
|
|
3814
|
+
{
|
|
3815
|
+
code: 6041,
|
|
3816
|
+
name: "NotUpgradeAuthority",
|
|
3817
|
+
msg: "Only the program upgrade authority can initialize the network"
|
|
3818
|
+
},
|
|
3819
|
+
{
|
|
3820
|
+
code: 6042,
|
|
3821
|
+
name: "InvalidFeeSplit",
|
|
3822
|
+
msg: "Fee wallets must be distinct, non-default and split at most the allowed total"
|
|
3823
|
+
},
|
|
3824
|
+
{
|
|
3825
|
+
code: 6043,
|
|
3826
|
+
name: "UnsupportedMintExtension",
|
|
3827
|
+
msg: "Token mint has an extension the pool does not support"
|
|
3107
3828
|
}
|
|
3108
3829
|
],
|
|
3109
3830
|
types: [
|
|
@@ -3231,8 +3952,104 @@ var veilix_devnet_default = {
|
|
|
3231
3952
|
type: "pubkey"
|
|
3232
3953
|
},
|
|
3233
3954
|
{
|
|
3234
|
-
name: "index",
|
|
3235
|
-
type: "u64"
|
|
3955
|
+
name: "index",
|
|
3956
|
+
type: "u64"
|
|
3957
|
+
},
|
|
3958
|
+
{
|
|
3959
|
+
name: "commitment",
|
|
3960
|
+
type: {
|
|
3961
|
+
array: [
|
|
3962
|
+
"u8",
|
|
3963
|
+
32
|
|
3964
|
+
]
|
|
3965
|
+
}
|
|
3966
|
+
},
|
|
3967
|
+
{
|
|
3968
|
+
name: "encrypted_output",
|
|
3969
|
+
type: "bytes"
|
|
3970
|
+
}
|
|
3971
|
+
]
|
|
3972
|
+
}
|
|
3973
|
+
},
|
|
3974
|
+
{
|
|
3975
|
+
name: "Notes",
|
|
3976
|
+
type: {
|
|
3977
|
+
kind: "struct",
|
|
3978
|
+
fields: [
|
|
3979
|
+
{
|
|
3980
|
+
name: "entries",
|
|
3981
|
+
type: {
|
|
3982
|
+
vec: "string"
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
]
|
|
3986
|
+
}
|
|
3987
|
+
},
|
|
3988
|
+
{
|
|
3989
|
+
name: "NotesV2",
|
|
3990
|
+
type: {
|
|
3991
|
+
kind: "struct",
|
|
3992
|
+
fields: [
|
|
3993
|
+
{
|
|
3994
|
+
name: "entries",
|
|
3995
|
+
type: {
|
|
3996
|
+
vec: "bytes"
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
]
|
|
4000
|
+
}
|
|
4001
|
+
},
|
|
4002
|
+
{
|
|
4003
|
+
name: "Nullifier",
|
|
4004
|
+
type: {
|
|
4005
|
+
kind: "struct"
|
|
4006
|
+
}
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
name: "PrivateSwapEvent",
|
|
4010
|
+
docs: [
|
|
4011
|
+
"Emitted once per swap. The asset-B note is `commitment` at `index` in the `mint_out` tree."
|
|
4012
|
+
],
|
|
4013
|
+
type: {
|
|
4014
|
+
kind: "struct",
|
|
4015
|
+
fields: [
|
|
4016
|
+
{
|
|
4017
|
+
name: "mint_in",
|
|
4018
|
+
type: "pubkey"
|
|
4019
|
+
},
|
|
4020
|
+
{
|
|
4021
|
+
name: "mint_out",
|
|
4022
|
+
type: "pubkey"
|
|
4023
|
+
},
|
|
4024
|
+
{
|
|
4025
|
+
name: "amount_in",
|
|
4026
|
+
type: "u64"
|
|
4027
|
+
},
|
|
4028
|
+
{
|
|
4029
|
+
name: "fee",
|
|
4030
|
+
type: "u64"
|
|
4031
|
+
},
|
|
4032
|
+
{
|
|
4033
|
+
name: "amount_out",
|
|
4034
|
+
type: "u64"
|
|
4035
|
+
},
|
|
4036
|
+
{
|
|
4037
|
+
name: "input_nullifiers",
|
|
4038
|
+
type: {
|
|
4039
|
+
array: [
|
|
4040
|
+
{
|
|
4041
|
+
array: [
|
|
4042
|
+
"u8",
|
|
4043
|
+
32
|
|
4044
|
+
]
|
|
4045
|
+
},
|
|
4046
|
+
2
|
|
4047
|
+
]
|
|
4048
|
+
}
|
|
4049
|
+
},
|
|
4050
|
+
{
|
|
4051
|
+
name: "relayer",
|
|
4052
|
+
type: "pubkey"
|
|
3236
4053
|
},
|
|
3237
4054
|
{
|
|
3238
4055
|
name: "commitment",
|
|
@@ -3244,46 +4061,12 @@ var veilix_devnet_default = {
|
|
|
3244
4061
|
}
|
|
3245
4062
|
},
|
|
3246
4063
|
{
|
|
3247
|
-
name: "
|
|
3248
|
-
type: "
|
|
3249
|
-
}
|
|
3250
|
-
]
|
|
3251
|
-
}
|
|
3252
|
-
},
|
|
3253
|
-
{
|
|
3254
|
-
name: "Notes",
|
|
3255
|
-
type: {
|
|
3256
|
-
kind: "struct",
|
|
3257
|
-
fields: [
|
|
3258
|
-
{
|
|
3259
|
-
name: "entries",
|
|
3260
|
-
type: {
|
|
3261
|
-
vec: "string"
|
|
3262
|
-
}
|
|
3263
|
-
}
|
|
3264
|
-
]
|
|
3265
|
-
}
|
|
3266
|
-
},
|
|
3267
|
-
{
|
|
3268
|
-
name: "NotesV2",
|
|
3269
|
-
type: {
|
|
3270
|
-
kind: "struct",
|
|
3271
|
-
fields: [
|
|
3272
|
-
{
|
|
3273
|
-
name: "entries",
|
|
3274
|
-
type: {
|
|
3275
|
-
vec: "bytes"
|
|
3276
|
-
}
|
|
4064
|
+
name: "index",
|
|
4065
|
+
type: "u64"
|
|
3277
4066
|
}
|
|
3278
4067
|
]
|
|
3279
4068
|
}
|
|
3280
4069
|
},
|
|
3281
|
-
{
|
|
3282
|
-
name: "Nullifier",
|
|
3283
|
-
type: {
|
|
3284
|
-
kind: "struct"
|
|
3285
|
-
}
|
|
3286
|
-
},
|
|
3287
4070
|
{
|
|
3288
4071
|
name: "RelayerAccount",
|
|
3289
4072
|
docs: [
|
|
@@ -3478,6 +4261,86 @@ var veilix_devnet_default = {
|
|
|
3478
4261
|
]
|
|
3479
4262
|
}
|
|
3480
4263
|
},
|
|
4264
|
+
{
|
|
4265
|
+
name: "SwapConfig",
|
|
4266
|
+
docs: [
|
|
4267
|
+
'Programs the swap escrow is allowed to call. PDA seeds: `["swap_config"]`.'
|
|
4268
|
+
],
|
|
4269
|
+
type: {
|
|
4270
|
+
kind: "struct",
|
|
4271
|
+
fields: [
|
|
4272
|
+
{
|
|
4273
|
+
name: "allowed_programs",
|
|
4274
|
+
type: {
|
|
4275
|
+
vec: "pubkey"
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
]
|
|
4279
|
+
}
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
name: "SwapParams",
|
|
4283
|
+
docs: [
|
|
4284
|
+
"Swap parameters. All of them are bound into the proof's `extDataHash`."
|
|
4285
|
+
],
|
|
4286
|
+
type: {
|
|
4287
|
+
kind: "struct",
|
|
4288
|
+
fields: [
|
|
4289
|
+
{
|
|
4290
|
+
name: "amount_in",
|
|
4291
|
+
docs: [
|
|
4292
|
+
"Asset-A amount spent from the pool, fee included."
|
|
4293
|
+
],
|
|
4294
|
+
type: "u64"
|
|
4295
|
+
},
|
|
4296
|
+
{
|
|
4297
|
+
name: "fee",
|
|
4298
|
+
docs: [
|
|
4299
|
+
"Asset-A fee: protocol wallets get their split of `amount_in`, the relayer the rest."
|
|
4300
|
+
],
|
|
4301
|
+
type: "u64"
|
|
4302
|
+
},
|
|
4303
|
+
{
|
|
4304
|
+
name: "min_amount_out",
|
|
4305
|
+
docs: [
|
|
4306
|
+
"Minimum asset-B amount that must reach the treasury."
|
|
4307
|
+
],
|
|
4308
|
+
type: "u64"
|
|
4309
|
+
},
|
|
4310
|
+
{
|
|
4311
|
+
name: "out_pubkey",
|
|
4312
|
+
docs: [
|
|
4313
|
+
"One-time shielded public key of the asset-B note (32-byte big-endian field element)."
|
|
4314
|
+
],
|
|
4315
|
+
type: {
|
|
4316
|
+
array: [
|
|
4317
|
+
"u8",
|
|
4318
|
+
32
|
|
4319
|
+
]
|
|
4320
|
+
}
|
|
4321
|
+
},
|
|
4322
|
+
{
|
|
4323
|
+
name: "out_blinding",
|
|
4324
|
+
docs: [
|
|
4325
|
+
"Blinding of the asset-B note (32-byte big-endian field element)."
|
|
4326
|
+
],
|
|
4327
|
+
type: {
|
|
4328
|
+
array: [
|
|
4329
|
+
"u8",
|
|
4330
|
+
32
|
|
4331
|
+
]
|
|
4332
|
+
}
|
|
4333
|
+
},
|
|
4334
|
+
{
|
|
4335
|
+
name: "encrypted_note",
|
|
4336
|
+
docs: [
|
|
4337
|
+
"Optional encrypted recovery data for the asset-B note."
|
|
4338
|
+
],
|
|
4339
|
+
type: "bytes"
|
|
4340
|
+
}
|
|
4341
|
+
]
|
|
4342
|
+
}
|
|
4343
|
+
},
|
|
3481
4344
|
{
|
|
3482
4345
|
name: "TransactionProof",
|
|
3483
4346
|
docs: [
|
|
@@ -7376,7 +8239,7 @@ var MAINNET_TOKEN_MINTS = {
|
|
|
7376
8239
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
7377
8240
|
};
|
|
7378
8241
|
var DEVNET_TOKEN_MINTS = {
|
|
7379
|
-
Veilix: "
|
|
8242
|
+
Veilix: "Gmo636w21RBZX9ySVtPYcuYP6f1E5bdW5eBYhvK1bc8J",
|
|
7380
8243
|
Bitcoin: "",
|
|
7381
8244
|
Ethereum: "",
|
|
7382
8245
|
USDC: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
@@ -7426,7 +8289,7 @@ function getDepositQueueForNetwork(network) {
|
|
|
7426
8289
|
// package.json
|
|
7427
8290
|
var package_default = {
|
|
7428
8291
|
name: "veilix-sdk",
|
|
7429
|
-
version: "0.
|
|
8292
|
+
version: "0.3.1"};
|
|
7430
8293
|
|
|
7431
8294
|
// src/circuits/constants.ts
|
|
7432
8295
|
var PACKAGE_NAME = package_default.name;
|
|
@@ -7601,10 +8464,19 @@ async function createRuntimeConfig(options) {
|
|
|
7601
8464
|
};
|
|
7602
8465
|
}
|
|
7603
8466
|
function pushRuntimeContext(config) {
|
|
8467
|
+
const active = runtimeContextStack.find((other) => other.programId !== config.programId);
|
|
8468
|
+
if (active) {
|
|
8469
|
+
throw new Error(
|
|
8470
|
+
`veilix-sdk: another SDK instance is running on program ${active.programId}; instances on different networks must run one at a time`
|
|
8471
|
+
);
|
|
8472
|
+
}
|
|
7604
8473
|
runtimeContextStack.push(config);
|
|
7605
8474
|
}
|
|
7606
|
-
function popRuntimeContext() {
|
|
7607
|
-
runtimeContextStack.
|
|
8475
|
+
function popRuntimeContext(config) {
|
|
8476
|
+
const index = runtimeContextStack.lastIndexOf(config);
|
|
8477
|
+
if (index !== -1) {
|
|
8478
|
+
runtimeContextStack.splice(index, 1);
|
|
8479
|
+
}
|
|
7608
8480
|
}
|
|
7609
8481
|
function getConfig() {
|
|
7610
8482
|
const active = runtimeContextStack.at(-1);
|
|
@@ -7669,10 +8541,10 @@ var DEPOSIT_COMPUTE_UNIT_LIMIT = 35e4;
|
|
|
7669
8541
|
function bytesToHex(bytes) {
|
|
7670
8542
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
7671
8543
|
}
|
|
7672
|
-
function hexToBytes(
|
|
7673
|
-
const clean =
|
|
8544
|
+
function hexToBytes(hex2) {
|
|
8545
|
+
const clean = hex2.startsWith("0x") || hex2.startsWith("0X") ? hex2.slice(2) : hex2;
|
|
7674
8546
|
if (clean.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(clean)) {
|
|
7675
|
-
throw new Error(`veilix-sdk: invalid hex string "${
|
|
8547
|
+
throw new Error(`veilix-sdk: invalid hex string "${hex2}"`);
|
|
7676
8548
|
}
|
|
7677
8549
|
const out = new Uint8Array(clean.length / 2);
|
|
7678
8550
|
for (let i = 0; i < out.length; i++) {
|
|
@@ -7681,15 +8553,15 @@ function hexToBytes(hex) {
|
|
|
7681
8553
|
return out;
|
|
7682
8554
|
}
|
|
7683
8555
|
function bigintToBytes32(value) {
|
|
7684
|
-
const
|
|
7685
|
-
if (
|
|
8556
|
+
const hex2 = BigInt(value).toString(16).padStart(64, "0");
|
|
8557
|
+
if (hex2.length > 64) {
|
|
7686
8558
|
throw new Error("veilix-sdk: value does not fit in 32 bytes");
|
|
7687
8559
|
}
|
|
7688
|
-
return hexToBytes(
|
|
8560
|
+
return hexToBytes(hex2);
|
|
7689
8561
|
}
|
|
7690
8562
|
function bytesToBigint(bytes) {
|
|
7691
|
-
const
|
|
7692
|
-
return
|
|
8563
|
+
const hex2 = bytesToHex(bytes);
|
|
8564
|
+
return hex2 ? BigInt(`0x${hex2}`) : 0n;
|
|
7693
8565
|
}
|
|
7694
8566
|
function toHex32(value) {
|
|
7695
8567
|
return `0x${BigInt(value).toString(16).padStart(64, "0")}`;
|
|
@@ -7807,6 +8679,7 @@ var Utxo = class _Utxo {
|
|
|
7807
8679
|
// src/core/note.ts
|
|
7808
8680
|
var NOTE_PREFIX = "vx2";
|
|
7809
8681
|
var ENCRYPTED_OUTPUT_VERSION = 1;
|
|
8682
|
+
var ENCRYPTED_SWAP_OUTPUT_VERSION = 2;
|
|
7810
8683
|
var ENCRYPTED_OUTPUT_PLAINTEXT_BYTES = 1 + 8 + 32 + 32;
|
|
7811
8684
|
var SECRETBOX_NONCE_BYTES = nacl__default.default.secretbox.nonceLength;
|
|
7812
8685
|
function encodeNote(utxo) {
|
|
@@ -7839,14 +8712,14 @@ function decodeNote(note) {
|
|
|
7839
8712
|
throw new Error("veilix-sdk: invalid note format");
|
|
7840
8713
|
}
|
|
7841
8714
|
const [, amountHex, privKeyHex, blindingHex, mint] = parts;
|
|
7842
|
-
const
|
|
7843
|
-
if (!
|
|
8715
|
+
const hex2 = /^[0-9a-f]+$/i;
|
|
8716
|
+
if (!hex2.test(amountHex) || !hex2.test(privKeyHex) || !hex2.test(blindingHex)) {
|
|
7844
8717
|
throw new Error("veilix-sdk: invalid note format");
|
|
7845
8718
|
}
|
|
7846
|
-
let
|
|
8719
|
+
let mintKey2 = null;
|
|
7847
8720
|
if (mint) {
|
|
7848
8721
|
try {
|
|
7849
|
-
|
|
8722
|
+
mintKey2 = new web3_js.PublicKey(mint);
|
|
7850
8723
|
} catch {
|
|
7851
8724
|
throw new Error("veilix-sdk: invalid note mint");
|
|
7852
8725
|
}
|
|
@@ -7855,7 +8728,7 @@ function decodeNote(note) {
|
|
|
7855
8728
|
amount: BigInt(`0x${amountHex}`),
|
|
7856
8729
|
keypair: VeilixKeypair.fromPrivateKey(BigInt(`0x${privKeyHex}`)),
|
|
7857
8730
|
blinding: BigInt(`0x${blindingHex}`),
|
|
7858
|
-
mint:
|
|
8731
|
+
mint: mintKey2
|
|
7859
8732
|
});
|
|
7860
8733
|
}
|
|
7861
8734
|
function describeUtxo(utxo) {
|
|
@@ -7873,7 +8746,7 @@ function describeUtxo(utxo) {
|
|
|
7873
8746
|
function parseSecretNote(note) {
|
|
7874
8747
|
return describeUtxo(decodeNote(note));
|
|
7875
8748
|
}
|
|
7876
|
-
function encryptNoteOutput(
|
|
8749
|
+
function encryptNoteOutput(key2, utxo) {
|
|
7877
8750
|
const amount = new Uint8Array(8);
|
|
7878
8751
|
new DataView(amount.buffer).setBigUint64(0, utxo.amount, true);
|
|
7879
8752
|
const plaintext = concatBytes([
|
|
@@ -7883,21 +8756,38 @@ function encryptNoteOutput(key, utxo) {
|
|
|
7883
8756
|
bigintToBytes32(utxo.blinding)
|
|
7884
8757
|
]);
|
|
7885
8758
|
const nonce = nacl__default.default.randomBytes(SECRETBOX_NONCE_BYTES);
|
|
7886
|
-
return concatBytes([nonce, nacl__default.default.secretbox(plaintext, nonce,
|
|
8759
|
+
return concatBytes([nonce, nacl__default.default.secretbox(plaintext, nonce, key2)]);
|
|
8760
|
+
}
|
|
8761
|
+
function encryptSwapNoteOutput(key2, keypair, blinding) {
|
|
8762
|
+
const plaintext = concatBytes([
|
|
8763
|
+
Uint8Array.of(ENCRYPTED_SWAP_OUTPUT_VERSION),
|
|
8764
|
+
new Uint8Array(8),
|
|
8765
|
+
bigintToBytes32(keypair.privKey),
|
|
8766
|
+
bigintToBytes32(blinding)
|
|
8767
|
+
]);
|
|
8768
|
+
const nonce = nacl__default.default.randomBytes(SECRETBOX_NONCE_BYTES);
|
|
8769
|
+
return concatBytes([nonce, nacl__default.default.secretbox(plaintext, nonce, key2)]);
|
|
7887
8770
|
}
|
|
7888
|
-
function decryptNoteOutput(
|
|
8771
|
+
function decryptNoteOutput(key2, encryptedOutput, mint, index, onchainAmount = null) {
|
|
7889
8772
|
if (encryptedOutput.length !== SECRETBOX_NONCE_BYTES + nacl__default.default.secretbox.overheadLength + ENCRYPTED_OUTPUT_PLAINTEXT_BYTES) {
|
|
7890
8773
|
return null;
|
|
7891
8774
|
}
|
|
7892
8775
|
const opened = nacl__default.default.secretbox.open(
|
|
7893
8776
|
encryptedOutput.subarray(SECRETBOX_NONCE_BYTES),
|
|
7894
8777
|
encryptedOutput.subarray(0, SECRETBOX_NONCE_BYTES),
|
|
7895
|
-
|
|
8778
|
+
key2
|
|
7896
8779
|
);
|
|
7897
|
-
if (!opened
|
|
8780
|
+
if (!opened) {
|
|
8781
|
+
return null;
|
|
8782
|
+
}
|
|
8783
|
+
let amount;
|
|
8784
|
+
if (opened[0] === ENCRYPTED_OUTPUT_VERSION) {
|
|
8785
|
+
amount = new DataView(opened.buffer, opened.byteOffset + 1, 8).getBigUint64(0, true);
|
|
8786
|
+
} else if (opened[0] === ENCRYPTED_SWAP_OUTPUT_VERSION && onchainAmount !== null) {
|
|
8787
|
+
amount = onchainAmount;
|
|
8788
|
+
} else {
|
|
7898
8789
|
return null;
|
|
7899
8790
|
}
|
|
7900
|
-
const amount = new DataView(opened.buffer, opened.byteOffset + 1, 8).getBigUint64(0, true);
|
|
7901
8791
|
return new Utxo({
|
|
7902
8792
|
amount,
|
|
7903
8793
|
keypair: VeilixKeypair.fromPrivateKey(bytesToBigint(opened.subarray(9, 41))),
|
|
@@ -16378,6 +17268,7 @@ async function proveTransaction({
|
|
|
16378
17268
|
inputs = [],
|
|
16379
17269
|
outputs = [],
|
|
16380
17270
|
ext,
|
|
17271
|
+
extDataHashOverride,
|
|
16381
17272
|
circuit
|
|
16382
17273
|
}) {
|
|
16383
17274
|
for (const utxo of [...inputs, ...outputs]) {
|
|
@@ -16427,7 +17318,7 @@ async function proveTransaction({
|
|
|
16427
17318
|
const input = {
|
|
16428
17319
|
root: proofRoot.toString(),
|
|
16429
17320
|
publicAmount: publicAmount.toString(),
|
|
16430
|
-
extDataHash: (await extDataHash(ext)).toString(),
|
|
17321
|
+
extDataHash: (extDataHashOverride ?? await extDataHash(ext)).toString(),
|
|
16431
17322
|
mint: mintToField(ext.mint).toString(),
|
|
16432
17323
|
inputNullifier: inputNullifiers.map(String),
|
|
16433
17324
|
outputCommitment: outputCommitments.map(String),
|
|
@@ -16568,8 +17459,8 @@ function generateDepositParams(amount, mint = null) {
|
|
|
16568
17459
|
if (value <= 0n) {
|
|
16569
17460
|
throw new Error("veilix-sdk: deposit amount must be positive");
|
|
16570
17461
|
}
|
|
16571
|
-
const
|
|
16572
|
-
const note = encodeNote(new Utxo({ amount: value, mint:
|
|
17462
|
+
const mintKey2 = mint && mint !== WRAPPED_SOL_MINT ? new web3_js.PublicKey(mint) : null;
|
|
17463
|
+
const note = encodeNote(new Utxo({ amount: value, mint: mintKey2 }));
|
|
16573
17464
|
return { note, params: parseSecretNote(note) };
|
|
16574
17465
|
}
|
|
16575
17466
|
function to32ByteBuffer(value) {
|
|
@@ -16603,8 +17494,8 @@ function toPublicKey(value) {
|
|
|
16603
17494
|
}
|
|
16604
17495
|
function normalizeTreeMint(mint) {
|
|
16605
17496
|
if (!mint) return null;
|
|
16606
|
-
const
|
|
16607
|
-
return
|
|
17497
|
+
const key2 = toPublicKey(mint);
|
|
17498
|
+
return key2.equals(splToken.NATIVE_MINT) || key2.equals(web3_js.PublicKey.default) ? null : key2;
|
|
16608
17499
|
}
|
|
16609
17500
|
function getTreePDA(mint) {
|
|
16610
17501
|
const treeMint = normalizeTreeMint(mint);
|
|
@@ -16776,9 +17667,11 @@ async function buildDepositTx({
|
|
|
16776
17667
|
onChainBackup = false,
|
|
16777
17668
|
computeUnitPrice = 5e3,
|
|
16778
17669
|
computeUnitLimit = DEPOSIT_COMPUTE_UNIT_LIMIT,
|
|
16779
|
-
circuitArtifacts
|
|
17670
|
+
circuitArtifacts,
|
|
17671
|
+
encryptKey
|
|
16780
17672
|
}) {
|
|
16781
17673
|
const { connection } = getConfig();
|
|
17674
|
+
const sealKey = onChainBackup ? encryptKey ?? requireEncryptKey() : null;
|
|
16782
17675
|
const sender = toPublicKey(senderPublicKey);
|
|
16783
17676
|
const utxo = decodeNote(note);
|
|
16784
17677
|
const mint = utxo.mint;
|
|
@@ -16791,7 +17684,7 @@ async function buildDepositTx({
|
|
|
16791
17684
|
`veilix-sdk: deposit amount ${utxo.amount} exceeds the tree limit of ${tree.maxDepositAmount}`
|
|
16792
17685
|
);
|
|
16793
17686
|
}
|
|
16794
|
-
const encryptedOutput1 =
|
|
17687
|
+
const encryptedOutput1 = sealKey ? encryptNoteOutput(sealKey, utxo) : new Uint8Array();
|
|
16795
17688
|
const encryptedOutput2 = new Uint8Array();
|
|
16796
17689
|
const proved = await withCircuitArtifacts(
|
|
16797
17690
|
circuitArtifacts,
|
|
@@ -16846,17 +17739,16 @@ async function buildInitNotesInstructionIfNeeded(sender) {
|
|
|
16846
17739
|
if (await fetchNotesAccount(sender)) return null;
|
|
16847
17740
|
return program.methods.initNotes().accountsPartial({ user: sender }).instruction();
|
|
16848
17741
|
}
|
|
16849
|
-
async function resolveEncryptKey() {
|
|
16850
|
-
const config = getConfig();
|
|
17742
|
+
async function resolveEncryptKey(config) {
|
|
16851
17743
|
if (!config.encryptKey) {
|
|
16852
17744
|
config.encryptKey = await getEncryptionKey(config.wallet);
|
|
16853
17745
|
}
|
|
16854
17746
|
return config.encryptKey;
|
|
16855
17747
|
}
|
|
16856
|
-
async function buildBackupNotesInstruction(sender, notes) {
|
|
16857
|
-
const { program } =
|
|
16858
|
-
const
|
|
16859
|
-
return program.methods.backupNotes(notes.map((note) => encryptData(
|
|
17748
|
+
async function buildBackupNotesInstruction(sender, notes, config = getConfig()) {
|
|
17749
|
+
const { program } = config;
|
|
17750
|
+
const key2 = await resolveEncryptKey(config);
|
|
17751
|
+
return program.methods.backupNotes(notes.map((note) => encryptData(key2, note))).accountsPartial({ user: sender }).instruction();
|
|
16860
17752
|
}
|
|
16861
17753
|
async function isExtendBackupPdaNeeded(walletPubkey, newNotesLength) {
|
|
16862
17754
|
const account = await fetchNotesAccount(walletPubkey);
|
|
@@ -16868,7 +17760,8 @@ function buildRequestHeapIx() {
|
|
|
16868
17760
|
return web3_js.ComputeBudgetProgram.requestHeapFrame({ bytes: 32 * 1024 });
|
|
16869
17761
|
}
|
|
16870
17762
|
async function buildBackupNotesTx(senderPublicKey, notes) {
|
|
16871
|
-
const
|
|
17763
|
+
const config = getConfig();
|
|
17764
|
+
const { connection } = config;
|
|
16872
17765
|
const sender = toPublicKey(senderPublicKey);
|
|
16873
17766
|
const tx = new web3_js.Transaction();
|
|
16874
17767
|
const initIx = await buildInitNotesInstructionIfNeeded(sender);
|
|
@@ -16877,7 +17770,7 @@ async function buildBackupNotesTx(senderPublicKey, notes) {
|
|
|
16877
17770
|
} else if (await isExtendBackupPdaNeeded(sender, notes.length)) {
|
|
16878
17771
|
tx.add(buildRequestHeapIx());
|
|
16879
17772
|
}
|
|
16880
|
-
tx.add(await buildBackupNotesInstruction(sender, notes));
|
|
17773
|
+
tx.add(await buildBackupNotesInstruction(sender, notes, config));
|
|
16881
17774
|
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
16882
17775
|
tx.feePayer = sender;
|
|
16883
17776
|
return tx;
|
|
@@ -16961,16 +17854,16 @@ async function getEncryptionKey(wallet) {
|
|
|
16961
17854
|
}
|
|
16962
17855
|
return nacl__default.default.hash(signature).slice(0, 32);
|
|
16963
17856
|
}
|
|
16964
|
-
function encryptData(
|
|
17857
|
+
function encryptData(key2, plaintext) {
|
|
16965
17858
|
const nonce = nacl__default.default.randomBytes(24);
|
|
16966
|
-
const box = nacl__default.default.secretbox(new TextEncoder().encode(plaintext), nonce,
|
|
17859
|
+
const box = nacl__default.default.secretbox(new TextEncoder().encode(plaintext), nonce, key2);
|
|
16967
17860
|
const combined = new Uint8Array(nonce.length + box.length);
|
|
16968
17861
|
combined.set(nonce);
|
|
16969
17862
|
combined.set(box, nonce.length);
|
|
16970
17863
|
return buffer.Buffer.from(combined);
|
|
16971
17864
|
}
|
|
16972
|
-
function decryptData(
|
|
16973
|
-
const decrypted = nacl__default.default.secretbox.open(combined.slice(24), combined.slice(0, 24),
|
|
17865
|
+
function decryptData(key2, combined) {
|
|
17866
|
+
const decrypted = nacl__default.default.secretbox.open(combined.slice(24), combined.slice(0, 24), key2);
|
|
16974
17867
|
if (!decrypted) throw new Error("Decryption failed");
|
|
16975
17868
|
return new TextDecoder().decode(decrypted);
|
|
16976
17869
|
}
|
|
@@ -17008,8 +17901,8 @@ var COMMITMENTS_PAGE_LIMIT = 8e3;
|
|
|
17008
17901
|
var VALIDATE_NULLIFIERS_BATCH = 64;
|
|
17009
17902
|
async function indexerGet(path, params) {
|
|
17010
17903
|
const query = new URLSearchParams();
|
|
17011
|
-
for (const [
|
|
17012
|
-
if (value !== void 0 && value !== "") query.set(
|
|
17904
|
+
for (const [key2, value] of Object.entries(params)) {
|
|
17905
|
+
if (value !== void 0 && value !== "") query.set(key2, value);
|
|
17013
17906
|
}
|
|
17014
17907
|
const qs = query.toString();
|
|
17015
17908
|
return httpFetch(`${getIndexerUrl()}${path}${qs ? `?${qs}` : ""}`, {
|
|
@@ -17224,7 +18117,7 @@ async function scanOwnedNotes({
|
|
|
17224
18117
|
mints,
|
|
17225
18118
|
includeSpent = false
|
|
17226
18119
|
} = {}) {
|
|
17227
|
-
const
|
|
18120
|
+
const key2 = requireEncryptKey();
|
|
17228
18121
|
const explicit = mints !== void 0;
|
|
17229
18122
|
const tokenMints = getTokenMintsForNetwork(getConfig().network);
|
|
17230
18123
|
const targets = mints ?? [null, tokenMints.Veilix, tokenMints.Bitcoin, tokenMints.Ethereum, tokenMints.USDC].filter(
|
|
@@ -17242,7 +18135,13 @@ async function scanOwnedNotes({
|
|
|
17242
18135
|
}
|
|
17243
18136
|
for (const leaf of leaves) {
|
|
17244
18137
|
if (!leaf.encryptedOutput || leaf.encryptedOutput.length <= 2) continue;
|
|
17245
|
-
const utxo = decryptNoteOutput(
|
|
18138
|
+
const utxo = decryptNoteOutput(
|
|
18139
|
+
key2,
|
|
18140
|
+
hexToBytes(leaf.encryptedOutput),
|
|
18141
|
+
treeMint,
|
|
18142
|
+
leaf.index,
|
|
18143
|
+
leaf.amountRaw ? BigInt(leaf.amountRaw) : null
|
|
18144
|
+
);
|
|
17246
18145
|
if (!utxo || utxo.amount === 0n) continue;
|
|
17247
18146
|
if (toHex32(utxo.commitment()) !== toHex32(BigInt(leaf.commitment))) continue;
|
|
17248
18147
|
found.push({ utxo, note: encodeNote(utxo), signature: null });
|
|
@@ -17522,6 +18421,364 @@ async function getQuote(params) {
|
|
|
17522
18421
|
}
|
|
17523
18422
|
return data;
|
|
17524
18423
|
}
|
|
18424
|
+
var SWAP_DOMAIN = new TextEncoder().encode("veilix:swap:v1");
|
|
18425
|
+
async function swapExtDataHash(ext) {
|
|
18426
|
+
const hash = await sha256(
|
|
18427
|
+
concatBytes([
|
|
18428
|
+
SWAP_DOMAIN,
|
|
18429
|
+
(ext.mintIn ?? web3_js.PublicKey.default).toBytes(),
|
|
18430
|
+
(ext.mintOut ?? web3_js.PublicKey.default).toBytes(),
|
|
18431
|
+
ext.relayer.toBytes(),
|
|
18432
|
+
u64le(ext.amountIn),
|
|
18433
|
+
u64le(ext.fee),
|
|
18434
|
+
u64le(ext.minAmountOut),
|
|
18435
|
+
bigintToBytes32(ext.outPubkey),
|
|
18436
|
+
bigintToBytes32(ext.outBlinding),
|
|
18437
|
+
u32le(ext.encryptedOutput1.length),
|
|
18438
|
+
ext.encryptedOutput1,
|
|
18439
|
+
u32le(ext.encryptedOutput2.length),
|
|
18440
|
+
ext.encryptedOutput2,
|
|
18441
|
+
u32le(ext.encryptedNote.length),
|
|
18442
|
+
ext.encryptedNote
|
|
18443
|
+
])
|
|
18444
|
+
);
|
|
18445
|
+
hash[0] = 0;
|
|
18446
|
+
return bytesToBigint(hash);
|
|
18447
|
+
}
|
|
18448
|
+
var CPMM_PROGRAM_IDS = {
|
|
18449
|
+
devnet: "DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb",
|
|
18450
|
+
mainnet: "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"
|
|
18451
|
+
};
|
|
18452
|
+
var FEE_RATE_DENOMINATOR = 1000000n;
|
|
18453
|
+
var SWAP_DISABLED_BIT = 2;
|
|
18454
|
+
var key = (data, offset) => new web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
18455
|
+
var u64 = (data, offset) => new DataView(data.buffer, data.byteOffset + offset, 8).getBigUint64(0, true);
|
|
18456
|
+
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
18457
|
+
var feeOf = (amount, rate) => ceilDiv(amount * rate, FEE_RATE_DENOMINATOR);
|
|
18458
|
+
async function quoteCpmm(connection, network, poolAddress, treeMintIn, treeMintOut, amountIn) {
|
|
18459
|
+
const programId = new web3_js.PublicKey(CPMM_PROGRAM_IDS[network]);
|
|
18460
|
+
const poolInfo = await connection.getAccountInfo(poolAddress, "confirmed");
|
|
18461
|
+
if (!poolInfo || !poolInfo.owner.equals(programId) || poolInfo.data.length < 381) {
|
|
18462
|
+
throw new Error("veilix-sdk: swap pool is not a Raydium CPMM pool");
|
|
18463
|
+
}
|
|
18464
|
+
const data = poolInfo.data;
|
|
18465
|
+
const pool = {
|
|
18466
|
+
ammConfig: key(data, 8),
|
|
18467
|
+
vault0: key(data, 72),
|
|
18468
|
+
vault1: key(data, 104),
|
|
18469
|
+
mint0: key(data, 168),
|
|
18470
|
+
mint1: key(data, 200),
|
|
18471
|
+
status: data[329],
|
|
18472
|
+
protocolFees: [u64(data, 341), u64(data, 349)],
|
|
18473
|
+
fundFees: [u64(data, 357), u64(data, 365)],
|
|
18474
|
+
creatorFeeOn: data.length >= 413 ? data[389] : 0,
|
|
18475
|
+
enableCreatorFee: data.length >= 413 ? data[390] === 1 : false,
|
|
18476
|
+
creatorFees: data.length >= 413 ? [u64(data, 397), u64(data, 405)] : [0n, 0n]
|
|
18477
|
+
};
|
|
18478
|
+
if (pool.status >> SWAP_DISABLED_BIT & 1) {
|
|
18479
|
+
throw new Error("veilix-sdk: swaps are disabled on this pool");
|
|
18480
|
+
}
|
|
18481
|
+
const mintIn = treeMintIn ?? splToken.NATIVE_MINT;
|
|
18482
|
+
const mintOut = treeMintOut ?? splToken.NATIVE_MINT;
|
|
18483
|
+
let zeroForOne;
|
|
18484
|
+
if (pool.mint0.equals(mintIn) && pool.mint1.equals(mintOut)) zeroForOne = true;
|
|
18485
|
+
else if (pool.mint1.equals(mintIn) && pool.mint0.equals(mintOut)) zeroForOne = false;
|
|
18486
|
+
else throw new Error("veilix-sdk: swap pool does not trade this pair");
|
|
18487
|
+
const [i, o] = zeroForOne ? [0, 1] : [1, 0];
|
|
18488
|
+
const [configInfo, vaultIn, vaultOut] = await connection.getMultipleAccountsInfo(
|
|
18489
|
+
[pool.ammConfig, zeroForOne ? pool.vault0 : pool.vault1, zeroForOne ? pool.vault1 : pool.vault0],
|
|
18490
|
+
"confirmed"
|
|
18491
|
+
);
|
|
18492
|
+
if (!configInfo || !vaultIn || !vaultOut) {
|
|
18493
|
+
throw new Error("veilix-sdk: swap pool accounts are missing");
|
|
18494
|
+
}
|
|
18495
|
+
const tradeFeeRate = u64(configInfo.data, 12);
|
|
18496
|
+
const creatorFeeRate = pool.enableCreatorFee && configInfo.data.length >= 116 ? u64(configInfo.data, 108) : 0n;
|
|
18497
|
+
const reserveIn = u64(vaultIn.data, 64) - pool.protocolFees[i] - pool.fundFees[i] - pool.creatorFees[i];
|
|
18498
|
+
const reserveOut = u64(vaultOut.data, 64) - pool.protocolFees[o] - pool.fundFees[o] - pool.creatorFees[o];
|
|
18499
|
+
if (reserveIn <= 0n || reserveOut <= 0n) {
|
|
18500
|
+
throw new Error("veilix-sdk: swap pool has no liquidity");
|
|
18501
|
+
}
|
|
18502
|
+
const creatorOnInput = pool.creatorFeeOn === 0 || pool.creatorFeeOn === 1 && zeroForOne || pool.creatorFeeOn === 2 && !zeroForOne;
|
|
18503
|
+
let inLessFees = amountIn - feeOf(amountIn, tradeFeeRate);
|
|
18504
|
+
if (creatorOnInput) inLessFees -= feeOf(amountIn, creatorFeeRate);
|
|
18505
|
+
let amountOut = inLessFees * reserveOut / (reserveIn + inLessFees);
|
|
18506
|
+
if (!creatorOnInput) amountOut -= feeOf(amountOut, creatorFeeRate);
|
|
18507
|
+
if (amountOut <= 0n) {
|
|
18508
|
+
throw new Error("veilix-sdk: swap amount is too small for this pool");
|
|
18509
|
+
}
|
|
18510
|
+
const spotOut = Number(inLessFees) * (Number(reserveOut) / Number(reserveIn));
|
|
18511
|
+
const priceImpact = spotOut > 0 ? Math.max(0, 1 - Number(amountOut) / spotOut) : 1;
|
|
18512
|
+
return { amountOut, priceImpact };
|
|
18513
|
+
}
|
|
18514
|
+
|
|
18515
|
+
// src/swap/execute.ts
|
|
18516
|
+
var SWAP_MAX_WAIT_MS = 18e4;
|
|
18517
|
+
var DEFAULT_SLIPPAGE_BPS = 100;
|
|
18518
|
+
var MAX_SLIPPAGE_BPS = 5e3;
|
|
18519
|
+
var MAX_PRICE_IMPACT = 0.1;
|
|
18520
|
+
var hex = (bytes) => `0x${bytesToHex(bytes)}`;
|
|
18521
|
+
var mintKey = (mint) => mint?.toBase58() ?? null;
|
|
18522
|
+
async function fetchRelayerQuote(relayerUrl, mintIn, mintOut, amountIn) {
|
|
18523
|
+
const params = new URLSearchParams({ amountIn: amountIn.toString() });
|
|
18524
|
+
if (mintIn) params.set("mintIn", mintIn.toBase58());
|
|
18525
|
+
if (mintOut) params.set("mintOut", mintOut.toBase58());
|
|
18526
|
+
const base = relayerUrl.replace(/\/$/, "");
|
|
18527
|
+
const res = await httpFetch(`${base}/v1/swapQuote?${params}`, {
|
|
18528
|
+
headers: { Accept: "application/json" }
|
|
18529
|
+
});
|
|
18530
|
+
const body = await res.json().catch(() => ({}));
|
|
18531
|
+
if (!res.ok) {
|
|
18532
|
+
throw new Error(body.error || `Swap quote failed (${res.status})`);
|
|
18533
|
+
}
|
|
18534
|
+
return { ...body, relayerUrl: base };
|
|
18535
|
+
}
|
|
18536
|
+
function swapCandidates(relayers, relayerUrl) {
|
|
18537
|
+
if (relayerUrl) {
|
|
18538
|
+
const wanted = relayerUrl.replace(/\/$/, "");
|
|
18539
|
+
const match = relayers.find((r) => r.url.replace(/\/$/, "") === wanted);
|
|
18540
|
+
if (!match) throw new Error(`veilix-sdk: relayer ${relayerUrl} is not available`);
|
|
18541
|
+
return [match];
|
|
18542
|
+
}
|
|
18543
|
+
if (!relayers.length) throw new Error("veilix-sdk: no relayer available");
|
|
18544
|
+
const first = getRandomRelayer(relayers);
|
|
18545
|
+
return [first, ...relayers.filter((r) => r !== first)];
|
|
18546
|
+
}
|
|
18547
|
+
async function getSwapQuote(params) {
|
|
18548
|
+
const { relayers } = getConfig();
|
|
18549
|
+
const mintIn = normalizeTreeMint(params.mintIn);
|
|
18550
|
+
const mintOut = normalizeTreeMint(params.mintOut);
|
|
18551
|
+
if (mintKey(mintIn) === mintKey(mintOut)) {
|
|
18552
|
+
throw new Error("veilix-sdk: swap needs two different assets");
|
|
18553
|
+
}
|
|
18554
|
+
const amountIn = BigInt(params.amountIn);
|
|
18555
|
+
if (amountIn <= 0n) throw new Error("veilix-sdk: swap amount must be positive");
|
|
18556
|
+
const { connection, network } = getConfig();
|
|
18557
|
+
const platformWallets = await fetchPlatformFeeWallets();
|
|
18558
|
+
let lastError = null;
|
|
18559
|
+
for (const relayer of swapCandidates(relayers, params.relayerUrl)) {
|
|
18560
|
+
try {
|
|
18561
|
+
const quote = await fetchRelayerQuote(relayer.url, mintIn, mintOut, amountIn);
|
|
18562
|
+
if (quote.relayer !== relayer.value) {
|
|
18563
|
+
throw new Error("Relayer quoted for a different reward account");
|
|
18564
|
+
}
|
|
18565
|
+
const { fee } = computeWithdrawFee(amountIn, relayer.fee, platformWallets);
|
|
18566
|
+
if (fee >= amountIn) throw new Error("Amount is too small to cover the fees");
|
|
18567
|
+
if (BigInt(quote.fee) !== fee) throw new Error("Relayer quoted a different fee");
|
|
18568
|
+
if (quote.dexProgram !== CPMM_PROGRAM_IDS[network]) {
|
|
18569
|
+
throw new Error("Relayer routes through an unsupported DEX");
|
|
18570
|
+
}
|
|
18571
|
+
const own = await quoteCpmm(
|
|
18572
|
+
connection,
|
|
18573
|
+
network,
|
|
18574
|
+
new web3_js.PublicKey(quote.pool),
|
|
18575
|
+
mintIn,
|
|
18576
|
+
mintOut,
|
|
18577
|
+
amountIn - fee
|
|
18578
|
+
);
|
|
18579
|
+
if (own.priceImpact > MAX_PRICE_IMPACT) {
|
|
18580
|
+
throw new Error(
|
|
18581
|
+
`Price impact ${(own.priceImpact * 100).toFixed(1)}% is too high for this pool; swap less`
|
|
18582
|
+
);
|
|
18583
|
+
}
|
|
18584
|
+
return {
|
|
18585
|
+
quote: {
|
|
18586
|
+
...quote,
|
|
18587
|
+
swapIn: (amountIn - fee).toString(),
|
|
18588
|
+
amountOut: own.amountOut.toString(),
|
|
18589
|
+
priceImpact: own.priceImpact
|
|
18590
|
+
},
|
|
18591
|
+
relayer
|
|
18592
|
+
};
|
|
18593
|
+
} catch (error) {
|
|
18594
|
+
lastError = error;
|
|
18595
|
+
}
|
|
18596
|
+
}
|
|
18597
|
+
const reason = lastError instanceof Error ? lastError.message : "no relayer routes this pair";
|
|
18598
|
+
throw new Error(`veilix-sdk: no swap route for this pair (${reason})`);
|
|
18599
|
+
}
|
|
18600
|
+
async function buildSwapPayload(params, options = {}) {
|
|
18601
|
+
const { encryptKey } = getConfig();
|
|
18602
|
+
const utxo = decodeNote(params.note);
|
|
18603
|
+
const mintIn = utxo.mint;
|
|
18604
|
+
const mintOut = normalizeTreeMint(params.mintOut ?? null);
|
|
18605
|
+
const slippageBps = params.slippageBps ?? DEFAULT_SLIPPAGE_BPS;
|
|
18606
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > MAX_SLIPPAGE_BPS) {
|
|
18607
|
+
throw new Error(`veilix-sdk: slippageBps must be an integer between 0 and ${MAX_SLIPPAGE_BPS}`);
|
|
18608
|
+
}
|
|
18609
|
+
const { index } = await locateNote(utxo);
|
|
18610
|
+
if (index === null) {
|
|
18611
|
+
throw new Error("Note is not in the Veilix pool yet (deposit not confirmed or not indexed)");
|
|
18612
|
+
}
|
|
18613
|
+
utxo.index = index;
|
|
18614
|
+
if ((await validateNullifier(toHex32(utxo.nullifier()))).exists) {
|
|
18615
|
+
throw new Error("This note has already been spent");
|
|
18616
|
+
}
|
|
18617
|
+
const amountIn = params.amount === void 0 ? utxo.amount : BigInt(params.amount);
|
|
18618
|
+
if (amountIn <= 0n || amountIn > utxo.amount) {
|
|
18619
|
+
throw new Error(`Swap amount must be between 1 and ${utxo.amount}`);
|
|
18620
|
+
}
|
|
18621
|
+
const { quote, relayer } = await getSwapQuote({
|
|
18622
|
+
mintIn,
|
|
18623
|
+
mintOut,
|
|
18624
|
+
amountIn,
|
|
18625
|
+
relayerUrl: params.relayerUrl
|
|
18626
|
+
});
|
|
18627
|
+
const fee = BigInt(quote.fee);
|
|
18628
|
+
const minAmountOut = BigInt(quote.amountOut) * BigInt(1e4 - slippageBps) / 10000n;
|
|
18629
|
+
if (minAmountOut <= 0n) {
|
|
18630
|
+
throw new Error("Swap amount is too small for this pool");
|
|
18631
|
+
}
|
|
18632
|
+
let tree = options.tree;
|
|
18633
|
+
if (!tree || tree.elements.length <= index) {
|
|
18634
|
+
tree = await fetchAssetTree(mintKey(mintIn));
|
|
18635
|
+
}
|
|
18636
|
+
if (tree.elements.length <= index) {
|
|
18637
|
+
throw new Error("The indexer has not synced this note yet, retry shortly");
|
|
18638
|
+
}
|
|
18639
|
+
const change = utxo.amount - amountIn;
|
|
18640
|
+
const changeUtxo = change > 0n ? new Utxo({ amount: change, mint: mintIn }) : null;
|
|
18641
|
+
const encryptedOutput1 = changeUtxo && encryptKey ? encryptNoteOutput(encryptKey, changeUtxo) : new Uint8Array();
|
|
18642
|
+
const encryptedOutput2 = new Uint8Array();
|
|
18643
|
+
const outKeypair = VeilixKeypair.random();
|
|
18644
|
+
const outBlinding = randomFieldElement();
|
|
18645
|
+
const encryptedNote = encryptKey ? encryptSwapNoteOutput(encryptKey, outKeypair, outBlinding) : new Uint8Array();
|
|
18646
|
+
const relayerKey = new web3_js.PublicKey(relayer.value);
|
|
18647
|
+
const hash = await swapExtDataHash({
|
|
18648
|
+
mintIn,
|
|
18649
|
+
mintOut,
|
|
18650
|
+
relayer: relayerKey,
|
|
18651
|
+
amountIn,
|
|
18652
|
+
fee,
|
|
18653
|
+
minAmountOut,
|
|
18654
|
+
outPubkey: outKeypair.pubKey,
|
|
18655
|
+
outBlinding,
|
|
18656
|
+
encryptedOutput1,
|
|
18657
|
+
encryptedOutput2,
|
|
18658
|
+
encryptedNote
|
|
18659
|
+
});
|
|
18660
|
+
const proved = await withCircuitArtifacts(
|
|
18661
|
+
options.circuitArtifacts,
|
|
18662
|
+
(artifacts) => proveTransaction({
|
|
18663
|
+
tree,
|
|
18664
|
+
inputs: [utxo],
|
|
18665
|
+
outputs: changeUtxo ? [changeUtxo] : [],
|
|
18666
|
+
ext: {
|
|
18667
|
+
mint: mintIn,
|
|
18668
|
+
recipient: web3_js.PublicKey.default,
|
|
18669
|
+
relayer: relayerKey,
|
|
18670
|
+
extAmount: -amountIn,
|
|
18671
|
+
fee,
|
|
18672
|
+
encryptedOutput1,
|
|
18673
|
+
encryptedOutput2
|
|
18674
|
+
},
|
|
18675
|
+
extDataHashOverride: hash,
|
|
18676
|
+
circuit: artifacts
|
|
18677
|
+
})
|
|
18678
|
+
);
|
|
18679
|
+
const { proof } = proved;
|
|
18680
|
+
const payload = {
|
|
18681
|
+
proof: hex(proof.proof),
|
|
18682
|
+
root: hex(proof.root),
|
|
18683
|
+
inputNullifiers: [hex(proof.inputNullifiers[0]), hex(proof.inputNullifiers[1])],
|
|
18684
|
+
outputCommitments: [hex(proof.outputCommitments[0]), hex(proof.outputCommitments[1])],
|
|
18685
|
+
...mintIn ? { mintIn: mintIn.toBase58() } : {},
|
|
18686
|
+
...mintOut ? { mintOut: mintOut.toBase58() } : {},
|
|
18687
|
+
amountIn: amountIn.toString(),
|
|
18688
|
+
fee: fee.toString(),
|
|
18689
|
+
minAmountOut: minAmountOut.toString(),
|
|
18690
|
+
outPubkey: hex(bigintToBytes32(outKeypair.pubKey)),
|
|
18691
|
+
outBlinding: hex(bigintToBytes32(outBlinding)),
|
|
18692
|
+
relayer: relayerKey.toBase58(),
|
|
18693
|
+
encryptedOutput1: hex(encryptedOutput1),
|
|
18694
|
+
encryptedOutput2: hex(encryptedOutput2),
|
|
18695
|
+
encryptedNote: hex(encryptedNote)
|
|
18696
|
+
};
|
|
18697
|
+
return {
|
|
18698
|
+
payload,
|
|
18699
|
+
relayerUrl: quote.relayerUrl,
|
|
18700
|
+
quote,
|
|
18701
|
+
amountIn,
|
|
18702
|
+
fee,
|
|
18703
|
+
minAmountOut,
|
|
18704
|
+
changeNote: changeUtxo ? encodeNote(changeUtxo) : null,
|
|
18705
|
+
output: {
|
|
18706
|
+
mint: mintKey(mintOut),
|
|
18707
|
+
privKey: outKeypair.privKey.toString(),
|
|
18708
|
+
blinding: outBlinding.toString()
|
|
18709
|
+
},
|
|
18710
|
+
nullifiers: [...payload.inputNullifiers]
|
|
18711
|
+
};
|
|
18712
|
+
}
|
|
18713
|
+
async function pollSwapJob(relayerUrl, jobId, maxWaitMs) {
|
|
18714
|
+
const start = Date.now();
|
|
18715
|
+
while (Date.now() - start < maxWaitMs) {
|
|
18716
|
+
const res = await httpFetch(`${relayerUrl}/v1/jobs/${encodeURIComponent(jobId)}`, {
|
|
18717
|
+
headers: { Accept: "application/json" }
|
|
18718
|
+
});
|
|
18719
|
+
const job = await res.json().catch(() => ({}));
|
|
18720
|
+
if (!res.ok) throw new Error(job.error || "Failed to poll relayer job");
|
|
18721
|
+
if (job.status === "CONFIRMED" || job.status === "FAILED") return job;
|
|
18722
|
+
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
18723
|
+
}
|
|
18724
|
+
throw new Error("Swap timed out");
|
|
18725
|
+
}
|
|
18726
|
+
function swapOutputNote(output, result) {
|
|
18727
|
+
const utxo = new Utxo({
|
|
18728
|
+
amount: BigInt(result.amountOut),
|
|
18729
|
+
keypair: VeilixKeypair.fromPrivateKey(output.privKey),
|
|
18730
|
+
blinding: BigInt(output.blinding),
|
|
18731
|
+
mint: output.mint ? new web3_js.PublicKey(output.mint) : null,
|
|
18732
|
+
index: result.outputIndex
|
|
18733
|
+
});
|
|
18734
|
+
if (toHex32(utxo.commitment()) !== toHex32(BigInt(result.outputCommitment))) {
|
|
18735
|
+
throw new Error("veilix-sdk: swapped note does not match the on-chain commitment");
|
|
18736
|
+
}
|
|
18737
|
+
return encodeNote(utxo);
|
|
18738
|
+
}
|
|
18739
|
+
async function submitSwapPayload(bundle) {
|
|
18740
|
+
const res = await httpFetch(`${bundle.relayerUrl}/v1/veilixSwap`, {
|
|
18741
|
+
method: "POST",
|
|
18742
|
+
headers: { "Content-Type": "application/json" },
|
|
18743
|
+
body: JSON.stringify(bundle.payload)
|
|
18744
|
+
});
|
|
18745
|
+
const body = await res.json().catch(() => ({}));
|
|
18746
|
+
if (!res.ok || !body.id) {
|
|
18747
|
+
throw new Error(body.error || "Swap submission failed");
|
|
18748
|
+
}
|
|
18749
|
+
const job = await pollSwapJob(bundle.relayerUrl, body.id, SWAP_MAX_WAIT_MS);
|
|
18750
|
+
const base = {
|
|
18751
|
+
changeNote: bundle.changeNote,
|
|
18752
|
+
amountIn: bundle.amountIn.toString(),
|
|
18753
|
+
fee: bundle.fee.toString(),
|
|
18754
|
+
minAmountOut: bundle.minAmountOut.toString()
|
|
18755
|
+
};
|
|
18756
|
+
if (job.status === "FAILED") {
|
|
18757
|
+
return {
|
|
18758
|
+
...base,
|
|
18759
|
+
txHash: job.txHash ?? "",
|
|
18760
|
+
status: "failed",
|
|
18761
|
+
error: job.failedReason || "Swap failed",
|
|
18762
|
+
// A failed swap spends nothing: the original note is still valid.
|
|
18763
|
+
outputNote: null,
|
|
18764
|
+
changeNote: null,
|
|
18765
|
+
amountOut: null
|
|
18766
|
+
};
|
|
18767
|
+
}
|
|
18768
|
+
if (!job.txHash || !job.swapResult) {
|
|
18769
|
+
throw new Error("Swap confirmed but the relayer did not report the swapped note");
|
|
18770
|
+
}
|
|
18771
|
+
return {
|
|
18772
|
+
...base,
|
|
18773
|
+
txHash: job.txHash,
|
|
18774
|
+
status: "success",
|
|
18775
|
+
outputNote: swapOutputNote(bundle.output, job.swapResult),
|
|
18776
|
+
amountOut: job.swapResult.amountOut
|
|
18777
|
+
};
|
|
18778
|
+
}
|
|
18779
|
+
async function executeSwap(params) {
|
|
18780
|
+
return submitSwapPayload(await buildSwapPayload(params));
|
|
18781
|
+
}
|
|
17525
18782
|
|
|
17526
18783
|
// src/withdraw/assets.ts
|
|
17527
18784
|
var TOKEN_UNITS = {
|
|
@@ -17645,6 +18902,8 @@ var SEND_OPTIONS = { skipPreflight: false, maxRetries: 3 };
|
|
|
17645
18902
|
var SUBMIT_MAX_PROOFS = 8;
|
|
17646
18903
|
var NOTE_INDEX_TIMEOUT_MS = 12e4;
|
|
17647
18904
|
var NOTE_INDEX_POLL_MS = 4e3;
|
|
18905
|
+
var SEND_ATTEMPTS = 4;
|
|
18906
|
+
var SEND_RETRY_MS = 2e3;
|
|
17648
18907
|
function sleep(ms) {
|
|
17649
18908
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
17650
18909
|
}
|
|
@@ -17666,7 +18925,18 @@ async function signTransactions(wallet, transactions) {
|
|
|
17666
18925
|
}
|
|
17667
18926
|
async function sendAndConfirm(signed) {
|
|
17668
18927
|
const { connection } = getConfig();
|
|
17669
|
-
const
|
|
18928
|
+
const raw = signed.serialize();
|
|
18929
|
+
let signature;
|
|
18930
|
+
for (let attempt = 1; signature === void 0; attempt++) {
|
|
18931
|
+
try {
|
|
18932
|
+
signature = await connection.sendRawTransaction(raw, SEND_OPTIONS);
|
|
18933
|
+
} catch (error) {
|
|
18934
|
+
if (attempt >= SEND_ATTEMPTS || !/blockhash not found/i.test(errorMessage(error))) {
|
|
18935
|
+
throw error;
|
|
18936
|
+
}
|
|
18937
|
+
await sleep(SEND_RETRY_MS);
|
|
18938
|
+
}
|
|
18939
|
+
}
|
|
17670
18940
|
const { value } = await connection.confirmTransaction(signature, "confirmed");
|
|
17671
18941
|
if (value.err) {
|
|
17672
18942
|
throw new Error(`Deposit transaction failed: ${JSON.stringify(value.err)}`);
|
|
@@ -17712,6 +18982,7 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
17712
18982
|
const { wallet, network, relayers, encryptKey } = getConfig();
|
|
17713
18983
|
const sender = wallet.publicKey;
|
|
17714
18984
|
const onChainBackup = options.onChainBackup ?? !!encryptKey;
|
|
18985
|
+
const sealKey = onChainBackup ? encryptKey ?? requireEncryptKey() : void 0;
|
|
17715
18986
|
const prepared = prepareDeposits(items);
|
|
17716
18987
|
result.notes = prepared.map((deposit) => deposit.note);
|
|
17717
18988
|
const circuitArtifacts = await prepareWithdrawCircuitArtifacts();
|
|
@@ -17722,7 +18993,8 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
17722
18993
|
senderPublicKey: sender,
|
|
17723
18994
|
note: deposit.note,
|
|
17724
18995
|
onChainBackup,
|
|
17725
|
-
circuitArtifacts
|
|
18996
|
+
circuitArtifacts,
|
|
18997
|
+
...sealKey ? { encryptKey: sealKey } : {}
|
|
17726
18998
|
});
|
|
17727
18999
|
} catch (error) {
|
|
17728
19000
|
result.depositFailed.push(toDepositFailure(deposit, error));
|
|
@@ -17733,6 +19005,10 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
17733
19005
|
result.error = true;
|
|
17734
19006
|
return result;
|
|
17735
19007
|
}
|
|
19008
|
+
const { blockhash } = await getConfig().connection.getLatestBlockhash();
|
|
19009
|
+
toSend.forEach((deposit) => {
|
|
19010
|
+
deposit.tx.message.recentBlockhash = blockhash;
|
|
19011
|
+
});
|
|
17736
19012
|
const signed = await signTransactions(wallet, toSend.map((deposit) => deposit.tx));
|
|
17737
19013
|
if (options.downloadNotes ?? true) {
|
|
17738
19014
|
downloadNotesCsv(toSend.map((deposit) => deposit.note));
|
|
@@ -17836,7 +19112,7 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
17836
19112
|
try {
|
|
17837
19113
|
return fn();
|
|
17838
19114
|
} finally {
|
|
17839
|
-
popRuntimeContext();
|
|
19115
|
+
popRuntimeContext(this.config);
|
|
17840
19116
|
}
|
|
17841
19117
|
}
|
|
17842
19118
|
async runAsync(fn) {
|
|
@@ -17844,7 +19120,7 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
17844
19120
|
try {
|
|
17845
19121
|
return await fn();
|
|
17846
19122
|
} finally {
|
|
17847
|
-
popRuntimeContext();
|
|
19123
|
+
popRuntimeContext(this.config);
|
|
17848
19124
|
}
|
|
17849
19125
|
}
|
|
17850
19126
|
// ── Config ───────────────────────────────────────────────────────────
|
|
@@ -17962,6 +19238,26 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
17962
19238
|
submitWithdrawPayload(bundle) {
|
|
17963
19239
|
return this.runAsync(() => submitWithdrawPayload(bundle));
|
|
17964
19240
|
}
|
|
19241
|
+
// ── Private swap ─────────────────────────────────────────────────────
|
|
19242
|
+
/** Fee and expected output of swapping `amountIn` of `mintIn` into `mintOut`. */
|
|
19243
|
+
getSwapQuote(params) {
|
|
19244
|
+
return this.runAsync(() => getSwapQuote(params));
|
|
19245
|
+
}
|
|
19246
|
+
/**
|
|
19247
|
+
* Swap a note of asset A into a new shielded note of asset B (`mintOut`, `null` for
|
|
19248
|
+
* SOL) through a relayer and an allowlisted DEX. Funds never leave the pool
|
|
19249
|
+
* unshielded. Returns the asset-B note and any asset-A change note.
|
|
19250
|
+
*/
|
|
19251
|
+
swap(params) {
|
|
19252
|
+
return this.runAsync(() => executeSwap(params));
|
|
19253
|
+
}
|
|
19254
|
+
/** Prove a swap without submitting it (see {@link submitSwapPayload}). */
|
|
19255
|
+
buildSwapPayload(params, options) {
|
|
19256
|
+
return this.runAsync(() => buildSwapPayload(params, options));
|
|
19257
|
+
}
|
|
19258
|
+
submitSwapPayload(bundle) {
|
|
19259
|
+
return this.runAsync(() => submitSwapPayload(bundle));
|
|
19260
|
+
}
|
|
17965
19261
|
/**
|
|
17966
19262
|
* Private transfer: deposit one note per item, then withdraw each note in full
|
|
17967
19263
|
* to its recipient through the indexer submission queue.
|
|
@@ -18073,15 +19369,15 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
18073
19369
|
* Accepts a frontend wallet adapter (`signMessage`) or a backend {@link Keypair}.
|
|
18074
19370
|
*/
|
|
18075
19371
|
async getEncryptionKey(wallet) {
|
|
18076
|
-
const
|
|
18077
|
-
this.config.encryptKey =
|
|
18078
|
-
return
|
|
19372
|
+
const key2 = await getEncryptionKey(wallet);
|
|
19373
|
+
this.config.encryptKey = key2;
|
|
19374
|
+
return key2;
|
|
18079
19375
|
}
|
|
18080
|
-
encryptData(
|
|
18081
|
-
return encryptData(
|
|
19376
|
+
encryptData(key2, plaintext) {
|
|
19377
|
+
return encryptData(key2, plaintext);
|
|
18082
19378
|
}
|
|
18083
|
-
decryptData(
|
|
18084
|
-
return decryptData(
|
|
19379
|
+
decryptData(key2, combined) {
|
|
19380
|
+
return decryptData(key2, combined);
|
|
18085
19381
|
}
|
|
18086
19382
|
// ── Utilities ────────────────────────────────────────────────────────
|
|
18087
19383
|
parseAmountToBaseUnits(amount, decimals) {
|
|
@@ -18119,9 +19415,11 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
18119
19415
|
* @license MIT
|
|
18120
19416
|
*/
|
|
18121
19417
|
|
|
19418
|
+
exports.CPMM_PROGRAM_IDS = CPMM_PROGRAM_IDS;
|
|
18122
19419
|
exports.FIELD_SIZE = FIELD_SIZE;
|
|
18123
19420
|
exports.MALICIOUS_RECIPIENT_ERROR = MALICIOUS_RECIPIENT_ERROR;
|
|
18124
19421
|
exports.NOTE_PREFIX = NOTE_PREFIX;
|
|
19422
|
+
exports.SWAP_DOMAIN = SWAP_DOMAIN;
|
|
18125
19423
|
exports.TREE_LEVELS = TREE_LEVELS;
|
|
18126
19424
|
exports.Utxo = Utxo;
|
|
18127
19425
|
exports.VeilixKeypair = VeilixKeypair;
|
|
@@ -18137,6 +19435,7 @@ exports.default = VeilixSDK;
|
|
|
18137
19435
|
exports.encodeNote = encodeNote;
|
|
18138
19436
|
exports.encryptData = encryptData;
|
|
18139
19437
|
exports.encryptNoteOutput = encryptNoteOutput;
|
|
19438
|
+
exports.encryptSwapNoteOutput = encryptSwapNoteOutput;
|
|
18140
19439
|
exports.extDataHash = extDataHash;
|
|
18141
19440
|
exports.formatBaseUnits = formatBaseUnits;
|
|
18142
19441
|
exports.formatNoteForDisplay = formatNoteForDisplay;
|
|
@@ -18147,7 +19446,10 @@ exports.parseAmountToBaseUnits = parseAmountToBaseUnits;
|
|
|
18147
19446
|
exports.parseSecretNote = parseSecretNote;
|
|
18148
19447
|
exports.prepareCircuitArtifacts = prepareCircuitArtifacts;
|
|
18149
19448
|
exports.proveTransaction = proveTransaction;
|
|
19449
|
+
exports.quoteCpmm = quoteCpmm;
|
|
18150
19450
|
exports.resolveCircuitPathsFromBase = resolveCircuitPathsFromBase;
|
|
18151
19451
|
exports.resolveNpmCdnCircuitBase = resolveNpmCdnCircuitBase;
|
|
19452
|
+
exports.swapExtDataHash = swapExtDataHash;
|
|
19453
|
+
exports.swapOutputNote = swapOutputNote;
|
|
18152
19454
|
//# sourceMappingURL=index.cjs.map
|
|
18153
19455
|
//# sourceMappingURL=index.cjs.map
|