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.js
CHANGED
|
@@ -36,7 +36,7 @@ function formatBaseUnits(value, decimals) {
|
|
|
36
36
|
|
|
37
37
|
// src/idl/veilix-devnet.json
|
|
38
38
|
var veilix_devnet_default = {
|
|
39
|
-
address: "
|
|
39
|
+
address: "Vxi1QK84Akv4yGngjvkWNmEsK7XpsSrpDaPBoiyXGPG",
|
|
40
40
|
metadata: {
|
|
41
41
|
name: "veilix",
|
|
42
42
|
version: "0.2.0",
|
|
@@ -637,6 +637,38 @@ var veilix_devnet_default = {
|
|
|
637
637
|
{
|
|
638
638
|
name: "system_program",
|
|
639
639
|
address: "11111111111111111111111111111111"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
name: "event_authority",
|
|
643
|
+
pda: {
|
|
644
|
+
seeds: [
|
|
645
|
+
{
|
|
646
|
+
kind: "const",
|
|
647
|
+
value: [
|
|
648
|
+
95,
|
|
649
|
+
95,
|
|
650
|
+
101,
|
|
651
|
+
118,
|
|
652
|
+
101,
|
|
653
|
+
110,
|
|
654
|
+
116,
|
|
655
|
+
95,
|
|
656
|
+
97,
|
|
657
|
+
117,
|
|
658
|
+
116,
|
|
659
|
+
104,
|
|
660
|
+
111,
|
|
661
|
+
114,
|
|
662
|
+
105,
|
|
663
|
+
116,
|
|
664
|
+
121
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
]
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: "program"
|
|
640
672
|
}
|
|
641
673
|
],
|
|
642
674
|
args: [
|
|
@@ -699,6 +731,91 @@ var veilix_devnet_default = {
|
|
|
699
731
|
]
|
|
700
732
|
}
|
|
701
733
|
},
|
|
734
|
+
{
|
|
735
|
+
name: "program_data",
|
|
736
|
+
docs: [
|
|
737
|
+
"This program's ProgramData. Only its upgrade authority may initialize the network,",
|
|
738
|
+
"so nobody can claim the config authority between deploy and setup."
|
|
739
|
+
],
|
|
740
|
+
pda: {
|
|
741
|
+
seeds: [
|
|
742
|
+
{
|
|
743
|
+
kind: "const",
|
|
744
|
+
value: [
|
|
745
|
+
7,
|
|
746
|
+
107,
|
|
747
|
+
64,
|
|
748
|
+
50,
|
|
749
|
+
251,
|
|
750
|
+
172,
|
|
751
|
+
47,
|
|
752
|
+
215,
|
|
753
|
+
89,
|
|
754
|
+
179,
|
|
755
|
+
92,
|
|
756
|
+
125,
|
|
757
|
+
67,
|
|
758
|
+
162,
|
|
759
|
+
96,
|
|
760
|
+
45,
|
|
761
|
+
239,
|
|
762
|
+
91,
|
|
763
|
+
223,
|
|
764
|
+
168,
|
|
765
|
+
251,
|
|
766
|
+
138,
|
|
767
|
+
165,
|
|
768
|
+
133,
|
|
769
|
+
253,
|
|
770
|
+
74,
|
|
771
|
+
152,
|
|
772
|
+
142,
|
|
773
|
+
6,
|
|
774
|
+
85,
|
|
775
|
+
93,
|
|
776
|
+
119
|
|
777
|
+
]
|
|
778
|
+
}
|
|
779
|
+
],
|
|
780
|
+
program: {
|
|
781
|
+
kind: "const",
|
|
782
|
+
value: [
|
|
783
|
+
2,
|
|
784
|
+
168,
|
|
785
|
+
246,
|
|
786
|
+
145,
|
|
787
|
+
78,
|
|
788
|
+
136,
|
|
789
|
+
161,
|
|
790
|
+
176,
|
|
791
|
+
226,
|
|
792
|
+
16,
|
|
793
|
+
21,
|
|
794
|
+
62,
|
|
795
|
+
247,
|
|
796
|
+
99,
|
|
797
|
+
174,
|
|
798
|
+
43,
|
|
799
|
+
0,
|
|
800
|
+
194,
|
|
801
|
+
185,
|
|
802
|
+
61,
|
|
803
|
+
22,
|
|
804
|
+
193,
|
|
805
|
+
36,
|
|
806
|
+
210,
|
|
807
|
+
192,
|
|
808
|
+
83,
|
|
809
|
+
122,
|
|
810
|
+
16,
|
|
811
|
+
4,
|
|
812
|
+
128,
|
|
813
|
+
0,
|
|
814
|
+
0
|
|
815
|
+
]
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
},
|
|
702
819
|
{
|
|
703
820
|
name: "system_program",
|
|
704
821
|
address: "11111111111111111111111111111111"
|
|
@@ -1027,6 +1144,31 @@ var veilix_devnet_default = {
|
|
|
1027
1144
|
]
|
|
1028
1145
|
}
|
|
1029
1146
|
},
|
|
1147
|
+
{
|
|
1148
|
+
name: "treasury",
|
|
1149
|
+
docs: [
|
|
1150
|
+
"Holds the SOL pool. Funded with its rent-exempt reserve here so that no withdrawal",
|
|
1151
|
+
"can fail for leaving it below that reserve."
|
|
1152
|
+
],
|
|
1153
|
+
writable: true,
|
|
1154
|
+
pda: {
|
|
1155
|
+
seeds: [
|
|
1156
|
+
{
|
|
1157
|
+
kind: "const",
|
|
1158
|
+
value: [
|
|
1159
|
+
116,
|
|
1160
|
+
114,
|
|
1161
|
+
101,
|
|
1162
|
+
97,
|
|
1163
|
+
115,
|
|
1164
|
+
117,
|
|
1165
|
+
114,
|
|
1166
|
+
121
|
|
1167
|
+
]
|
|
1168
|
+
}
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
},
|
|
1030
1172
|
{
|
|
1031
1173
|
name: "system_program",
|
|
1032
1174
|
address: "11111111111111111111111111111111"
|
|
@@ -1457,6 +1599,336 @@ var veilix_devnet_default = {
|
|
|
1457
1599
|
}
|
|
1458
1600
|
]
|
|
1459
1601
|
},
|
|
1602
|
+
{
|
|
1603
|
+
name: "swap",
|
|
1604
|
+
docs: [
|
|
1605
|
+
"Private swap. Remaining accounts: the protocol fee wallets for the input asset (SOL",
|
|
1606
|
+
"accounts or their token accounts, in config order), then the DEX instruction's accounts."
|
|
1607
|
+
],
|
|
1608
|
+
discriminator: [
|
|
1609
|
+
248,
|
|
1610
|
+
198,
|
|
1611
|
+
158,
|
|
1612
|
+
145,
|
|
1613
|
+
225,
|
|
1614
|
+
117,
|
|
1615
|
+
135,
|
|
1616
|
+
200
|
|
1617
|
+
],
|
|
1618
|
+
accounts: [
|
|
1619
|
+
{
|
|
1620
|
+
name: "relayer",
|
|
1621
|
+
writable: true,
|
|
1622
|
+
signer: true
|
|
1623
|
+
},
|
|
1624
|
+
{
|
|
1625
|
+
name: "relayer_account",
|
|
1626
|
+
writable: true,
|
|
1627
|
+
pda: {
|
|
1628
|
+
seeds: [
|
|
1629
|
+
{
|
|
1630
|
+
kind: "const",
|
|
1631
|
+
value: [
|
|
1632
|
+
114,
|
|
1633
|
+
101,
|
|
1634
|
+
108,
|
|
1635
|
+
97,
|
|
1636
|
+
121,
|
|
1637
|
+
101,
|
|
1638
|
+
114
|
|
1639
|
+
]
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
kind: "account",
|
|
1643
|
+
path: "relayer_account.owner",
|
|
1644
|
+
account: "RelayerAccount"
|
|
1645
|
+
}
|
|
1646
|
+
]
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
{
|
|
1650
|
+
name: "network_state",
|
|
1651
|
+
pda: {
|
|
1652
|
+
seeds: [
|
|
1653
|
+
{
|
|
1654
|
+
kind: "const",
|
|
1655
|
+
value: [
|
|
1656
|
+
99,
|
|
1657
|
+
111,
|
|
1658
|
+
110,
|
|
1659
|
+
102,
|
|
1660
|
+
105,
|
|
1661
|
+
103
|
|
1662
|
+
]
|
|
1663
|
+
}
|
|
1664
|
+
]
|
|
1665
|
+
}
|
|
1666
|
+
},
|
|
1667
|
+
{
|
|
1668
|
+
name: "swap_config",
|
|
1669
|
+
pda: {
|
|
1670
|
+
seeds: [
|
|
1671
|
+
{
|
|
1672
|
+
kind: "const",
|
|
1673
|
+
value: [
|
|
1674
|
+
115,
|
|
1675
|
+
119,
|
|
1676
|
+
97,
|
|
1677
|
+
112,
|
|
1678
|
+
95,
|
|
1679
|
+
99,
|
|
1680
|
+
111,
|
|
1681
|
+
110,
|
|
1682
|
+
102,
|
|
1683
|
+
105,
|
|
1684
|
+
103
|
|
1685
|
+
]
|
|
1686
|
+
}
|
|
1687
|
+
]
|
|
1688
|
+
}
|
|
1689
|
+
},
|
|
1690
|
+
{
|
|
1691
|
+
name: "tree_in",
|
|
1692
|
+
docs: [
|
|
1693
|
+
"Tree of the asset being spent. The handler checks it is the PDA for its mint."
|
|
1694
|
+
],
|
|
1695
|
+
writable: true
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
name: "tree_out",
|
|
1699
|
+
docs: [
|
|
1700
|
+
"Tree that receives the swapped note."
|
|
1701
|
+
],
|
|
1702
|
+
writable: true
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
name: "treasury",
|
|
1706
|
+
writable: true,
|
|
1707
|
+
pda: {
|
|
1708
|
+
seeds: [
|
|
1709
|
+
{
|
|
1710
|
+
kind: "const",
|
|
1711
|
+
value: [
|
|
1712
|
+
116,
|
|
1713
|
+
114,
|
|
1714
|
+
101,
|
|
1715
|
+
97,
|
|
1716
|
+
115,
|
|
1717
|
+
117,
|
|
1718
|
+
114,
|
|
1719
|
+
121
|
|
1720
|
+
]
|
|
1721
|
+
}
|
|
1722
|
+
]
|
|
1723
|
+
}
|
|
1724
|
+
},
|
|
1725
|
+
{
|
|
1726
|
+
name: "escrow",
|
|
1727
|
+
docs: [
|
|
1728
|
+
"Signs the DEX call. Holds nothing between transactions."
|
|
1729
|
+
],
|
|
1730
|
+
writable: true,
|
|
1731
|
+
pda: {
|
|
1732
|
+
seeds: [
|
|
1733
|
+
{
|
|
1734
|
+
kind: "const",
|
|
1735
|
+
value: [
|
|
1736
|
+
115,
|
|
1737
|
+
119,
|
|
1738
|
+
97,
|
|
1739
|
+
112,
|
|
1740
|
+
95,
|
|
1741
|
+
101,
|
|
1742
|
+
115,
|
|
1743
|
+
99,
|
|
1744
|
+
114,
|
|
1745
|
+
111,
|
|
1746
|
+
119
|
|
1747
|
+
]
|
|
1748
|
+
}
|
|
1749
|
+
]
|
|
1750
|
+
}
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
name: "treasury_ata_in",
|
|
1754
|
+
docs: [
|
|
1755
|
+
"Treasury ATA for `mint_in`. `None` when spending SOL."
|
|
1756
|
+
],
|
|
1757
|
+
writable: true,
|
|
1758
|
+
optional: true
|
|
1759
|
+
},
|
|
1760
|
+
{
|
|
1761
|
+
name: "treasury_ata_out",
|
|
1762
|
+
docs: [
|
|
1763
|
+
"Treasury ATA for `mint_out`. `None` when receiving SOL."
|
|
1764
|
+
],
|
|
1765
|
+
writable: true,
|
|
1766
|
+
optional: true
|
|
1767
|
+
},
|
|
1768
|
+
{
|
|
1769
|
+
name: "escrow_ata_in",
|
|
1770
|
+
docs: [
|
|
1771
|
+
"Escrow ATA for `mint_in` (wrapped SOL when spending SOL). Must exist: prepend an",
|
|
1772
|
+
"idempotent ATA create. A wrapped-SOL escrow account is closed at the end of the swap."
|
|
1773
|
+
],
|
|
1774
|
+
writable: true
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
name: "escrow_ata_out",
|
|
1778
|
+
docs: [
|
|
1779
|
+
"Escrow ATA for `mint_out` (wrapped SOL when receiving SOL). Must exist, as above."
|
|
1780
|
+
],
|
|
1781
|
+
writable: true
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
name: "relayer_ata",
|
|
1785
|
+
docs: [
|
|
1786
|
+
"Relayer ATA for `mint_in`, paid the relayer fee. `None` when spending SOL."
|
|
1787
|
+
],
|
|
1788
|
+
writable: true,
|
|
1789
|
+
optional: true
|
|
1790
|
+
},
|
|
1791
|
+
{
|
|
1792
|
+
name: "nullifier0",
|
|
1793
|
+
writable: true,
|
|
1794
|
+
pda: {
|
|
1795
|
+
seeds: [
|
|
1796
|
+
{
|
|
1797
|
+
kind: "const",
|
|
1798
|
+
value: [
|
|
1799
|
+
110,
|
|
1800
|
+
117,
|
|
1801
|
+
108,
|
|
1802
|
+
108,
|
|
1803
|
+
105,
|
|
1804
|
+
102,
|
|
1805
|
+
105,
|
|
1806
|
+
101,
|
|
1807
|
+
114
|
|
1808
|
+
]
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
kind: "arg",
|
|
1812
|
+
path: "proof.input_nullifiers [0]"
|
|
1813
|
+
}
|
|
1814
|
+
]
|
|
1815
|
+
}
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
name: "nullifier1",
|
|
1819
|
+
writable: true,
|
|
1820
|
+
pda: {
|
|
1821
|
+
seeds: [
|
|
1822
|
+
{
|
|
1823
|
+
kind: "const",
|
|
1824
|
+
value: [
|
|
1825
|
+
110,
|
|
1826
|
+
117,
|
|
1827
|
+
108,
|
|
1828
|
+
108,
|
|
1829
|
+
105,
|
|
1830
|
+
102,
|
|
1831
|
+
105,
|
|
1832
|
+
101,
|
|
1833
|
+
114
|
|
1834
|
+
]
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
kind: "arg",
|
|
1838
|
+
path: "proof.input_nullifiers [1]"
|
|
1839
|
+
}
|
|
1840
|
+
]
|
|
1841
|
+
}
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
name: "mint_in",
|
|
1845
|
+
docs: [
|
|
1846
|
+
"Mint of the spent asset (the native mint when spending SOL)."
|
|
1847
|
+
]
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
name: "mint_out",
|
|
1851
|
+
docs: [
|
|
1852
|
+
"Mint of the received asset (the native mint when receiving SOL)."
|
|
1853
|
+
]
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
name: "token_program_in"
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
name: "token_program_out"
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
name: "dex_program"
|
|
1863
|
+
},
|
|
1864
|
+
{
|
|
1865
|
+
name: "system_program",
|
|
1866
|
+
address: "11111111111111111111111111111111"
|
|
1867
|
+
},
|
|
1868
|
+
{
|
|
1869
|
+
name: "event_authority",
|
|
1870
|
+
pda: {
|
|
1871
|
+
seeds: [
|
|
1872
|
+
{
|
|
1873
|
+
kind: "const",
|
|
1874
|
+
value: [
|
|
1875
|
+
95,
|
|
1876
|
+
95,
|
|
1877
|
+
101,
|
|
1878
|
+
118,
|
|
1879
|
+
101,
|
|
1880
|
+
110,
|
|
1881
|
+
116,
|
|
1882
|
+
95,
|
|
1883
|
+
97,
|
|
1884
|
+
117,
|
|
1885
|
+
116,
|
|
1886
|
+
104,
|
|
1887
|
+
111,
|
|
1888
|
+
114,
|
|
1889
|
+
105,
|
|
1890
|
+
116,
|
|
1891
|
+
121
|
|
1892
|
+
]
|
|
1893
|
+
}
|
|
1894
|
+
]
|
|
1895
|
+
}
|
|
1896
|
+
},
|
|
1897
|
+
{
|
|
1898
|
+
name: "program"
|
|
1899
|
+
}
|
|
1900
|
+
],
|
|
1901
|
+
args: [
|
|
1902
|
+
{
|
|
1903
|
+
name: "proof",
|
|
1904
|
+
type: {
|
|
1905
|
+
defined: {
|
|
1906
|
+
name: "TransactionProof"
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
name: "params",
|
|
1912
|
+
type: {
|
|
1913
|
+
defined: {
|
|
1914
|
+
name: "SwapParams"
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
name: "encrypted_output1",
|
|
1920
|
+
type: "bytes"
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
name: "encrypted_output2",
|
|
1924
|
+
type: "bytes"
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
name: "route_data",
|
|
1928
|
+
type: "bytes"
|
|
1929
|
+
}
|
|
1930
|
+
]
|
|
1931
|
+
},
|
|
1460
1932
|
{
|
|
1461
1933
|
name: "token_deposit",
|
|
1462
1934
|
discriminator: [
|
|
@@ -1683,14 +2155,46 @@ var veilix_devnet_default = {
|
|
|
1683
2155
|
}
|
|
1684
2156
|
},
|
|
1685
2157
|
{
|
|
1686
|
-
name: "mint"
|
|
1687
|
-
},
|
|
1688
|
-
{
|
|
1689
|
-
name: "token_program"
|
|
1690
|
-
},
|
|
1691
|
-
{
|
|
1692
|
-
name: "system_program",
|
|
1693
|
-
address: "11111111111111111111111111111111"
|
|
2158
|
+
name: "mint"
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
name: "token_program"
|
|
2162
|
+
},
|
|
2163
|
+
{
|
|
2164
|
+
name: "system_program",
|
|
2165
|
+
address: "11111111111111111111111111111111"
|
|
2166
|
+
},
|
|
2167
|
+
{
|
|
2168
|
+
name: "event_authority",
|
|
2169
|
+
pda: {
|
|
2170
|
+
seeds: [
|
|
2171
|
+
{
|
|
2172
|
+
kind: "const",
|
|
2173
|
+
value: [
|
|
2174
|
+
95,
|
|
2175
|
+
95,
|
|
2176
|
+
101,
|
|
2177
|
+
118,
|
|
2178
|
+
101,
|
|
2179
|
+
110,
|
|
2180
|
+
116,
|
|
2181
|
+
95,
|
|
2182
|
+
97,
|
|
2183
|
+
117,
|
|
2184
|
+
116,
|
|
2185
|
+
104,
|
|
2186
|
+
111,
|
|
2187
|
+
114,
|
|
2188
|
+
105,
|
|
2189
|
+
116,
|
|
2190
|
+
121
|
|
2191
|
+
]
|
|
2192
|
+
}
|
|
2193
|
+
]
|
|
2194
|
+
}
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
name: "program"
|
|
1694
2198
|
}
|
|
1695
2199
|
],
|
|
1696
2200
|
args: [
|
|
@@ -2057,6 +2561,38 @@ var veilix_devnet_default = {
|
|
|
2057
2561
|
{
|
|
2058
2562
|
name: "system_program",
|
|
2059
2563
|
address: "11111111111111111111111111111111"
|
|
2564
|
+
},
|
|
2565
|
+
{
|
|
2566
|
+
name: "event_authority",
|
|
2567
|
+
pda: {
|
|
2568
|
+
seeds: [
|
|
2569
|
+
{
|
|
2570
|
+
kind: "const",
|
|
2571
|
+
value: [
|
|
2572
|
+
95,
|
|
2573
|
+
95,
|
|
2574
|
+
101,
|
|
2575
|
+
118,
|
|
2576
|
+
101,
|
|
2577
|
+
110,
|
|
2578
|
+
116,
|
|
2579
|
+
95,
|
|
2580
|
+
97,
|
|
2581
|
+
117,
|
|
2582
|
+
116,
|
|
2583
|
+
104,
|
|
2584
|
+
111,
|
|
2585
|
+
114,
|
|
2586
|
+
105,
|
|
2587
|
+
116,
|
|
2588
|
+
121
|
|
2589
|
+
]
|
|
2590
|
+
}
|
|
2591
|
+
]
|
|
2592
|
+
}
|
|
2593
|
+
},
|
|
2594
|
+
{
|
|
2595
|
+
name: "program"
|
|
2060
2596
|
}
|
|
2061
2597
|
],
|
|
2062
2598
|
args: [
|
|
@@ -2505,6 +3041,83 @@ var veilix_devnet_default = {
|
|
|
2505
3041
|
}
|
|
2506
3042
|
]
|
|
2507
3043
|
},
|
|
3044
|
+
{
|
|
3045
|
+
name: "update_swap_config",
|
|
3046
|
+
docs: [
|
|
3047
|
+
"Replaces the list of DEX programs the swap escrow may call. Config authority only."
|
|
3048
|
+
],
|
|
3049
|
+
discriminator: [
|
|
3050
|
+
123,
|
|
3051
|
+
172,
|
|
3052
|
+
158,
|
|
3053
|
+
60,
|
|
3054
|
+
104,
|
|
3055
|
+
133,
|
|
3056
|
+
39,
|
|
3057
|
+
13
|
|
3058
|
+
],
|
|
3059
|
+
accounts: [
|
|
3060
|
+
{
|
|
3061
|
+
name: "authority",
|
|
3062
|
+
writable: true,
|
|
3063
|
+
signer: true
|
|
3064
|
+
},
|
|
3065
|
+
{
|
|
3066
|
+
name: "network_state",
|
|
3067
|
+
pda: {
|
|
3068
|
+
seeds: [
|
|
3069
|
+
{
|
|
3070
|
+
kind: "const",
|
|
3071
|
+
value: [
|
|
3072
|
+
99,
|
|
3073
|
+
111,
|
|
3074
|
+
110,
|
|
3075
|
+
102,
|
|
3076
|
+
105,
|
|
3077
|
+
103
|
|
3078
|
+
]
|
|
3079
|
+
}
|
|
3080
|
+
]
|
|
3081
|
+
}
|
|
3082
|
+
},
|
|
3083
|
+
{
|
|
3084
|
+
name: "swap_config",
|
|
3085
|
+
writable: true,
|
|
3086
|
+
pda: {
|
|
3087
|
+
seeds: [
|
|
3088
|
+
{
|
|
3089
|
+
kind: "const",
|
|
3090
|
+
value: [
|
|
3091
|
+
115,
|
|
3092
|
+
119,
|
|
3093
|
+
97,
|
|
3094
|
+
112,
|
|
3095
|
+
95,
|
|
3096
|
+
99,
|
|
3097
|
+
111,
|
|
3098
|
+
110,
|
|
3099
|
+
102,
|
|
3100
|
+
105,
|
|
3101
|
+
103
|
|
3102
|
+
]
|
|
3103
|
+
}
|
|
3104
|
+
]
|
|
3105
|
+
}
|
|
3106
|
+
},
|
|
3107
|
+
{
|
|
3108
|
+
name: "system_program",
|
|
3109
|
+
address: "11111111111111111111111111111111"
|
|
3110
|
+
}
|
|
3111
|
+
],
|
|
3112
|
+
args: [
|
|
3113
|
+
{
|
|
3114
|
+
name: "allowed_programs",
|
|
3115
|
+
type: {
|
|
3116
|
+
vec: "pubkey"
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
]
|
|
3120
|
+
},
|
|
2508
3121
|
{
|
|
2509
3122
|
name: "withdraw",
|
|
2510
3123
|
discriminator: [
|
|
@@ -2663,6 +3276,38 @@ var veilix_devnet_default = {
|
|
|
2663
3276
|
{
|
|
2664
3277
|
name: "system_program",
|
|
2665
3278
|
address: "11111111111111111111111111111111"
|
|
3279
|
+
},
|
|
3280
|
+
{
|
|
3281
|
+
name: "event_authority",
|
|
3282
|
+
pda: {
|
|
3283
|
+
seeds: [
|
|
3284
|
+
{
|
|
3285
|
+
kind: "const",
|
|
3286
|
+
value: [
|
|
3287
|
+
95,
|
|
3288
|
+
95,
|
|
3289
|
+
101,
|
|
3290
|
+
118,
|
|
3291
|
+
101,
|
|
3292
|
+
110,
|
|
3293
|
+
116,
|
|
3294
|
+
95,
|
|
3295
|
+
97,
|
|
3296
|
+
117,
|
|
3297
|
+
116,
|
|
3298
|
+
104,
|
|
3299
|
+
111,
|
|
3300
|
+
114,
|
|
3301
|
+
105,
|
|
3302
|
+
116,
|
|
3303
|
+
121
|
|
3304
|
+
]
|
|
3305
|
+
}
|
|
3306
|
+
]
|
|
3307
|
+
}
|
|
3308
|
+
},
|
|
3309
|
+
{
|
|
3310
|
+
name: "program"
|
|
2666
3311
|
}
|
|
2667
3312
|
],
|
|
2668
3313
|
args: [
|
|
@@ -2772,6 +3417,19 @@ var veilix_devnet_default = {
|
|
|
2772
3417
|
20
|
|
2773
3418
|
]
|
|
2774
3419
|
},
|
|
3420
|
+
{
|
|
3421
|
+
name: "SwapConfig",
|
|
3422
|
+
discriminator: [
|
|
3423
|
+
212,
|
|
3424
|
+
45,
|
|
3425
|
+
70,
|
|
3426
|
+
222,
|
|
3427
|
+
245,
|
|
3428
|
+
122,
|
|
3429
|
+
125,
|
|
3430
|
+
166
|
|
3431
|
+
]
|
|
3432
|
+
},
|
|
2775
3433
|
{
|
|
2776
3434
|
name: "TreeAccount",
|
|
2777
3435
|
discriminator: [
|
|
@@ -2813,6 +3471,19 @@ var veilix_devnet_default = {
|
|
|
2813
3471
|
159
|
|
2814
3472
|
]
|
|
2815
3473
|
},
|
|
3474
|
+
{
|
|
3475
|
+
name: "PrivateSwapEvent",
|
|
3476
|
+
discriminator: [
|
|
3477
|
+
150,
|
|
3478
|
+
165,
|
|
3479
|
+
138,
|
|
3480
|
+
189,
|
|
3481
|
+
123,
|
|
3482
|
+
86,
|
|
3483
|
+
117,
|
|
3484
|
+
39
|
|
3485
|
+
]
|
|
3486
|
+
},
|
|
2816
3487
|
{
|
|
2817
3488
|
name: "RelayerCancelled",
|
|
2818
3489
|
discriminator: [
|
|
@@ -3075,6 +3746,56 @@ var veilix_devnet_default = {
|
|
|
3075
3746
|
code: 6033,
|
|
3076
3747
|
name: "FeeRepaymentAccounts",
|
|
3077
3748
|
msg: "Fee repayment accounts do not match earned fees"
|
|
3749
|
+
},
|
|
3750
|
+
{
|
|
3751
|
+
code: 6034,
|
|
3752
|
+
name: "DexProgramNotAllowed",
|
|
3753
|
+
msg: "DEX program is not on the swap allowlist"
|
|
3754
|
+
},
|
|
3755
|
+
{
|
|
3756
|
+
code: 6035,
|
|
3757
|
+
name: "TooManyDexPrograms",
|
|
3758
|
+
msg: "Too many allowlisted DEX programs"
|
|
3759
|
+
},
|
|
3760
|
+
{
|
|
3761
|
+
code: 6036,
|
|
3762
|
+
name: "SlippageExceeded",
|
|
3763
|
+
msg: "Swap output is below the minimum amount"
|
|
3764
|
+
},
|
|
3765
|
+
{
|
|
3766
|
+
code: 6037,
|
|
3767
|
+
name: "SwapInputMismatch",
|
|
3768
|
+
msg: "DEX did not use exactly the escrowed swap input"
|
|
3769
|
+
},
|
|
3770
|
+
{
|
|
3771
|
+
code: 6038,
|
|
3772
|
+
name: "InvalidSwapAccounts",
|
|
3773
|
+
msg: "Swap accounts do not match the trees"
|
|
3774
|
+
},
|
|
3775
|
+
{
|
|
3776
|
+
code: 6039,
|
|
3777
|
+
name: "EscrowTampered",
|
|
3778
|
+
msg: "Swap escrow was modified by the DEX"
|
|
3779
|
+
},
|
|
3780
|
+
{
|
|
3781
|
+
code: 6040,
|
|
3782
|
+
name: "InvalidNoteKey",
|
|
3783
|
+
msg: "Note public key or blinding is not a valid field element"
|
|
3784
|
+
},
|
|
3785
|
+
{
|
|
3786
|
+
code: 6041,
|
|
3787
|
+
name: "NotUpgradeAuthority",
|
|
3788
|
+
msg: "Only the program upgrade authority can initialize the network"
|
|
3789
|
+
},
|
|
3790
|
+
{
|
|
3791
|
+
code: 6042,
|
|
3792
|
+
name: "InvalidFeeSplit",
|
|
3793
|
+
msg: "Fee wallets must be distinct, non-default and split at most the allowed total"
|
|
3794
|
+
},
|
|
3795
|
+
{
|
|
3796
|
+
code: 6043,
|
|
3797
|
+
name: "UnsupportedMintExtension",
|
|
3798
|
+
msg: "Token mint has an extension the pool does not support"
|
|
3078
3799
|
}
|
|
3079
3800
|
],
|
|
3080
3801
|
types: [
|
|
@@ -3202,8 +3923,104 @@ var veilix_devnet_default = {
|
|
|
3202
3923
|
type: "pubkey"
|
|
3203
3924
|
},
|
|
3204
3925
|
{
|
|
3205
|
-
name: "index",
|
|
3206
|
-
type: "u64"
|
|
3926
|
+
name: "index",
|
|
3927
|
+
type: "u64"
|
|
3928
|
+
},
|
|
3929
|
+
{
|
|
3930
|
+
name: "commitment",
|
|
3931
|
+
type: {
|
|
3932
|
+
array: [
|
|
3933
|
+
"u8",
|
|
3934
|
+
32
|
|
3935
|
+
]
|
|
3936
|
+
}
|
|
3937
|
+
},
|
|
3938
|
+
{
|
|
3939
|
+
name: "encrypted_output",
|
|
3940
|
+
type: "bytes"
|
|
3941
|
+
}
|
|
3942
|
+
]
|
|
3943
|
+
}
|
|
3944
|
+
},
|
|
3945
|
+
{
|
|
3946
|
+
name: "Notes",
|
|
3947
|
+
type: {
|
|
3948
|
+
kind: "struct",
|
|
3949
|
+
fields: [
|
|
3950
|
+
{
|
|
3951
|
+
name: "entries",
|
|
3952
|
+
type: {
|
|
3953
|
+
vec: "string"
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
]
|
|
3957
|
+
}
|
|
3958
|
+
},
|
|
3959
|
+
{
|
|
3960
|
+
name: "NotesV2",
|
|
3961
|
+
type: {
|
|
3962
|
+
kind: "struct",
|
|
3963
|
+
fields: [
|
|
3964
|
+
{
|
|
3965
|
+
name: "entries",
|
|
3966
|
+
type: {
|
|
3967
|
+
vec: "bytes"
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
]
|
|
3971
|
+
}
|
|
3972
|
+
},
|
|
3973
|
+
{
|
|
3974
|
+
name: "Nullifier",
|
|
3975
|
+
type: {
|
|
3976
|
+
kind: "struct"
|
|
3977
|
+
}
|
|
3978
|
+
},
|
|
3979
|
+
{
|
|
3980
|
+
name: "PrivateSwapEvent",
|
|
3981
|
+
docs: [
|
|
3982
|
+
"Emitted once per swap. The asset-B note is `commitment` at `index` in the `mint_out` tree."
|
|
3983
|
+
],
|
|
3984
|
+
type: {
|
|
3985
|
+
kind: "struct",
|
|
3986
|
+
fields: [
|
|
3987
|
+
{
|
|
3988
|
+
name: "mint_in",
|
|
3989
|
+
type: "pubkey"
|
|
3990
|
+
},
|
|
3991
|
+
{
|
|
3992
|
+
name: "mint_out",
|
|
3993
|
+
type: "pubkey"
|
|
3994
|
+
},
|
|
3995
|
+
{
|
|
3996
|
+
name: "amount_in",
|
|
3997
|
+
type: "u64"
|
|
3998
|
+
},
|
|
3999
|
+
{
|
|
4000
|
+
name: "fee",
|
|
4001
|
+
type: "u64"
|
|
4002
|
+
},
|
|
4003
|
+
{
|
|
4004
|
+
name: "amount_out",
|
|
4005
|
+
type: "u64"
|
|
4006
|
+
},
|
|
4007
|
+
{
|
|
4008
|
+
name: "input_nullifiers",
|
|
4009
|
+
type: {
|
|
4010
|
+
array: [
|
|
4011
|
+
{
|
|
4012
|
+
array: [
|
|
4013
|
+
"u8",
|
|
4014
|
+
32
|
|
4015
|
+
]
|
|
4016
|
+
},
|
|
4017
|
+
2
|
|
4018
|
+
]
|
|
4019
|
+
}
|
|
4020
|
+
},
|
|
4021
|
+
{
|
|
4022
|
+
name: "relayer",
|
|
4023
|
+
type: "pubkey"
|
|
3207
4024
|
},
|
|
3208
4025
|
{
|
|
3209
4026
|
name: "commitment",
|
|
@@ -3215,46 +4032,12 @@ var veilix_devnet_default = {
|
|
|
3215
4032
|
}
|
|
3216
4033
|
},
|
|
3217
4034
|
{
|
|
3218
|
-
name: "
|
|
3219
|
-
type: "
|
|
3220
|
-
}
|
|
3221
|
-
]
|
|
3222
|
-
}
|
|
3223
|
-
},
|
|
3224
|
-
{
|
|
3225
|
-
name: "Notes",
|
|
3226
|
-
type: {
|
|
3227
|
-
kind: "struct",
|
|
3228
|
-
fields: [
|
|
3229
|
-
{
|
|
3230
|
-
name: "entries",
|
|
3231
|
-
type: {
|
|
3232
|
-
vec: "string"
|
|
3233
|
-
}
|
|
3234
|
-
}
|
|
3235
|
-
]
|
|
3236
|
-
}
|
|
3237
|
-
},
|
|
3238
|
-
{
|
|
3239
|
-
name: "NotesV2",
|
|
3240
|
-
type: {
|
|
3241
|
-
kind: "struct",
|
|
3242
|
-
fields: [
|
|
3243
|
-
{
|
|
3244
|
-
name: "entries",
|
|
3245
|
-
type: {
|
|
3246
|
-
vec: "bytes"
|
|
3247
|
-
}
|
|
4035
|
+
name: "index",
|
|
4036
|
+
type: "u64"
|
|
3248
4037
|
}
|
|
3249
4038
|
]
|
|
3250
4039
|
}
|
|
3251
4040
|
},
|
|
3252
|
-
{
|
|
3253
|
-
name: "Nullifier",
|
|
3254
|
-
type: {
|
|
3255
|
-
kind: "struct"
|
|
3256
|
-
}
|
|
3257
|
-
},
|
|
3258
4041
|
{
|
|
3259
4042
|
name: "RelayerAccount",
|
|
3260
4043
|
docs: [
|
|
@@ -3449,6 +4232,86 @@ var veilix_devnet_default = {
|
|
|
3449
4232
|
]
|
|
3450
4233
|
}
|
|
3451
4234
|
},
|
|
4235
|
+
{
|
|
4236
|
+
name: "SwapConfig",
|
|
4237
|
+
docs: [
|
|
4238
|
+
'Programs the swap escrow is allowed to call. PDA seeds: `["swap_config"]`.'
|
|
4239
|
+
],
|
|
4240
|
+
type: {
|
|
4241
|
+
kind: "struct",
|
|
4242
|
+
fields: [
|
|
4243
|
+
{
|
|
4244
|
+
name: "allowed_programs",
|
|
4245
|
+
type: {
|
|
4246
|
+
vec: "pubkey"
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
]
|
|
4250
|
+
}
|
|
4251
|
+
},
|
|
4252
|
+
{
|
|
4253
|
+
name: "SwapParams",
|
|
4254
|
+
docs: [
|
|
4255
|
+
"Swap parameters. All of them are bound into the proof's `extDataHash`."
|
|
4256
|
+
],
|
|
4257
|
+
type: {
|
|
4258
|
+
kind: "struct",
|
|
4259
|
+
fields: [
|
|
4260
|
+
{
|
|
4261
|
+
name: "amount_in",
|
|
4262
|
+
docs: [
|
|
4263
|
+
"Asset-A amount spent from the pool, fee included."
|
|
4264
|
+
],
|
|
4265
|
+
type: "u64"
|
|
4266
|
+
},
|
|
4267
|
+
{
|
|
4268
|
+
name: "fee",
|
|
4269
|
+
docs: [
|
|
4270
|
+
"Asset-A fee: protocol wallets get their split of `amount_in`, the relayer the rest."
|
|
4271
|
+
],
|
|
4272
|
+
type: "u64"
|
|
4273
|
+
},
|
|
4274
|
+
{
|
|
4275
|
+
name: "min_amount_out",
|
|
4276
|
+
docs: [
|
|
4277
|
+
"Minimum asset-B amount that must reach the treasury."
|
|
4278
|
+
],
|
|
4279
|
+
type: "u64"
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
name: "out_pubkey",
|
|
4283
|
+
docs: [
|
|
4284
|
+
"One-time shielded public key of the asset-B note (32-byte big-endian field element)."
|
|
4285
|
+
],
|
|
4286
|
+
type: {
|
|
4287
|
+
array: [
|
|
4288
|
+
"u8",
|
|
4289
|
+
32
|
|
4290
|
+
]
|
|
4291
|
+
}
|
|
4292
|
+
},
|
|
4293
|
+
{
|
|
4294
|
+
name: "out_blinding",
|
|
4295
|
+
docs: [
|
|
4296
|
+
"Blinding of the asset-B note (32-byte big-endian field element)."
|
|
4297
|
+
],
|
|
4298
|
+
type: {
|
|
4299
|
+
array: [
|
|
4300
|
+
"u8",
|
|
4301
|
+
32
|
|
4302
|
+
]
|
|
4303
|
+
}
|
|
4304
|
+
},
|
|
4305
|
+
{
|
|
4306
|
+
name: "encrypted_note",
|
|
4307
|
+
docs: [
|
|
4308
|
+
"Optional encrypted recovery data for the asset-B note."
|
|
4309
|
+
],
|
|
4310
|
+
type: "bytes"
|
|
4311
|
+
}
|
|
4312
|
+
]
|
|
4313
|
+
}
|
|
4314
|
+
},
|
|
3452
4315
|
{
|
|
3453
4316
|
name: "TransactionProof",
|
|
3454
4317
|
docs: [
|
|
@@ -7347,7 +8210,7 @@ var MAINNET_TOKEN_MINTS = {
|
|
|
7347
8210
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
7348
8211
|
};
|
|
7349
8212
|
var DEVNET_TOKEN_MINTS = {
|
|
7350
|
-
Veilix: "
|
|
8213
|
+
Veilix: "Gmo636w21RBZX9ySVtPYcuYP6f1E5bdW5eBYhvK1bc8J",
|
|
7351
8214
|
Bitcoin: "",
|
|
7352
8215
|
Ethereum: "",
|
|
7353
8216
|
USDC: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
@@ -7397,7 +8260,7 @@ function getDepositQueueForNetwork(network) {
|
|
|
7397
8260
|
// package.json
|
|
7398
8261
|
var package_default = {
|
|
7399
8262
|
name: "veilix-sdk",
|
|
7400
|
-
version: "0.
|
|
8263
|
+
version: "0.3.1"};
|
|
7401
8264
|
|
|
7402
8265
|
// src/circuits/constants.ts
|
|
7403
8266
|
var PACKAGE_NAME = package_default.name;
|
|
@@ -7572,10 +8435,19 @@ async function createRuntimeConfig(options) {
|
|
|
7572
8435
|
};
|
|
7573
8436
|
}
|
|
7574
8437
|
function pushRuntimeContext(config) {
|
|
8438
|
+
const active = runtimeContextStack.find((other) => other.programId !== config.programId);
|
|
8439
|
+
if (active) {
|
|
8440
|
+
throw new Error(
|
|
8441
|
+
`veilix-sdk: another SDK instance is running on program ${active.programId}; instances on different networks must run one at a time`
|
|
8442
|
+
);
|
|
8443
|
+
}
|
|
7575
8444
|
runtimeContextStack.push(config);
|
|
7576
8445
|
}
|
|
7577
|
-
function popRuntimeContext() {
|
|
7578
|
-
runtimeContextStack.
|
|
8446
|
+
function popRuntimeContext(config) {
|
|
8447
|
+
const index = runtimeContextStack.lastIndexOf(config);
|
|
8448
|
+
if (index !== -1) {
|
|
8449
|
+
runtimeContextStack.splice(index, 1);
|
|
8450
|
+
}
|
|
7579
8451
|
}
|
|
7580
8452
|
function getConfig() {
|
|
7581
8453
|
const active = runtimeContextStack.at(-1);
|
|
@@ -7640,10 +8512,10 @@ var DEPOSIT_COMPUTE_UNIT_LIMIT = 35e4;
|
|
|
7640
8512
|
function bytesToHex(bytes) {
|
|
7641
8513
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
7642
8514
|
}
|
|
7643
|
-
function hexToBytes(
|
|
7644
|
-
const clean =
|
|
8515
|
+
function hexToBytes(hex2) {
|
|
8516
|
+
const clean = hex2.startsWith("0x") || hex2.startsWith("0X") ? hex2.slice(2) : hex2;
|
|
7645
8517
|
if (clean.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(clean)) {
|
|
7646
|
-
throw new Error(`veilix-sdk: invalid hex string "${
|
|
8518
|
+
throw new Error(`veilix-sdk: invalid hex string "${hex2}"`);
|
|
7647
8519
|
}
|
|
7648
8520
|
const out = new Uint8Array(clean.length / 2);
|
|
7649
8521
|
for (let i = 0; i < out.length; i++) {
|
|
@@ -7652,15 +8524,15 @@ function hexToBytes(hex) {
|
|
|
7652
8524
|
return out;
|
|
7653
8525
|
}
|
|
7654
8526
|
function bigintToBytes32(value) {
|
|
7655
|
-
const
|
|
7656
|
-
if (
|
|
8527
|
+
const hex2 = BigInt(value).toString(16).padStart(64, "0");
|
|
8528
|
+
if (hex2.length > 64) {
|
|
7657
8529
|
throw new Error("veilix-sdk: value does not fit in 32 bytes");
|
|
7658
8530
|
}
|
|
7659
|
-
return hexToBytes(
|
|
8531
|
+
return hexToBytes(hex2);
|
|
7660
8532
|
}
|
|
7661
8533
|
function bytesToBigint(bytes) {
|
|
7662
|
-
const
|
|
7663
|
-
return
|
|
8534
|
+
const hex2 = bytesToHex(bytes);
|
|
8535
|
+
return hex2 ? BigInt(`0x${hex2}`) : 0n;
|
|
7664
8536
|
}
|
|
7665
8537
|
function toHex32(value) {
|
|
7666
8538
|
return `0x${BigInt(value).toString(16).padStart(64, "0")}`;
|
|
@@ -7778,6 +8650,7 @@ var Utxo = class _Utxo {
|
|
|
7778
8650
|
// src/core/note.ts
|
|
7779
8651
|
var NOTE_PREFIX = "vx2";
|
|
7780
8652
|
var ENCRYPTED_OUTPUT_VERSION = 1;
|
|
8653
|
+
var ENCRYPTED_SWAP_OUTPUT_VERSION = 2;
|
|
7781
8654
|
var ENCRYPTED_OUTPUT_PLAINTEXT_BYTES = 1 + 8 + 32 + 32;
|
|
7782
8655
|
var SECRETBOX_NONCE_BYTES = nacl.secretbox.nonceLength;
|
|
7783
8656
|
function encodeNote(utxo) {
|
|
@@ -7810,14 +8683,14 @@ function decodeNote(note) {
|
|
|
7810
8683
|
throw new Error("veilix-sdk: invalid note format");
|
|
7811
8684
|
}
|
|
7812
8685
|
const [, amountHex, privKeyHex, blindingHex, mint] = parts;
|
|
7813
|
-
const
|
|
7814
|
-
if (!
|
|
8686
|
+
const hex2 = /^[0-9a-f]+$/i;
|
|
8687
|
+
if (!hex2.test(amountHex) || !hex2.test(privKeyHex) || !hex2.test(blindingHex)) {
|
|
7815
8688
|
throw new Error("veilix-sdk: invalid note format");
|
|
7816
8689
|
}
|
|
7817
|
-
let
|
|
8690
|
+
let mintKey2 = null;
|
|
7818
8691
|
if (mint) {
|
|
7819
8692
|
try {
|
|
7820
|
-
|
|
8693
|
+
mintKey2 = new PublicKey(mint);
|
|
7821
8694
|
} catch {
|
|
7822
8695
|
throw new Error("veilix-sdk: invalid note mint");
|
|
7823
8696
|
}
|
|
@@ -7826,7 +8699,7 @@ function decodeNote(note) {
|
|
|
7826
8699
|
amount: BigInt(`0x${amountHex}`),
|
|
7827
8700
|
keypair: VeilixKeypair.fromPrivateKey(BigInt(`0x${privKeyHex}`)),
|
|
7828
8701
|
blinding: BigInt(`0x${blindingHex}`),
|
|
7829
|
-
mint:
|
|
8702
|
+
mint: mintKey2
|
|
7830
8703
|
});
|
|
7831
8704
|
}
|
|
7832
8705
|
function describeUtxo(utxo) {
|
|
@@ -7844,7 +8717,7 @@ function describeUtxo(utxo) {
|
|
|
7844
8717
|
function parseSecretNote(note) {
|
|
7845
8718
|
return describeUtxo(decodeNote(note));
|
|
7846
8719
|
}
|
|
7847
|
-
function encryptNoteOutput(
|
|
8720
|
+
function encryptNoteOutput(key2, utxo) {
|
|
7848
8721
|
const amount = new Uint8Array(8);
|
|
7849
8722
|
new DataView(amount.buffer).setBigUint64(0, utxo.amount, true);
|
|
7850
8723
|
const plaintext = concatBytes([
|
|
@@ -7854,21 +8727,38 @@ function encryptNoteOutput(key, utxo) {
|
|
|
7854
8727
|
bigintToBytes32(utxo.blinding)
|
|
7855
8728
|
]);
|
|
7856
8729
|
const nonce = nacl.randomBytes(SECRETBOX_NONCE_BYTES);
|
|
7857
|
-
return concatBytes([nonce, nacl.secretbox(plaintext, nonce,
|
|
8730
|
+
return concatBytes([nonce, nacl.secretbox(plaintext, nonce, key2)]);
|
|
8731
|
+
}
|
|
8732
|
+
function encryptSwapNoteOutput(key2, keypair, blinding) {
|
|
8733
|
+
const plaintext = concatBytes([
|
|
8734
|
+
Uint8Array.of(ENCRYPTED_SWAP_OUTPUT_VERSION),
|
|
8735
|
+
new Uint8Array(8),
|
|
8736
|
+
bigintToBytes32(keypair.privKey),
|
|
8737
|
+
bigintToBytes32(blinding)
|
|
8738
|
+
]);
|
|
8739
|
+
const nonce = nacl.randomBytes(SECRETBOX_NONCE_BYTES);
|
|
8740
|
+
return concatBytes([nonce, nacl.secretbox(plaintext, nonce, key2)]);
|
|
7858
8741
|
}
|
|
7859
|
-
function decryptNoteOutput(
|
|
8742
|
+
function decryptNoteOutput(key2, encryptedOutput, mint, index, onchainAmount = null) {
|
|
7860
8743
|
if (encryptedOutput.length !== SECRETBOX_NONCE_BYTES + nacl.secretbox.overheadLength + ENCRYPTED_OUTPUT_PLAINTEXT_BYTES) {
|
|
7861
8744
|
return null;
|
|
7862
8745
|
}
|
|
7863
8746
|
const opened = nacl.secretbox.open(
|
|
7864
8747
|
encryptedOutput.subarray(SECRETBOX_NONCE_BYTES),
|
|
7865
8748
|
encryptedOutput.subarray(0, SECRETBOX_NONCE_BYTES),
|
|
7866
|
-
|
|
8749
|
+
key2
|
|
7867
8750
|
);
|
|
7868
|
-
if (!opened
|
|
8751
|
+
if (!opened) {
|
|
8752
|
+
return null;
|
|
8753
|
+
}
|
|
8754
|
+
let amount;
|
|
8755
|
+
if (opened[0] === ENCRYPTED_OUTPUT_VERSION) {
|
|
8756
|
+
amount = new DataView(opened.buffer, opened.byteOffset + 1, 8).getBigUint64(0, true);
|
|
8757
|
+
} else if (opened[0] === ENCRYPTED_SWAP_OUTPUT_VERSION && onchainAmount !== null) {
|
|
8758
|
+
amount = onchainAmount;
|
|
8759
|
+
} else {
|
|
7869
8760
|
return null;
|
|
7870
8761
|
}
|
|
7871
|
-
const amount = new DataView(opened.buffer, opened.byteOffset + 1, 8).getBigUint64(0, true);
|
|
7872
8762
|
return new Utxo({
|
|
7873
8763
|
amount,
|
|
7874
8764
|
keypair: VeilixKeypair.fromPrivateKey(bytesToBigint(opened.subarray(9, 41))),
|
|
@@ -16349,6 +17239,7 @@ async function proveTransaction({
|
|
|
16349
17239
|
inputs = [],
|
|
16350
17240
|
outputs = [],
|
|
16351
17241
|
ext,
|
|
17242
|
+
extDataHashOverride,
|
|
16352
17243
|
circuit
|
|
16353
17244
|
}) {
|
|
16354
17245
|
for (const utxo of [...inputs, ...outputs]) {
|
|
@@ -16398,7 +17289,7 @@ async function proveTransaction({
|
|
|
16398
17289
|
const input = {
|
|
16399
17290
|
root: proofRoot.toString(),
|
|
16400
17291
|
publicAmount: publicAmount.toString(),
|
|
16401
|
-
extDataHash: (await extDataHash(ext)).toString(),
|
|
17292
|
+
extDataHash: (extDataHashOverride ?? await extDataHash(ext)).toString(),
|
|
16402
17293
|
mint: mintToField(ext.mint).toString(),
|
|
16403
17294
|
inputNullifier: inputNullifiers.map(String),
|
|
16404
17295
|
outputCommitment: outputCommitments.map(String),
|
|
@@ -16539,8 +17430,8 @@ function generateDepositParams(amount, mint = null) {
|
|
|
16539
17430
|
if (value <= 0n) {
|
|
16540
17431
|
throw new Error("veilix-sdk: deposit amount must be positive");
|
|
16541
17432
|
}
|
|
16542
|
-
const
|
|
16543
|
-
const note = encodeNote(new Utxo({ amount: value, mint:
|
|
17433
|
+
const mintKey2 = mint && mint !== WRAPPED_SOL_MINT ? new PublicKey(mint) : null;
|
|
17434
|
+
const note = encodeNote(new Utxo({ amount: value, mint: mintKey2 }));
|
|
16544
17435
|
return { note, params: parseSecretNote(note) };
|
|
16545
17436
|
}
|
|
16546
17437
|
function to32ByteBuffer(value) {
|
|
@@ -16574,8 +17465,8 @@ function toPublicKey(value) {
|
|
|
16574
17465
|
}
|
|
16575
17466
|
function normalizeTreeMint(mint) {
|
|
16576
17467
|
if (!mint) return null;
|
|
16577
|
-
const
|
|
16578
|
-
return
|
|
17468
|
+
const key2 = toPublicKey(mint);
|
|
17469
|
+
return key2.equals(NATIVE_MINT) || key2.equals(PublicKey.default) ? null : key2;
|
|
16579
17470
|
}
|
|
16580
17471
|
function getTreePDA(mint) {
|
|
16581
17472
|
const treeMint = normalizeTreeMint(mint);
|
|
@@ -16747,9 +17638,11 @@ async function buildDepositTx({
|
|
|
16747
17638
|
onChainBackup = false,
|
|
16748
17639
|
computeUnitPrice = 5e3,
|
|
16749
17640
|
computeUnitLimit = DEPOSIT_COMPUTE_UNIT_LIMIT,
|
|
16750
|
-
circuitArtifacts
|
|
17641
|
+
circuitArtifacts,
|
|
17642
|
+
encryptKey
|
|
16751
17643
|
}) {
|
|
16752
17644
|
const { connection } = getConfig();
|
|
17645
|
+
const sealKey = onChainBackup ? encryptKey ?? requireEncryptKey() : null;
|
|
16753
17646
|
const sender = toPublicKey(senderPublicKey);
|
|
16754
17647
|
const utxo = decodeNote(note);
|
|
16755
17648
|
const mint = utxo.mint;
|
|
@@ -16762,7 +17655,7 @@ async function buildDepositTx({
|
|
|
16762
17655
|
`veilix-sdk: deposit amount ${utxo.amount} exceeds the tree limit of ${tree.maxDepositAmount}`
|
|
16763
17656
|
);
|
|
16764
17657
|
}
|
|
16765
|
-
const encryptedOutput1 =
|
|
17658
|
+
const encryptedOutput1 = sealKey ? encryptNoteOutput(sealKey, utxo) : new Uint8Array();
|
|
16766
17659
|
const encryptedOutput2 = new Uint8Array();
|
|
16767
17660
|
const proved = await withCircuitArtifacts(
|
|
16768
17661
|
circuitArtifacts,
|
|
@@ -16817,17 +17710,16 @@ async function buildInitNotesInstructionIfNeeded(sender) {
|
|
|
16817
17710
|
if (await fetchNotesAccount(sender)) return null;
|
|
16818
17711
|
return program.methods.initNotes().accountsPartial({ user: sender }).instruction();
|
|
16819
17712
|
}
|
|
16820
|
-
async function resolveEncryptKey() {
|
|
16821
|
-
const config = getConfig();
|
|
17713
|
+
async function resolveEncryptKey(config) {
|
|
16822
17714
|
if (!config.encryptKey) {
|
|
16823
17715
|
config.encryptKey = await getEncryptionKey(config.wallet);
|
|
16824
17716
|
}
|
|
16825
17717
|
return config.encryptKey;
|
|
16826
17718
|
}
|
|
16827
|
-
async function buildBackupNotesInstruction(sender, notes) {
|
|
16828
|
-
const { program } =
|
|
16829
|
-
const
|
|
16830
|
-
return program.methods.backupNotes(notes.map((note) => encryptData(
|
|
17719
|
+
async function buildBackupNotesInstruction(sender, notes, config = getConfig()) {
|
|
17720
|
+
const { program } = config;
|
|
17721
|
+
const key2 = await resolveEncryptKey(config);
|
|
17722
|
+
return program.methods.backupNotes(notes.map((note) => encryptData(key2, note))).accountsPartial({ user: sender }).instruction();
|
|
16831
17723
|
}
|
|
16832
17724
|
async function isExtendBackupPdaNeeded(walletPubkey, newNotesLength) {
|
|
16833
17725
|
const account = await fetchNotesAccount(walletPubkey);
|
|
@@ -16839,7 +17731,8 @@ function buildRequestHeapIx() {
|
|
|
16839
17731
|
return ComputeBudgetProgram.requestHeapFrame({ bytes: 32 * 1024 });
|
|
16840
17732
|
}
|
|
16841
17733
|
async function buildBackupNotesTx(senderPublicKey, notes) {
|
|
16842
|
-
const
|
|
17734
|
+
const config = getConfig();
|
|
17735
|
+
const { connection } = config;
|
|
16843
17736
|
const sender = toPublicKey(senderPublicKey);
|
|
16844
17737
|
const tx = new Transaction();
|
|
16845
17738
|
const initIx = await buildInitNotesInstructionIfNeeded(sender);
|
|
@@ -16848,7 +17741,7 @@ async function buildBackupNotesTx(senderPublicKey, notes) {
|
|
|
16848
17741
|
} else if (await isExtendBackupPdaNeeded(sender, notes.length)) {
|
|
16849
17742
|
tx.add(buildRequestHeapIx());
|
|
16850
17743
|
}
|
|
16851
|
-
tx.add(await buildBackupNotesInstruction(sender, notes));
|
|
17744
|
+
tx.add(await buildBackupNotesInstruction(sender, notes, config));
|
|
16852
17745
|
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
16853
17746
|
tx.feePayer = sender;
|
|
16854
17747
|
return tx;
|
|
@@ -16932,16 +17825,16 @@ async function getEncryptionKey(wallet) {
|
|
|
16932
17825
|
}
|
|
16933
17826
|
return nacl.hash(signature).slice(0, 32);
|
|
16934
17827
|
}
|
|
16935
|
-
function encryptData(
|
|
17828
|
+
function encryptData(key2, plaintext) {
|
|
16936
17829
|
const nonce = nacl.randomBytes(24);
|
|
16937
|
-
const box = nacl.secretbox(new TextEncoder().encode(plaintext), nonce,
|
|
17830
|
+
const box = nacl.secretbox(new TextEncoder().encode(plaintext), nonce, key2);
|
|
16938
17831
|
const combined = new Uint8Array(nonce.length + box.length);
|
|
16939
17832
|
combined.set(nonce);
|
|
16940
17833
|
combined.set(box, nonce.length);
|
|
16941
17834
|
return Buffer.from(combined);
|
|
16942
17835
|
}
|
|
16943
|
-
function decryptData(
|
|
16944
|
-
const decrypted = nacl.secretbox.open(combined.slice(24), combined.slice(0, 24),
|
|
17836
|
+
function decryptData(key2, combined) {
|
|
17837
|
+
const decrypted = nacl.secretbox.open(combined.slice(24), combined.slice(0, 24), key2);
|
|
16945
17838
|
if (!decrypted) throw new Error("Decryption failed");
|
|
16946
17839
|
return new TextDecoder().decode(decrypted);
|
|
16947
17840
|
}
|
|
@@ -16979,8 +17872,8 @@ var COMMITMENTS_PAGE_LIMIT = 8e3;
|
|
|
16979
17872
|
var VALIDATE_NULLIFIERS_BATCH = 64;
|
|
16980
17873
|
async function indexerGet(path, params) {
|
|
16981
17874
|
const query = new URLSearchParams();
|
|
16982
|
-
for (const [
|
|
16983
|
-
if (value !== void 0 && value !== "") query.set(
|
|
17875
|
+
for (const [key2, value] of Object.entries(params)) {
|
|
17876
|
+
if (value !== void 0 && value !== "") query.set(key2, value);
|
|
16984
17877
|
}
|
|
16985
17878
|
const qs = query.toString();
|
|
16986
17879
|
return httpFetch(`${getIndexerUrl()}${path}${qs ? `?${qs}` : ""}`, {
|
|
@@ -17195,7 +18088,7 @@ async function scanOwnedNotes({
|
|
|
17195
18088
|
mints,
|
|
17196
18089
|
includeSpent = false
|
|
17197
18090
|
} = {}) {
|
|
17198
|
-
const
|
|
18091
|
+
const key2 = requireEncryptKey();
|
|
17199
18092
|
const explicit = mints !== void 0;
|
|
17200
18093
|
const tokenMints = getTokenMintsForNetwork(getConfig().network);
|
|
17201
18094
|
const targets = mints ?? [null, tokenMints.Veilix, tokenMints.Bitcoin, tokenMints.Ethereum, tokenMints.USDC].filter(
|
|
@@ -17213,7 +18106,13 @@ async function scanOwnedNotes({
|
|
|
17213
18106
|
}
|
|
17214
18107
|
for (const leaf of leaves) {
|
|
17215
18108
|
if (!leaf.encryptedOutput || leaf.encryptedOutput.length <= 2) continue;
|
|
17216
|
-
const utxo = decryptNoteOutput(
|
|
18109
|
+
const utxo = decryptNoteOutput(
|
|
18110
|
+
key2,
|
|
18111
|
+
hexToBytes(leaf.encryptedOutput),
|
|
18112
|
+
treeMint,
|
|
18113
|
+
leaf.index,
|
|
18114
|
+
leaf.amountRaw ? BigInt(leaf.amountRaw) : null
|
|
18115
|
+
);
|
|
17217
18116
|
if (!utxo || utxo.amount === 0n) continue;
|
|
17218
18117
|
if (toHex32(utxo.commitment()) !== toHex32(BigInt(leaf.commitment))) continue;
|
|
17219
18118
|
found.push({ utxo, note: encodeNote(utxo), signature: null });
|
|
@@ -17493,6 +18392,364 @@ async function getQuote(params) {
|
|
|
17493
18392
|
}
|
|
17494
18393
|
return data;
|
|
17495
18394
|
}
|
|
18395
|
+
var SWAP_DOMAIN = new TextEncoder().encode("veilix:swap:v1");
|
|
18396
|
+
async function swapExtDataHash(ext) {
|
|
18397
|
+
const hash = await sha256(
|
|
18398
|
+
concatBytes([
|
|
18399
|
+
SWAP_DOMAIN,
|
|
18400
|
+
(ext.mintIn ?? PublicKey.default).toBytes(),
|
|
18401
|
+
(ext.mintOut ?? PublicKey.default).toBytes(),
|
|
18402
|
+
ext.relayer.toBytes(),
|
|
18403
|
+
u64le(ext.amountIn),
|
|
18404
|
+
u64le(ext.fee),
|
|
18405
|
+
u64le(ext.minAmountOut),
|
|
18406
|
+
bigintToBytes32(ext.outPubkey),
|
|
18407
|
+
bigintToBytes32(ext.outBlinding),
|
|
18408
|
+
u32le(ext.encryptedOutput1.length),
|
|
18409
|
+
ext.encryptedOutput1,
|
|
18410
|
+
u32le(ext.encryptedOutput2.length),
|
|
18411
|
+
ext.encryptedOutput2,
|
|
18412
|
+
u32le(ext.encryptedNote.length),
|
|
18413
|
+
ext.encryptedNote
|
|
18414
|
+
])
|
|
18415
|
+
);
|
|
18416
|
+
hash[0] = 0;
|
|
18417
|
+
return bytesToBigint(hash);
|
|
18418
|
+
}
|
|
18419
|
+
var CPMM_PROGRAM_IDS = {
|
|
18420
|
+
devnet: "DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb",
|
|
18421
|
+
mainnet: "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"
|
|
18422
|
+
};
|
|
18423
|
+
var FEE_RATE_DENOMINATOR = 1000000n;
|
|
18424
|
+
var SWAP_DISABLED_BIT = 2;
|
|
18425
|
+
var key = (data, offset) => new PublicKey(data.subarray(offset, offset + 32));
|
|
18426
|
+
var u64 = (data, offset) => new DataView(data.buffer, data.byteOffset + offset, 8).getBigUint64(0, true);
|
|
18427
|
+
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
18428
|
+
var feeOf = (amount, rate) => ceilDiv(amount * rate, FEE_RATE_DENOMINATOR);
|
|
18429
|
+
async function quoteCpmm(connection, network, poolAddress, treeMintIn, treeMintOut, amountIn) {
|
|
18430
|
+
const programId = new PublicKey(CPMM_PROGRAM_IDS[network]);
|
|
18431
|
+
const poolInfo = await connection.getAccountInfo(poolAddress, "confirmed");
|
|
18432
|
+
if (!poolInfo || !poolInfo.owner.equals(programId) || poolInfo.data.length < 381) {
|
|
18433
|
+
throw new Error("veilix-sdk: swap pool is not a Raydium CPMM pool");
|
|
18434
|
+
}
|
|
18435
|
+
const data = poolInfo.data;
|
|
18436
|
+
const pool = {
|
|
18437
|
+
ammConfig: key(data, 8),
|
|
18438
|
+
vault0: key(data, 72),
|
|
18439
|
+
vault1: key(data, 104),
|
|
18440
|
+
mint0: key(data, 168),
|
|
18441
|
+
mint1: key(data, 200),
|
|
18442
|
+
status: data[329],
|
|
18443
|
+
protocolFees: [u64(data, 341), u64(data, 349)],
|
|
18444
|
+
fundFees: [u64(data, 357), u64(data, 365)],
|
|
18445
|
+
creatorFeeOn: data.length >= 413 ? data[389] : 0,
|
|
18446
|
+
enableCreatorFee: data.length >= 413 ? data[390] === 1 : false,
|
|
18447
|
+
creatorFees: data.length >= 413 ? [u64(data, 397), u64(data, 405)] : [0n, 0n]
|
|
18448
|
+
};
|
|
18449
|
+
if (pool.status >> SWAP_DISABLED_BIT & 1) {
|
|
18450
|
+
throw new Error("veilix-sdk: swaps are disabled on this pool");
|
|
18451
|
+
}
|
|
18452
|
+
const mintIn = treeMintIn ?? NATIVE_MINT;
|
|
18453
|
+
const mintOut = treeMintOut ?? NATIVE_MINT;
|
|
18454
|
+
let zeroForOne;
|
|
18455
|
+
if (pool.mint0.equals(mintIn) && pool.mint1.equals(mintOut)) zeroForOne = true;
|
|
18456
|
+
else if (pool.mint1.equals(mintIn) && pool.mint0.equals(mintOut)) zeroForOne = false;
|
|
18457
|
+
else throw new Error("veilix-sdk: swap pool does not trade this pair");
|
|
18458
|
+
const [i, o] = zeroForOne ? [0, 1] : [1, 0];
|
|
18459
|
+
const [configInfo, vaultIn, vaultOut] = await connection.getMultipleAccountsInfo(
|
|
18460
|
+
[pool.ammConfig, zeroForOne ? pool.vault0 : pool.vault1, zeroForOne ? pool.vault1 : pool.vault0],
|
|
18461
|
+
"confirmed"
|
|
18462
|
+
);
|
|
18463
|
+
if (!configInfo || !vaultIn || !vaultOut) {
|
|
18464
|
+
throw new Error("veilix-sdk: swap pool accounts are missing");
|
|
18465
|
+
}
|
|
18466
|
+
const tradeFeeRate = u64(configInfo.data, 12);
|
|
18467
|
+
const creatorFeeRate = pool.enableCreatorFee && configInfo.data.length >= 116 ? u64(configInfo.data, 108) : 0n;
|
|
18468
|
+
const reserveIn = u64(vaultIn.data, 64) - pool.protocolFees[i] - pool.fundFees[i] - pool.creatorFees[i];
|
|
18469
|
+
const reserveOut = u64(vaultOut.data, 64) - pool.protocolFees[o] - pool.fundFees[o] - pool.creatorFees[o];
|
|
18470
|
+
if (reserveIn <= 0n || reserveOut <= 0n) {
|
|
18471
|
+
throw new Error("veilix-sdk: swap pool has no liquidity");
|
|
18472
|
+
}
|
|
18473
|
+
const creatorOnInput = pool.creatorFeeOn === 0 || pool.creatorFeeOn === 1 && zeroForOne || pool.creatorFeeOn === 2 && !zeroForOne;
|
|
18474
|
+
let inLessFees = amountIn - feeOf(amountIn, tradeFeeRate);
|
|
18475
|
+
if (creatorOnInput) inLessFees -= feeOf(amountIn, creatorFeeRate);
|
|
18476
|
+
let amountOut = inLessFees * reserveOut / (reserveIn + inLessFees);
|
|
18477
|
+
if (!creatorOnInput) amountOut -= feeOf(amountOut, creatorFeeRate);
|
|
18478
|
+
if (amountOut <= 0n) {
|
|
18479
|
+
throw new Error("veilix-sdk: swap amount is too small for this pool");
|
|
18480
|
+
}
|
|
18481
|
+
const spotOut = Number(inLessFees) * (Number(reserveOut) / Number(reserveIn));
|
|
18482
|
+
const priceImpact = spotOut > 0 ? Math.max(0, 1 - Number(amountOut) / spotOut) : 1;
|
|
18483
|
+
return { amountOut, priceImpact };
|
|
18484
|
+
}
|
|
18485
|
+
|
|
18486
|
+
// src/swap/execute.ts
|
|
18487
|
+
var SWAP_MAX_WAIT_MS = 18e4;
|
|
18488
|
+
var DEFAULT_SLIPPAGE_BPS = 100;
|
|
18489
|
+
var MAX_SLIPPAGE_BPS = 5e3;
|
|
18490
|
+
var MAX_PRICE_IMPACT = 0.1;
|
|
18491
|
+
var hex = (bytes) => `0x${bytesToHex(bytes)}`;
|
|
18492
|
+
var mintKey = (mint) => mint?.toBase58() ?? null;
|
|
18493
|
+
async function fetchRelayerQuote(relayerUrl, mintIn, mintOut, amountIn) {
|
|
18494
|
+
const params = new URLSearchParams({ amountIn: amountIn.toString() });
|
|
18495
|
+
if (mintIn) params.set("mintIn", mintIn.toBase58());
|
|
18496
|
+
if (mintOut) params.set("mintOut", mintOut.toBase58());
|
|
18497
|
+
const base = relayerUrl.replace(/\/$/, "");
|
|
18498
|
+
const res = await httpFetch(`${base}/v1/swapQuote?${params}`, {
|
|
18499
|
+
headers: { Accept: "application/json" }
|
|
18500
|
+
});
|
|
18501
|
+
const body = await res.json().catch(() => ({}));
|
|
18502
|
+
if (!res.ok) {
|
|
18503
|
+
throw new Error(body.error || `Swap quote failed (${res.status})`);
|
|
18504
|
+
}
|
|
18505
|
+
return { ...body, relayerUrl: base };
|
|
18506
|
+
}
|
|
18507
|
+
function swapCandidates(relayers, relayerUrl) {
|
|
18508
|
+
if (relayerUrl) {
|
|
18509
|
+
const wanted = relayerUrl.replace(/\/$/, "");
|
|
18510
|
+
const match = relayers.find((r) => r.url.replace(/\/$/, "") === wanted);
|
|
18511
|
+
if (!match) throw new Error(`veilix-sdk: relayer ${relayerUrl} is not available`);
|
|
18512
|
+
return [match];
|
|
18513
|
+
}
|
|
18514
|
+
if (!relayers.length) throw new Error("veilix-sdk: no relayer available");
|
|
18515
|
+
const first = getRandomRelayer(relayers);
|
|
18516
|
+
return [first, ...relayers.filter((r) => r !== first)];
|
|
18517
|
+
}
|
|
18518
|
+
async function getSwapQuote(params) {
|
|
18519
|
+
const { relayers } = getConfig();
|
|
18520
|
+
const mintIn = normalizeTreeMint(params.mintIn);
|
|
18521
|
+
const mintOut = normalizeTreeMint(params.mintOut);
|
|
18522
|
+
if (mintKey(mintIn) === mintKey(mintOut)) {
|
|
18523
|
+
throw new Error("veilix-sdk: swap needs two different assets");
|
|
18524
|
+
}
|
|
18525
|
+
const amountIn = BigInt(params.amountIn);
|
|
18526
|
+
if (amountIn <= 0n) throw new Error("veilix-sdk: swap amount must be positive");
|
|
18527
|
+
const { connection, network } = getConfig();
|
|
18528
|
+
const platformWallets = await fetchPlatformFeeWallets();
|
|
18529
|
+
let lastError = null;
|
|
18530
|
+
for (const relayer of swapCandidates(relayers, params.relayerUrl)) {
|
|
18531
|
+
try {
|
|
18532
|
+
const quote = await fetchRelayerQuote(relayer.url, mintIn, mintOut, amountIn);
|
|
18533
|
+
if (quote.relayer !== relayer.value) {
|
|
18534
|
+
throw new Error("Relayer quoted for a different reward account");
|
|
18535
|
+
}
|
|
18536
|
+
const { fee } = computeWithdrawFee(amountIn, relayer.fee, platformWallets);
|
|
18537
|
+
if (fee >= amountIn) throw new Error("Amount is too small to cover the fees");
|
|
18538
|
+
if (BigInt(quote.fee) !== fee) throw new Error("Relayer quoted a different fee");
|
|
18539
|
+
if (quote.dexProgram !== CPMM_PROGRAM_IDS[network]) {
|
|
18540
|
+
throw new Error("Relayer routes through an unsupported DEX");
|
|
18541
|
+
}
|
|
18542
|
+
const own = await quoteCpmm(
|
|
18543
|
+
connection,
|
|
18544
|
+
network,
|
|
18545
|
+
new PublicKey(quote.pool),
|
|
18546
|
+
mintIn,
|
|
18547
|
+
mintOut,
|
|
18548
|
+
amountIn - fee
|
|
18549
|
+
);
|
|
18550
|
+
if (own.priceImpact > MAX_PRICE_IMPACT) {
|
|
18551
|
+
throw new Error(
|
|
18552
|
+
`Price impact ${(own.priceImpact * 100).toFixed(1)}% is too high for this pool; swap less`
|
|
18553
|
+
);
|
|
18554
|
+
}
|
|
18555
|
+
return {
|
|
18556
|
+
quote: {
|
|
18557
|
+
...quote,
|
|
18558
|
+
swapIn: (amountIn - fee).toString(),
|
|
18559
|
+
amountOut: own.amountOut.toString(),
|
|
18560
|
+
priceImpact: own.priceImpact
|
|
18561
|
+
},
|
|
18562
|
+
relayer
|
|
18563
|
+
};
|
|
18564
|
+
} catch (error) {
|
|
18565
|
+
lastError = error;
|
|
18566
|
+
}
|
|
18567
|
+
}
|
|
18568
|
+
const reason = lastError instanceof Error ? lastError.message : "no relayer routes this pair";
|
|
18569
|
+
throw new Error(`veilix-sdk: no swap route for this pair (${reason})`);
|
|
18570
|
+
}
|
|
18571
|
+
async function buildSwapPayload(params, options = {}) {
|
|
18572
|
+
const { encryptKey } = getConfig();
|
|
18573
|
+
const utxo = decodeNote(params.note);
|
|
18574
|
+
const mintIn = utxo.mint;
|
|
18575
|
+
const mintOut = normalizeTreeMint(params.mintOut ?? null);
|
|
18576
|
+
const slippageBps = params.slippageBps ?? DEFAULT_SLIPPAGE_BPS;
|
|
18577
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > MAX_SLIPPAGE_BPS) {
|
|
18578
|
+
throw new Error(`veilix-sdk: slippageBps must be an integer between 0 and ${MAX_SLIPPAGE_BPS}`);
|
|
18579
|
+
}
|
|
18580
|
+
const { index } = await locateNote(utxo);
|
|
18581
|
+
if (index === null) {
|
|
18582
|
+
throw new Error("Note is not in the Veilix pool yet (deposit not confirmed or not indexed)");
|
|
18583
|
+
}
|
|
18584
|
+
utxo.index = index;
|
|
18585
|
+
if ((await validateNullifier(toHex32(utxo.nullifier()))).exists) {
|
|
18586
|
+
throw new Error("This note has already been spent");
|
|
18587
|
+
}
|
|
18588
|
+
const amountIn = params.amount === void 0 ? utxo.amount : BigInt(params.amount);
|
|
18589
|
+
if (amountIn <= 0n || amountIn > utxo.amount) {
|
|
18590
|
+
throw new Error(`Swap amount must be between 1 and ${utxo.amount}`);
|
|
18591
|
+
}
|
|
18592
|
+
const { quote, relayer } = await getSwapQuote({
|
|
18593
|
+
mintIn,
|
|
18594
|
+
mintOut,
|
|
18595
|
+
amountIn,
|
|
18596
|
+
relayerUrl: params.relayerUrl
|
|
18597
|
+
});
|
|
18598
|
+
const fee = BigInt(quote.fee);
|
|
18599
|
+
const minAmountOut = BigInt(quote.amountOut) * BigInt(1e4 - slippageBps) / 10000n;
|
|
18600
|
+
if (minAmountOut <= 0n) {
|
|
18601
|
+
throw new Error("Swap amount is too small for this pool");
|
|
18602
|
+
}
|
|
18603
|
+
let tree = options.tree;
|
|
18604
|
+
if (!tree || tree.elements.length <= index) {
|
|
18605
|
+
tree = await fetchAssetTree(mintKey(mintIn));
|
|
18606
|
+
}
|
|
18607
|
+
if (tree.elements.length <= index) {
|
|
18608
|
+
throw new Error("The indexer has not synced this note yet, retry shortly");
|
|
18609
|
+
}
|
|
18610
|
+
const change = utxo.amount - amountIn;
|
|
18611
|
+
const changeUtxo = change > 0n ? new Utxo({ amount: change, mint: mintIn }) : null;
|
|
18612
|
+
const encryptedOutput1 = changeUtxo && encryptKey ? encryptNoteOutput(encryptKey, changeUtxo) : new Uint8Array();
|
|
18613
|
+
const encryptedOutput2 = new Uint8Array();
|
|
18614
|
+
const outKeypair = VeilixKeypair.random();
|
|
18615
|
+
const outBlinding = randomFieldElement();
|
|
18616
|
+
const encryptedNote = encryptKey ? encryptSwapNoteOutput(encryptKey, outKeypair, outBlinding) : new Uint8Array();
|
|
18617
|
+
const relayerKey = new PublicKey(relayer.value);
|
|
18618
|
+
const hash = await swapExtDataHash({
|
|
18619
|
+
mintIn,
|
|
18620
|
+
mintOut,
|
|
18621
|
+
relayer: relayerKey,
|
|
18622
|
+
amountIn,
|
|
18623
|
+
fee,
|
|
18624
|
+
minAmountOut,
|
|
18625
|
+
outPubkey: outKeypair.pubKey,
|
|
18626
|
+
outBlinding,
|
|
18627
|
+
encryptedOutput1,
|
|
18628
|
+
encryptedOutput2,
|
|
18629
|
+
encryptedNote
|
|
18630
|
+
});
|
|
18631
|
+
const proved = await withCircuitArtifacts(
|
|
18632
|
+
options.circuitArtifacts,
|
|
18633
|
+
(artifacts) => proveTransaction({
|
|
18634
|
+
tree,
|
|
18635
|
+
inputs: [utxo],
|
|
18636
|
+
outputs: changeUtxo ? [changeUtxo] : [],
|
|
18637
|
+
ext: {
|
|
18638
|
+
mint: mintIn,
|
|
18639
|
+
recipient: PublicKey.default,
|
|
18640
|
+
relayer: relayerKey,
|
|
18641
|
+
extAmount: -amountIn,
|
|
18642
|
+
fee,
|
|
18643
|
+
encryptedOutput1,
|
|
18644
|
+
encryptedOutput2
|
|
18645
|
+
},
|
|
18646
|
+
extDataHashOverride: hash,
|
|
18647
|
+
circuit: artifacts
|
|
18648
|
+
})
|
|
18649
|
+
);
|
|
18650
|
+
const { proof } = proved;
|
|
18651
|
+
const payload = {
|
|
18652
|
+
proof: hex(proof.proof),
|
|
18653
|
+
root: hex(proof.root),
|
|
18654
|
+
inputNullifiers: [hex(proof.inputNullifiers[0]), hex(proof.inputNullifiers[1])],
|
|
18655
|
+
outputCommitments: [hex(proof.outputCommitments[0]), hex(proof.outputCommitments[1])],
|
|
18656
|
+
...mintIn ? { mintIn: mintIn.toBase58() } : {},
|
|
18657
|
+
...mintOut ? { mintOut: mintOut.toBase58() } : {},
|
|
18658
|
+
amountIn: amountIn.toString(),
|
|
18659
|
+
fee: fee.toString(),
|
|
18660
|
+
minAmountOut: minAmountOut.toString(),
|
|
18661
|
+
outPubkey: hex(bigintToBytes32(outKeypair.pubKey)),
|
|
18662
|
+
outBlinding: hex(bigintToBytes32(outBlinding)),
|
|
18663
|
+
relayer: relayerKey.toBase58(),
|
|
18664
|
+
encryptedOutput1: hex(encryptedOutput1),
|
|
18665
|
+
encryptedOutput2: hex(encryptedOutput2),
|
|
18666
|
+
encryptedNote: hex(encryptedNote)
|
|
18667
|
+
};
|
|
18668
|
+
return {
|
|
18669
|
+
payload,
|
|
18670
|
+
relayerUrl: quote.relayerUrl,
|
|
18671
|
+
quote,
|
|
18672
|
+
amountIn,
|
|
18673
|
+
fee,
|
|
18674
|
+
minAmountOut,
|
|
18675
|
+
changeNote: changeUtxo ? encodeNote(changeUtxo) : null,
|
|
18676
|
+
output: {
|
|
18677
|
+
mint: mintKey(mintOut),
|
|
18678
|
+
privKey: outKeypair.privKey.toString(),
|
|
18679
|
+
blinding: outBlinding.toString()
|
|
18680
|
+
},
|
|
18681
|
+
nullifiers: [...payload.inputNullifiers]
|
|
18682
|
+
};
|
|
18683
|
+
}
|
|
18684
|
+
async function pollSwapJob(relayerUrl, jobId, maxWaitMs) {
|
|
18685
|
+
const start = Date.now();
|
|
18686
|
+
while (Date.now() - start < maxWaitMs) {
|
|
18687
|
+
const res = await httpFetch(`${relayerUrl}/v1/jobs/${encodeURIComponent(jobId)}`, {
|
|
18688
|
+
headers: { Accept: "application/json" }
|
|
18689
|
+
});
|
|
18690
|
+
const job = await res.json().catch(() => ({}));
|
|
18691
|
+
if (!res.ok) throw new Error(job.error || "Failed to poll relayer job");
|
|
18692
|
+
if (job.status === "CONFIRMED" || job.status === "FAILED") return job;
|
|
18693
|
+
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
18694
|
+
}
|
|
18695
|
+
throw new Error("Swap timed out");
|
|
18696
|
+
}
|
|
18697
|
+
function swapOutputNote(output, result) {
|
|
18698
|
+
const utxo = new Utxo({
|
|
18699
|
+
amount: BigInt(result.amountOut),
|
|
18700
|
+
keypair: VeilixKeypair.fromPrivateKey(output.privKey),
|
|
18701
|
+
blinding: BigInt(output.blinding),
|
|
18702
|
+
mint: output.mint ? new PublicKey(output.mint) : null,
|
|
18703
|
+
index: result.outputIndex
|
|
18704
|
+
});
|
|
18705
|
+
if (toHex32(utxo.commitment()) !== toHex32(BigInt(result.outputCommitment))) {
|
|
18706
|
+
throw new Error("veilix-sdk: swapped note does not match the on-chain commitment");
|
|
18707
|
+
}
|
|
18708
|
+
return encodeNote(utxo);
|
|
18709
|
+
}
|
|
18710
|
+
async function submitSwapPayload(bundle) {
|
|
18711
|
+
const res = await httpFetch(`${bundle.relayerUrl}/v1/veilixSwap`, {
|
|
18712
|
+
method: "POST",
|
|
18713
|
+
headers: { "Content-Type": "application/json" },
|
|
18714
|
+
body: JSON.stringify(bundle.payload)
|
|
18715
|
+
});
|
|
18716
|
+
const body = await res.json().catch(() => ({}));
|
|
18717
|
+
if (!res.ok || !body.id) {
|
|
18718
|
+
throw new Error(body.error || "Swap submission failed");
|
|
18719
|
+
}
|
|
18720
|
+
const job = await pollSwapJob(bundle.relayerUrl, body.id, SWAP_MAX_WAIT_MS);
|
|
18721
|
+
const base = {
|
|
18722
|
+
changeNote: bundle.changeNote,
|
|
18723
|
+
amountIn: bundle.amountIn.toString(),
|
|
18724
|
+
fee: bundle.fee.toString(),
|
|
18725
|
+
minAmountOut: bundle.minAmountOut.toString()
|
|
18726
|
+
};
|
|
18727
|
+
if (job.status === "FAILED") {
|
|
18728
|
+
return {
|
|
18729
|
+
...base,
|
|
18730
|
+
txHash: job.txHash ?? "",
|
|
18731
|
+
status: "failed",
|
|
18732
|
+
error: job.failedReason || "Swap failed",
|
|
18733
|
+
// A failed swap spends nothing: the original note is still valid.
|
|
18734
|
+
outputNote: null,
|
|
18735
|
+
changeNote: null,
|
|
18736
|
+
amountOut: null
|
|
18737
|
+
};
|
|
18738
|
+
}
|
|
18739
|
+
if (!job.txHash || !job.swapResult) {
|
|
18740
|
+
throw new Error("Swap confirmed but the relayer did not report the swapped note");
|
|
18741
|
+
}
|
|
18742
|
+
return {
|
|
18743
|
+
...base,
|
|
18744
|
+
txHash: job.txHash,
|
|
18745
|
+
status: "success",
|
|
18746
|
+
outputNote: swapOutputNote(bundle.output, job.swapResult),
|
|
18747
|
+
amountOut: job.swapResult.amountOut
|
|
18748
|
+
};
|
|
18749
|
+
}
|
|
18750
|
+
async function executeSwap(params) {
|
|
18751
|
+
return submitSwapPayload(await buildSwapPayload(params));
|
|
18752
|
+
}
|
|
17496
18753
|
|
|
17497
18754
|
// src/withdraw/assets.ts
|
|
17498
18755
|
var TOKEN_UNITS = {
|
|
@@ -17616,6 +18873,8 @@ var SEND_OPTIONS = { skipPreflight: false, maxRetries: 3 };
|
|
|
17616
18873
|
var SUBMIT_MAX_PROOFS = 8;
|
|
17617
18874
|
var NOTE_INDEX_TIMEOUT_MS = 12e4;
|
|
17618
18875
|
var NOTE_INDEX_POLL_MS = 4e3;
|
|
18876
|
+
var SEND_ATTEMPTS = 4;
|
|
18877
|
+
var SEND_RETRY_MS = 2e3;
|
|
17619
18878
|
function sleep(ms) {
|
|
17620
18879
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
17621
18880
|
}
|
|
@@ -17637,7 +18896,18 @@ async function signTransactions(wallet, transactions) {
|
|
|
17637
18896
|
}
|
|
17638
18897
|
async function sendAndConfirm(signed) {
|
|
17639
18898
|
const { connection } = getConfig();
|
|
17640
|
-
const
|
|
18899
|
+
const raw = signed.serialize();
|
|
18900
|
+
let signature;
|
|
18901
|
+
for (let attempt = 1; signature === void 0; attempt++) {
|
|
18902
|
+
try {
|
|
18903
|
+
signature = await connection.sendRawTransaction(raw, SEND_OPTIONS);
|
|
18904
|
+
} catch (error) {
|
|
18905
|
+
if (attempt >= SEND_ATTEMPTS || !/blockhash not found/i.test(errorMessage(error))) {
|
|
18906
|
+
throw error;
|
|
18907
|
+
}
|
|
18908
|
+
await sleep(SEND_RETRY_MS);
|
|
18909
|
+
}
|
|
18910
|
+
}
|
|
17641
18911
|
const { value } = await connection.confirmTransaction(signature, "confirmed");
|
|
17642
18912
|
if (value.err) {
|
|
17643
18913
|
throw new Error(`Deposit transaction failed: ${JSON.stringify(value.err)}`);
|
|
@@ -17683,6 +18953,7 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
17683
18953
|
const { wallet, network, relayers, encryptKey } = getConfig();
|
|
17684
18954
|
const sender = wallet.publicKey;
|
|
17685
18955
|
const onChainBackup = options.onChainBackup ?? !!encryptKey;
|
|
18956
|
+
const sealKey = onChainBackup ? encryptKey ?? requireEncryptKey() : void 0;
|
|
17686
18957
|
const prepared = prepareDeposits(items);
|
|
17687
18958
|
result.notes = prepared.map((deposit) => deposit.note);
|
|
17688
18959
|
const circuitArtifacts = await prepareWithdrawCircuitArtifacts();
|
|
@@ -17693,7 +18964,8 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
17693
18964
|
senderPublicKey: sender,
|
|
17694
18965
|
note: deposit.note,
|
|
17695
18966
|
onChainBackup,
|
|
17696
|
-
circuitArtifacts
|
|
18967
|
+
circuitArtifacts,
|
|
18968
|
+
...sealKey ? { encryptKey: sealKey } : {}
|
|
17697
18969
|
});
|
|
17698
18970
|
} catch (error) {
|
|
17699
18971
|
result.depositFailed.push(toDepositFailure(deposit, error));
|
|
@@ -17704,6 +18976,10 @@ async function executeVeilixTransfer(items, options = {}) {
|
|
|
17704
18976
|
result.error = true;
|
|
17705
18977
|
return result;
|
|
17706
18978
|
}
|
|
18979
|
+
const { blockhash } = await getConfig().connection.getLatestBlockhash();
|
|
18980
|
+
toSend.forEach((deposit) => {
|
|
18981
|
+
deposit.tx.message.recentBlockhash = blockhash;
|
|
18982
|
+
});
|
|
17707
18983
|
const signed = await signTransactions(wallet, toSend.map((deposit) => deposit.tx));
|
|
17708
18984
|
if (options.downloadNotes ?? true) {
|
|
17709
18985
|
downloadNotesCsv(toSend.map((deposit) => deposit.note));
|
|
@@ -17807,7 +19083,7 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
17807
19083
|
try {
|
|
17808
19084
|
return fn();
|
|
17809
19085
|
} finally {
|
|
17810
|
-
popRuntimeContext();
|
|
19086
|
+
popRuntimeContext(this.config);
|
|
17811
19087
|
}
|
|
17812
19088
|
}
|
|
17813
19089
|
async runAsync(fn) {
|
|
@@ -17815,7 +19091,7 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
17815
19091
|
try {
|
|
17816
19092
|
return await fn();
|
|
17817
19093
|
} finally {
|
|
17818
|
-
popRuntimeContext();
|
|
19094
|
+
popRuntimeContext(this.config);
|
|
17819
19095
|
}
|
|
17820
19096
|
}
|
|
17821
19097
|
// ── Config ───────────────────────────────────────────────────────────
|
|
@@ -17933,6 +19209,26 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
17933
19209
|
submitWithdrawPayload(bundle) {
|
|
17934
19210
|
return this.runAsync(() => submitWithdrawPayload(bundle));
|
|
17935
19211
|
}
|
|
19212
|
+
// ── Private swap ─────────────────────────────────────────────────────
|
|
19213
|
+
/** Fee and expected output of swapping `amountIn` of `mintIn` into `mintOut`. */
|
|
19214
|
+
getSwapQuote(params) {
|
|
19215
|
+
return this.runAsync(() => getSwapQuote(params));
|
|
19216
|
+
}
|
|
19217
|
+
/**
|
|
19218
|
+
* Swap a note of asset A into a new shielded note of asset B (`mintOut`, `null` for
|
|
19219
|
+
* SOL) through a relayer and an allowlisted DEX. Funds never leave the pool
|
|
19220
|
+
* unshielded. Returns the asset-B note and any asset-A change note.
|
|
19221
|
+
*/
|
|
19222
|
+
swap(params) {
|
|
19223
|
+
return this.runAsync(() => executeSwap(params));
|
|
19224
|
+
}
|
|
19225
|
+
/** Prove a swap without submitting it (see {@link submitSwapPayload}). */
|
|
19226
|
+
buildSwapPayload(params, options) {
|
|
19227
|
+
return this.runAsync(() => buildSwapPayload(params, options));
|
|
19228
|
+
}
|
|
19229
|
+
submitSwapPayload(bundle) {
|
|
19230
|
+
return this.runAsync(() => submitSwapPayload(bundle));
|
|
19231
|
+
}
|
|
17936
19232
|
/**
|
|
17937
19233
|
* Private transfer: deposit one note per item, then withdraw each note in full
|
|
17938
19234
|
* to its recipient through the indexer submission queue.
|
|
@@ -18044,15 +19340,15 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
18044
19340
|
* Accepts a frontend wallet adapter (`signMessage`) or a backend {@link Keypair}.
|
|
18045
19341
|
*/
|
|
18046
19342
|
async getEncryptionKey(wallet) {
|
|
18047
|
-
const
|
|
18048
|
-
this.config.encryptKey =
|
|
18049
|
-
return
|
|
19343
|
+
const key2 = await getEncryptionKey(wallet);
|
|
19344
|
+
this.config.encryptKey = key2;
|
|
19345
|
+
return key2;
|
|
18050
19346
|
}
|
|
18051
|
-
encryptData(
|
|
18052
|
-
return encryptData(
|
|
19347
|
+
encryptData(key2, plaintext) {
|
|
19348
|
+
return encryptData(key2, plaintext);
|
|
18053
19349
|
}
|
|
18054
|
-
decryptData(
|
|
18055
|
-
return decryptData(
|
|
19350
|
+
decryptData(key2, combined) {
|
|
19351
|
+
return decryptData(key2, combined);
|
|
18056
19352
|
}
|
|
18057
19353
|
// ── Utilities ────────────────────────────────────────────────────────
|
|
18058
19354
|
parseAmountToBaseUnits(amount, decimals) {
|
|
@@ -18090,6 +19386,6 @@ var VeilixSDK = class _VeilixSDK {
|
|
|
18090
19386
|
* @license MIT
|
|
18091
19387
|
*/
|
|
18092
19388
|
|
|
18093
|
-
export { FIELD_SIZE, MALICIOUS_RECIPIENT_ERROR, NOTE_PREFIX, TREE_LEVELS, Utxo, VeilixKeypair, VeilixSDK, WITHDRAW_CIRCUIT_WASM, WITHDRAW_CIRCUIT_ZKEY, ZERO_LEAF, buildMerkleTree, decodeNote, decryptData, decryptNoteOutput, VeilixSDK as default, encodeNote, encryptData, encryptNoteOutput, extDataHash, formatBaseUnits, formatNoteForDisplay, getQuote, isLegacyNote, mintToField, parseAmountToBaseUnits, parseSecretNote, prepareCircuitArtifacts, proveTransaction, resolveCircuitPathsFromBase, resolveNpmCdnCircuitBase };
|
|
19389
|
+
export { CPMM_PROGRAM_IDS, FIELD_SIZE, MALICIOUS_RECIPIENT_ERROR, NOTE_PREFIX, SWAP_DOMAIN, TREE_LEVELS, Utxo, VeilixKeypair, VeilixSDK, WITHDRAW_CIRCUIT_WASM, WITHDRAW_CIRCUIT_ZKEY, ZERO_LEAF, buildMerkleTree, decodeNote, decryptData, decryptNoteOutput, VeilixSDK as default, encodeNote, encryptData, encryptNoteOutput, encryptSwapNoteOutput, extDataHash, formatBaseUnits, formatNoteForDisplay, getQuote, isLegacyNote, mintToField, parseAmountToBaseUnits, parseSecretNote, prepareCircuitArtifacts, proveTransaction, quoteCpmm, resolveCircuitPathsFromBase, resolveNpmCdnCircuitBase, swapExtDataHash, swapOutputNote };
|
|
18094
19390
|
//# sourceMappingURL=index.js.map
|
|
18095
19391
|
//# sourceMappingURL=index.js.map
|