Dexon is a decentralized order execution protocol built on top of Uniswap V3, enabling advanced trading features like limit orders, stop orders, and TWAP (Time-Weighted Average Price) orders.
- Limit Orders: Execute trades when an asset reaches a specific price
- Stop Orders: Trigger trades when price crosses a threshold
- TWAP Orders: Split large orders into smaller parts executed over time
- Market Orders: Direct execution through Uniswap V3 pools
- EIP-712 compliant signatures for gasless order submission
- Price feeds using Uniswap V3 TWAP oracles
- Multi-hop swaps support (up to 2 hops via WETH)
- Customizable slippage protection
- Nonce-based replay protection
contract Dexon is EIP712 {
// Core order types
struct Order {
address account;
uint256 nonce;
bytes path;
uint256 amount;
uint256 triggerPrice;
uint256 slippage;
OrderType orderType;
OrderSide orderSide;
uint256 deadline;
bytes signature;
}
struct TwapOrder {
address account;
uint256 nonce;
bytes path;
uint256 amount;
OrderSide orderSide;
uint256 interval;
uint256 totalOrders;
uint256 startTimestamp;
bytes signature;
}
}
-
Order Execution
- Validates order signatures and conditions
- Checks price triggers against Uniswap V3 oracle
- Executes swaps through Uniswap V3 Router
- Handles token transfers and approvals
-
TWAP Execution
- Splits orders into multiple parts
- Enforces time intervals between executions
- Manages partial fills and remaining amounts
-
Price Oracle
- Uses Uniswap V3 TWAP for reliable price feeds
- Supports direct and WETH-quoted pairs
- Handles decimal normalization
Network | Address |
---|---|
Monad Testnet | 0x45acD584500c747dCE86c77389b3b3B458Eb0A0b |
# Clone the repository
git clone https://github.com/zuni-lab/dexon-contract
cd dexon-contract
# Install dependencies
bun install
# Copy and configure environment variables
cp .env.example .env
# Run all tests
forge test
# Run with gas reporting
forge test --gas-report
# Run specific test
forge test --match-test testExecuteOrder
# Generate coverage report
bun run test:coverage
# Deploy to local network
forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
# Deploy to testnet (requires configured .env)
forge script script/Deploy.s.sol --broadcast --network sepolia
const order = {
account: userAddress,
nonce: await dexon.nonces(userAddress),
path: encodePath([WETH, USDC], [3000]),
amount: parseEther("1"),
triggerPrice: parseUnits("1800", 18), // $1800 per ETH
slippage: 100, // 0.01%
orderType: OrderType.LIMIT_ORDER,
orderSide: OrderSide.SELL,
deadline: Math.floor(Date.now() / 1000) + 3600,
};
const signature = await signOrder(order, signer);
const twapOrder = {
account: userAddress,
nonce: await dexon.nonces(userAddress),
path: encodePath([WETH, USDC], [3000]),
amount: parseEther("10"),
orderSide: OrderSide.SELL,
interval: 3600, // 1 hour between executions
totalOrders: 10, // Split into 10 parts
startTimestamp: Math.floor(Date.now() / 1000),
};
const signature = await signTwapOrder(twapOrder, signer);
- [Audit Report 1] - Date: TBD
- [Audit Report 2] - Date: TBD
- All orders require valid EIP-712 signatures
- Nonce-based replay protection
- Slippage protection on all trades
- Time-bound execution windows
- Partial fill support for TWAP orders
- Fork the repository
- Create your feature branch
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE.md file for details.