{"id":35752758,"url":"https://github.com/chicunic/hyperliquid-swift","last_synced_at":"2026-01-30T11:40:46.113Z","repository":{"id":330686618,"uuid":"1123523199","full_name":"chicunic/hyperliquid-swift","owner":"chicunic","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-27T05:20:31.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-27T17:25:35.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chicunic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-27T03:57:11.000Z","updated_at":"2026-01-27T05:19:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/chicunic/hyperliquid-swift","commit_stats":null,"previous_names":["chicunic/hyperliquid-swift"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/chicunic/hyperliquid-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicunic%2Fhyperliquid-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicunic%2Fhyperliquid-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicunic%2Fhyperliquid-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicunic%2Fhyperliquid-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chicunic","download_url":"https://codeload.github.com/chicunic/hyperliquid-swift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chicunic%2Fhyperliquid-swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28911854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T08:15:08.179Z","status":"ssl_error","status_checked_at":"2026-01-30T08:14:31.507Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-06T20:26:34.886Z","updated_at":"2026-01-30T11:40:46.089Z","avatar_url":"https://github.com/chicunic.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hyperliquid-swift\n\n![Swift 6.0](https://img.shields.io/badge/Swift-6.0-orange.svg)\n![Platform](https://img.shields.io/badge/platform-iOS%2018.0%2B%20%7C%20macOS%2015.0%2B-lightgrey.svg)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA native, type-safe Swift SDK for interacting with the [Hyperliquid](https://hyperliquid.xyz) DEX API.\n\n## Overview\n\nThis SDK provides a comprehensive Swift interface for the Hyperliquid decentralized exchange, supporting both **Info (read-only)** and **Exchange (trading)** APIs. The implementation is rigorously tested and aligned with the official [Python SDK](https://github.com/hyperliquid-dex/hyperliquid-python-sdk) to ensure signature compatibility and reliability.\n\n## Requirements\n\n- **Swift:** 6.0+\n- **Platforms:**\n  - macOS 15.0+\n  - iOS 18.0+\n- **Tools:** Xcode 16.0+\n\n## Installation\n\n### Swift Package Manager\n\nAdd the package to your `Package.swift` dependencies:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/chicunic/hyperliquid-swift.git\", from: \"0.2.0\")\n]\n```\n\nOr add it via Xcode:\n\n1. **File** → **Add Package Dependencies...**\n2. Enter URL: `https://github.com/chicunic/hyperliquid-swift.git`\n3. Select the version rule (e.g., Up to Next Major).\n\n## Quick Start\n\n### Info API (Public Data)\n\nQuery market data and account information without authentication keys.\n\n```swift\nimport HyperliquidSwift\n\n// 1. Initialize Client\nlet client = HyperliquidClient(network: .mainnet)\n\n// 2. Query Market Data\nlet mids = try await client.info.getAllMids()\nprint(\"BTC Price: \\(mids[\"BTC\"] ?? \"N/A\")\")\n\n// 3. Get Account State\nlet userAddress = \"0x...\"\nlet state = try await client.info.getUserState(address: userAddress)\nprint(\"Account Value: \\(state.marginSummary.accountValue)\")\n\n// 4. Get Historical Candles\nlet candles = try await client.info.getCandleSnapshot(\n    coin: \"ETH\",\n    interval: \"1h\",\n    startTime: startTimestamp,\n    endTime: endTimestamp\n)\n```\n\n### Exchange API (Trading)\n\nExecute trades and manage funds securely.\n\n```swift\nimport HyperliquidSwift\n\n// 1. Initialize with Private Key\n// Note: Never hardcode private keys in production apps.\nlet privateKey = \"0x...\"\nlet signer = try PrivateKeySigner(privateKeyHex: privateKey)\nlet client = HyperliquidClient(network: .mainnet, signer: signer)\n\n// 2. Place a Limit Order\nlet orderRequest = OrderRequest(\n    coin: \"ETH\",\n    isBuy: true,\n    sz: Decimal(string: \"0.1\")!,\n    limitPx: Decimal(string: \"3000\")!,\n    orderType: .limit(LimitOrderType(tif: .gtc)),\n    reduceOnly: false\n)\n\nlet result = try await client.exchange.order(orderRequest)\nprint(\"Order placed: \\(result)\")\n\n// 3. Cancel an Order\ntry await client.exchange.cancel(coin: \"ETH\", oid: 123456)\n```\n\n## Features\n\n### 📊 Info API\n\n- **Market Data:** `getAllMids`, `getL2Book`, `getCandleSnapshot`\n- **Account Info:** `getUserState`, `getSpotUserState`, `getUserFills`\n- **Metadata:** `getMeta`, `getSpotMeta`, `getMetaAndAssetCtxs`\n- **Orders:** `getOpenOrders`, `queryOrderByOid`\n\n### ⚡ Exchange API\n\n- **Trading:** Place, Modify, and Cancel orders (Single \u0026 Bulk)\n- **Account Management:** `updateLeverage`, `updateIsolatedMargin`\n- **Transfers:** USD \u0026 Spot transfers, Withdrawals from Bridge\n- **Advanced:** EIP-712 Signing support for external wallets\n\n## Architecture \u0026 Security\n\n- **Type Safety:** leveraging Swift's strong type system to prevent common API errors.\n- **Concurrency:** Built entirely with Swift `async`/`await` and `Actors`.\n- **Cryptography:**\n  - **secp256k1.swift:** High-performance ECDSA signing.\n  - **EIP-712:** Full typed data hashing implementation matching the Python SDK.\n- **Serialization:** Custom MessagePack handling ensures binary-compatible payloads with the Hyperliquid backend.\n\n### Signing Support\n\nThe SDK supports two modes for signing transactions:\n\n1. **PrivateKeySigner:** For automated bots or backend services where you hold the key.\n2. **EIP712Signer (Protocol):** For integrating with user wallets (MetaMask, WalletConnect, Privy, etc.). You implement `signTypedData` and the SDK handles the payload construction.\n\n## Development\n\nThis project uses a `Makefile` to simplify common development tasks.\n\n```bash\n# Build the project\nmake build\n\n# Run unit tests\nmake test\n\n# Check code style (SwiftLint + swift-format)\nmake check\n\n# Fix code style issues\nmake fix\n\n# Update dependencies\nmake resolve\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchicunic%2Fhyperliquid-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchicunic%2Fhyperliquid-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchicunic%2Fhyperliquid-swift/lists"}