Aevo4J is an unofficial implementation of Aevo's REST APIs and WebSockets in Java.
Aevo is a decentralized derivatives exchange built on Ethereum.
- Full coverage of the REST APIs and WebSockets
- Automatic deserialization of responses into Java objects
- Automatic authentication for private endpoints (REST APIs and WebSockets)
- Orderbook checksum validator
- Built-in order-signing for placing/editing orders
Note: Aevo4J requires Java 17 or higher!
<dependency>
<groupId>dev.alphaserpentis.web3</groupId>
<artifactId>aevo4j</artifactId>
<version>1.2.0</version>
</dependency>
implementation 'dev.alphaserpentis.web3:aevo4j:1.2.0'
The PublicService
and PrivateService
class contains the REST APIs for the public and private endpoints respectively.
These can be obtained via AevoHandler.getPublicService(Retrofit)
or AevoHandler.getPrivateService(Retrofit, String, String, Boolean)
.
For Retrofit, you can either obtain a default Retrofit
instance via AevoHandler.defaultRetrofit()
and pass it inside the service.
Alternatively, if you need to customize Retrofit for your needs, you can call the AevoHandler.getCustomRetrofit
method and pass in your needed arguments.
To authenticate a request, you have two methods:
- Use API Key + API Secret
- Use API Key + Signature + Timestamp (recommended)
Both methods are automatically handled by the library.
See the REST Authentication for more information.
The AevoHandler
class has a method getCustomRetrofit
available to pass in a custom call adapter factory and converter factory.
However, you're not required to call this method if you need more customization.
You can get the websockets from the methods found in PublicWebSockets
and PrivateWebSockets
.
Alternatively, you can obtain the needed websockets from this table below:
Channel | WebSocket Listener Class | API Type |
---|---|---|
PUBLISH Channels | ChannelsListener |
Public |
PUBLISH Ping | PingListener |
Public |
SUBSCRIBE Orderbook | OrderbookListener |
Public |
SUBSCRIBE Ticker | TickerListener |
Public |
SUBSCRIBE Index | IndexListener |
Public |
SUBSCRIBE Trades | TradesListener |
Public |
SUBSCRIBE RFQs | RFQsListener |
Public |
PUBLISH Status | StatusListener |
Private |
PUBLISH Create Order | CreateOrderListener |
Private |
PUBLISH Edit Order | EditOrderListener |
Private |
PUBLISH Cancel Order | CancelOrderListener |
Private |
PUBLISH Cancel All Orders | CancelAllOrdersListener |
Private |
PUBLISH Create RFQ | CreateRFQListener |
Private |
PUBLISH Cancel RFQ | CancelRFQListener |
Private |
PUBLISH Create Quote RFQ | CreateQuoteRFQListener |
Private |
SUBSCRIBE Orders | OrdersListener |
Private |
SUBSCRIBE Fills | FillsListener |
Private |
SUBSCRIBE Positions | PositionsListener |
Private |
Requests using private websockets are automatically authenticated by the library.
In order to place orders in either the REST APIs or WebSockets, you will need to be able to pass in a signature parameter. This signature is generated by signing the order payload with the signing key that was generated from the Aevo website.
See the Signing Orders for more information.
- Instrument ID:
2054
(Testnet ETH-PERP) - Side:
BUY
- Amount:
1.0
(contracts) - Price:
1000.0
(USD)
// Create the order payload
UnsignedOrder order = new UnsignedOrder.Builder(
2054, // Instrument ID
"YOUR WALLET ADDRESS", // maker address
true, // true = buy, false = sell
1000000, // amount of contracts (1.0)
1000000000 // price in USD (1000.0)
).build();
// Sign the unsigned order
SignedOrder signedOrder = UnsignedOrder.signOrder(
order, // the unsigned order payload
true, // true if testnet, false if mainnet
"YOUR SIGNING KEY" // the signing key generated from the Aevo website
);