forked from binance-exchange/binance-java-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSwapEndpointExample.java
More file actions
executable file
·32 lines (28 loc) · 1.53 KB
/
SwapEndpointExample.java
File metadata and controls
executable file
·32 lines (28 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.binance.api.examples;
import com.binance.api.client.api.sync.BinanceApiSwapRestClient;
import com.binance.api.client.domain.swap.Liquidity;
import com.binance.api.client.domain.swap.Pool;
import com.binance.api.client.domain.swap.SwapHistory;
import com.binance.api.client.domain.swap.SwapQuote;
import com.binance.api.client.domain.swap.SwapRecord;
import com.binance.api.client.factory.BinanceAbstractFactory;
import com.binance.api.client.factory.BinanceSwapApiClientFactory;
import java.util.List;
public class SwapEndpointExample {
public static void main(String[] args) {
// BinanceSwapApiClientFactory factory = (BinanceSwapApiClientFactory) BinanceAbstractFactory.createFactory("YOUR_API_KEY", "YOUR_SECRET", BinanceEngineType.SWAP);
BinanceSwapApiClientFactory factory = BinanceAbstractFactory.createSwapFactory("YOUR_API_KEY", "YOUR_SECRET");
BinanceApiSwapRestClient swapClient = factory.newRestClient();
List<Pool> pools = swapClient.listAllSwapPools();
for (Pool pool : pools) {
System.out.println(pool);
Liquidity poolLiquidityInfo = swapClient.getPoolLiquidityInfo(pool.getPoolId());
System.out.println(poolLiquidityInfo);
}
SwapQuote swapQuote = swapClient.requestQuote("USDT", "USDC", "10");
System.out.println(swapQuote);
SwapRecord swapRecord = swapClient.swap("USDT", "USDC", "10");
SwapHistory swapHistory = swapClient.getSwapHistory(swapRecord.getSwapId());
System.out.println(swapHistory);
}
}