Skip to content

Commit

Permalink
feat: Delete Portfolio and Tokenomics pages - MEED-7161 - Meeds-io/me…
Browse files Browse the repository at this point in the history
…eds#2250 (#765)

This change will delete Token Metrics pages to let community rely on DEX sites instead.
  • Loading branch information
boubaker authored Jul 9, 2024
1 parent 2e36ab7 commit 74dffc7
Show file tree
Hide file tree
Showing 36 changed files with 51 additions and 2,772 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import io.meeds.dapp.storage.CurrencyExchangeRateRepository;
import io.meeds.dapp.storage.MeedExchangeRateRepository;

import jakarta.annotation.PostConstruct;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
Expand Down Expand Up @@ -144,6 +143,7 @@ public BigDecimal getExchangeRate(Currency currency) {
} else {
return meedExchangeRates.stream()
.max(Comparator.comparing(MeedExchangeRate::getDate))
.filter(rate -> rate.getEthUsdPrice() != null && !BigDecimal.ZERO.equals(rate.getEthUsdPrice()))
.map(rate -> BigDecimal.ONE.divide(rate.getEthUsdPrice(), 18, RoundingMode.HALF_UP))
.orElse(BigDecimal.ZERO);
}
Expand All @@ -168,16 +168,6 @@ public void computeTodayCurrencyExchangeRate() {
computeCurrencyExchangeRateOfDay(LocalDate.now(ZoneOffset.UTC));
}

/**
* Compute and store EURO Currency Exchange rate from first date when MEED
* Contract has been created until today
*/
@PostConstruct
public void computeRates() {
new Thread(this::computeCurrencyExchangeRate).start();
new Thread(this::computeMeedExchangeRate).start();
}

/**
* Compute and store MEED Token Exchange rates from first date when MEED
* Contract has been created until today
Expand Down Expand Up @@ -444,6 +434,9 @@ private BigDecimal getMeedPriceInCurrency(BigDecimal meedEthPrice,
Currency currency,
List<CurrencyExchangeRate> currencyExchangeRates,
LocalDate date) {
if (meedEthPrice == null) {
return BigDecimal.ZERO;
}
BigDecimal currencyPrice = meedEthPrice;
if (currency == Currency.USD) {
currencyPrice = currencyPrice.multiply(ethUsdPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
return;
}
} else if (servletPath.equals("/farm")) {
} else if (servletPath.equals("/farm")
|| servletPath.equals("/tokenomics")
|| servletPath.equals("/portfolio")
|| servletPath.equals("/fr/tokenomics")
|| servletPath.equals("/fr/portefeuille")) {
response.setHeader("Location", "/");
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import javax.net.ssl.HttpsURLConnection;

import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
Expand Down Expand Up @@ -100,12 +98,7 @@ void testComputeCurrencyExchangeRate() {
exchangeService.computeCurrencyExchangeRate();
Duration between = Duration.between(exchangeService.firstMeedTokenDate().atStartOfDay(), LocalDate.now().atStartOfDay());
verify(currencyExchangeRateRepository,
times((int) between.toDays() + 2)).save(argThat(new ArgumentMatcher<CurrencyExchangeRate>() {
@Override
public boolean matches(CurrencyExchangeRate argument) {
return BigDecimal.valueOf(1.8d).equals(argument.getRate()) && argument.getCurrency() == Currency.EUR;
}
}));
times((int) between.toDays() + 2)).save(argThat(rate -> BigDecimal.valueOf(1.8d).equals(rate.getRate()) && rate.getCurrency() == Currency.EUR));

verify(currencyExchangeRateRepository,
times(1)).save(new CurrencyExchangeRate(exchangeService.firstMeedTokenDate(), Currency.EUR, BigDecimal.valueOf(1.8d)));
Expand All @@ -117,16 +110,13 @@ void testComputeMeedExchangeRate() {

exchangeService.computeMeedExchangeRate();
Duration between = Duration.between(exchangeService.firstMeedTokenDate().atStartOfDay(), LocalDate.now().atStartOfDay());
verify(meedExchangeRateRepository, times((int) between.toDays() + 1)).save(argThat(new ArgumentMatcher<MeedExchangeRate>() {
@Override
public boolean matches(MeedExchangeRate argument) {
return argument != null && argument.getDate() != null
&& BigDecimal.valueOf(300).equals(argument.getEthReserve())
&& BigDecimal.valueOf(200).equals(argument.getMeedReserve())
&& BigDecimal.valueOf(2).equals(argument.getMeedEthPrice())
&& BigDecimal.valueOf(3).equals(argument.getEthUsdPrice());
}
}));
verify(meedExchangeRateRepository,
times((int) between.toDays() + 1)).save(
argThat(rate -> rate != null && rate.getDate() != null
&& BigDecimal.valueOf(300).equals(rate.getEthReserve())
&& BigDecimal.valueOf(200).equals(rate.getMeedReserve())
&& BigDecimal.valueOf(2).equals(rate.getMeedEthPrice())
&& BigDecimal.valueOf(3).equals(rate.getEthUsdPrice())));

verify(meedExchangeRateRepository, times(1)).save(new MeedExchangeRate(exchangeService.firstMeedTokenDate(),
BigDecimal.valueOf(3),
Expand Down Expand Up @@ -195,7 +185,7 @@ void testGetExchangeRate() {
void testGetMeedUsdPrice() {
assertNotNull(exchangeService);

List<MeedExchangeRate> meedExchangeRates = new ArrayList<MeedExchangeRate>();
List<MeedExchangeRate> meedExchangeRates = new ArrayList<>();

when(meedExchangeRateRepository.save(any())).thenAnswer(invocation -> {
MeedExchangeRate exchangeRate = invocation.getArgument(0, MeedExchangeRate.class);
Expand All @@ -213,16 +203,16 @@ void testGetMeedUsdPrice() {
|| meedExchangeRate.getDate().isEqual(fromDate))
&& (meedExchangeRate.getDate().isBefore(toDate)
|| meedExchangeRate.getDate().isEqual(toDate)))
.collect(Collectors.toList());
.toList();
});

BigDecimal price = exchangeService.getMeedUsdPrice();
assertEquals(BigDecimal.valueOf(6), price);
}

private void mockExchangeRates() {
List<CurrencyExchangeRate> currencyExchangeRates = new ArrayList<CurrencyExchangeRate>();
List<MeedExchangeRate> meedExchangeRates = new ArrayList<MeedExchangeRate>();
List<CurrencyExchangeRate> currencyExchangeRates = new ArrayList<>();
List<MeedExchangeRate> meedExchangeRates = new ArrayList<>();

when(meedExchangeRateRepository.save(any())).thenAnswer(invocation -> {
MeedExchangeRate exchangeRate = invocation.getArgument(0, MeedExchangeRate.class);
Expand All @@ -246,7 +236,7 @@ private void mockExchangeRates() {
|| currencyExchangeRate.getDate().isEqual(fromDate))
&& (currencyExchangeRate.getDate().isBefore(toDate)
|| currencyExchangeRate.getDate().isEqual(toDate)))
.collect(Collectors.toList());
.toList();
});

when(meedExchangeRateRepository.findByDateBetween(any(), any())).thenAnswer(invocation -> {
Expand All @@ -257,21 +247,18 @@ private void mockExchangeRates() {
|| meedExchangeRate.getDate().isEqual(fromDate))
&& (meedExchangeRate.getDate().isBefore(toDate)
|| meedExchangeRate.getDate().isEqual(toDate)))
.collect(Collectors.toList());
.toList();
});
}

@Component
public static class ExchangeServiceNoInit extends ExchangeService {
private static final String LP_TOKEN_API_URL = "LpTokenApiUrl";

private AtomicBoolean ethPriceRequest = new AtomicBoolean(false);

private AtomicBoolean simulateErrorRequest = new AtomicBoolean(false);

@Override
public void computeRates() {
// Delete @PostConstruct
}

@Override
protected String executeQuery(String url, String body) {
ethPriceRequest.set(StringUtils.contains(body, "ethPrice"));
Expand All @@ -294,19 +281,19 @@ protected HttpsURLConnection newURLConnection(String apiUrl) throws IOException
when(connection.getOutputStream()).thenReturn(mock(OutputStream.class));
when(connection.getInputStream()).thenReturn(new ByteArrayInputStream("{\"data\": {\"blocks\": [{\"number\": \"1111\"}]}}".getBytes()));
return connection;
} else if (StringUtils.contains(apiUrl, "LpTokenApiUrl") && simulateErrorRequest.get()) {
} else if (StringUtils.contains(apiUrl, LP_TOKEN_API_URL) && simulateErrorRequest.get()) {
HttpsURLConnection connection = mock(HttpsURLConnection.class);
when(connection.getResponseCode()).thenReturn(200);
when(connection.getOutputStream()).thenReturn(mock(OutputStream.class));
when(connection.getInputStream()).thenReturn(new ByteArrayInputStream("{\"errors\": [{\"message\": \"Error: up to block number 1000 .\"}]}".getBytes()));
return connection;
} else if (StringUtils.contains(apiUrl, "LpTokenApiUrl") && ethPriceRequest.get()) {
} else if (StringUtils.contains(apiUrl, LP_TOKEN_API_URL) && ethPriceRequest.get()) {
HttpsURLConnection connection = mock(HttpsURLConnection.class);
when(connection.getResponseCode()).thenReturn(200);
when(connection.getOutputStream()).thenReturn(mock(OutputStream.class));
when(connection.getInputStream()).thenReturn(new ByteArrayInputStream("{\"data\": {\"bundle\": {\"ethPrice\": \"3\"}}}".getBytes()));
return connection;
} else if (StringUtils.contains(apiUrl, "LpTokenApiUrl")) {
} else if (StringUtils.contains(apiUrl, LP_TOKEN_API_URL)) {
HttpsURLConnection connection = mock(HttpsURLConnection.class);
when(connection.getResponseCode()).thenReturn(200);
when(connection.getOutputStream()).thenReturn(mock(OutputStream.class));
Expand Down
15 changes: 0 additions & 15 deletions deeds-dapp-webapp/src/main/webapp/WEB-INF/metadata/portfolio.html

This file was deleted.

15 changes: 0 additions & 15 deletions deeds-dapp-webapp/src/main/webapp/WEB-INF/metadata/tokenomics.html

This file was deleted.

20 changes: 0 additions & 20 deletions deeds-dapp-webapp/src/main/webapp/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,11 @@
<lastmod>2023-11-08</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://www.meeds.io/portfolio</loc>
<lastmod>2023-04-17</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://www.meeds.io/tenants</loc>
<lastmod>2023-04-17</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://www.meeds.io/tokenomics</loc>
<lastmod>2023-04-17</lastmod>
<priority>0.70</priority>
</url>
<url>
<loc>https://www.meeds.io/about-us</loc>
<lastmod>2023-04-17</lastmod>
Expand All @@ -79,11 +69,6 @@
<lastmod>2023-11-06</lastmod>
<priority>0.90</priority>
</url>
<url>
<loc>https://www.meeds.io/fr/portefeuille</loc>
<lastmod>2023-04-17</lastmod>
<priority>0.80</priority>
</url>
<url>
<loc>https://www.meeds.io/fr/visite-guidee</loc>
<lastmod>2023-04-17</lastmod>
Expand All @@ -99,11 +84,6 @@
<lastmod>2023-04-17</lastmod>
<priority>0.90</priority>
</url>
<url>
<loc>https://www.meeds.io/fr/tokenomics</loc>
<lastmod>2023-04-17</lastmod>
<priority>0.70</priority>
</url>
<url>
<loc>https://www.meeds.io/fr/mint</loc>
<lastmod>2023-04-17</lastmod>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import './layout/initComponents';
import './marketplace/initComponents';
import './tenants/initComponents';
import './owners/initComponents';
import './snapshot/initComponents';
import './deeds/initComponents';
import './stake/initComponents';
import './farming/initComponents';
Expand Down
Loading

0 comments on commit 74dffc7

Please sign in to comment.