Quickstart
Get the SDK
The Solidity base contract and interfaces are served from /sdk/. Copy them into your Foundry project:
curl -O https://asyncium.com/sdk/IAsync.sol curl -O https://asyncium.com/sdk/AsyncClient.sol curl -O https://asyncium.com/sdk/MockAsyncRouter.sol
Write a consumer
Inherit AsyncClient, send intents with _request, and handle every outcome in _onReceipt. Only the router can call it.
contract MyVault is AsyncClient {
int256 public position;
constructor(IAsyncRouter router) AsyncClient(router, msg.sender) {}
function buy(uint64 sz, uint64 limitPx) external onlyAsyncOwner returns (uint256) {
return _request(AsyncTypes.Intent({
asset: 10107, // HYPE/USDC spot on HyperCore
isBuy: true,
reduceOnly: false,
tif: AsyncTypes.Tif.Ioc,
sz: sz, // 8 decimals: 0.18 HYPE = 18_000_000
limitPx: limitPx, // 8 decimals
deadline: uint64(block.timestamp + 60),
callbackGas: 150_000
}));
}
function _onReceipt(uint256, AsyncTypes.Receipt calldata r) internal override {
if (r.status == AsyncTypes.Status.Filled || r.status == AsyncTypes.Status.Partial) {
position += int256(uint256(r.filledSz));
}
}
}Test it with the mock router
MockAsyncRouter records intents and answers them with scripted receipts, through the same onReceipt call the real router makes.
MockAsyncRouter m = new MockAsyncRouter(); MyVault v = new MyVault(IAsyncRouter(address(m))); uint256 id = v.buy(0.18e8, 61e8); m.answer(id, AsyncTypes.Status.Partial, 0.07e8, 60.95e8); assertEq(v.position(), 0.07e8);
Then the sandbox
The sandbox on the home page gives you a fork of Elysium with the real router, two bonded relayers and a QuickVault you own. Intents there are answered by the same relayer code that runs in production, with HyperCore priced on the live book.
Then a real intent
Bind your contract to a HyperCore account (Bind), fund a callback subscription in HYPE, and send. The first real intents should be small: HyperCore's minimum order value is 10 USDC.