Skip to content

Commit

Permalink
coinbase: handle accounts with multiple deposit addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed May 6, 2024
1 parent aa8ef86 commit 0394016
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/coinbase_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ impl ExchangeClient for CoinbaseExchangeClient {
let addresses = self.client.list_addresses(&id);
pin_mut!(addresses);

let mut pubkeys = vec![];
let mut best_pubkey_updated_at = None;
let mut best_pubkey = None;
while let Some(addresses_result) = addresses.next().await {
for address in addresses_result.unwrap() {
let push = match address.network.as_str() {
"solana" => true,

// SPL-USDC addresses are currently reported incorrectly
"ethereum" if token.name() == "USDC" => true,
_ => false,
};

if push {
if let Ok(pubkey) = address.address.parse::<Pubkey>() {
pubkeys.push(pubkey);
if address.updated_at > best_pubkey_updated_at {
best_pubkey_updated_at = address.updated_at;
best_pubkey = Some(pubkey);
}
}
}
}
}
assert!(pubkeys.len() <= 1);
if let Some(pubkey) = pubkeys.pop() {
if let Some(pubkey) = best_pubkey {
return Ok(pubkey);
}
break;
Expand Down

0 comments on commit 0394016

Please sign in to comment.