@luxfi/exchange 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/__tests__/use-private-teleport.test.d.ts +2 -0
- package/dist/bridge/__tests__/use-private-teleport.test.d.ts.map +1 -0
- package/dist/bridge/__tests__/use-private-teleport.test.js +272 -0
- package/dist/bridge/cross-chain-store.d.ts +57 -0
- package/dist/bridge/cross-chain-store.d.ts.map +1 -0
- package/dist/bridge/cross-chain-store.js +158 -0
- package/dist/bridge/index.d.ts +78 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +79 -0
- package/dist/bridge/private-teleport-types.d.ts +634 -0
- package/dist/bridge/private-teleport-types.d.ts.map +1 -0
- package/dist/bridge/private-teleport-types.js +308 -0
- package/dist/bridge/types.d.ts +84 -0
- package/dist/bridge/types.d.ts.map +1 -0
- package/dist/bridge/types.js +37 -0
- package/dist/bridge/use-cross-chain-mint.d.ts +34 -0
- package/dist/bridge/use-cross-chain-mint.d.ts.map +1 -0
- package/dist/bridge/use-cross-chain-mint.js +228 -0
- package/dist/bridge/use-private-teleport.d.ts +69 -0
- package/dist/bridge/use-private-teleport.d.ts.map +1 -0
- package/dist/bridge/use-private-teleport.js +666 -0
- package/dist/chains/index.d.ts +6 -0
- package/dist/chains/index.d.ts.map +1 -0
- package/dist/chains/index.js +6 -0
- package/dist/chains/lux.d.ts +508 -0
- package/dist/chains/lux.d.ts.map +1 -0
- package/dist/chains/lux.js +131 -0
- package/dist/contracts/abis/dex-swap-router.d.ts +137 -0
- package/dist/contracts/abis/dex-swap-router.d.ts.map +1 -0
- package/dist/contracts/abis/dex-swap-router.js +95 -0
- package/dist/contracts/abis/erc20.d.ts +136 -0
- package/dist/contracts/abis/erc20.d.ts.map +1 -0
- package/dist/contracts/abis/erc20.js +96 -0
- package/dist/contracts/abis/index.d.ts +15 -0
- package/dist/contracts/abis/index.d.ts.map +1 -0
- package/dist/contracts/abis/index.js +15 -0
- package/dist/contracts/abis/nft-position-manager.d.ts +235 -0
- package/dist/contracts/abis/nft-position-manager.d.ts.map +1 -0
- package/dist/contracts/abis/nft-position-manager.js +146 -0
- package/dist/contracts/abis/pool-manager.d.ts +315 -0
- package/dist/contracts/abis/pool-manager.d.ts.map +1 -0
- package/dist/contracts/abis/pool-manager.js +191 -0
- package/dist/contracts/abis/quoter-v2.d.ts +103 -0
- package/dist/contracts/abis/quoter-v2.d.ts.map +1 -0
- package/dist/contracts/abis/quoter-v2.js +68 -0
- package/dist/contracts/abis/swap-router.d.ts +119 -0
- package/dist/contracts/abis/swap-router.d.ts.map +1 -0
- package/dist/contracts/abis/swap-router.js +75 -0
- package/dist/contracts/abis/uniswap-v2-factory.d.ts +75 -0
- package/dist/contracts/abis/uniswap-v2-factory.d.ts.map +1 -0
- package/dist/contracts/abis/uniswap-v2-factory.js +49 -0
- package/dist/contracts/abis/uniswap-v2-pair.d.ts +119 -0
- package/dist/contracts/abis/uniswap-v2-pair.d.ts.map +1 -0
- package/dist/contracts/abis/uniswap-v2-pair.js +85 -0
- package/dist/contracts/abis/uniswap-v2-router.d.ts +249 -0
- package/dist/contracts/abis/uniswap-v2-router.d.ts.map +1 -0
- package/dist/contracts/abis/uniswap-v2-router.js +146 -0
- package/dist/contracts/abis/uniswap-v3-factory.d.ts +77 -0
- package/dist/contracts/abis/uniswap-v3-factory.d.ts.map +1 -0
- package/dist/contracts/abis/uniswap-v3-factory.js +45 -0
- package/dist/contracts/abis/uniswap-v3-pool.d.ts +128 -0
- package/dist/contracts/abis/uniswap-v3-pool.d.ts.map +1 -0
- package/dist/contracts/abis/uniswap-v3-pool.js +81 -0
- package/dist/contracts/addresses.d.ts +141 -0
- package/dist/contracts/addresses.d.ts.map +1 -0
- package/dist/contracts/addresses.js +108 -0
- package/dist/contracts/index.d.ts +6 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +5 -0
- package/dist/dex/balance-delta.d.ts +27 -0
- package/dist/dex/balance-delta.d.ts.map +1 -0
- package/dist/dex/balance-delta.js +45 -0
- package/dist/dex/index.d.ts +7 -0
- package/dist/dex/index.d.ts.map +1 -0
- package/dist/dex/index.js +6 -0
- package/dist/dex/pool-key.d.ts +19 -0
- package/dist/dex/pool-key.d.ts.map +1 -0
- package/dist/dex/pool-key.js +44 -0
- package/dist/dex/types.d.ts +71 -0
- package/dist/dex/types.d.ts.map +1 -0
- package/dist/dex/types.js +28 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/use-pools.d.ts +24 -0
- package/dist/hooks/use-pools.d.ts.map +1 -0
- package/dist/hooks/use-pools.js +85 -0
- package/dist/hooks/use-positions.d.ts +17 -0
- package/dist/hooks/use-positions.d.ts.map +1 -0
- package/dist/hooks/use-positions.js +65 -0
- package/dist/hooks/use-swap-quote.d.ts +19 -0
- package/dist/hooks/use-swap-quote.d.ts.map +1 -0
- package/dist/hooks/use-swap-quote.js +54 -0
- package/dist/hooks/use-swap.d.ts +22 -0
- package/dist/hooks/use-swap.d.ts.map +1 -0
- package/dist/hooks/use-swap.js +46 -0
- package/dist/hooks/use-token-allowance.d.ts +27 -0
- package/dist/hooks/use-token-allowance.d.ts.map +1 -0
- package/dist/hooks/use-token-allowance.js +59 -0
- package/dist/hooks/use-token-balance.d.ts +17 -0
- package/dist/hooks/use-token-balance.d.ts.map +1 -0
- package/dist/hooks/use-token-balance.js +58 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/stores/index.d.ts +7 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +6 -0
- package/dist/stores/settings-store.d.ts +25 -0
- package/dist/stores/settings-store.d.ts.map +1 -0
- package/dist/stores/settings-store.js +16 -0
- package/dist/stores/swap-store.d.ts +38 -0
- package/dist/stores/swap-store.d.ts.map +1 -0
- package/dist/stores/swap-store.js +58 -0
- package/dist/stores/token-store.d.ts +21 -0
- package/dist/stores/token-store.d.ts.map +1 -0
- package/dist/stores/token-store.js +32 -0
- package/dist/tokens/index.d.ts +65 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +185 -0
- package/package.json +78 -0
- package/src/chains/index.ts +21 -0
- package/src/chains/lux.ts +141 -0
- package/src/contracts/abis/dex-swap-router.ts +98 -0
- package/src/contracts/abis/erc20.ts +96 -0
- package/src/contracts/abis/index.ts +17 -0
- package/src/contracts/abis/nft-position-manager.ts +146 -0
- package/src/contracts/abis/pool-manager.ts +198 -0
- package/src/contracts/abis/quoter-v2.ts +68 -0
- package/src/contracts/abis/swap-router.ts +75 -0
- package/src/contracts/abis/uniswap-v2-factory.ts +49 -0
- package/src/contracts/abis/uniswap-v2-pair.ts +85 -0
- package/src/contracts/abis/uniswap-v2-router.ts +146 -0
- package/src/contracts/abis/uniswap-v3-factory.ts +45 -0
- package/src/contracts/abis/uniswap-v3-pool.ts +81 -0
- package/src/contracts/addresses.ts +128 -0
- package/src/contracts/index.ts +14 -0
- package/src/dex/balance-delta.ts +52 -0
- package/src/dex/index.ts +7 -0
- package/src/dex/pool-key.ts +62 -0
- package/src/dex/types.ts +87 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/use-pools.ts +116 -0
- package/src/hooks/use-positions.ts +90 -0
- package/src/hooks/use-swap-quote.ts +81 -0
- package/src/hooks/use-swap.ts +64 -0
- package/src/hooks/use-token-allowance.ts +74 -0
- package/src/hooks/use-token-balance.ts +71 -0
- package/src/index.ts +31 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/settings-store.ts +54 -0
- package/src/stores/swap-store.ts +112 -0
- package/src/stores/token-store.ts +62 -0
- package/src/tokens/index.ts +220 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private Teleport Types
|
|
3
|
+
*
|
|
4
|
+
* Types for cross-chain private teleportation using Z-Chain privacy layer
|
|
5
|
+
* Flow: XVM UTXO → Warp → ZNote (shielded) → Z-Chain AMM (private swap) → C-Chain/XVM
|
|
6
|
+
*/
|
|
7
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
8
|
+
// TELEPORT STATE
|
|
9
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
10
|
+
/** Teleport state enum (matches contract) */
|
|
11
|
+
export var TeleportState;
|
|
12
|
+
(function (TeleportState) {
|
|
13
|
+
TeleportState[TeleportState["INITIATED"] = 0] = "INITIATED";
|
|
14
|
+
TeleportState[TeleportState["SHIELDED"] = 1] = "SHIELDED";
|
|
15
|
+
TeleportState[TeleportState["SWAP_COMPLETE"] = 2] = "SWAP_COMPLETE";
|
|
16
|
+
TeleportState[TeleportState["EXPORTED"] = 3] = "EXPORTED";
|
|
17
|
+
TeleportState[TeleportState["COMPLETED"] = 4] = "COMPLETED";
|
|
18
|
+
TeleportState[TeleportState["CANCELLED"] = 5] = "CANCELLED";
|
|
19
|
+
TeleportState[TeleportState["EXPIRED"] = 6] = "EXPIRED";
|
|
20
|
+
})(TeleportState || (TeleportState = {}));
|
|
21
|
+
export const DEFAULT_PRIVATE_TELEPORT_CONFIG = {
|
|
22
|
+
networkId: 1,
|
|
23
|
+
teleportContract: '0x0000000000000000000000000000000000000420',
|
|
24
|
+
zNoteContract: '0x0000000000000000000000000000000000000421',
|
|
25
|
+
zChainAMMContract: '0x0000000000000000000000000000000000000422',
|
|
26
|
+
privateBridgeContract: '0x0000000000000000000000000000000000000423',
|
|
27
|
+
warpPrecompile: '0x0200000000000000000000000000000000000005',
|
|
28
|
+
defaultDeadline: 3600,
|
|
29
|
+
minShieldBlocks: 5,
|
|
30
|
+
};
|
|
31
|
+
export const LUX_CHAINS = {
|
|
32
|
+
xChain: {
|
|
33
|
+
chainId: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
34
|
+
name: 'X-Chain (XVM)',
|
|
35
|
+
type: 'xvm',
|
|
36
|
+
},
|
|
37
|
+
cChain: {
|
|
38
|
+
chainId: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
39
|
+
name: 'C-Chain (EVM)',
|
|
40
|
+
type: 'cchain',
|
|
41
|
+
},
|
|
42
|
+
zChain: {
|
|
43
|
+
chainId: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
44
|
+
name: 'Z-Chain (Privacy)',
|
|
45
|
+
type: 'zchain',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
49
|
+
// CONTRACT ABIS (PARTIAL)
|
|
50
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
51
|
+
export const PRIVATE_TELEPORT_ABI = [
|
|
52
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
53
|
+
// INITIATE & SWAP
|
|
54
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
55
|
+
{
|
|
56
|
+
name: 'initiateTeleport',
|
|
57
|
+
type: 'function',
|
|
58
|
+
stateMutability: 'nonpayable',
|
|
59
|
+
inputs: [
|
|
60
|
+
{ name: 'warpMessage', type: 'bytes' },
|
|
61
|
+
{ name: 'commitment', type: 'bytes32' },
|
|
62
|
+
{ name: 'encryptedAmount', type: 'bytes32' },
|
|
63
|
+
{ name: 'recipient', type: 'address' },
|
|
64
|
+
{ name: 'destChain', type: 'bytes32' },
|
|
65
|
+
{ name: 'destAsset', type: 'bytes32' },
|
|
66
|
+
{ name: 'privateSwap', type: 'bool' },
|
|
67
|
+
],
|
|
68
|
+
outputs: [{ name: 'teleportId', type: 'bytes32' }],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'executePrivateSwap',
|
|
72
|
+
type: 'function',
|
|
73
|
+
stateMutability: 'nonpayable',
|
|
74
|
+
inputs: [
|
|
75
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
76
|
+
{ name: 'poolId', type: 'bytes32' },
|
|
77
|
+
{ name: 'minOutput', type: 'bytes32' },
|
|
78
|
+
{ name: 'proof', type: 'bytes' },
|
|
79
|
+
],
|
|
80
|
+
outputs: [],
|
|
81
|
+
},
|
|
82
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
83
|
+
// EXPORT (UNSHIELD)
|
|
84
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
85
|
+
{
|
|
86
|
+
name: 'exportToDestination',
|
|
87
|
+
type: 'function',
|
|
88
|
+
stateMutability: 'nonpayable',
|
|
89
|
+
inputs: [
|
|
90
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
91
|
+
{ name: 'rangeProof', type: 'bytes' },
|
|
92
|
+
{ name: 'nullifier', type: 'bytes32' },
|
|
93
|
+
{ name: 'merkleProof', type: 'bytes32[]' },
|
|
94
|
+
],
|
|
95
|
+
outputs: [],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'unshieldToXChain',
|
|
99
|
+
type: 'function',
|
|
100
|
+
stateMutability: 'nonpayable',
|
|
101
|
+
inputs: [
|
|
102
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
103
|
+
{ name: 'destinationAddress', type: 'bytes' },
|
|
104
|
+
{ name: 'amount', type: 'uint64' },
|
|
105
|
+
{ name: 'nullifier', type: 'bytes32' },
|
|
106
|
+
{ name: 'merkleProof', type: 'bytes32[]' },
|
|
107
|
+
{ name: 'rangeProof', type: 'bytes' },
|
|
108
|
+
],
|
|
109
|
+
outputs: [{ name: 'exportTxId', type: 'bytes32' }],
|
|
110
|
+
},
|
|
111
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
112
|
+
// PRIVATE TRANSFERS (STAY SHIELDED)
|
|
113
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
114
|
+
{
|
|
115
|
+
name: 'privateTransferToRecipient',
|
|
116
|
+
type: 'function',
|
|
117
|
+
stateMutability: 'nonpayable',
|
|
118
|
+
inputs: [
|
|
119
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
120
|
+
{ name: 'recipientCommitment', type: 'bytes32' },
|
|
121
|
+
{ name: 'encryptedNote', type: 'bytes' },
|
|
122
|
+
{ name: 'nullifier', type: 'bytes32' },
|
|
123
|
+
{ name: 'merkleProof', type: 'bytes32[]' },
|
|
124
|
+
{ name: 'transferProof', type: 'bytes' },
|
|
125
|
+
],
|
|
126
|
+
outputs: [{ name: 'newNoteIndex', type: 'uint256' }],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'splitAndTransfer',
|
|
130
|
+
type: 'function',
|
|
131
|
+
stateMutability: 'nonpayable',
|
|
132
|
+
inputs: [
|
|
133
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
134
|
+
{ name: 'outputs', type: 'tuple[]', components: [
|
|
135
|
+
{ name: 'commitment', type: 'bytes32' },
|
|
136
|
+
{ name: 'encryptedNote', type: 'bytes' },
|
|
137
|
+
{ name: 'encryptedMemo', type: 'bytes' },
|
|
138
|
+
] },
|
|
139
|
+
{ name: 'nullifier', type: 'bytes32' },
|
|
140
|
+
{ name: 'merkleProof', type: 'bytes32[]' },
|
|
141
|
+
{ name: 'splitProof', type: 'bytes' },
|
|
142
|
+
],
|
|
143
|
+
outputs: [{ name: 'noteIndices', type: 'uint256[]' }],
|
|
144
|
+
},
|
|
145
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
146
|
+
// COMPLETE & CANCEL
|
|
147
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
148
|
+
{
|
|
149
|
+
name: 'completeTeleport',
|
|
150
|
+
type: 'function',
|
|
151
|
+
stateMutability: 'nonpayable',
|
|
152
|
+
inputs: [
|
|
153
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
154
|
+
{ name: 'warpConfirmation', type: 'bytes' },
|
|
155
|
+
],
|
|
156
|
+
outputs: [],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'cancelTeleport',
|
|
160
|
+
type: 'function',
|
|
161
|
+
stateMutability: 'nonpayable',
|
|
162
|
+
inputs: [{ name: 'teleportId', type: 'bytes32' }],
|
|
163
|
+
outputs: [],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'getTeleport',
|
|
167
|
+
type: 'function',
|
|
168
|
+
stateMutability: 'view',
|
|
169
|
+
inputs: [{ name: 'teleportId', type: 'bytes32' }],
|
|
170
|
+
outputs: [
|
|
171
|
+
{
|
|
172
|
+
name: '',
|
|
173
|
+
type: 'tuple',
|
|
174
|
+
components: [
|
|
175
|
+
{ name: 'teleportId', type: 'bytes32' },
|
|
176
|
+
{ name: 'state', type: 'uint8' },
|
|
177
|
+
{ name: 'sourceChain', type: 'bytes32' },
|
|
178
|
+
{ name: 'destChain', type: 'bytes32' },
|
|
179
|
+
{ name: 'sourceAsset', type: 'bytes32' },
|
|
180
|
+
{ name: 'destAsset', type: 'bytes32' },
|
|
181
|
+
{ name: 'noteCommitment', type: 'bytes32' },
|
|
182
|
+
{ name: 'encryptedAmount', type: 'bytes32' },
|
|
183
|
+
{ name: 'nullifierHash', type: 'bytes32' },
|
|
184
|
+
{ name: 'sender', type: 'address' },
|
|
185
|
+
{ name: 'recipient', type: 'address' },
|
|
186
|
+
{ name: 'deadline', type: 'uint256' },
|
|
187
|
+
{ name: 'createdBlock', type: 'uint256' },
|
|
188
|
+
{ name: 'privateSwap', type: 'bool' },
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'isComplete',
|
|
195
|
+
type: 'function',
|
|
196
|
+
stateMutability: 'view',
|
|
197
|
+
inputs: [{ name: 'teleportId', type: 'bytes32' }],
|
|
198
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'isExpired',
|
|
202
|
+
type: 'function',
|
|
203
|
+
stateMutability: 'view',
|
|
204
|
+
inputs: [{ name: 'teleportId', type: 'bytes32' }],
|
|
205
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
export const ZNOTE_ABI = [
|
|
209
|
+
{
|
|
210
|
+
name: 'importFromXChain',
|
|
211
|
+
type: 'function',
|
|
212
|
+
stateMutability: 'nonpayable',
|
|
213
|
+
inputs: [
|
|
214
|
+
{ name: 'commitment', type: 'bytes32' },
|
|
215
|
+
{ name: 'encryptedAmount', type: 'bytes32' },
|
|
216
|
+
{ name: 'assetId', type: 'bytes32' },
|
|
217
|
+
{ name: 'recipient', type: 'address' },
|
|
218
|
+
],
|
|
219
|
+
outputs: [{ name: 'noteIndex', type: 'uint256' }],
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: 'verifyMerkleProof',
|
|
223
|
+
type: 'function',
|
|
224
|
+
stateMutability: 'view',
|
|
225
|
+
inputs: [
|
|
226
|
+
{ name: 'proof', type: 'bytes32[]' },
|
|
227
|
+
{ name: 'commitment', type: 'bytes32' },
|
|
228
|
+
],
|
|
229
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'getMerkleProof',
|
|
233
|
+
type: 'function',
|
|
234
|
+
stateMutability: 'view',
|
|
235
|
+
inputs: [{ name: 'noteIndex', type: 'uint256' }],
|
|
236
|
+
outputs: [{ name: 'proof', type: 'bytes32[]' }],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: 'getNoteRoot',
|
|
240
|
+
type: 'function',
|
|
241
|
+
stateMutability: 'view',
|
|
242
|
+
inputs: [],
|
|
243
|
+
outputs: [{ name: '', type: 'bytes32' }],
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'getNote',
|
|
247
|
+
type: 'function',
|
|
248
|
+
stateMutability: 'view',
|
|
249
|
+
inputs: [{ name: 'commitment', type: 'bytes32' }],
|
|
250
|
+
outputs: [
|
|
251
|
+
{
|
|
252
|
+
name: '',
|
|
253
|
+
type: 'tuple',
|
|
254
|
+
components: [
|
|
255
|
+
{ name: 'commitment', type: 'bytes32' },
|
|
256
|
+
{ name: 'encryptedOwner', type: 'bytes' },
|
|
257
|
+
{ name: 'encryptedValue', type: 'bytes' },
|
|
258
|
+
{ name: 'assetId', type: 'bytes32' },
|
|
259
|
+
{ name: 'createdAt', type: 'uint64' },
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
export const ZCHAIN_AMM_ABI = [
|
|
266
|
+
{
|
|
267
|
+
name: 'swapEncrypted',
|
|
268
|
+
type: 'function',
|
|
269
|
+
stateMutability: 'nonpayable',
|
|
270
|
+
inputs: [
|
|
271
|
+
{ name: 'poolId', type: 'bytes32' },
|
|
272
|
+
{ name: 'encryptedAmount', type: 'bytes32' },
|
|
273
|
+
{ name: 'encryptedMinOutput', type: 'bytes32' },
|
|
274
|
+
{ name: 'recipient', type: 'address' },
|
|
275
|
+
],
|
|
276
|
+
outputs: [{ name: 'outputCommitment', type: 'bytes32' }],
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: 'verifySwapProof',
|
|
280
|
+
type: 'function',
|
|
281
|
+
stateMutability: 'view',
|
|
282
|
+
inputs: [
|
|
283
|
+
{ name: 'proof', type: 'bytes' },
|
|
284
|
+
{ name: 'commitment', type: 'bytes32' },
|
|
285
|
+
{ name: 'poolId', type: 'bytes32' },
|
|
286
|
+
],
|
|
287
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'getPool',
|
|
291
|
+
type: 'function',
|
|
292
|
+
stateMutability: 'view',
|
|
293
|
+
inputs: [{ name: 'poolId', type: 'bytes32' }],
|
|
294
|
+
outputs: [
|
|
295
|
+
{
|
|
296
|
+
name: '',
|
|
297
|
+
type: 'tuple',
|
|
298
|
+
components: [
|
|
299
|
+
{ name: 'poolId', type: 'bytes32' },
|
|
300
|
+
{ name: 'assetA', type: 'bytes32' },
|
|
301
|
+
{ name: 'assetB', type: 'bytes32' },
|
|
302
|
+
{ name: 'feeRate', type: 'uint16' },
|
|
303
|
+
{ name: 'active', type: 'bool' },
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
},
|
|
308
|
+
];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-chain bridge types for XVM ↔ C-Chain atomic swaps
|
|
3
|
+
*/
|
|
4
|
+
export type CrossChainMintStatus = 'idle' | 'initiating' | 'locking' | 'waiting_confirmation' | 'minting' | 'swapping' | 'complete' | 'failed' | 'cancelled';
|
|
5
|
+
export interface CrossChainMintRequest {
|
|
6
|
+
/** Source chain (XVM) asset ID */
|
|
7
|
+
sourceAsset: `0x${string}`;
|
|
8
|
+
/** Amount to bridge (in source chain decimals) */
|
|
9
|
+
amount: bigint;
|
|
10
|
+
/** Recipient address on C-Chain */
|
|
11
|
+
recipient: `0x${string}`;
|
|
12
|
+
/** Optional: target token on C-Chain (if swap desired) */
|
|
13
|
+
targetToken?: `0x${string}`;
|
|
14
|
+
/** Minimum amount to receive (slippage protection) */
|
|
15
|
+
minReceive?: bigint;
|
|
16
|
+
/** Deadline timestamp in seconds */
|
|
17
|
+
deadline: number;
|
|
18
|
+
}
|
|
19
|
+
export interface CrossChainMintState {
|
|
20
|
+
/** Unique swap ID from bridge */
|
|
21
|
+
swapId: `0x${string}` | null;
|
|
22
|
+
/** Current status of the mint operation */
|
|
23
|
+
status: CrossChainMintStatus;
|
|
24
|
+
/** Source transaction hash on X-Chain */
|
|
25
|
+
sourceTxHash: string | null;
|
|
26
|
+
/** Mint transaction hash on C-Chain */
|
|
27
|
+
mintTxHash: string | null;
|
|
28
|
+
/** Swap transaction hash (if target token specified) */
|
|
29
|
+
swapTxHash: string | null;
|
|
30
|
+
/** Error message if failed */
|
|
31
|
+
error: string | null;
|
|
32
|
+
/** Timestamp when operation started */
|
|
33
|
+
startedAt: number | null;
|
|
34
|
+
/** Timestamp when operation completed */
|
|
35
|
+
completedAt: number | null;
|
|
36
|
+
}
|
|
37
|
+
export interface SwapRoute {
|
|
38
|
+
tokenIn: `0x${string}`;
|
|
39
|
+
tokenOut: `0x${string}`;
|
|
40
|
+
poolFee: number;
|
|
41
|
+
tickSpacing: number;
|
|
42
|
+
hooks?: `0x${string}`;
|
|
43
|
+
}
|
|
44
|
+
export interface AtomicSwapConfig {
|
|
45
|
+
/** Network ID for Warp messages */
|
|
46
|
+
networkId: number;
|
|
47
|
+
/** XVM chain ID */
|
|
48
|
+
xvmChainId: `0x${string}`;
|
|
49
|
+
/** C-Chain ID */
|
|
50
|
+
cChainId: `0x${string}`;
|
|
51
|
+
/** Warp precompile address */
|
|
52
|
+
warpPrecompile: `0x${string}`;
|
|
53
|
+
/** Atomic swap bridge contract on C-Chain */
|
|
54
|
+
bridgeContract: `0x${string}`;
|
|
55
|
+
/** Default deadline in seconds */
|
|
56
|
+
defaultDeadline: number;
|
|
57
|
+
}
|
|
58
|
+
export declare const DEFAULT_SWAP_CONFIG: AtomicSwapConfig;
|
|
59
|
+
/**
|
|
60
|
+
* XVM asset mapping to C-Chain wrapped tokens
|
|
61
|
+
*/
|
|
62
|
+
export interface AssetMapping {
|
|
63
|
+
/** XVM asset ID */
|
|
64
|
+
xvmAssetId: `0x${string}`;
|
|
65
|
+
/** C-Chain wrapped token address */
|
|
66
|
+
wrappedToken: `0x${string}`;
|
|
67
|
+
/** Token symbol */
|
|
68
|
+
symbol: string;
|
|
69
|
+
/** Token decimals (always 6 for XVM) */
|
|
70
|
+
decimals: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Well-known asset mappings for Lux mainnet
|
|
74
|
+
*/
|
|
75
|
+
export declare const ASSET_MAPPINGS: AssetMapping[];
|
|
76
|
+
/**
|
|
77
|
+
* Get wrapped token address for an XVM asset
|
|
78
|
+
*/
|
|
79
|
+
export declare function getWrappedToken(xvmAssetId: `0x${string}`): `0x${string}` | null;
|
|
80
|
+
/**
|
|
81
|
+
* Get XVM asset ID for a wrapped token
|
|
82
|
+
*/
|
|
83
|
+
export declare function getXvmAsset(wrappedToken: `0x${string}`): `0x${string}` | null;
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,YAAY,GACZ,SAAS,GACT,sBAAsB,GACtB,SAAS,GACT,UAAU,GACV,UAAU,GACV,QAAQ,GACR,WAAW,CAAA;AAEf,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAA;IAC1B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAA;IACd,mCAAmC;IACnC,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;IAC3B,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,MAAM,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5B,2CAA2C;IAC3C,MAAM,EAAE,oBAAoB,CAAA;IAC5B,yCAAyC;IACzC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,uCAAuC;IACvC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,wDAAwD;IACxD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,uCAAuC;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,yCAAyC;IACzC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,mBAAmB;IACnB,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;IACzB,iBAAiB;IACjB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,8BAA8B;IAC9B,cAAc,EAAE,KAAK,MAAM,EAAE,CAAA;IAC7B,6CAA6C;IAC7C,cAAc,EAAE,KAAK,MAAM,EAAE,CAAA;IAC7B,kCAAkC;IAClC,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAOjC,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,mBAAmB;IACnB,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;IACzB,oCAAoC;IACpC,YAAY,EAAE,KAAK,MAAM,EAAE,CAAA;IAC3B,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EAQxC,CAAA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,MAAM,EAAE,GAAG,IAAI,CAG/E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,KAAK,MAAM,EAAE,GAAG,IAAI,CAK7E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-chain bridge types for XVM ↔ C-Chain atomic swaps
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_SWAP_CONFIG = {
|
|
5
|
+
networkId: 1,
|
|
6
|
+
xvmChainId: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
7
|
+
cChainId: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
8
|
+
warpPrecompile: '0x0200000000000000000000000000000000000005',
|
|
9
|
+
bridgeContract: '0x0000000000000000000000000000000000000410',
|
|
10
|
+
defaultDeadline: 3600, // 1 hour
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Well-known asset mappings for Lux mainnet
|
|
14
|
+
*/
|
|
15
|
+
export const ASSET_MAPPINGS = [
|
|
16
|
+
{
|
|
17
|
+
xvmAssetId: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
18
|
+
wrappedToken: '0x0000000000000000000000000000000000000001', // WLUX
|
|
19
|
+
symbol: 'WLUX',
|
|
20
|
+
decimals: 6,
|
|
21
|
+
},
|
|
22
|
+
// Add more mappings as tokens are registered
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Get wrapped token address for an XVM asset
|
|
26
|
+
*/
|
|
27
|
+
export function getWrappedToken(xvmAssetId) {
|
|
28
|
+
const mapping = ASSET_MAPPINGS.find((m) => m.xvmAssetId === xvmAssetId);
|
|
29
|
+
return mapping?.wrappedToken ?? null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get XVM asset ID for a wrapped token
|
|
33
|
+
*/
|
|
34
|
+
export function getXvmAsset(wrappedToken) {
|
|
35
|
+
const mapping = ASSET_MAPPINGS.find((m) => m.wrappedToken.toLowerCase() === wrappedToken.toLowerCase());
|
|
36
|
+
return mapping?.xvmAssetId ?? null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook for one-click cross-chain minting
|
|
3
|
+
*
|
|
4
|
+
* Enables users to mint wrapped tokens on C-Chain from X-Chain assets
|
|
5
|
+
* with a single transaction using Warp atomic swaps.
|
|
6
|
+
*/
|
|
7
|
+
import { type CrossChainStore } from './cross-chain-store';
|
|
8
|
+
import type { CrossChainMintRequest, CrossChainMintState, AtomicSwapConfig } from './types';
|
|
9
|
+
export interface UseCrossChainMintOptions {
|
|
10
|
+
/** Configuration overrides */
|
|
11
|
+
config?: Partial<AtomicSwapConfig>;
|
|
12
|
+
/** Poll interval for status updates (ms) */
|
|
13
|
+
pollInterval?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface UseCrossChainMintReturn {
|
|
16
|
+
/** Initiate a cross-chain mint */
|
|
17
|
+
mint: (request: Omit<CrossChainMintRequest, 'deadline'> & {
|
|
18
|
+
deadline?: number;
|
|
19
|
+
}) => Promise<string>;
|
|
20
|
+
/** Cancel a pending mint after deadline */
|
|
21
|
+
cancel: (swapId: string) => Promise<void>;
|
|
22
|
+
/** Current state of a mint by swap ID */
|
|
23
|
+
getMintState: (swapId: string) => CrossChainMintState | undefined;
|
|
24
|
+
/** All active mints */
|
|
25
|
+
activeMints: CrossChainStore['pendingMints'];
|
|
26
|
+
/** Recent completed mints */
|
|
27
|
+
recentMints: CrossChainStore['recentMints'];
|
|
28
|
+
/** Loading state */
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
/** Error message */
|
|
31
|
+
error: string | null;
|
|
32
|
+
}
|
|
33
|
+
export declare function useCrossChainMint(options?: UseCrossChainMintOptions): UseCrossChainMintReturn;
|
|
34
|
+
//# sourceMappingURL=use-cross-chain-mint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-cross-chain-mint.d.ts","sourceRoot":"","sources":["../../src/bridge/use-cross-chain-mint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EAGnB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAgBhB,MAAM,WAAW,wBAAwB;IACvC,8BAA8B;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAClC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IACnG,2CAA2C;IAC3C,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,yCAAyC;IACzC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,mBAAmB,GAAG,SAAS,CAAA;IACjE,uBAAuB;IACvB,WAAW,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IAC5C,6BAA6B;IAC7B,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;IAC3C,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,oBAAoB;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,uBAAuB,CAiPjG"}
|