Skip to content

Commit

Permalink
Add Tether token support via ERC20 and Omni
Browse files Browse the repository at this point in the history
  • Loading branch information
pingiun committed Aug 26, 2020
1 parent f45a26c commit 585d3ec
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
10 changes: 10 additions & 0 deletions assets/src/main/java/bisq/asset/coins/TetherOmni.java
@@ -0,0 +1,10 @@
package bisq.asset.coins;

import bisq.asset.Base58BitcoinAddressValidator;
import bisq.asset.Coin;

public class TetherOmni extends Coin {
public TetherOmni() {
super("Tether (Omni)", "USDT-O", new Base58BitcoinAddressValidator());
}
}
9 changes: 9 additions & 0 deletions assets/src/main/java/bisq/asset/tokens/TetherERC20.java
@@ -0,0 +1,9 @@
package bisq.asset.tokens;

import bisq.asset.Erc20Token;

public class TetherERC20 extends Erc20Token {
public TetherERC20() {
super("Tether (ERC20)", "USDT-E");
}
}
2 changes: 2 additions & 0 deletions assets/src/main/resources/META-INF/services/bisq.asset.Asset
Expand Up @@ -104,6 +104,7 @@ bisq.asset.coins.Spectrecoin
bisq.asset.coins.Starwels
bisq.asset.coins.SUB1X
bisq.asset.coins.TEO
bisq.asset.coins.TetherOmni
bisq.asset.coins.TurtleCoin
bisq.asset.coins.UnitedCommunityCoin
bisq.asset.coins.Unobtanium
Expand All @@ -123,6 +124,7 @@ bisq.asset.coins.ZeroClassic
bisq.asset.tokens.AugmintEuro
bisq.asset.tokens.DaiStablecoin
bisq.asset.tokens.EtherStone
bisq.asset.tokens.TetherERC20
bisq.asset.tokens.TrueUSD
bisq.asset.tokens.USDCoin
bisq.asset.tokens.VectorspaceAI
10 changes: 9 additions & 1 deletion core/src/main/java/bisq/core/provider/price/PriceProvider.java
Expand Up @@ -70,7 +70,11 @@ public Tuple2<Map<String, Long>, Map<String, MarketPrice>> getAll() throws IOExc
final double price = (Double) treeMap.get("price");
// json uses double for our timestampSec long value...
final long timestampSec = MathUtils.doubleToLong((Double) treeMap.get("timestampSec"));
marketPriceMap.put(currencyCode, new MarketPrice(currencyCode, price, timestampSec, true));
if (currencyCode.equals("USDT")) {
addPrice(marketPriceMap, "USDT-O", price, timestampSec);
addPrice(marketPriceMap, "USDT-E", price, timestampSec);
}
addPrice(marketPriceMap, currencyCode, price, timestampSec);
} catch (Throwable t) {
log.error(t.toString());
t.printStackTrace();
Expand All @@ -80,6 +84,10 @@ public Tuple2<Map<String, Long>, Map<String, MarketPrice>> getAll() throws IOExc
return new Tuple2<>(tsMap, marketPriceMap);
}

private void addPrice(Map<String, MarketPrice> marketPriceMap, String currencyCode, double price, long timestampSec) {
marketPriceMap.put(currencyCode, new MarketPrice(currencyCode, price, timestampSec, true));
}

public String getBaseUrl() {
return httpClient.getBaseUrl();
}
Expand Down
3 changes: 1 addition & 2 deletions desktop/src/main/java/bisq/desktop/main/MainView.java
Expand Up @@ -534,11 +534,10 @@ private String getPriceProviderTooltipString() {

String selectedCurrencyCode = model.getPriceFeedService().getCurrencyCode();
MarketPrice selectedMarketPrice = model.getPriceFeedService().getMarketPrice(selectedCurrencyCode);

return Res.get("mainView.marketPrice.tooltip",
"Bisq Price Index for " + selectedCurrencyCode,
"",
DisplayUtils.formatTime(new Date(selectedMarketPrice.getTimestampSec())),
selectedMarketPrice != null ? DisplayUtils.formatTime(new Date(selectedMarketPrice.getTimestampSec())) : Res.get("shared.na"),
model.getPriceFeedService().getProviderNodeAddress());
}

Expand Down

0 comments on commit 585d3ec

Please sign in to comment.