Skip to content

Commit

Permalink
Add a couple more alts
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed May 16, 2024
1 parent fe0416e commit bbd8120
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/coin_gecko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ fn token_to_coin(token: &MaybeToken) -> Result<&'static str, Box<dyn std::error:
Token::JLP => "jupiter-perpetuals-liquidity-provider-token",
Token::JUP => "jupiter-exchange-solana",
Token::JTO => "jito-governance-token",
Token::BONK => "bonk",
Token::KMNO => "kamino",
Token::PYTH => "pyth-network",
Token::WEN => "wen-4",
Token::WIF => "dogwifcoin",
unsupported_token => {
Expand Down Expand Up @@ -104,8 +106,12 @@ pub async fn get_current_price(token: &MaybeToken) -> Result<Decimal, Box<dyn st
jup: Option<CurrencyList>,
#[serde(rename = "jito-governance-token")]
jto: Option<CurrencyList>,
#[serde(rename = "bonk")]
bonk: Option<CurrencyList>,
#[serde(rename = "kamino")]
kmno: Option<CurrencyList>,
#[serde(rename = "pyth-network")]
pyth: Option<CurrencyList>,
#[serde(rename = "wen-4")]
wen: Option<CurrencyList>,
#[serde(rename = "dogwifcoin")]
Expand All @@ -125,7 +131,9 @@ pub async fn get_current_price(token: &MaybeToken) -> Result<Decimal, Box<dyn st
.or(coins.jlp)
.or(coins.jup)
.or(coins.jto)
.or(coins.bonk)
.or(coins.kmno)
.or(coins.pyth)
.or(coins.wen)
.or(coins.wif)
.ok_or_else(|| format!("Simple price data not available for {coin}").into())
Expand Down
11 changes: 10 additions & 1 deletion src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ pub enum Token {
JLP,
JUP,
JTO,
BONK,
KMNO,
PYTH,
WEN,
WIF,
}
Expand All @@ -69,7 +71,9 @@ impl Token {
Token::JLP => pubkey!("27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4"),
Token::JUP => pubkey!("JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"),
Token::JTO => pubkey!("jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL"),
Token::BONK => pubkey!("DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"),
Token::KMNO => pubkey!("KMNo3nJsBXfcpJTVhZcXLW7RmTwTt4GVFE7suUBo9sS"),
Token::PYTH => pubkey!("HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3"),
Token::WEN => pubkey!("WENWENvqqNya429ubCdR81ZmD69brwQaaBYY6p3LCpk"),
Token::WIF => pubkey!("EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm"),
}
Expand All @@ -96,22 +100,25 @@ impl Token {
Token::JLP => "JLP/",
Token::JUP => "JUP/",
Token::JTO => "JTO/",
Token::BONK => "!",
Token::KMNO => "KMNO/",
Token::PYTH => "PYTH/",
Token::WEN => "WEN/",
Token::WIF => "WIF/",
}
}

pub fn decimals(&self) -> u8 {
match self {
Token::WEN => 5,
Token::BONK | Token::WEN => 5,
Token::USDC
| Token::USDT
| Token::UXD
| Token::tuUSDC
| Token::JLP
| Token::JUP
| Token::KMNO
| Token::PYTH
| Token::WIF => 6,
Token::stSOL
| Token::tuSOL
Expand Down Expand Up @@ -231,7 +238,9 @@ impl Token {
| Token::JLP
| Token::JUP
| Token::JTO
| Token::BONK
| Token::KMNO
| Token::PYTH
| Token::WEN
| Token::WIF => coin_gecko::get_current_price(&MaybeToken(Some(*self))).await,
Token::tuUSDC | Token::tuSOL | Token::tumSOL | Token::tustSOL => {
Expand Down

0 comments on commit bbd8120

Please sign in to comment.