Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ Expected cost: ~8M gas at ~0.1 gwei ≈ **0.0008 OKB (~$0.20)**.

---

## Deployed contracts — X Layer **Mainnet** (chain 196) ⚡

| Contract | Address | Bytecode size |
|----------|---------|---------|
| **FloatVault** | [`0x42Ff0c72A17d5b13bf01a20B194b0D1fe43e50BF`](https://www.oklink.com/xlayer/address/0x42Ff0c72A17d5b13bf01a20B194b0D1fe43e50BF) | 5,115 b |
| **AgentFloatHook** | [`0x010023fcb7Cc4a6f4f867D3AF0C428d80d2B8580`](https://www.oklink.com/xlayer/address/0x010023fcb7Cc4a6f4f867D3AF0C428d80d2B8580) | 5,101 b |
| IdleStrategy | [`0xBC049aAD700ee69a72bedF7AE7032e462450Fb5d`](https://www.oklink.com/xlayer/address/0xBC049aAD700ee69a72bedF7AE7032e462450Fb5d) | 939 b |
| AaveStrategy (real Aave V3 USDT) | [`0x1f34e7b58A81a84Def4fdE0ED23daE4B60c500cf`](https://www.oklink.com/xlayer/address/0x1f34e7b58A81a84Def4fdE0ED23daE4B60c500cf) | 2,429 b |

The hook address ends in `0x...8580` — the low 14 bits encode the permission flags `0x580` (afterAddLiquidity + afterRemoveLiquidity + beforeSwap). Verified via `Hooks.validateHookPermissions` in the canonical `BaseHook` constructor.

Total mainnet deploy cost: **0.000372 OKB (~$0.09)** at 0.02 gwei.

The vault attaches to the canonical Uniswap v4 PoolManager (`0x360E68fa…b9FB32`) and routes idle USDT through Aave V3 (`0xE3F3Caef…84F116`). The IdleStrategy is the active baseline; the AaveStrategy starts as shadow and earns its way to active via the on-chain `consecutiveWins` counter.

---

## Deployed contracts — X Layer Testnet (chain 1952)

| Contract | Address |
Expand Down
58 changes: 58 additions & 0 deletions contracts/script/DeployHookOnly.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "forge-std/Script.sol";
import {AgentFloatHook} from "../src/AgentFloatHook.sol";
import {FloatVault} from "../src/FloatVault.sol";
import {IPoolManager} from "v4-core/src/interfaces/IPoolManager.sol";

/// @title Deploy AgentFloatHook against an already-deployed FloatVault
/// @notice Mines a CREATE2 salt + deploys via the universal CREATE2 deployer in one tx.
contract DeployHookOnly is Script {
address constant CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
// Required low-14-bit mask: AFTER_ADD_LIQUIDITY (0x400) | AFTER_REMOVE_LIQUIDITY (0x100) | BEFORE_SWAP (0x80)
uint160 constant REQUIRED_FLAGS = 0x580;
uint160 constant FLAG_MASK = 0x3FFF;

function run() public {
uint256 pk = vm.envUint("DEPLOYER_PRIVATE_KEY");
address poolManager = vm.envAddress("POOL_MANAGER_ADDRESS");
address vaultAddr = vm.envAddress("VAULT_ADDRESS");

bytes memory creationCode = type(AgentFloatHook).creationCode;
bytes memory bytecode = abi.encodePacked(creationCode, abi.encode(poolManager, vaultAddr));
bytes32 bytecodeHash = keccak256(bytecode);

bytes32 salt;
address predicted;
for (uint256 i = 0; i < 200_000; i++) {
salt = bytes32(i);
predicted = address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), CREATE2_DEPLOYER, salt, bytecodeHash)))));
if ((uint160(predicted) & FLAG_MASK) == REQUIRED_FLAGS) {
console.log("Mined salt after", i, "attempts");
console.logBytes32(salt);
console.log("Predicted hook address:", predicted);
break;
}
}
require((uint160(predicted) & FLAG_MASK) == REQUIRED_FLAGS, "Salt search failed; widen range");

vm.startBroadcast(pk);

// Deploy via the universal CREATE2 deployer with a single call
(bool ok, ) = CREATE2_DEPLOYER.call(abi.encodePacked(salt, bytecode));
require(ok, "CREATE2 deploy call failed");

vm.stopBroadcast();

// Verify
uint256 size;
assembly { size := extcodesize(predicted) }
require(size > 0, "Hook bytecode empty at predicted address");

console.log("");
console.log("=== Hook deployed ===");
console.log("Address:", predicted);
console.log("Code size:", size);
}
}
20 changes: 18 additions & 2 deletions docs/submission.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ A Uniswap v4 hook on X Layer that routes out-of-range LP capital into a self-imp
https://github.com/ronkenx9/agentfloat-hook

**Primary verifiable contract address (the Hook):**
0x3A00B5A2F15bE68AfE5415290ca4D3022e3B3b5F
https://www.oklink.com/xlayer-test/address/0x3A00B5A2F15bE68AfE5415290ca4D3022e3B3b5F
**MAINNET:** `0x010023fcb7Cc4a6f4f867D3AF0C428d80d2B8580` — https://www.oklink.com/xlayer/address/0x010023fcb7Cc4a6f4f867D3AF0C428d80d2B8580
TESTNET: `0x3A00B5A2F15bE68AfE5415290ca4D3022e3B3b5F` — https://www.oklink.com/xlayer-test/address/0x3A00B5A2F15bE68AfE5415290ca4D3022e3B3b5F

**Demo video:**
[TBD — record per `docs/video_script.md`, upload as unlisted YouTube, paste link here]
Expand All @@ -23,6 +23,22 @@ https://www.oklink.com/xlayer-test/address/0x3A00B5A2F15bE68AfE5415290ca4D3022e3

---

## ⚡ Deployed contracts — X Layer **Mainnet** (chain 196)

| Role | Address |
|------|---------|
| **FloatVault** | [`0x42Ff0c72A17d5b13bf01a20B194b0D1fe43e50BF`](https://www.oklink.com/xlayer/address/0x42Ff0c72A17d5b13bf01a20B194b0D1fe43e50BF) |
| **AgentFloatHook** | [`0x010023fcb7Cc4a6f4f867D3AF0C428d80d2B8580`](https://www.oklink.com/xlayer/address/0x010023fcb7Cc4a6f4f867D3AF0C428d80d2B8580) |
| IdleStrategy | [`0xBC049aAD700ee69a72bedF7AE7032e462450Fb5d`](https://www.oklink.com/xlayer/address/0xBC049aAD700ee69a72bedF7AE7032e462450Fb5d) |
| AaveStrategy | [`0x1f34e7b58A81a84Def4fdE0ED23daE4B60c500cf`](https://www.oklink.com/xlayer/address/0x1f34e7b58A81a84Def4fdE0ED23daE4B60c500cf) |
| Uniswap v4 PoolManager (canonical) | [`0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32`](https://www.oklink.com/xlayer/address/0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32) |
| Aave V3 Pool (USDT reserve) | [`0xE3F3Caefdd7180F884c01E57f65Df979Af84f116`](https://www.oklink.com/xlayer/address/0xE3F3Caefdd7180F884c01E57f65Df979Af84f116) |
| USDT (underlying) | [`0x779Ded0c9e1022225f8E0630b35a9b54bE713736`](https://www.oklink.com/xlayer/address/0x779Ded0c9e1022225f8E0630b35a9b54bE713736) |

Total deploy cost: **0.000372 OKB (~$0.09)**. The mainnet build uses real USDT routed through real Aave V3, attaches to the canonical Uniswap v4 PoolManager (no PoolManager redeploy needed). The AI operating mode is bounded to `register_strategy / retire / scoring_change / no_action` on chain 196 — new Solidity to mainnet requires human review per `chain_actions_allowed`.

---

## Deployed contracts — X Layer Testnet (chain 1952)

| Role | Address | Explorer |
Expand Down