caelum0x 94c26e9496 feat: QIE Forge — clean-room AMM + lending vault, SDK, and CLI for QIE
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>
2026-10-26 23:34:51 +03:00

120 lines
2.7 KiB
Solidity

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.13 <0.9.0;
import {stdError} from "../src/StdError.sol";
import {Test} from "../src/Test.sol";
contract StdErrorsTest is Test {
ErrorsTest test;
function setUp() public {
test = new ErrorsTest();
}
function test_RevertIf_AssertionError() public {
vm.expectRevert(stdError.assertionError);
test.assertionError();
}
function test_RevertIf_ArithmeticError() public {
vm.expectRevert(stdError.arithmeticError);
test.arithmeticError(10);
}
function test_RevertIf_DivisionError() public {
vm.expectRevert(stdError.divisionError);
test.divError(0);
}
function test_RevertIf_ModError() public {
vm.expectRevert(stdError.divisionError);
test.modError(0);
}
function test_RevertIf_EnumConversionError() public {
vm.expectRevert(stdError.enumConversionError);
test.enumConversion(1);
}
function test_RevertIf_EncodeStgError() public {
vm.expectRevert(stdError.encodeStorageError);
test.encodeStgError();
}
function test_RevertIf_PopError() public {
vm.expectRevert(stdError.popError);
test.pop();
}
function test_RevertIf_IndexOOBError() public {
vm.expectRevert(stdError.indexOOBError);
test.indexOOBError(1);
}
function test_RevertIf_MemOverflowError() public {
vm.expectRevert(stdError.memOverflowError);
test.mem();
}
function test_RevertIf_InternError() public {
vm.expectRevert(stdError.zeroVarError);
test.intern();
}
}
contract ErrorsTest {
enum T {
T1
}
uint256[] public someArr;
bytes someBytes;
function assertionError() public pure {
assert(false);
}
function arithmeticError(uint256 a) public pure {
a -= 100;
}
function divError(uint256 a) public pure {
100 / a;
}
function modError(uint256 a) public pure {
100 % a;
}
function enumConversion(uint256 a) public pure {
T(a);
}
function encodeStgError() public {
assembly ("memory-safe") {
sstore(someBytes.slot, 1)
}
keccak256(someBytes);
}
function pop() public {
someArr.pop();
}
function indexOOBError(uint256 a) public pure {
uint256[] memory t = new uint256[](0);
t[a];
}
function mem() public pure {
uint256 l = 2 ** 256 / 32;
new uint256[](l);
}
function intern() public returns (uint256) {
function(uint256) internal returns (uint256) x;
x(2);
return 7;
}
}