-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started implementing StablecoinsClient
- Loading branch information
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/no/jansoren/defillama/StablecoinsClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package no.jansoren.defillama; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import no.jansoren.defillama.model.protocols.BaseDefiLlamaClient; | ||
import no.jansoren.defillama.model.stablecoins.Stablecoins; | ||
|
||
import java.net.http.HttpClient; | ||
|
||
public class StablecoinsClient extends BaseDefiLlamaClient { | ||
|
||
public StablecoinsClient(HttpClient httpClient, ObjectMapper objectMapper) { | ||
super(httpClient, objectMapper); | ||
} | ||
|
||
public Stablecoins getStablecoins(boolean includePrices) { | ||
return get(HOSTNAME_STABLECOINS+"/stablecoins?includePrices="+includePrices, Stablecoins.class); | ||
} | ||
|
||
// TODO - Work in progress | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/no/jansoren/defillama/model/stablecoins/PeggedAssetsItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package no.jansoren.defillama.model.stablecoins; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public record PeggedAssetsItem( | ||
|
||
@JsonProperty("symbol") | ||
String symbol, | ||
|
||
@JsonProperty("chainCirculating") | ||
Map<String, Map<String, Object>> chainCirculating, | ||
|
||
@JsonProperty("gecko_id") | ||
String geckoId, | ||
|
||
@JsonProperty("chains") | ||
List<String> chains, | ||
|
||
@JsonProperty("circulatingPrevWeek") | ||
Map<String, BigDecimal> circulatingPrevWeek, | ||
|
||
@JsonProperty("pegType") | ||
String pegType, | ||
|
||
@JsonProperty("circulatingPrevMonth") | ||
Object circulatingPrevMonth, | ||
|
||
@JsonProperty("pegMechanism") | ||
String pegMechanism, | ||
|
||
@JsonProperty("circulating") | ||
Map<String, BigDecimal> circulating, | ||
|
||
@JsonProperty("circulatingPrevDay") | ||
Map<String, BigDecimal> circulatingPrevDay, | ||
|
||
@JsonProperty("price") | ||
int price, | ||
|
||
@JsonProperty("priceSource") | ||
String priceSource, | ||
|
||
@JsonProperty("name") | ||
String name, | ||
|
||
@JsonProperty("id") | ||
String id | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/no/jansoren/defillama/model/stablecoins/Stablecoins.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package no.jansoren.defillama.model.stablecoins; | ||
|
||
import java.util.List; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public record Stablecoins( | ||
|
||
@JsonProperty("peggedAssets") | ||
List<PeggedAssetsItem> peggedAssets | ||
) { | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/no/jansoren/defillama/StablecoinsClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package no.jansoren.defillama; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import no.jansoren.defillama.model.stablecoins.Stablecoins; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.http.HttpClient; | ||
|
||
class StablecoinsClientTest { | ||
|
||
private StablecoinsClient client; | ||
|
||
@BeforeEach | ||
void before() { | ||
var httpClient = HttpClient.newBuilder().build(); | ||
var objectMapper = new ObjectMapper(); | ||
client = new StablecoinsClient(httpClient, objectMapper); | ||
} | ||
|
||
@Test | ||
void testGetStablecoins() { | ||
Stablecoins stablecoins = client.getStablecoins(true); | ||
Assertions.assertNotNull(stablecoins); | ||
} | ||
|
||
} |