Expanded solutions (10 new industries) and products (Compliance & Data section) to cover full docs.lux.financial capability surface.
233 lines
9.7 KiB
TypeScript
233 lines
9.7 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import {
|
|
getUrls,
|
|
rpcCall,
|
|
httpStatus,
|
|
} from './helpers'
|
|
|
|
const urls = getUrls()
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// DEX Smart Contract Verification — on-chain contract state queries
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Well-known Uniswap contract addresses (canonical deployments)
|
|
const V2_FACTORY = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'
|
|
const V2_ROUTER = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
|
|
const V3_FACTORY = '0x1F98431c8aD98523631AE4a59f267346ea31F984'
|
|
const V3_ROUTER = '0xE592427A0AEce92De3Edee1F18E0157C05861564'
|
|
const V3_QUOTER = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6'
|
|
|
|
// ABI function selectors
|
|
const SELECTORS = {
|
|
allPairsLength: '0x574f2ba3', // V2 Factory
|
|
feeTo: '0x017e7e58', // V2 Factory
|
|
getPair: '0xe6a43905', // V2 Factory — getPair(address,address)
|
|
factory: '0xc45a0155', // V2 Router — factory()
|
|
WETH: '0xad5c4648', // V2 Router — WETH()
|
|
owner: '0x8da5cb5b', // V3 Factory — owner()
|
|
feeAmountTickSpacing: '0x22afcccb', // V3 Factory — feeAmountTickSpacing(uint24)
|
|
}
|
|
|
|
// ── V2 Factory ─────────────────────────────────────────────────────
|
|
test.describe('DEX Contracts — Uniswap V2 Factory', () => {
|
|
test('V2 factory has deployed bytecode', async ({ request }) => {
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
V2_FACTORY, 'latest',
|
|
]) as string
|
|
if (code && code !== '0x' && code.length > 2) {
|
|
console.log(` V2 factory bytecode: ${code.length} chars`)
|
|
expect(code.length).toBeGreaterThan(100)
|
|
} else {
|
|
console.log(' V2 factory not at canonical address (chain uses custom deployment)')
|
|
}
|
|
})
|
|
|
|
test('V2 factory allPairsLength() returns count', async ({ request }) => {
|
|
const result = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V2_FACTORY, data: SELECTORS.allPairsLength }, 'latest',
|
|
]) as string
|
|
if (result && result !== '0x' && result.length > 2) {
|
|
const count = parseInt(result, 16)
|
|
console.log(` V2 pair count: ${count}`)
|
|
expect(count).toBeGreaterThanOrEqual(0)
|
|
} else {
|
|
console.log(' V2 factory not responding at canonical address')
|
|
}
|
|
})
|
|
|
|
test('V2 factory feeTo() returns valid address', async ({ request }) => {
|
|
const result = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V2_FACTORY, data: SELECTORS.feeTo }, 'latest',
|
|
]) as string
|
|
if (result && result !== '0x' && result.length >= 66) {
|
|
const addr = '0x' + result.slice(26)
|
|
console.log(` V2 feeTo: ${addr}`)
|
|
expect(result.length).toBe(66)
|
|
} else {
|
|
console.log(' V2 factory feeTo not available')
|
|
}
|
|
})
|
|
})
|
|
|
|
// ── V2 Router ──────────────────────────────────────────────────────
|
|
test.describe('DEX Contracts — Uniswap V2 Router', () => {
|
|
test('V2 router has deployed bytecode', async ({ request }) => {
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
V2_ROUTER, 'latest',
|
|
]) as string
|
|
if (code && code !== '0x' && code.length > 2) {
|
|
console.log(` V2 router bytecode: ${code.length} chars`)
|
|
expect(code.length).toBeGreaterThan(100)
|
|
} else {
|
|
console.log(' V2 router not at canonical address')
|
|
}
|
|
})
|
|
|
|
test('V2 router factory() returns factory address', async ({ request }) => {
|
|
const result = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V2_ROUTER, data: SELECTORS.factory }, 'latest',
|
|
]) as string
|
|
if (result && result !== '0x' && result.length >= 66) {
|
|
const addr = '0x' + result.slice(26)
|
|
console.log(` V2 router factory: ${addr}`)
|
|
expect(result.length).toBe(66)
|
|
} else {
|
|
console.log(' V2 router not responding at canonical address')
|
|
}
|
|
})
|
|
|
|
test('V2 router WETH() returns wrapped native token', async ({ request }) => {
|
|
const result = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V2_ROUTER, data: SELECTORS.WETH }, 'latest',
|
|
]) as string
|
|
if (result && result !== '0x' && result.length >= 66) {
|
|
const weth = '0x' + result.slice(26)
|
|
console.log(` WLUX (WETH): ${weth}`)
|
|
expect(result.length).toBe(66)
|
|
// Address should not be zero
|
|
expect(weth).not.toBe('0x' + '0'.repeat(40))
|
|
} else {
|
|
console.log(' V2 router WETH() not available')
|
|
}
|
|
})
|
|
})
|
|
|
|
// ── V3 Factory ─────────────────────────────────────────────────────
|
|
test.describe('DEX Contracts — Uniswap V3 Factory', () => {
|
|
test('V3 factory has deployed bytecode', async ({ request }) => {
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
V3_FACTORY, 'latest',
|
|
]) as string
|
|
if (code && code !== '0x' && code.length > 2) {
|
|
console.log(` V3 factory bytecode: ${code.length} chars`)
|
|
expect(code.length).toBeGreaterThan(100)
|
|
} else {
|
|
console.log(' V3 factory not at canonical address')
|
|
}
|
|
})
|
|
|
|
test('V3 factory owner() returns valid address', async ({ request }) => {
|
|
const result = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V3_FACTORY, data: SELECTORS.owner }, 'latest',
|
|
]) as string
|
|
if (result && result !== '0x' && result.length >= 66) {
|
|
const owner = '0x' + result.slice(26)
|
|
console.log(` V3 factory owner: ${owner}`)
|
|
expect(result.length).toBe(66)
|
|
} else {
|
|
console.log(' V3 factory not responding at canonical address')
|
|
}
|
|
})
|
|
|
|
test('V3 factory supports standard fee tiers', async ({ request }) => {
|
|
// feeAmountTickSpacing(500) — 0.05% tier
|
|
// Encode: selector + uint24 padded to 32 bytes
|
|
const feeData = SELECTORS.feeAmountTickSpacing +
|
|
'00000000000000000000000000000000000000000000000000000000000001f4' // 500
|
|
const result = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V3_FACTORY, data: feeData }, 'latest',
|
|
]) as string
|
|
if (result && result !== '0x' && result.length >= 66) {
|
|
const tickSpacing = parseInt(result, 16)
|
|
console.log(` V3 fee tier 500 (0.05%): tick spacing = ${tickSpacing}`)
|
|
expect(tickSpacing).toBe(10) // Standard tick spacing for 0.05%
|
|
} else {
|
|
console.log(' V3 factory fee tier query not available')
|
|
}
|
|
})
|
|
})
|
|
|
|
// ── V3 Router & Quoter ─────────────────────────────────────────────
|
|
test.describe('DEX Contracts — Uniswap V3 Router & Quoter', () => {
|
|
test('V3 router has deployed bytecode', async ({ request }) => {
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
V3_ROUTER, 'latest',
|
|
]) as string
|
|
if (code && code !== '0x' && code.length > 2) {
|
|
console.log(` V3 router bytecode: ${code.length} chars`)
|
|
} else {
|
|
console.log(' V3 router not at canonical address')
|
|
}
|
|
// Test passes regardless — we're checking deployment status
|
|
})
|
|
|
|
test('V3 quoter has deployed bytecode', async ({ request }) => {
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
V3_QUOTER, 'latest',
|
|
]) as string
|
|
if (code && code !== '0x' && code.length > 2) {
|
|
console.log(` V3 quoter bytecode: ${code.length} chars`)
|
|
} else {
|
|
console.log(' V3 quoter not at canonical address')
|
|
}
|
|
})
|
|
})
|
|
|
|
// ── WLUX Token Contract ───────────────────────────────────────────
|
|
test.describe('DEX Contracts — WLUX (Wrapped LUX)', () => {
|
|
test('WLUX contract exists if router references it', async ({ request }) => {
|
|
// Get WETH address from router first
|
|
const wethResult = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: V2_ROUTER, data: SELECTORS.WETH }, 'latest',
|
|
]) as string
|
|
|
|
if (wethResult && wethResult !== '0x' && wethResult.length >= 66) {
|
|
const wlux = '0x' + wethResult.slice(26)
|
|
if (wlux !== '0x' + '0'.repeat(40)) {
|
|
// Verify WLUX contract has bytecode
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
wlux, 'latest',
|
|
]) as string
|
|
console.log(` WLUX at ${wlux}: bytecode ${code.length} chars`)
|
|
if (code && code !== '0x') {
|
|
expect(code.length).toBeGreaterThan(10)
|
|
|
|
// Check name() — selector 0x06fdde03
|
|
const nameResult = await rpcCall(request, urls.rpc, 'eth_call', [
|
|
{ to: wlux, data: '0x06fdde03' }, 'latest',
|
|
]) as string
|
|
if (nameResult && nameResult !== '0x' && nameResult.length > 2) {
|
|
console.log(` WLUX name data: ${nameResult.slice(0, 66)}...`)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
console.log(' WLUX address not obtainable (V2 router not deployed)')
|
|
}
|
|
})
|
|
})
|
|
|
|
// ── DEX Precompile ─────────────────────────────────────────────────
|
|
test.describe('DEX Contracts — DEX Precompile', () => {
|
|
test('DEX precompile address responds if applicable', async ({ request }) => {
|
|
// Lux may have custom DEX precompiles in the 0x02... range
|
|
const DEX_PRECOMPILE = '0x0200000000000000000000000000000000000004'
|
|
const code = await rpcCall(request, urls.rpc, 'eth_getCode', [
|
|
DEX_PRECOMPILE, 'latest',
|
|
]) as string
|
|
console.log(` DEX precompile (${DEX_PRECOMPILE}): ${code === '0x' ? 'not deployed' : `${code.length} chars`}`)
|
|
expect(code).toBeDefined()
|
|
})
|
|
})
|