HyperLiquid.Net
HyperLiquid.Net is a client library for accessing the HyperLiquid DEX REST and Websocket API.
Features
- Response data is mapped to descriptive models
- Input parameters and response values are mapped to discriptive enum values where possible
- Automatic websocket (re)connection management
- Client side rate limiting
- Cient side order book implementation
- Extensive logging
- Support for different environments
- Easy integration with other exchange client based on the CryptoExchange.Net base library
Supported Frameworks
The library is targeting both .NET Standard 2.0
and .NET Standard 2.1
for optimal compatibility
.NET implementation | Version Support |
---|---|
.NET Core | 2.0 and higher |
.NET Framework | 4.6.1 and higher |
Mono | 5.4 and higher |
Xamarin.iOS | 10.14 and higher |
Xamarin.Android | 8.0 and higher |
UWP | 10.0.16299 and higher |
Unity | 2018.1 and higher |
Discord
A Discord server is available here. Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries.
Support the project
ReferralIf you do not yet have an account please consider using this referal link to sign up: Link
Not only will you support development at no cost, you also get a 4% discount in fees.
DonateMake a one time donation in a crypto currency of your choice. If you prefer to donate a currency not listed here please contact me.
Btc: bc1q277a5n54s2l2mzlu778ef7lpkwhjhyvghuv8qf
Eth: 0xcb1b63aCF9fef2755eBf4a0506250074496Ad5b7
USDT (TRX): TKigKeJPXZYyMVDgMyXxMf17MWYia92Rjd
Alternatively, sponsor me on Github using Github Sponsors.
Getting Started
The package is available on Nuget. After installing the package the HyperLiquid API is available by using the HyperLiquidRestClient
and HyperLiquidSocketClient
.
Installation
Nuget
dotnet add package HyperLiquid.Net
GitHub packages
HyperLiquid.Net is available on GitHub packages. You'll need to add https://nuget.pkg.github.com/JKorf/index.json
as a NuGet package source.
Download release
The NuGet package files are added along side the source with the latest GitHub release which can found here.
API Access
HyperLiquid.Net can be configured using Dotnet dependency injection, after which the clients can be injected into your services. It also correctly configures logging and HttpClient usage.
// Configure options from config file
// see https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples/example-config.json for an example
builder.Services.AddHyperLiquid(builder.Configuration.GetSection("HyperLiquid"));
// OR
builder.Services.AddHyperLiquid(options => {
// Configure options in code
options.ApiCredentials = new ApiCredentials("APIKEY", "APISECRET");
});
The IHyperLiquidRestClient
and IHyperLiquidSocketClient
can then be injected.
Alternatively the rest and socket client can be constructed directly
var restClient = new HyperLiquidRestClient(options => {
// Options can be configured here, for example:
options.ApiCredentials = new ApiCredentials("APIKEY", "APISECRET");
});
var socketClient = new HyperLiquidSocketClient();
Examples
Spot API
Get SymbolsGet a list of supported spot symbols
var hyperLiquidClient = new HyperLiquidRestClient();
var result = await hyperLiquidClient.SpotApi.ExchangeData.GetExchangeInfoAsync();
var symbols = result.Data.Symbols;
Get Symbol TickerGet the 24h price ticker of a spot symbol
var hyperLiquidClient = new HyperLiquidRestClient();
var result = await hyperLiquidClient.SpotApi.ExchangeData.GetExchangeInfoAndTickersAsync();
var symbolTicker = result.Data.Tickers.Single(x => x.Symbol == "HYPE/USDC");
Get BalancesGet asset balances of the spot account
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var result = await hyperLiquidClient.SpotApi.Account.GetBalancesAsync();
Place Limit OrderPlace a new limit order for buying 1 HYPE at a price of 20 USDC
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var result = await hyperLiquidClient.SpotApi.Trading.PlaceOrderAsync(
"HYPE/USDC",
OrderSide.Buy,
OrderType.Limit,
1m,
20);
Place Market OrderPlace a new market order for buying 1 HYPE at the best available price. Note that the current symbol price needs to be passed to calculate max slippage as HyperLiquid does not natively support market orders
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var currentPrices = await hyperLiquidClient.SpotApi.ExchangeData.GetPricesAsync();
var symbolPrice = currentPrices.Data.Single(x => x.Key == "HYPE/USDC");
var result = await hyperLiquidClient.SpotApi.Trading.PlaceOrderAsync(
"HYPE/USDC",
OrderSide.Buy,
OrderType.Market,
quantity: 1,
price: symbolPrice.Value);
Get Order InfoRetrieve order information for a specific order
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var result = await hyperLiquidClient.SpotApi.Trading.GetOrderAsync(123);
Cancel an orderCancel a currently active order
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var result = await hyperLiquidClient.SpotApi.Trading.CancelOrderAsync("HYPE/USDC", 123);
Futures API
Get SymbolsGet a list of supported usd futures symbols
var hyperLiquidClient = new HyperLiquidRestClient();
var result = await hyperLiquidClient.FuturesApi.ExchangeData.GetExchangeInfoAsync();
Get Symbol TickerGet the 24h price ticker of a futures symbol
var result = await hyperLiquidClient.SpotApi.ExchangeData.GetExchangeInfoAndTickersAsync();
var symbolTicker = result.Data.Tickers.Single(x => x.Symbol == "ETH");
Get Balances and PositionGet balance of the perpetual futures account
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var result = await hyperLiquidClient.FuturesApi.Account.GetAccountInfoAsync();
Place Limit OrderPlace a new limit order for going long on 0.1 ETH at a price of 2000 USDT
var hyperLiquidClient = new HyperLiquidRestClient(options => {
options.ApiCredentials = new ApiCredentials("ADDRESS", "PRIVATE KEY");
});
var result = await hyperLiquidClient.FuturesApi.Trading.PlaceOrderAsync(
"ETH",
OrderSide.Buy,
OrderType.Limit,
0.1m,
price: 2000);