diff --git a/.gitignore b/.gitignore index a1c2a238..f83e82b3 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +**/transactions diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/LunaWeightedMeanCalculatorService.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/LunaWeightedMeanCalculatorService.java new file mode 100644 index 00000000..0f530a8d --- /dev/null +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/LunaWeightedMeanCalculatorService.java @@ -0,0 +1,17 @@ +package com.github.kerner1000.terra; + +import com.github.kerner1000.terra.commons.Coin; +import com.github.kerner1000.terra.transactions.*; + +import java.util.Arrays; + +public class LunaWeightedMeanCalculatorService extends WeightedMeanCalculatorService { + + public LunaWeightedMeanCalculatorService() { + super(Coin.LUNA); + } + + protected Iterable getVisitors() { + return Arrays.asList(new TerraswapTransactionVisitor(), new AstroportTransactionVisitor(), new MarketTransactionVisitor(), new LoopSwapTransactionVisitor()); + } +} diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/MarsWeightedMeanCalculatorService.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/MarsWeightedMeanCalculatorService.java new file mode 100644 index 00000000..6f5db367 --- /dev/null +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/MarsWeightedMeanCalculatorService.java @@ -0,0 +1,17 @@ +package com.github.kerner1000.terra; + +import com.github.kerner1000.terra.commons.Coin; +import com.github.kerner1000.terra.transactions.*; + +import java.util.Arrays; + +public class MarsWeightedMeanCalculatorService extends WeightedMeanCalculatorService { + + public MarsWeightedMeanCalculatorService() { + super(Coin.MARS); + } + + protected Iterable getVisitors() { + return Arrays.asList(new AstroportTransactionVisitorMars(), new TerraswapTransactionVisitorMars()); + } +} diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/TerraAppController.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/TerraAppController.java index dd62446a..e388fbd2 100755 --- a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/TerraAppController.java +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/TerraAppController.java @@ -1,9 +1,7 @@ package com.github.kerner1000.terra; import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.kerner1000.terra.commons.BinnedBuySellMaps; -import com.github.kerner1000.terra.commons.BuySellMaps; -import com.github.kerner1000.terra.commons.SwapPrices; +import com.github.kerner1000.terra.commons.*; import com.github.kerner1000.terra.feign.LcdClient; import com.github.kerner1000.terra.feign.LcdTransactionsPagination; import com.github.kerner1000.terra.json.data.Transaction; @@ -11,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.openapitools.api.SwapsApi; import org.openapitools.model.BuySellSwaps; +import org.openapitools.model.BuySellSwapsPerCoin; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -18,6 +17,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.TreeMap; @Slf4j @RestController @@ -25,30 +26,30 @@ public class TerraAppController implements SwapsApi { private final LcdClient lcdClient; - private final WeightedMeanCalculatorService callbackService; - private final ObjectMapper objectMapper; private final TerraConfig terraConfig; - public TerraAppController(LcdClient lcdClient, WeightedMeanCalculatorService callbackService, ObjectMapper objectMapper, TerraConfig terraConfig) { + public TerraAppController(LcdClient lcdClient, ObjectMapper objectMapper, TerraConfig terraConfig) { this.lcdClient = lcdClient; - this.callbackService = callbackService; this.objectMapper = objectMapper; this.terraConfig = terraConfig; } @Override - public ResponseEntity getSwaps(String token, String terraAddress) { - log.info("Calculating average buy/sell for {} and address {}", token, terraAddress); + public ResponseEntity getSwaps(String terraAddress, List hide) { + log.info("Calculating average buy/sell for address {}", terraAddress); long transactionsCount = 0; long offset = 0; - BuySellMaps collectedSwaps = new BuySellMaps(); + BuySellMapsForCoin coinToCollectedSwaps = new BuySellMapsForCoin(); do { try { LcdTransactionsPagination lcdTransactionsPagination = lcdClient.searchTransactions(terraAddress, 100, offset); List transactions = new ArrayList<>(lcdTransactionsPagination.getTxs()); - collectedSwaps.add(callbackService.visit(lcdTransactionsPagination.getTxs())); + BuySellMapsForCoin buySellMapsForCoin = new LunaWeightedMeanCalculatorService().visit(lcdTransactionsPagination.getTxs()); + BuySellMapsForCoin buySellMapsForCoinMars = new MarsWeightedMeanCalculatorService().visit(lcdTransactionsPagination.getTxs()); + coinToCollectedSwaps.add(buySellMapsForCoin); + coinToCollectedSwaps.add(buySellMapsForCoinMars); transactionsCount += transactions.size(); log.info("Collected {} transactions, current offset: {}", transactionsCount, offset); if(terraConfig.isWriteTransactions()) { @@ -69,11 +70,10 @@ public ResponseEntity getSwaps(String token, String terraAddress) } } while (offset != 0); - SwapPrices result2 = new Transactions().getWeightedMean(collectedSwaps); - log.info("Collected {} transactions, average swap price is {}", transactionsCount, result2); - BinnedBuySellMaps binnedBuySellMaps = BinnedBuySellMaps.BinnedBuySellMapsFactory.buildWithFixBinSize(collectedSwaps.getBuyMap(), 5); - log.debug("Buy price distribution:\n{}", binnedBuySellMaps.toAsciiHistogram(false)); - org.openapitools.model.BuySellSwaps result = Transformer.transform(collectedSwaps); + BuySellSwapsPerCoin result = new BuySellSwapsPerCoin(); + for(Map.Entry entry : coinToCollectedSwaps.entrySet()){ + result.addEntriesItem(Transformer.transform(entry.getKey(), entry.getValue())); + } return ResponseEntity.ok(result); } } diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/Transformer.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/Transformer.java index 76b1b581..2acf4ad1 100644 --- a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/Transformer.java +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/Transformer.java @@ -2,6 +2,7 @@ import com.github.kerner1000.terra.commons.BuySellMap; import com.github.kerner1000.terra.commons.BuySellMaps; +import com.github.kerner1000.terra.commons.Coin; import org.openapitools.model.BuySellSwaps; import org.openapitools.model.SwapEntry; import org.openapitools.model.Swaps; @@ -11,8 +12,9 @@ public class Transformer { - public static BuySellSwaps transform(BuySellMaps maps){ + public static BuySellSwaps transform(Coin coin, BuySellMaps maps){ BuySellSwaps buySellSwaps = new BuySellSwaps(); + buySellSwaps.setCoin(coin.toString()); buySellSwaps.setBuy(new Swaps()); buySellSwaps.setSell(new Swaps()); for(Map.Entry element : maps.getBuyMap().getMap().entrySet()){ diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/WeightedMeanCalculatorService.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/WeightedMeanCalculatorService.java index b45e6d87..f4452fc1 100644 --- a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/WeightedMeanCalculatorService.java +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/WeightedMeanCalculatorService.java @@ -1,24 +1,35 @@ package com.github.kerner1000.terra; import com.github.kerner1000.terra.commons.BuySellMaps; +import com.github.kerner1000.terra.commons.BuySellMapsForCoin; +import com.github.kerner1000.terra.commons.Coin; import com.github.kerner1000.terra.json.data.Transaction; -import com.github.kerner1000.terra.transactions.Transactions; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.web.context.annotation.RequestScope; +import com.github.kerner1000.terra.transactions.AbstractTransactionVisitor; import java.util.List; -@Slf4j -@RequestScope -@Service -public class WeightedMeanCalculatorService { - - public BuySellMaps visit(List transactions) throws InterruptedException { - BuySellMaps wm = new Transactions().getWeightedMeanSwapMaps(transactions); -// if(log.isDebugEnabled() && wm.getBuyMap().getMap().size() > 1 || wm.getSellMap().getMap().size() > 1) { -// log.debug("swap map:\n{}\n======\nweighted mean: {}", result, new Transactions().getWeightedMean(result)); -// } - return wm; +public abstract class WeightedMeanCalculatorService { + + private final Coin coin; + + protected WeightedMeanCalculatorService(Coin coin) { + this.coin = coin; + } + + public BuySellMapsForCoin visit(List transactions) throws InterruptedException { + + BuySellMaps result = new BuySellMaps(); + + for (Transaction transaction : transactions) { + if(Thread.currentThread().isInterrupted()){ + break; + } + for (AbstractTransactionVisitor visitor : getVisitors()) { + result.add(visitor.visit(transaction)); + } + } + return new BuySellMapsForCoin(coin, result); } + + protected abstract Iterable getVisitors(); } diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/ExecuteMessage.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/ExecuteMessage.java index df68518c..2d01eda9 100644 --- a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/ExecuteMessage.java +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/ExecuteMessage.java @@ -8,6 +8,8 @@ public class ExecuteMessage { Swap swap; + Send send; + @JsonProperty("assert_limit_order") AssertLimitOrder assertLimitOrder; diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/MsgValue.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/MsgValue.java index 2eb8a0bb..2e5f6e49 100644 --- a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/MsgValue.java +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/MsgValue.java @@ -31,6 +31,10 @@ public void setExecuteMessageString(JsonNode executeMessageString) { messages = Additional.extract(executeMessageString.toString()); } catch (JsonProcessingException jsonProcessingException) { var text = executeMessageString.textValue(); + // "send" msg + if(text == null){ + return; + } try { byte[] decodedBytes = Base64.getDecoder().decode(text); String decodedString = new String(decodedBytes); diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/Send.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/Send.java new file mode 100644 index 00000000..58f6c220 --- /dev/null +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/json/data/Send.java @@ -0,0 +1,35 @@ +package com.github.kerner1000.terra.json.data; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.Data; + +import java.util.Base64; + +@Data +public class Send { + + static ObjectMapper objectMapper = new ObjectMapper(); + + static { + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + Number amount; + + String contract; + + Swap msg; + + @JsonProperty("msg") + public void setMsg(JsonNode msg) throws JsonProcessingException { + byte[] decodedBytes = Base64.getDecoder().decode(msg.textValue()); + String decodedString = new String(decodedBytes); + ExecuteMessage swap = objectMapper.readValue(decodedString, ExecuteMessage.class); + this.msg = swap.getSwap(); + } +} diff --git a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/transactions/Transactions.java b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/transactions/Transactions.java index a0934192..865b016e 100644 --- a/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/transactions/Transactions.java +++ b/terra-stats-api-service/src/main/java/com/github/kerner1000/terra/transactions/Transactions.java @@ -6,11 +6,9 @@ import com.github.kerner1000.terra.commons.SwapPrices; import com.github.kerner1000.terra.json.data.Additional; import com.github.kerner1000.terra.json.data.Swap; -import com.github.kerner1000.terra.json.data.Transaction; import lombok.extern.slf4j.Slf4j; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.function.Predicate; @@ -28,27 +26,6 @@ public class Transactions { static final Predicate ASTROPORT_FILTER = a -> a != null && a.getContract() != null && a.getContract().stream().anyMatch(c -> c.contains(SwapPairs.Astroport.LUNA_UST)); - private final List visitors = Arrays.asList(new TerraswapTransactionVisitor(), new AstroportTransactionVisitor(), new MarketTransactionVisitor(), new LoopSwapTransactionVisitor()); - - public BuySellMaps getWeightedMeanSwapMaps(Collection transactionsList) { - - BuySellMaps result = new BuySellMaps(); - - for (Transaction transaction : transactionsList) { - if(Thread.currentThread().isInterrupted()){ - break; - } - for (AbstractTransactionVisitor visitor : visitors) { - result.add(visitor.visit(transaction)); - } - } - return result; - } - - public SwapPrices getWeightedMean(Collection transactionsList) throws InterruptedException { - return getWeightedMean(getWeightedMeanSwapMaps(transactionsList)); - } - public SwapPrices getWeightedMean(BuySellMaps swapResult) { return new SwapPrices(weightedMean(swapResult.getBuyMap()), weightedMean(swapResult.getSellMap())); } diff --git a/terra-stats-api-service/src/main/resources/application.yaml b/terra-stats-api-service/src/main/resources/application.yaml index 4f4353f3..8909c336 100644 --- a/terra-stats-api-service/src/main/resources/application.yaml +++ b/terra-stats-api-service/src/main/resources/application.yaml @@ -11,7 +11,7 @@ feign: default: loggerLevel: NONE -app.terra.sleep-between-calls: 800 +app.terra.sleep-between-calls: 900 app.terra.write-transactions: true spring: diff --git a/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/AstroportTransactionVisitorTest.java b/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/AstroportTransactionVisitorTest.java index 24a04395..eb300dfc 100644 --- a/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/AstroportTransactionVisitorTest.java +++ b/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/AstroportTransactionVisitorTest.java @@ -33,8 +33,9 @@ public void testAstroportUstToLuna() throws IOException { Transaction transaction = objectMapper.readValue(new File("src/test/resources/example-transaction-astroport-UST-to-LUNA.json"), Transaction.class); var result = transactionVisitor.visit(transaction); assertNotNull(result); - assertEquals(1,result.getBuyMap().getMap().size()); - assertEquals(0,result.getSellMap().getMap().size()); + assertEquals(1, result.getBuyMap().getMap().size()); + assertEquals(0, result.getSellMap().getMap().size()); + assertEquals(10d, result.getBuyMap().getMap().values().iterator().next()); } diff --git a/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/DecodeTest.java b/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/DecodeTest.java index 835b1f0b..2a40ecbc 100644 --- a/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/DecodeTest.java +++ b/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/DecodeTest.java @@ -8,7 +8,7 @@ public class DecodeTest { @Test public void test(){ - var text = "eyJhc3NlcnRfbGltaXRfb3JkZXIiOnsib2ZmZXJfY29pbiI6eyJkZW5vbSI6InVsdW5hIiwiYW1vdW50IjoiMTAwMDAwMDAifSwiYXNrX2Rlbm9tIjoidXVzZCIsIm1pbmltdW1fcmVjZWl2ZSI6IjE1NDgzNjMxNiJ9fQ=="; + var text = "eyJzd2FwIjp7Im1heF9zcHJlYWQiOiIwLjAwNSIsImJlbGllZl9wcmljZSI6IjEuMTc3Njg3MzQ3MDkyMDE5MDcxIn19"; byte[] decodedBytes = Base64.getDecoder().decode(text); String decodedString = new String(decodedBytes); System.out.println(decodedString); diff --git a/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/json/data/SwapTest.java b/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/json/data/SwapTest.java new file mode 100644 index 00000000..67e6f982 --- /dev/null +++ b/terra-stats-api-service/src/test/java/com/github/kerner1000/terra/json/data/SwapTest.java @@ -0,0 +1,29 @@ +package com.github.kerner1000.terra.json.data; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class SwapTest { + + @BeforeEach + void setUp() { + } + + @AfterEach + void tearDown() { + } + + @Test + void simpleTest() throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + ExecuteMessage hans = objectMapper.readValue("{\"swap\":{\"max_spread\":\"0.005\",\"belief_price\":\"1.177687347092019071\"}}", ExecuteMessage.class); + assertNotNull(hans); + } +} \ No newline at end of file diff --git a/terra-stats-api-service/src/test/resources/example-transaction-astroport-MARS-to-UST.json b/terra-stats-api-service/src/test/resources/example-transaction-astroport-MARS-to-UST.json new file mode 100644 index 00000000..a8164adb --- /dev/null +++ b/terra-stats-api-service/src/test/resources/example-transaction-astroport-MARS-to-UST.json @@ -0,0 +1,820 @@ +{ + "height": "7522009", + "txhash": "F1B5C06CAFA5FE339056FF8D5292BE05640F6F62ACB350CB0973EF6EBB1ACBB2", + "data": "0A280A262F74657272612E7761736D2E763162657461312E4D736745786563757465436F6E7472616374", + "raw_log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"8491041uusd\"},{\"key\":\"receiver\",\"value\":\"terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0\"},{\"key\":\"amount\",\"value\":\"8515uusd\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"8491041uusd\"},{\"key\":\"spender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"8515uusd\"}]},{\"type\":\"execute_contract\",\"attributes\":[{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"sender\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"contract_address\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"}]},{\"type\":\"from_contract\",\"attributes\":[{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"send\"},{\"key\":\"from\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"to\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"10000000\"},{\"key\":\"contract_address\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"action\",\"value\":\"swap\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"offer_asset\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"ask_asset\",\"value\":\"uusd\"},{\"key\":\"offer_amount\",\"value\":\"10000000\"},{\"key\":\"return_amount\",\"value\":\"8491041\"},{\"key\":\"tax_amount\",\"value\":\"0\"},{\"key\":\"spread_amount\",\"value\":\"5\"},{\"key\":\"commission_amount\",\"value\":\"25549\"},{\"key\":\"maker_fee_amount\",\"value\":\"8515\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/terra.wasm.v1beta1.MsgExecuteContract\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"module\",\"value\":\"bank\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"module\",\"value\":\"bank\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"8491041uusd\"},{\"key\":\"recipient\",\"value\":\"terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"8515uusd\"}]},{\"type\":\"wasm\",\"attributes\":[{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"send\"},{\"key\":\"from\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"to\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"10000000\"},{\"key\":\"contract_address\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"action\",\"value\":\"swap\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"offer_asset\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"ask_asset\",\"value\":\"uusd\"},{\"key\":\"offer_amount\",\"value\":\"10000000\"},{\"key\":\"return_amount\",\"value\":\"8491041\"},{\"key\":\"tax_amount\",\"value\":\"0\"},{\"key\":\"spread_amount\",\"value\":\"5\"},{\"key\":\"commission_amount\",\"value\":\"25549\"},{\"key\":\"maker_fee_amount\",\"value\":\"8515\"}]}]}]", + "logs": [ + { + "events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "8491041uusd" + }, + { + "key": "receiver", + "value": "terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0" + }, + { + "key": "amount", + "value": "8515uusd" + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "spender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "8491041uusd" + }, + { + "key": "spender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "8515uusd" + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "sender", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "contract_address", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "send" + }, + { + "key": "from", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "to", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "10000000" + }, + { + "key": "contract_address", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "action", + "value": "swap" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "offer_asset", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "ask_asset", + "value": "uusd" + }, + { + "key": "offer_amount", + "value": "10000000" + }, + { + "key": "return_amount", + "value": "8491041" + }, + { + "key": "tax_amount", + "value": "0" + }, + { + "key": "spread_amount", + "value": "5" + }, + { + "key": "commission_amount", + "value": "25549" + }, + { + "key": "maker_fee_amount", + "value": "8515" + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "action", + "value": "/terra.wasm.v1beta1.MsgExecuteContract" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "module", + "value": "bank" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "module", + "value": "bank" + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "recipient", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "8491041uusd" + }, + { + "key": "recipient", + "value": "terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "8515uusd" + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "send" + }, + { + "key": "from", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "to", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "10000000" + }, + { + "key": "contract_address", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "action", + "value": "swap" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "offer_asset", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "ask_asset", + "value": "uusd" + }, + { + "key": "offer_amount", + "value": "10000000" + }, + { + "key": "return_amount", + "value": "8491041" + }, + { + "key": "tax_amount", + "value": "0" + }, + { + "key": "spread_amount", + "value": "5" + }, + { + "key": "commission_amount", + "value": "25549" + }, + { + "key": "maker_fee_amount", + "value": "8515" + } + ] + } + ] + } + ], + "gas_wanted": "369417", + "gas_used": "318272", + "tx": { + "type": "core/StdTx", + "value": { + "msg": [ + { + "type": "wasm/MsgExecuteContract", + "value": { + "sender": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js", + "contract": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n", + "execute_msg": { + "send": { + "amount": "10000000", + "contract": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds", + "msg": "eyJzd2FwIjp7Im1heF9zcHJlYWQiOiIwLjAwNSIsImJlbGllZl9wcmljZSI6IjEuMTc3Njg3MzQ3MDkyMDE5MDcxIn19" + } + }, + "coins": [] + } + } + ], + "fee": { + "amount": [ + { + "denom": "uusd", + "amount": "55413" + } + ], + "gas": "369417" + }, + "signatures": [], + "memo": "", + "timeout_height": "0" + } + }, + "timestamp": "2022-05-05T20:53:45Z", + "events": [ + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NTU0MTN1dXNk", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWxrYWVxZmE=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NTU0MTN1dXNk", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWxrYWVxZmE=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NTU0MTN1dXNk", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": "NTU0MTN1dXNk", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanMvMzU5Mg==", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "VXlKS0U3MDcrckZRcnY4UlhvRGYvdklMQWtFZDlkTTZmTHRmV2k0OXZuY3dhQmxZeW9IWlNpZ096QnQ4RmRzRHRwWi9lc0dZVzFjekZpWm5BQ25KbXc9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L3RlcnJhLndhc20udjFiZXRhMS5Nc2dFeGVjdXRlQ29udHJhY3Q=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c2VuZA==", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c2VuZA==", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c3dhcA==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "b2ZmZXJfYXNzZXQ=", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YXNrX2Fzc2V0", + "value": "dXVzZA==", + "index": true + }, + { + "key": "b2ZmZXJfYW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + }, + { + "key": "cmV0dXJuX2Ftb3VudA==", + "value": "ODQ5MTA0MQ==", + "index": true + }, + { + "key": "dGF4X2Ftb3VudA==", + "value": "MA==", + "index": true + }, + { + "key": "c3ByZWFkX2Ftb3VudA==", + "value": "NQ==", + "index": true + }, + { + "key": "Y29tbWlzc2lvbl9hbW91bnQ=", + "value": "MjU1NDk=", + "index": true + }, + { + "key": "bWFrZXJfZmVlX2Ftb3VudA==", + "value": "ODUxNQ==", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c3dhcA==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "b2ZmZXJfYXNzZXQ=", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YXNrX2Fzc2V0", + "value": "dXVzZA==", + "index": true + }, + { + "key": "b2ZmZXJfYW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + }, + { + "key": "cmV0dXJuX2Ftb3VudA==", + "value": "ODQ5MTA0MQ==", + "index": true + }, + { + "key": "dGF4X2Ftb3VudA==", + "value": "MA==", + "index": true + }, + { + "key": "c3ByZWFkX2Ftb3VudA==", + "value": "NQ==", + "index": true + }, + { + "key": "Y29tbWlzc2lvbl9hbW91bnQ=", + "value": "MjU1NDk=", + "index": true + }, + { + "key": "bWFrZXJfZmVlX2Ftb3VudA==", + "value": "ODUxNQ==", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "ODQ5MTA0MXV1c2Q=", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "ODQ5MTA0MXV1c2Q=", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "ODQ5MTA0MXV1c2Q=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "YmFuaw==", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "ODUxNXV1c2Q=", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExMnU3aGNtcGx0YXptbW5xMGZ2eWwyMjV1c24zZnk2cXFscDA1dzA=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "ODUxNXV1c2Q=", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExMnU3aGNtcGx0YXptbW5xMGZ2eWwyMjV1c24zZnk2cXFscDA1dzA=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "ODUxNXV1c2Q=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "YmFuaw==", + "index": true + } + ] + } + ] +} \ No newline at end of file diff --git a/terra-stats-api-service/src/test/resources/example-transaction-astroport-UST-to-MARS.json b/terra-stats-api-service/src/test/resources/example-transaction-astroport-UST-to-MARS.json new file mode 100644 index 00000000..63196ddd --- /dev/null +++ b/terra-stats-api-service/src/test/resources/example-transaction-astroport-UST-to-MARS.json @@ -0,0 +1,858 @@ +{ + "height": "7521991", + "txhash": "56F12BD8A68C38A6156D1C49C3B8F04B8DD2787BA1E111F86399F0FC5DD017B5", + "data": "0A280A262F74657272612E7761736D2E763162657461312E4D736745786563757465436F6E7472616374", + "raw_log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"amount\",\"value\":\"10000000uusd\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"10000000uusd\"}]},{\"type\":\"execute_contract\",\"attributes\":[{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"contract_address\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"}]},{\"type\":\"from_contract\",\"attributes\":[{\"key\":\"contract_address\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"action\",\"value\":\"swap\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"offer_asset\",\"value\":\"uusd\"},{\"key\":\"ask_asset\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"offer_amount\",\"value\":\"10000000\"},{\"key\":\"return_amount\",\"value\":\"11706320\"},{\"key\":\"tax_amount\",\"value\":\"0\"},{\"key\":\"spread_amount\",\"value\":\"8\"},{\"key\":\"commission_amount\",\"value\":\"35224\"},{\"key\":\"maker_fee_amount\",\"value\":\"11740\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"transfer\"},{\"key\":\"from\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"to\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"11706320\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"transfer\"},{\"key\":\"from\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"to\",\"value\":\"terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0\"},{\"key\":\"amount\",\"value\":\"11740\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/terra.wasm.v1beta1.MsgExecuteContract\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"10000000uusd\"}]},{\"type\":\"wasm\",\"attributes\":[{\"key\":\"contract_address\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"action\",\"value\":\"swap\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"offer_asset\",\"value\":\"uusd\"},{\"key\":\"ask_asset\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"offer_amount\",\"value\":\"10000000\"},{\"key\":\"return_amount\",\"value\":\"11706320\"},{\"key\":\"tax_amount\",\"value\":\"0\"},{\"key\":\"spread_amount\",\"value\":\"8\"},{\"key\":\"commission_amount\",\"value\":\"35224\"},{\"key\":\"maker_fee_amount\",\"value\":\"11740\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"transfer\"},{\"key\":\"from\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"to\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"11706320\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"transfer\"},{\"key\":\"from\",\"value\":\"terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds\"},{\"key\":\"to\",\"value\":\"terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0\"},{\"key\":\"amount\",\"value\":\"11740\"}]}]}]", + "logs": [ + { + "events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "receiver", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "amount", + "value": "10000000uusd" + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "spender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "10000000uusd" + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "contract_address", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "contract_address", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "action", + "value": "swap" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "offer_asset", + "value": "uusd" + }, + { + "key": "ask_asset", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "offer_amount", + "value": "10000000" + }, + { + "key": "return_amount", + "value": "11706320" + }, + { + "key": "tax_amount", + "value": "0" + }, + { + "key": "spread_amount", + "value": "8" + }, + { + "key": "commission_amount", + "value": "35224" + }, + { + "key": "maker_fee_amount", + "value": "11740" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "transfer" + }, + { + "key": "from", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "to", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "11706320" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "transfer" + }, + { + "key": "from", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "to", + "value": "terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0" + }, + { + "key": "amount", + "value": "11740" + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "action", + "value": "/terra.wasm.v1beta1.MsgExecuteContract" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "recipient", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "10000000uusd" + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "contract_address", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "action", + "value": "swap" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "offer_asset", + "value": "uusd" + }, + { + "key": "ask_asset", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "offer_amount", + "value": "10000000" + }, + { + "key": "return_amount", + "value": "11706320" + }, + { + "key": "tax_amount", + "value": "0" + }, + { + "key": "spread_amount", + "value": "8" + }, + { + "key": "commission_amount", + "value": "35224" + }, + { + "key": "maker_fee_amount", + "value": "11740" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "transfer" + }, + { + "key": "from", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "to", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "11706320" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "transfer" + }, + { + "key": "from", + "value": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds" + }, + { + "key": "to", + "value": "terra12u7hcmpltazmmnq0fvyl225usn3fy6qqlp05w0" + }, + { + "key": "amount", + "value": "11740" + } + ] + } + ] + } + ], + "gas_wanted": "389558", + "gas_used": "352142", + "tx": { + "type": "core/StdTx", + "value": { + "msg": [ + { + "type": "wasm/MsgExecuteContract", + "value": { + "sender": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js", + "contract": "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds", + "execute_msg": { + "swap": { + "belief_price": "0.854239419390551428", + "max_spread": "0.005", + "offer_asset": { + "amount": "10000000", + "info": { + "native_token": { + "denom": "uusd" + } + } + } + } + }, + "coins": [ + { + "denom": "uusd", + "amount": "10000000" + } + ] + } + } + ], + "fee": { + "amount": [ + { + "denom": "uusd", + "amount": "58434" + } + ], + "gas": "389558" + }, + "signatures": [], + "memo": "", + "timeout_height": "0" + } + }, + "timestamp": "2022-05-05T20:51:44Z", + "events": [ + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NTg0MzR1dXNk", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWxrYWVxZmE=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NTg0MzR1dXNk", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWxrYWVxZmE=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NTg0MzR1dXNk", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": "NTg0MzR1dXNk", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanMvMzU5MQ==", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "WFlHM1NVMVZQM1MxMlVFamJhby9hbWZQbk5Dd3hSNktOKzFaQ0RvaWxOZGUwejUxQmpNUjlmYlBSOUdMQ1R5d0dGcmRnSnhRazI3QnlScEhqZ2szTWc9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L3RlcnJhLndhc20udjFiZXRhMS5Nc2dFeGVjdXRlQ29udHJhY3Q=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDB1dXNk", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDB1dXNk", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDB1dXNk", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c3dhcA==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "b2ZmZXJfYXNzZXQ=", + "value": "dXVzZA==", + "index": true + }, + { + "key": "YXNrX2Fzc2V0", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "b2ZmZXJfYW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + }, + { + "key": "cmV0dXJuX2Ftb3VudA==", + "value": "MTE3MDYzMjA=", + "index": true + }, + { + "key": "dGF4X2Ftb3VudA==", + "value": "MA==", + "index": true + }, + { + "key": "c3ByZWFkX2Ftb3VudA==", + "value": "OA==", + "index": true + }, + { + "key": "Y29tbWlzc2lvbl9hbW91bnQ=", + "value": "MzUyMjQ=", + "index": true + }, + { + "key": "bWFrZXJfZmVlX2Ftb3VudA==", + "value": "MTE3NDA=", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c3dhcA==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "b2ZmZXJfYXNzZXQ=", + "value": "dXVzZA==", + "index": true + }, + { + "key": "YXNrX2Fzc2V0", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "b2ZmZXJfYW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + }, + { + "key": "cmV0dXJuX2Ftb3VudA==", + "value": "MTE3MDYzMjA=", + "index": true + }, + { + "key": "dGF4X2Ftb3VudA==", + "value": "MA==", + "index": true + }, + { + "key": "c3ByZWFkX2Ftb3VudA==", + "value": "OA==", + "index": true + }, + { + "key": "Y29tbWlzc2lvbl9hbW91bnQ=", + "value": "MzUyMjQ=", + "index": true + }, + { + "key": "bWFrZXJfZmVlX2Ftb3VudA==", + "value": "MTE3NDA=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "dHJhbnNmZXI=", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTE3MDYzMjA=", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "dHJhbnNmZXI=", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTE3MDYzMjA=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "dHJhbnNmZXI=", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExMnU3aGNtcGx0YXptbW5xMGZ2eWwyMjV1c24zZnk2cXFscDA1dzA=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTE3NDA=", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "dHJhbnNmZXI=", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExOXdhdWg3OXk0MnU1dnQ2MmM1YWR0Mmc1aDRleGdoMjZ0M3JwZHM=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExMnU3aGNtcGx0YXptbW5xMGZ2eWwyMjV1c24zZnk2cXFscDA1dzA=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTE3NDA=", + "index": true + } + ] + } + ] +} \ No newline at end of file diff --git a/terra-stats-api-service/src/test/resources/example-transaction-terraswap-UST-to-MARS.json b/terra-stats-api-service/src/test/resources/example-transaction-terraswap-UST-to-MARS.json new file mode 100644 index 00000000..cf4fc9e6 --- /dev/null +++ b/terra-stats-api-service/src/test/resources/example-transaction-terraswap-UST-to-MARS.json @@ -0,0 +1,694 @@ +{ + "height": "7535552", + "txhash": "5239500A7C6118EBC7D883525C46734D1ED40EF9AC5728FA8FF3B7B89DC8DCBF", + "data": "0A280A262F74657272612E7761736D2E763162657461312E4D736745786563757465436F6E7472616374", + "raw_log": "[{\"events\":[{\"type\":\"coin_received\",\"attributes\":[{\"key\":\"receiver\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"amount\",\"value\":\"10000000uusd\"}]},{\"type\":\"coin_spent\",\"attributes\":[{\"key\":\"spender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"10000000uusd\"}]},{\"type\":\"execute_contract\",\"attributes\":[{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"contract_address\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"sender\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"}]},{\"type\":\"from_contract\",\"attributes\":[{\"key\":\"contract_address\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"action\",\"value\":\"swap\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"offer_asset\",\"value\":\"uusd\"},{\"key\":\"ask_asset\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"offer_amount\",\"value\":\"10000000\"},{\"key\":\"return_amount\",\"value\":\"12107728\"},{\"key\":\"tax_amount\",\"value\":\"0\"},{\"key\":\"spread_amount\",\"value\":\"7871\"},{\"key\":\"commission_amount\",\"value\":\"36432\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"transfer\"},{\"key\":\"from\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"to\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"12107728\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"/terra.wasm.v1beta1.MsgExecuteContract\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"10000000uusd\"}]},{\"type\":\"wasm\",\"attributes\":[{\"key\":\"contract_address\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"action\",\"value\":\"swap\"},{\"key\":\"sender\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"receiver\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"offer_asset\",\"value\":\"uusd\"},{\"key\":\"ask_asset\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"offer_amount\",\"value\":\"10000000\"},{\"key\":\"return_amount\",\"value\":\"12107728\"},{\"key\":\"tax_amount\",\"value\":\"0\"},{\"key\":\"spread_amount\",\"value\":\"7871\"},{\"key\":\"commission_amount\",\"value\":\"36432\"},{\"key\":\"contract_address\",\"value\":\"terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n\"},{\"key\":\"action\",\"value\":\"transfer\"},{\"key\":\"from\",\"value\":\"terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f\"},{\"key\":\"to\",\"value\":\"terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js\"},{\"key\":\"amount\",\"value\":\"12107728\"}]}]}]", + "logs": [ + { + "events": [ + { + "type": "coin_received", + "attributes": [ + { + "key": "receiver", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "amount", + "value": "10000000uusd" + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "spender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "10000000uusd" + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "contract_address", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "sender", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "contract_address", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "action", + "value": "swap" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "offer_asset", + "value": "uusd" + }, + { + "key": "ask_asset", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "offer_amount", + "value": "10000000" + }, + { + "key": "return_amount", + "value": "12107728" + }, + { + "key": "tax_amount", + "value": "0" + }, + { + "key": "spread_amount", + "value": "7871" + }, + { + "key": "commission_amount", + "value": "36432" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "transfer" + }, + { + "key": "from", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "to", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "12107728" + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "action", + "value": "/terra.wasm.v1beta1.MsgExecuteContract" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "module", + "value": "wasm" + }, + { + "key": "sender", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "recipient", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "10000000uusd" + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "contract_address", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "action", + "value": "swap" + }, + { + "key": "sender", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "receiver", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "offer_asset", + "value": "uusd" + }, + { + "key": "ask_asset", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "offer_amount", + "value": "10000000" + }, + { + "key": "return_amount", + "value": "12107728" + }, + { + "key": "tax_amount", + "value": "0" + }, + { + "key": "spread_amount", + "value": "7871" + }, + { + "key": "commission_amount", + "value": "36432" + }, + { + "key": "contract_address", + "value": "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n" + }, + { + "key": "action", + "value": "transfer" + }, + { + "key": "from", + "value": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f" + }, + { + "key": "to", + "value": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js" + }, + { + "key": "amount", + "value": "12107728" + } + ] + } + ] + } + ], + "gas_wanted": "318847", + "gas_used": "222976", + "tx": { + "type": "core/StdTx", + "value": { + "msg": [ + { + "type": "wasm/MsgExecuteContract", + "value": { + "sender": "terra1cm4t47pzkg0kqt53ypdpzmp77d24lmawqpw2js", + "contract": "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f", + "execute_msg": { + "swap": { + "belief_price": "0.825918785093289178", + "max_spread": "0.005", + "offer_asset": { + "amount": "10000000", + "info": { + "native_token": { + "denom": "uusd" + } + } + } + } + }, + "coins": [ + { + "denom": "uusd", + "amount": "10000000" + } + ] + } + } + ], + "fee": { + "amount": [ + { + "denom": "uusd", + "amount": "47828" + } + ], + "gas": "318847" + }, + "signatures": [], + "memo": "", + "timeout_height": "0" + } + }, + "timestamp": "2022-05-06T21:44:52Z", + "events": [ + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NDc4Mjh1dXNk", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWxrYWVxZmE=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NDc4Mjh1dXNk", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExN3hwZnZha20yYW1nOTYyeWxzNmY4NHoza2VsbDhjNWxrYWVxZmE=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "NDc4Mjh1dXNk", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "ZmVl", + "value": "NDc4Mjh1dXNk", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "YWNjX3NlcQ==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanMvMzU5NQ==", + "index": true + } + ] + }, + { + "type": "tx", + "attributes": [ + { + "key": "c2lnbmF0dXJl", + "value": "M0xVSkNNL0RjQXZ4aVo0Q2p0cksrVXdUUStNOFUxU2M2Sk9PbUF0enBkaDBmNTV0ZWR0ak1BWFhPZTlra2l6cVRnYzZHVTFpa0owdXJvNkxpM3haSVE9PQ==", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "YWN0aW9u", + "value": "L3RlcnJhLndhc20udjFiZXRhMS5Nc2dFeGVjdXRlQ29udHJhY3Q=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "coin_spent", + "attributes": [ + { + "key": "c3BlbmRlcg==", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDB1dXNk", + "index": true + } + ] + }, + { + "type": "coin_received", + "attributes": [ + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDB1dXNk", + "index": true + } + ] + }, + { + "type": "transfer", + "attributes": [ + { + "key": "cmVjaXBpZW50", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTAwMDAwMDB1dXNk", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c3dhcA==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "b2ZmZXJfYXNzZXQ=", + "value": "dXVzZA==", + "index": true + }, + { + "key": "YXNrX2Fzc2V0", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "b2ZmZXJfYW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + }, + { + "key": "cmV0dXJuX2Ftb3VudA==", + "value": "MTIxMDc3Mjg=", + "index": true + }, + { + "key": "dGF4X2Ftb3VudA==", + "value": "MA==", + "index": true + }, + { + "key": "c3ByZWFkX2Ftb3VudA==", + "value": "Nzg3MQ==", + "index": true + }, + { + "key": "Y29tbWlzc2lvbl9hbW91bnQ=", + "value": "MzY0MzI=", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "c3dhcA==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "cmVjZWl2ZXI=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "b2ZmZXJfYXNzZXQ=", + "value": "dXVzZA==", + "index": true + }, + { + "key": "YXNrX2Fzc2V0", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "b2ZmZXJfYW1vdW50", + "value": "MTAwMDAwMDA=", + "index": true + }, + { + "key": "cmV0dXJuX2Ftb3VudA==", + "value": "MTIxMDc3Mjg=", + "index": true + }, + { + "key": "dGF4X2Ftb3VudA==", + "value": "MA==", + "index": true + }, + { + "key": "c3ByZWFkX2Ftb3VudA==", + "value": "Nzg3MQ==", + "index": true + }, + { + "key": "Y29tbWlzc2lvbl9hbW91bnQ=", + "value": "MzY0MzI=", + "index": true + } + ] + }, + { + "type": "execute_contract", + "attributes": [ + { + "key": "c2VuZGVy", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + } + ] + }, + { + "type": "message", + "attributes": [ + { + "key": "bW9kdWxl", + "value": "d2FzbQ==", + "index": true + }, + { + "key": "c2VuZGVy", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + } + ] + }, + { + "type": "wasm", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "dHJhbnNmZXI=", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTIxMDc3Mjg=", + "index": true + } + ] + }, + { + "type": "from_contract", + "attributes": [ + { + "key": "Y29udHJhY3RfYWRkcmVzcw==", + "value": "dGVycmExMmhnd25wdXBmbGZwdXVhbDUzMndncnh1MmdqcDB0Y2Fnemd4NG4=", + "index": true + }, + { + "key": "YWN0aW9u", + "value": "dHJhbnNmZXI=", + "index": true + }, + { + "key": "ZnJvbQ==", + "value": "dGVycmExNXN1dDg5bXM0bHRzNGRkNXlyY3V3Y3BjdGxlcDNoZGdldTcyOWY=", + "index": true + }, + { + "key": "dG8=", + "value": "dGVycmExY200dDQ3cHprZzBrcXQ1M3lwZHB6bXA3N2QyNGxtYXdxcHcyanM=", + "index": true + }, + { + "key": "YW1vdW50", + "value": "MTIxMDc3Mjg=", + "index": true + } + ] + } + ] +} \ No newline at end of file diff --git a/terra-stats-bot/src/main/java/com/github/kerner1000/terra/bot/message/average/AverageMessageListener.java b/terra-stats-bot/src/main/java/com/github/kerner1000/terra/bot/message/average/AverageMessageListener.java index eea71518..2e0f1d58 100644 --- a/terra-stats-bot/src/main/java/com/github/kerner1000/terra/bot/message/average/AverageMessageListener.java +++ b/terra-stats-bot/src/main/java/com/github/kerner1000/terra/bot/message/average/AverageMessageListener.java @@ -8,6 +8,7 @@ import discord4j.core.spec.MessageCreateMono; import lombok.extern.slf4j.Slf4j; import org.openapitools.model.BuySellSwaps; +import org.openapitools.model.BuySellSwapsPerCoin; import org.springframework.http.ResponseEntity; import reactor.core.publisher.Mono; @@ -71,28 +72,30 @@ void processResult(String string){ private String processBuyCommand(String buyCommandString) { try { - if (buyCommandString.startsWith("LUNA")) { - String terraAddress = buyCommandString.substring("LUNA".length()).trim(); - ResponseEntity apiResponse = accountStatsApiClient.getSwaps("Luna", terraAddress); - - BuySellSwaps buySellSwaps = apiResponse.getBody(); - BuySellMap buyMap = new BuySellMap(buySellSwaps.getBuy()); - BinnedBuySellMaps binnedBuyMap = BinnedBuySellMaps.BinnedBuySellMapsFactory.buildWithFixBinSize(buyMap, 5); - BuySellMap sellMap = new BuySellMap(buySellSwaps.getSell()); - BinnedBuySellMaps binnedSellMap = BinnedBuySellMaps.BinnedBuySellMapsFactory.buildWithFixBinSize(sellMap, 5); - SwapPrices swapPrices = new SwapPrices(Util.weightedMean(buySellSwaps.getBuy().getSwaps()),Util.weightedMean(buySellSwaps.getSell().getSwaps())); + String terraAddress = buyCommandString.trim(); + ResponseEntity apiResponse = accountStatsApiClient.getSwaps(terraAddress,null); StringBuilder sb = new StringBuilder(); - sb.append("Average swap prices are:\n"); - sb.append(swapPrices); - sb.append("\n"); - sb.append("Your buy price distribution:"); - sb.append("\n"); - sb.append("```" + binnedBuyMap.toAsciiHistogram(false) + "```"); - sb.append("Your sell price distribution:"); - sb.append("```" + binnedSellMap.toAsciiHistogram(false) + "```"); + for(BuySellSwaps buySellSwaps : apiResponse.getBody().getEntries()){ + sb.append(buySellSwaps.getCoin()); + sb.append(":\n"); + BuySellMap buyMap = new BuySellMap(buySellSwaps.getBuy()); + BinnedBuySellMaps binnedBuyMap = BinnedBuySellMaps.BinnedBuySellMapsFactory.buildWithFixBinSize(buyMap); + BuySellMap sellMap = new BuySellMap(buySellSwaps.getSell()); + BinnedBuySellMaps binnedSellMap = BinnedBuySellMaps.BinnedBuySellMapsFactory.buildWithFixBinSize(sellMap); + SwapPrices swapPrices = new SwapPrices(Util.weightedMean(buySellSwaps.getBuy().getSwaps()),Util.weightedMean(buySellSwaps.getSell().getSwaps())); + sb.append("Average swap prices are:\n"); + sb.append(swapPrices); + sb.append("\n"); + sb.append("Your buy price distribution:"); + sb.append("\n"); + sb.append("```" + binnedBuyMap.toAsciiHistogram(false) + "```"); + sb.append("Your sell price distribution:"); + sb.append("```" + binnedSellMap.toAsciiHistogram(false) + "```"); + sb.append("\n"); + } return sb.toString(); - } + } catch(Exception e){ log.error(e.getLocalizedMessage(), e); } diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BinnedBuySellMaps.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BinnedBuySellMaps.java index 438ffba8..c4ccad17 100644 --- a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BinnedBuySellMaps.java +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BinnedBuySellMaps.java @@ -74,6 +74,13 @@ public static BinnedBuySellMaps buildWithFixBinSize(BuySellMap map, int return binnedBuySellMaps; } + public static BinnedBuySellMaps buildWithFixBinSize(BuySellMap map) { + double max = map.getMap().keySet().stream().mapToDouble(k -> k.price().doubleValue()).max().orElse(0); + int binSize = (int)Math.round (max / 100d * 5); + binSize = Math.max(binSize, 1); + return buildWithFixBinSize(map, binSize); + } + public static BinnedBuySellMaps buildWithFixBinCount(BuySellMap map, int binCnt) { double max = map.getMap().keySet().stream().mapToDouble(k -> k.price().doubleValue()).max().orElse(0); double min = 0; diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMap.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMap.java index 0cd800df..a0d4aedc 100644 --- a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMap.java +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMap.java @@ -1,6 +1,5 @@ package com.github.kerner1000.terra.commons; -import org.openapitools.model.BuySellSwaps; import org.openapitools.model.SwapEntry; import org.openapitools.model.Swaps; @@ -31,6 +30,7 @@ public String toString() { public BuySellMap(Swaps swaps) { this.map = new TreeMap<>(Collections.reverseOrder()); + if(swaps != null && swaps.getSwaps() != null) for(SwapEntry s : swaps.getSwaps()){ add(s.getId(), s.getPrice(), s.getAmount()); } diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMapsForCoin.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMapsForCoin.java new file mode 100644 index 00000000..6b7d17e7 --- /dev/null +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/BuySellMapsForCoin.java @@ -0,0 +1,46 @@ +package com.github.kerner1000.terra.commons; + +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; + +public class BuySellMapsForCoin { + + private final Map coinToBuySellMaps = new TreeMap<>(); + + public BuySellMapsForCoin(Coin coin, BuySellMaps result) { + coinToBuySellMaps.put(coin, result); + } + + public BuySellMapsForCoin() { + + } + + public BuySellMaps get(Coin coin){ + return coinToBuySellMaps.get(coin); + } + + public void add(BuySellMapsForCoin other){ + for(Map.Entry entry : other.entrySet()){ + add(entry); + } + } + + private void add(Map.Entry entry) { + add(entry.getKey(), entry.getValue()); + } + + private void add(Coin coin, BuySellMaps buySellMaps) { + BuySellMaps value = coinToBuySellMaps.get(coin); + if(value != null){ + value.add(buySellMaps); + } else { + coinToBuySellMaps.put(coin, buySellMaps); + } + } + + public Set> entrySet() { + return coinToBuySellMaps.entrySet(); + } +} diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Coin.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Coin.java index c37effbb..1f3e0031 100644 --- a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Coin.java +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Coin.java @@ -1,5 +1,19 @@ package com.github.kerner1000.terra.commons; -public enum Coin { - UST, LUNA +public enum Coin implements Contract { + UST { + @Override + public String getContract() { + return ""; + } + }, LUNA { + @Override + public String getContract() { + return ""; + } + }, MARS { + public String getContract() { + return "terra12hgwnpupflfpuual532wgrxu2gjp0tcagzgx4n"; + } + } } diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Contract.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Contract.java new file mode 100644 index 00000000..aecc57de --- /dev/null +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Contract.java @@ -0,0 +1,6 @@ +package com.github.kerner1000.terra.commons; + +public interface Contract { + + String getContract(); +} diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/SwapPairs.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/SwapPairs.java index ac45182f..11b0b34f 100644 --- a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/SwapPairs.java +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/SwapPairs.java @@ -8,16 +8,22 @@ public class SwapPairs { public static class TerraSwap { public static String LUNA_UST = "terra1tndcaqxkpc5ce9qee5ggqf430mr2z3pefe5wj6"; + + public static String MARS_UST = "terra15sut89ms4lts4dd5yrcuwcpctlep3hdgeu729f"; } public static class Market { public static String LUNA_UST = "terra1vs9jr7pxuqwct3j29lez3pfetuu8xmq7tk3lzk"; + + } public static class Astroport { public static String LUNA_UST = "terra1m6ywlgn6wrjuagcmmezzz2a029gtldhey5k552"; + + public static String MARS_UST = "terra19wauh79y42u5vt62c5adt2g5h4exgh26t3rpds"; } public static class Loop { diff --git a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Util.java b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Util.java index 9e0a882f..c682e449 100644 --- a/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Util.java +++ b/terra-stats-commons/src/main/java/com/github/kerner1000/terra/commons/Util.java @@ -10,6 +10,9 @@ public class Util { public static double weightedMean(Collection swapEntries){ + if(swapEntries == null ||swapEntries.isEmpty()){ + return 0; + } double num = 0; double denom = 0; for (SwapEntry entry : swapEntries) { diff --git a/terra-stats-contract/src/main/resources/contract.yaml b/terra-stats-contract/src/main/resources/contract.yaml index bbb6aec6..f842f616 100644 --- a/terra-stats-contract/src/main/resources/contract.yaml +++ b/terra-stats-contract/src/main/resources/contract.yaml @@ -4,7 +4,7 @@ info: description: Terra Stats OpenAPI contract version: 1.0.0 paths: - /swaps/{coin}/{terra-address}: + /swaps/{terra-address}: get: summary: get swaps for given coin description: get swaps for given coin @@ -12,23 +12,26 @@ paths: tags: - /swaps parameters: - - name: coin - in: path - schema: - type: string - required: true - name: terra-address in: path schema: type: string required: true + - name: hide + in: query + schema: + type: array + items: + type: string + required: false + responses: 200: description: Successful operation content: application/json: schema: - $ref: '#/components/schemas/BuySellSwaps' + $ref: '#/components/schemas/BuySellSwapsPerCoin' 500: description: internal server error content: @@ -56,9 +59,18 @@ components: BuySellSwaps: type: object properties: + coin: + type: string buy: $ref: '#/components/schemas/Swaps' sell: $ref: '#/components/schemas/Swaps' + BuySellSwapsPerCoin: + type: object + properties: + entries: + type: array + items: + $ref: '#/components/schemas/BuySellSwaps' Error: type: object \ No newline at end of file