import { IllaSDK } from '@illalabs/sdk'
const sdk = new IllaSDK({ apiKey: process.env.ILLA_API_KEY! })
// `actionMetadata` and `signatureRequests` come from a preceding hyperliquid* tool result.
const sigHex = await wallet.signTypedData(signatureRequests[0].typedData)
const res = await sdk.submitHyperliquidAction({
action: actionMetadata.unsignedAction, // unsigned action, verbatim from the tool
nonce: actionMetadata.nonce, // ms nonce the signature commits to
signature: { // Hyperliquid expects the { r, s, v } split
r: `0x${sigHex.slice(2, 66)}`,
s: `0x${sigHex.slice(66, 130)}`,
v: parseInt(sigHex.slice(130, 132), 16),
},
network: actionMetadata.network, // 'mainnet' | 'testnet'
hmac: signatureRequests[0].hmac, // integrity HMAC, if the request carried one
})
if (!res.success) {
console.error('Hyperliquid submission failed:', res.error)
} else {
console.log(res.status, res.oid, res.avgPx, res.totalSz)
}