Skip to content

Commit

Permalink
Merge pull request #1620 from p2p-org/bugfix/pwn-674
Browse files Browse the repository at this point in the history
[ETH-674] Get exchange rates from moonpay service instead of keyapp s…
  • Loading branch information
bigearsenal authored Jan 11, 2024
2 parents 43a25ea + f00c935 commit 2c3a643
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions p2p_wallet/Scenes/Main/Buy/BuyViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,14 @@ final class BuyViewModel: ObservableObject {

Task {
for fiat in BuyViewModel.fiats {
self.tokenPrices[fiat] = try Dictionary(
await pricesService.getPrices(
tokens: BuyViewModel.tokens,
fiat: fiat.rawValue
)
.map { token, price in
(token.address, price.doubleValue)
}
) { lhs, _ in lhs }
guard let fiatCurrency = fiat.buyFiatCurrency() else { continue }
var tokenPrice: [String: Double] = [:]
for token in BuyViewModel.tokens {
guard let cryptoCurrency = token.buyCryptoCurrency() else { continue }
let rate = try await exchangeService.getExchangeRate(from: fiatCurrency, to: cryptoCurrency)
tokenPrice[token.mintAddress] = rate.amount
}
self.tokenPrices[fiat] = tokenPrice
}

let banks = try await exchangeService.isBankTransferEnabled()
Expand Down

0 comments on commit 2c3a643

Please sign in to comment.