AGLITY
Agentic liquidity · Robinhood Chain

Liquidity strategies for tokens on Robinhood Chain. You set the rules, an AI agent runs them on live pool prices.

BuildCreate a strategyMarketTokens and stocksCopyYour vaultToken$AGLITY soon
AGLITYAgentic liquidity
Docs

How it
works

Everything AGLITY does, how every number is computed, and the full source of the vault contracts. Nothing here is hidden.

01Overview

AGLITY runs AI strategy pools for tokens on Robinhood Chain. A strategy pool is a written plan for providing liquidity across many token pools at once: which pools, how much in each, which price range, and when to rebalance or step out. You write the plan in the Strategy Lab; an agent runs it on live pool prices, and every decision goes on a public, hash chained record.

$AGLITY is the token of AGLITY. Its contract address is shown on the home page once it is live, and nowhere else. Tokens with the same name and logo are easy to make and are not ours: before you buy, check the address against the home page, character by character. AGLITY never sends DMs, never runs airdrops or presales, and never asks for your seed phrase.

02Strategy pools

  • Pools. Rank the tokens by FDV, by the ETH in their pool or by 24 hour volume, then filter by a minimum ETH in pool or a minimum age. Or hand pick up to ten pools.
  • Split. Evenly, by ETH in pool, by FDV, by volume, or decided by the AI agent. No pool may hold more than 50 percent; anything not allocated stays in ETH.
  • Range. Full range, or 80, 50 or 25 percent each way around the token price. With the same capital these provide 1.0x, 2.5x, 4.2x and 8.3x the liquidity of a full range position.
  • Rules. Rebalance when a position leaves its range, every hour, every 6 hours or every 24 hours, and optionally exit a pool after a 30 or 50 percent fall from entry.

Every strategy is created with a wallet signature. Signing is free and moves no funds. One wallet can run three strategies.

03How results are computed

Every strategy starts from the same 1 ETH so results compare fairly. Each token pool pairs the token with ETH, and its price P is the number of tokens per ETH. A position with liquidity L between prices Pa and Pb holds:

below the range:   ETH = L (1/sqrt(Pa) - 1/sqrt(Pb)),  token = 0
inside the range:  ETH = L (1/sqrt(P)  - 1/sqrt(Pb)),  token = L (sqrt(P) - sqrt(Pa))
above the range:   ETH = 0,                            token = L (sqrt(Pb) - sqrt(Pa))
value in ETH = ETH + token / P
  • Entry price impact. To open a position the strategy buys the token side through the pool itself, using its live active liquidity: 1/sqrt(P1) = 1/sqrt(P0) + dx/L. The cost is charged at entry.
  • Rebalancing. Positions are closed, only the net token difference is traded, and the new ranges are minted.
  • No LP fee. These pools charge no LP fee, so a position earns nothing from trades. The result is the value of the positions against price, and nothing else is added.
  • Not modelled. Fees the launch hook takes on swaps are not included in the tracked results.
  • Tracking. Strategies are valued on live pool prices about every five minutes. Vaults that copy a strategy place real positions on chain through the contracts below.

04The AI agent

Strategies that let the AI decide use Claude Opus 5.5. At each decision the agent sees every candidate pool with its FDV, ETH in pool, 24 hour volume, 1 hour and 24 hour price change, buys and sells, and age, plus the strategy current positions. It is told the facts that matter: no LP fee, the range, the 50 percent cap, and that ETH is a valid choice. It answers with weights, a confidence and one plain sentence that explains the move.

  • The house AGLITY Agent decides every hour and trades only when its target differs from what it holds or a position has left its range. Otherwise it records a hold with its reasoning.
  • Community AI strategies decide at most every 3 hours; in between, ranges recenter on the last weights.
  • Spend is capped per day. When the model is unavailable or the cap is reached, the decision waits. A missing decision is never filled in.

05The decision record

Every open, rebalance, hold and exit is stored with a SHA-256 hash that covers the hash before it. Changing any record breaks every later link. You can check any strategy yourself:

const r = await fetch('/api/strategies/al-agent').then((x) => x.json());
const sha = async (s) => [...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(s)))]
  .map((b) => b.toString(16).padStart(2, '0')).join('');
const round = (x) => Math.round(Number(x) * 1e6) / 1e6;
let prev = r.records.at(-1).prev;
for (const d of [...r.records].reverse()) {
  const body = JSON.stringify({
    strategy: r.id, t: d.t, kind: d.kind,
    weights: Object.fromEntries(Object.entries(d.weights).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => [k, round(v)])),
    range: d.range || null, value: d.value != null ? round(d.value) : null, note: d.note || '',
    ...(d.model ? { model: d.model } : {}),
  });
  if (d.prev !== prev || (await sha(prev + body)) !== d.hash) throw new Error('broken at ' + d.t);
  prev = d.hash;
}
console.log('chain verified', r.records.length, 'records');

06Where the data comes from

  • Tokens and pools. Every graduated token is read from the launch factory events. Each pool price and liquidity is read from the pool manager storage, many pools per call.
  • 24 hour price paths. Read from the pool manager at past blocks, one point per hour, then one point every 10 minutes going forward.
  • FDV. Live pool price times total supply. Pools with almost no ETH left are skipped, since their price says little.
  • Activity. 24 hour volume, buys, sells and price change come from a public market feed.
  • Stocks. Each tokenized stock is priced from its own pool, reading the correct side of pairs such as SPY / AAPL.
  • Charts. Built from pool trades, cached and paced so the feed limits are never hit.

07Copy pools and vaults

Copying a strategy pool with real ETH works through a personal vault, opened on the vault page. Nothing is sent to a server: deposits go from your wallet straight into a contract that only you control.

  1. Create your vault through the factory, choosing the strategy pool to copy. ETH sent with the call is deposited at once.
  2. The operator mirrors the strategy inside your vault: it buys the token side, adds liquidity in the same ranges and removes it when the strategy moves.
  3. Leave at any time. Withdraw any amount, revoke the operator, switch strategy, or call exitAll to close every position and receive everything.
Only you withdrawThe operator has no function that moves funds out of the vault.
Allowed pools onlyOnly ETH pools keyed to the launch hook, with fee 0 and tick spacing 200, checked on chain.
Bounded swapsEvery swap has a price limit of 3 percent around the current pool price.
Positions stay yoursLiquidity positions are minted to your vault and pay back to your vault.
Always an exitexitAll closes every position at any price and sends everything to you.
Capped depositsEach vault takes at most 1 ETH while the product is new.

Status: the factory is live at 0xe16F7343EB09D93f70267C915cC0213910F2c27A.

08Smart contracts

The full source of the vault contracts, exactly as tested. Solidity 0.8.28, OpenZeppelin SafeERC20 and ReentrancyGuard.

344 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IPoolManager, IPositionManager, IPermit2, IUnlockCallback, PoolKey, SwapParams} from "./interfaces/IV4.sol";

/// @title ALVault
/// @notice A personal vault that copies one Agentic Liquidity strategy pool with real ETH on Robinhood Chain.
/// The owner deposits ETH and can withdraw everything at any time. An operator chosen by the owner mirrors the
/// followed strategy by swapping ETH for tokens and by adding or removing Uniswap v4 liquidity, and nothing else:
///   - only in the ETH pool of a token launched through the allowed launchpad hook (fee 0, tick spacing 200)
///   - every swap is bounded by a price limit around the current pool price
///   - every swap output, every liquidity position and every withdrawn amount belongs to this vault
/// The operator has no function that moves funds out of the vault.
contract ALVault is IUnlockCallback, ReentrancyGuard {
    using SafeERC20 for IERC20;

    uint256 internal constant BPS = 10_000;
    uint24 public constant POOL_FEE = 0;
    int24 public constant TICK_SPACING = 200;
    int24 public constant MIN_TICK = -887_200;
    int24 public constant MAX_TICK = 887_200;
    uint256 internal constant POOLS_SLOT = 6; // PoolManager._pools

    // PositionManager actions
    uint8 internal constant DECREASE_LIQUIDITY = 0x01;
    uint8 internal constant MINT_POSITION = 0x02;
    uint8 internal constant BURN_POSITION = 0x03;
    uint8 internal constant SETTLE_PAIR = 0x0d;
    uint8 internal constant TAKE_PAIR = 0x11;
    uint8 internal constant SWEEP = 0x14;

    address public immutable factory;
    address public immutable owner;
    IPoolManager public immutable poolManager;
    IPositionManager public immutable positionManager;
    IPermit2 public immutable permit2;
    address public immutable hook;
    uint16 public immutable maxSlippageBps;
    /// @notice Most ETH the owner can have deposited at once (deposits minus ETH withdrawals). Zero means no cap.
    uint256 public immutable maxDeposit;

    address public operator;
    bytes32 public strategy;
    bool public active;
    uint256 public totalDeposited;
    uint256 public totalWithdrawn;

    uint256[] internal _positions;
    mapping(uint256 tokenId => uint256 indexPlusOne) internal _positionIndex;
    mapping(uint256 tokenId => address token) public positionToken;
    address[] internal _tokens;
    mapping(address token => bool) public knownToken;

    bool private _unlocking;

    error NotOwner();
    error NotAllowed();
    error ZeroAmount();
    error BadConfig();
    error UnknownPool(address token);
    error BadTicks();
    error UnknownPosition(uint256 tokenId);
    error BadCallback();
    error OutBelowMin(uint256 out, uint256 min);
    error OverDepositCap(uint256 room, uint256 amount);
    error OverBalance();
    error EthTransferFailed();

    event Deposited(address indexed from, uint256 amount);
    event Withdrawn(address indexed token, uint256 amount, address indexed to);
    event WithdrawSkipped(address indexed token, uint256 amount);
    event Swapped(address indexed token, bool buyToken, uint256 amountIn, uint256 amountOut, address indexed by);
    event PositionOpened(uint256 indexed tokenId, address indexed token, int24 tickLower, int24 tickUpper, uint128 liquidity, address indexed by);
    event PositionClosed(uint256 indexed tokenId, address indexed token, address indexed by);
    event OperatorSet(address indexed operator);
    event StrategySet(bytes32 indexed strategy);
    event ActiveSet(bool active);

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    /// owner always; the operator only while the vault is active
    modifier onlyAgent() {
        if (msg.sender != owner && !(msg.sender == operator && operator != address(0) && active)) revert NotAllowed();
        _;
    }

    constructor(
        address owner_,
        address operator_,
        bytes32 strategy_,
        address poolManager_,
        address positionManager_,
        address permit2_,
        address hook_,
        uint16 maxSlippageBps_,
        uint256 maxDeposit_
    ) {
        if (
            owner_ == address(0) || poolManager_ == address(0) || positionManager_ == address(0) || permit2_ == address(0)
                || hook_ == address(0) || maxSlippageBps_ == 0 || maxSlippageBps_ > 2_000
        ) revert BadConfig();
        factory = msg.sender;
        owner = owner_;
        poolManager = IPoolManager(poolManager_);
        positionManager = IPositionManager(positionManager_);
        permit2 = IPermit2(permit2_);
        hook = hook_;
        maxSlippageBps = maxSlippageBps_;
        maxDeposit = maxDeposit_;
        operator = operator_;
        strategy = strategy_;
        active = operator_ != address(0) && strategy_ != bytes32(0);
        emit OperatorSet(operator_);
        emit StrategySet(strategy_);
        emit ActiveSet(active);
    }

    /// ETH arrives from the owner through deposit(), and from the pool or position manager during operations.
    receive() external payable {
        if (msg.sender != address(poolManager) && msg.sender != address(positionManager)) revert NotAllowed();
    }

    /* ---------------------------------------------------------------- views */

    /// @notice The pool key of a token's ETH pool under the allowed hook.
    function keyFor(address token) public view returns (PoolKey memory) {
        return PoolKey(address(0), token, POOL_FEE, TICK_SPACING, hook);
    }

    /// @notice Current sqrt price and tick of a token's pool; reverts when the pool does not exist.
    function slot0(address token) public view returns (uint160 sqrtPriceX96, int24 tick) {
        bytes32 id = keccak256(abi.encode(keyFor(token)));
        bytes32 word = poolManager.extsload(keccak256(abi.encode(id, POOLS_SLOT)), 1)[0];
        sqrtPriceX96 = uint160(uint256(word));
        tick = int24(int256(uint256(word) >> 160));
        if (sqrtPriceX96 == 0) revert UnknownPool(token);
    }

    function positions() external view returns (uint256[] memory) {
        return _positions;
    }

    function tokens() external view returns (address[] memory) {
        return _tokens;
    }

    /// @notice ETH deposited and not yet withdrawn. Profits withdrawn beyond the deposits count as zero.
    function principal() public view returns (uint256) {
        return totalDeposited > totalWithdrawn ? totalDeposited - totalWithdrawn : 0;
    }

    function depositRoom() public view returns (uint256) {
        if (maxDeposit == 0) return type(uint256).max;
        uint256 p = principal();
        return p >= maxDeposit ? 0 : maxDeposit - p;
    }

    /* ---------------------------------------------------------------- owner */

    function deposit() external payable onlyOwner nonReentrant {
        _deposit(msg.value);
    }

    /// @notice Deposit made by the factory on the owner's behalf when the vault is created.
    function depositFor() external payable nonReentrant {
        if (msg.sender != factory) revert NotAllowed();
        _deposit(msg.value);
    }

    function _deposit(uint256 amount) internal {
        if (amount == 0) revert ZeroAmount();
        uint256 room = depositRoom();
        if (amount > room) revert OverDepositCap(room, amount);
        totalDeposited += amount;
        emit Deposited(owner, amount);
    }

    /// @notice Send ETH (token zero) or any token the vault holds to any address.
    function withdraw(address token, uint256 amount, address to) external onlyOwner nonReentrant {
        if (amount == 0) revert ZeroAmount();
        _send(token, amount, to);
        emit Withdrawn(token, amount, to);
    }

    /// @notice Close every position, send every balance to `to`, and stop following. Positions close at any
    /// price (no minimum), so the owner can always leave; a token that cannot move right now is skipped.
    function exitAll(address to) external onlyOwner nonReentrant {
        while (_positions.length > 0) _burn(_positions[_positions.length - 1], 0, 0);
        for (uint256 i; i < _tokens.length; ++i) {
            uint256 bal = IERC20(_tokens[i]).balanceOf(address(this));
            if (bal == 0) continue;
            (bool ok, bytes memory ret) = _tokens[i].call(abi.encodeCall(IERC20.transfer, (to, bal)));
            if (ok && (ret.length == 0 || abi.decode(ret, (bool)))) emit Withdrawn(_tokens[i], bal, to);
            else emit WithdrawSkipped(_tokens[i], bal);
        }
        uint256 eth = address(this).balance;
        if (eth > 0) {
            _send(address(0), eth, to);
            emit Withdrawn(address(0), eth, to);
        }
        if (active) {
            active = false;
            emit ActiveSet(false);
        }
    }

    /// @notice Choose who may mirror the strategy. Zero revokes the operator at once.
    function setOperator(address operator_) external onlyOwner {
        operator = operator_;
        emit OperatorSet(operator_);
    }

    /// @notice Choose the strategy pool to copy.
    function setStrategy(bytes32 strategy_) external onlyOwner {
        strategy = strategy_;
        emit StrategySet(strategy_);
    }

    /// @notice Start or stop copying.
    function setActive(bool active_) external onlyOwner {
        active = active_;
        emit ActiveSet(active_);
    }

    /* ------------------------------------------------------- owner or agent */

    /// @notice Swap exactly `amountIn` of ETH for a token (`buyToken`) or the token for ETH, in the token's pool.
    /// The price may move at most maxSlippageBps against the vault; a larger move fills only partly.
    function swap(address token, bool buyToken, uint256 amountIn, uint256 minOut) external onlyAgent nonReentrant returns (uint256 amountOut) {
        if (amountIn == 0) revert ZeroAmount();
        if (buyToken ? amountIn > address(this).balance : amountIn > IERC20(token).balanceOf(address(this))) revert OverBalance();
        (uint160 sqrtP,) = slot0(token);
        // buying the token moves the pool price (token per ETH) down, selling moves it up
        uint256 lim = buyToken ? (uint256(sqrtP) * Math.sqrt((BPS - maxSlippageBps) * 1e18)) / 1e11 : (uint256(sqrtP) * Math.sqrt((BPS + maxSlippageBps) * 1e18)) / 1e11;
        _unlocking = true;
        bytes memory ret = poolManager.unlock(abi.encode(token, buyToken, amountIn, uint160(lim)));
        _unlocking = false;
        uint256 paid;
        (amountOut, paid) = abi.decode(ret, (uint256, uint256));
        if (amountOut < minOut) revert OutBelowMin(amountOut, minOut);
        _remember(token);
        emit Swapped(token, buyToken, paid, amountOut, msg.sender);
    }

    function unlockCallback(bytes calldata data) external returns (bytes memory) {
        if (msg.sender != address(poolManager) || !_unlocking) revert BadCallback();
        (address token, bool buyToken, uint256 amountIn, uint160 limit) = abi.decode(data, (address, bool, uint256, uint160));
        int256 delta = poolManager.swap(keyFor(token), SwapParams(buyToken, -int256(amountIn), limit), "");
        int128 d0 = int128(delta >> 128); // ETH
        int128 d1 = int128(delta); // token
        (int128 pay, int128 get) = buyToken ? (d0, d1) : (d1, d0);
        uint256 paid = uint256(uint128(-pay));
        uint256 got = get > 0 ? uint256(uint128(get)) : 0;
        if (buyToken) {
            poolManager.settle{value: paid}();
            if (got > 0) poolManager.take(token, address(this), got);
        } else {
            poolManager.sync(token);
            IERC20(token).safeTransfer(address(poolManager), paid);
            poolManager.settle();
            if (got > 0) poolManager.take(address(0), address(this), got);
        }
        return abi.encode(got, paid);
    }

    /// @notice Add liquidity to a token's ETH pool between two ticks. Spends at most the given amounts;
    /// the position belongs to this vault and unused ETH comes straight back.
    function mint(address token, int24 tickLower, int24 tickUpper, uint128 liquidity, uint128 amount0Max, uint128 amount1Max)
        external
        onlyAgent
        nonReentrant
        returns (uint256 tokenId)
    {
        if (tickLower >= tickUpper || tickLower < MIN_TICK || tickUpper > MAX_TICK || tickLower % TICK_SPACING != 0 || tickUpper % TICK_SPACING != 0) revert BadTicks();
        if (liquidity == 0) revert ZeroAmount();
        if (amount0Max > address(this).balance || amount1Max > IERC20(token).balanceOf(address(this))) revert OverBalance();
        slot0(token); // the pool must exist
        if (amount1Max > 0) {
            IERC20(token).forceApprove(address(permit2), type(uint256).max);
            permit2.approve(token, address(positionManager), amount1Max, uint48(block.timestamp + 60));
        }
        bytes[] memory params = new bytes[](3);
        params[0] = abi.encode(keyFor(token), tickLower, tickUpper, uint256(liquidity), amount0Max, amount1Max, address(this), bytes(""));
        params[1] = abi.encode(address(0), token);
        params[2] = abi.encode(address(0), address(this));
        tokenId = positionManager.nextTokenId();
        positionManager.modifyLiquidities{value: amount0Max}(abi.encode(abi.encodePacked(MINT_POSITION, SETTLE_PAIR, SWEEP), params), block.timestamp);
        if (positionManager.ownerOf(tokenId) != address(this)) revert BadCallback();
        _positions.push(tokenId);
        _positionIndex[tokenId] = _positions.length;
        positionToken[tokenId] = token;
        _remember(token);
        emit PositionOpened(tokenId, token, tickLower, tickUpper, liquidity, msg.sender);
    }

    /// @notice Remove all liquidity from a position and close it; both tokens come back to this vault.
    function burn(uint256 tokenId, uint128 amount0Min, uint128 amount1Min) external onlyAgent nonReentrant {
        _burn(tokenId, amount0Min, amount1Min);
    }

    /* ------------------------------------------------------------- internal */

    function _burn(uint256 tokenId, uint128 amount0Min, uint128 amount1Min) internal {
        uint256 idx = _positionIndex[tokenId];
        if (idx == 0) revert UnknownPosition(tokenId);
        address token = positionToken[tokenId];
        bytes[] memory params = new bytes[](2);
        params[0] = abi.encode(tokenId, amount0Min, amount1Min, bytes(""));
        params[1] = abi.encode(address(0), token, address(this));
        positionManager.modifyLiquidities(abi.encode(abi.encodePacked(BURN_POSITION, TAKE_PAIR), params), block.timestamp);
        uint256 last = _positions[_positions.length - 1];
        _positions[idx - 1] = last;
        _positionIndex[last] = idx;
        _positions.pop();
        delete _positionIndex[tokenId];
        delete positionToken[tokenId];
        emit PositionClosed(tokenId, token, msg.sender);
    }

    function _remember(address token) internal {
        if (!knownToken[token]) {
            knownToken[token] = true;
            _tokens.push(token);
        }
    }

    function _send(address token, uint256 amount, address to) internal {
        if (token == address(0)) {
            (bool ok,) = to.call{value: amount}("");
            if (!ok) revert EthTransferFailed();
            totalWithdrawn += amount;
        } else {
            IERC20(token).safeTransfer(to, amount);
        }
    }
}

Tested on a fork of mainnet

The test suite forks Robinhood Chain and runs against a real token pool. Every test below passes.

PASS create vault sets owner strategy and deposit
PASS one vault per wallet
PASS deposit cap
PASS stranger cannot deposit or send eth
PASS operator swap mint burn funds stay in vault
PASS operator has no way out
PASS stranger cannot operate
PASS inactive or revoked operator is blocked
PASS unknown pool is rejected
PASS bad ticks are rejected
PASS cannot spend more than held
PASS min out is enforced
PASS owner exit all closes positions and pays out

Addresses the vault uses

Pool manager0x8366a39cc670b4001a1121b8f6a443a643e40951Holds every token pool; prices and liquidity are read from it
Position manager0x58daec3116aae6d93017baaea7749052e8a04fa7Mints and burns liquidity positions
Permit20x000000000022d473030f116ddee9f6b43ac78ba3Token approvals for the position manager
Launch hook0xe5e702641ea86f4ae6cc3cdaed2b886f976be044Every token pool the vault may use is keyed to this hook

09Public API

GET /api/poolsToken pools: FDV, ETH in pool, 24h activity, 24h price path
GET /api/marketTokens and stocks with live prices
GET /api/chart?a=<address>&r=24h|7d|30d|90dPrice candles for one listed asset
GET /api/strategiesEvery strategy ranked by return
GET /api/strategies/<id>One strategy: positions, value history, decision record, chain check
GET /api/statusLast update, block, ETH price, agent status