Skip to content

Commit

Permalink
fix: stable market tiers (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana authored Feb 14, 2022
1 parent 4258756 commit 4d0a8dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dex/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl FeeTier {
pub fn from_srm_and_msrm_balances(market: &Pubkey, srm_held: u64, msrm_held: u64) -> FeeTier {
let one_srm = 1_000_000;

if market == &stable_markets::usdt_usdc::ID || market == &stable_markets::msol_sol::ID {
if market == &stable_markets::usdt_usdc::ID || market == &stable_markets::msol_sol::ID || market == &stable_markets::ust_usdc::ID || market == &stable_markets::ust_usdt::ID || market == &stable_markets::stsol_sol::ID {
return FeeTier::Stable;
}

Expand Down
5 changes: 2 additions & 3 deletions dex/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,18 +537,17 @@ impl MarketState {
expected_owner: &[u64; 4],
srm_or_msrm_account: Option<account_parser::TokenAccount>,
) -> DexResult<FeeTier> {
let market_addr = self.pubkey();
let srm_or_msrm_account = match srm_or_msrm_account {
Some(a) => a,
None => return Ok(FeeTier::Base),
None => return Ok(FeeTier::from_srm_and_msrm_balances(&market_addr, 0, 0)),
};
let data = srm_or_msrm_account.inner().try_borrow_data()?;

let mut aligned_data: [u64; 9] = Zeroable::zeroed();
bytes_of_mut(&mut aligned_data).copy_from_slice(&data[..72]);
let (mint, owner, &[balance]) = array_refs![&aligned_data, 4, 4, 1];

let market_addr = self.pubkey();

check_assert_eq!(owner, expected_owner)?;
if mint == &srm_token::ID.to_aligned_bytes() {
return Ok(FeeTier::from_srm_and_msrm_balances(
Expand Down

0 comments on commit 4d0a8dc

Please sign in to comment.