Skip to content

Commit

Permalink
app: Fixed config generation problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
patniemeyer committed Dec 6, 2022
1 parent 79c34df commit c30d1ed
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class OrchidVPNConfigGenerate {
};

var chain = hop.account.chain;
var currency = chain.nativeCurrency.exchangeRateSource.symbolOverride ??
var currency = chain.nativeCurrency.configSymbolOverride ??
chain.nativeCurrency.symbol;

// V1 fields
Expand Down
4 changes: 4 additions & 0 deletions gui-orchid/lib/api/orchid_eth/token_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class TokenType {
final ExchangeRateSource exchangeRateSource;
final String iconPath;

/// The symbol name to be used in the Orchid config for the back-end.
final String configSymbolOverride;

/// The ERC20 contract address if this is a non-native token on its chain.
final EthereumAddress erc20Address;

Expand All @@ -37,6 +40,7 @@ class TokenType {
const TokenType({
@required this.chainId,
@required this.symbol,
this.configSymbolOverride,
this.exchangeRateSource,
this.decimals = 18,
this.erc20Address,
Expand Down
3 changes: 2 additions & 1 deletion gui-orchid/lib/api/orchid_eth/tokens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Tokens {

static const TokenType XDAI = TokenType(
symbol: 'xDAI',
// Binance lists DAIUSDT but the value is bogus. The real pair is USDTDAI, so invert.
configSymbolOverride: 'DAI',
exchangeRateSource: CoinGeckoExchangeRateSource(tokenId: 'xdai'),
chainId: Chains.GNOSIS_CHAINID,
iconPath: OrchidAssetSvgToken.xdai_token_path,
Expand Down Expand Up @@ -108,6 +108,7 @@ class Tokens {

static const TokenType RBTC = TokenType(
symbol: 'RTBC',
configSymbolOverride: 'BTC',
exchangeRateSource: CoinGeckoExchangeRateSource(tokenId: 'bitcoin'),
chainId: Chains.RSK_CHAINID,
iconPath: OrchidAssetSvgToken.bitcoin_btc_token_path,
Expand Down
5 changes: 2 additions & 3 deletions gui-orchid/lib/api/pricing/binance_pricing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class BinanceExchangeRateSource extends ExchangeRateSource {
/// the rate consistent with that. e.g. for DAI we must use 1/USDTDAI and
/// not DAIUSDT since DAIUSDT was delisted.
final bool inverted;
final String symbolOverride;

const BinanceExchangeRateSource(
{this.inverted = false, String symbolOverride})
: super(symbolOverride: symbolOverride); // Binance exchange rates
const BinanceExchangeRateSource({this.inverted = false, this.symbolOverride});

// https://api.binance.com/api/v3/avgPrice?symbol=ETHUSDT
String _url(TokenType tokenType) {
Expand Down
2 changes: 1 addition & 1 deletion gui-orchid/lib/api/pricing/coingecko_pricing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'orchid_pricing.dart';
class CoinGeckoExchangeRateSource extends ExchangeRateSource {
final String tokenId;

const CoinGeckoExchangeRateSource({required this.tokenId}) : super();
const CoinGeckoExchangeRateSource({required this.tokenId});

/// Return the price, USD/Token: Tokens * Rate = USD
Future<double?> tokenToUsdRate(TokenType tokenType) async {
Expand Down
5 changes: 1 addition & 4 deletions gui-orchid/lib/api/pricing/orchid_pricing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class OrchidPricing {
}

abstract class ExchangeRateSource {
final String symbolOverride;

const ExchangeRateSource({this.symbolOverride});
const ExchangeRateSource();

/// Return the price (USD/Token): tokens * Rate = USD
Future<double> tokenToUsdRate(TokenType tokenType);
Expand All @@ -79,4 +77,3 @@ abstract class ExchangeRateSource {
return 1.0 / rate;
}
}

1 change: 1 addition & 0 deletions gui-orchid/test/service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:orchid/api/orchid_eth/chains.dart';
import 'package:orchid/api/orchid_eth/token_type.dart';
import 'package:orchid/api/orchid_eth/tokens.dart';
import 'package:orchid/api/orchid_eth/v1/orchid_eth_v1.dart';
import 'package:orchid/api/pricing/binance_pricing.dart';
import 'package:orchid/api/pricing/orchid_pricing.dart';
import 'package:orchid/api/purchase/orchid_pac_seller.dart';
import 'package:orchid/api/purchase/orchid_pac_server.dart';
Expand Down

0 comments on commit c30d1ed

Please sign in to comment.