// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {ElysioTypes, IElysioRouter} from "./IElysio.sol"; import {ElysioClient} from "./ElysioClient.sol"; /// @title QuickVault /// @notice The sample consumer behind the desk and the sandbox: sends one HYPE/USDC intent at a time and keeps /// the last receipt it heard plus its running position. contract QuickVault is ElysioClient { uint32 public constant HYPE_USDC = 10107; int256 public position; // 8 decimals, signed ElysioTypes.Status public lastStatus; uint64 public lastFilled; uint64 public lastPx; uint256 public receiptsSeen; mapping(uint256 => bool) public isBuyOf; event Sent(uint256 indexed intentId, bool isBuy, uint64 sz, uint64 limitPx); event Heard(uint256 indexed intentId, ElysioTypes.Status status, uint64 filledSz, uint64 avgPx, int256 position); constructor(IElysioRouter router) ElysioClient(router, msg.sender) {} function trade(bool isBuy, uint64 sz, uint64 limitPx, ElysioTypes.Tif tif, uint64 ttl) external onlyElysioOwner returns (uint256 intentId) { intentId = _request(ElysioTypes.Intent({ asset: HYPE_USDC, isBuy: isBuy, reduceOnly: false, tif: tif, sz: sz, limitPx: limitPx, deadline: uint64(block.timestamp + ttl), callbackGas: 150_000 })); isBuyOf[intentId] = isBuy; emit Sent(intentId, isBuy, sz, limitPx); } function _onReceipt(uint256 intentId, ElysioTypes.Receipt calldata r) internal override { // Only Filled and Partial move the position; Dropped and Unanswered are heard and recorded. if (r.status == ElysioTypes.Status.Filled || r.status == ElysioTypes.Status.Partial) { int256 filled = int256(uint256(r.filledSz)); position += isBuyOf[intentId] ? filled : -filled; } lastStatus = r.status; lastFilled = r.filledSz; lastPx = r.avgPx; receiptsSeen++; emit Heard(intentId, r.status, r.filledSz, r.avgPx, position); } }