diff --git a/src/main/java/no/jansoren/defillama/CoinsClient.java b/src/main/java/no/jansoren/defillama/CoinsClient.java index 2aefa7a..ecfc042 100644 --- a/src/main/java/no/jansoren/defillama/CoinsClient.java +++ b/src/main/java/no/jansoren/defillama/CoinsClient.java @@ -16,4 +16,8 @@ public CoinsClient(HttpClient httpClient, ObjectMapper objectMapper) { public Coins getPricesOfTokensByContractAddress(String coins, String searchWidth) { return get("https://coins.llama.fi/prices/current/"+coins+"?searchWidth="+searchWidth, new TypeReference<>(){}); } + + public Coins getHistoricalPricesOfTokensByContractAddress(String coins, int timestamp, String searchWidth) { + return get("https://coins.llama.fi/prices/historical/" + timestamp + "/" +coins+"?searchWidth="+searchWidth, new TypeReference<>(){}); + } } diff --git a/src/test/java/no/jansoren/defillama/CoinsClientTest.java b/src/test/java/no/jansoren/defillama/CoinsClientTest.java index 7f12213..bdd3b4f 100644 --- a/src/test/java/no/jansoren/defillama/CoinsClientTest.java +++ b/src/test/java/no/jansoren/defillama/CoinsClientTest.java @@ -27,4 +27,13 @@ void testGetPricesOfTokensByContractAddress() { Assertions.assertNotNull(coins); } + @Test + void testGetHistoricalPricesOfTokensByContractAddress() { + var contractAddresses = "ethereum:0xdF574c24545E5FfEcb9a659c229253D4111d87e1,coingecko:ethereum,bsc:0x762539b45a1dcce3d36d080f74d1aed37844b878,ethereum:0xdB25f211AB05b1c97D595516F45794528a807ad8"; + var timestamp = 1648680149; + var searchWidth = "4h"; + Coins coins = client.getHistoricalPricesOfTokensByContractAddress(contractAddresses, timestamp, searchWidth); + Assertions.assertNotNull(coins); + } + }