Initial build for QIE Mainnet Hackathon 3.0 (DeFi & Financial Infrastructure track). Includes: - packages/contracts: constant-product AMM (factory/pair/router), over-collateralized lending vault, and an oracle adapter wrapping QIE's real deployed price-feed contracts. 25/25 Foundry tests pass locally. Clean-room: no existing DEX/lending protocol source was read or copied. - packages/core: TypeScript SDK (viem-based) for QIE's chain, the real (corrected) oracle ABI, a fail-closed QUSDC helper, a Blockscout explorer client, and QIE Wallet connection constants. Live-verified against real testnet (chain 1983) and mainnet (chain 1990) RPCs and the real oracle contracts. - packages/cli: a small CLI built on @qie-forge/core. Real findings from building this, documented in README.md and docs/STATUS.md: the previously-documented testnet RPC URL is dead (replacement found and verified live); QIE's own oracle docs describe a getPrice(string) function that reverts on the real deployed contracts, which actually implement a Chainlink AggregatorV3-style interface (verified live via raw eth_call); the oracle is deployed on Mainnet only, not Testnet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
60 lines
2.3 KiB
JavaScript
Executable File
60 lines
2.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import prettier from 'prettier';
|
|
import { Eta } from 'eta';
|
|
|
|
// Shared data + helpers. The full set is injected into every `.sol.eta` template (e.g. it.SLOT_TYPES, it.sanitize).
|
|
import * as context from './data.js';
|
|
|
|
const repoRoot = path.join(import.meta.dirname, '../..');
|
|
const templatesDir = path.join(import.meta.dirname, 'templates');
|
|
const eta = new Eta({ views: templatesDir, autoEscape: false, autoTrim: false, defaultExtension: '' });
|
|
|
|
// Each output is rendered from `templates/<basename>.eta`.
|
|
for (const [filepath, needsPrettier] of Object.entries({
|
|
'contracts/mocks/StorageSlotMock.sol': false,
|
|
'contracts/mocks/TransientSlotMock.sol': false,
|
|
'contracts/utils/Arrays.sol': false,
|
|
'contracts/utils/Calldata.sol': false,
|
|
'contracts/utils/Packing.sol': false,
|
|
'contracts/utils/SlotDerivation.sol': false,
|
|
'contracts/utils/StorageSlot.sol': false,
|
|
'contracts/utils/TransientSlot.sol': false,
|
|
'contracts/utils/cryptography/MerkleProof.sol': true,
|
|
'contracts/utils/math/SafeCast.sol': false,
|
|
'contracts/utils/structs/Checkpoints.sol': false,
|
|
'contracts/utils/structs/EnumerableMap.sol': true,
|
|
'contracts/utils/structs/EnumerableSet.sol': false,
|
|
'test/utils/Calldata.t.sol': false,
|
|
'test/utils/Packing.t.sol': false,
|
|
'test/utils/SlotDerivation.t.sol': false,
|
|
'test/utils/structs/Checkpoints.t.sol': false,
|
|
})) {
|
|
console.log(`Generating ${filepath}...`);
|
|
const template = `${path.basename(filepath)}.eta`;
|
|
const input = path.relative(repoRoot, path.join(templatesDir, template));
|
|
const version =
|
|
fs.existsSync(filepath) &&
|
|
fs.readFileSync(filepath, 'utf8').match(/^\/\/ OpenZeppelin Contracts \(last updated v[^)]+\) \([^)]+\)$/m)?.[0];
|
|
const content = [
|
|
'// SPDX-License-Identifier: MIT',
|
|
...(version ? [version] : []),
|
|
`// This file was procedurally generated from ${input}.`,
|
|
'',
|
|
eta.render(template, context),
|
|
].join('\n');
|
|
|
|
await (
|
|
needsPrettier
|
|
? prettier
|
|
.resolveConfig(filepath)
|
|
.then(prettierConfig => prettier.format(content, { ...prettierConfig, filepath }))
|
|
: Promise.resolve(content)
|
|
).then(formatted => {
|
|
fs.mkdirSync(path.dirname(filepath), { recursive: true });
|
|
fs.writeFileSync(filepath, formatted);
|
|
});
|
|
}
|