ensure fallbacks are only used for stale or unconfident oracles
This commit is contained in:
parent
a0a47af6a4
commit
aed2afbde4
|
@ -467,7 +467,7 @@ pub fn token_edit(
|
|||
let bank = ctx.remaining_accounts.first().unwrap().load_mut::<Bank>()?;
|
||||
bank.verify()?;
|
||||
|
||||
emit_stack!(TokenMetaDataLogV2 {
|
||||
emit_stack(TokenMetaDataLogV2 {
|
||||
mango_group: ctx.accounts.group.key(),
|
||||
mint: mint_info.mint.key(),
|
||||
token_index: bank.token_index,
|
||||
|
|
|
@ -152,7 +152,7 @@ pub fn token_register(
|
|||
mint_info.banks[0] = ctx.accounts.bank.key();
|
||||
mint_info.vaults[0] = ctx.accounts.vault.key();
|
||||
|
||||
emit_stack!(TokenMetaDataLogV2 {
|
||||
emit_stack(TokenMetaDataLogV2 {
|
||||
mango_group: ctx.accounts.group.key(),
|
||||
mint: ctx.accounts.mint.key(),
|
||||
token_index,
|
||||
|
|
|
@ -135,7 +135,7 @@ pub fn token_register_trustless(
|
|||
mint_info.banks[0] = ctx.accounts.bank.key();
|
||||
mint_info.vaults[0] = ctx.accounts.vault.key();
|
||||
|
||||
emit_stack!(TokenMetaDataLogV2 {
|
||||
emit_stack(TokenMetaDataLogV2 {
|
||||
mango_group: ctx.accounts.group.key(),
|
||||
mint: ctx.accounts.mint.key(),
|
||||
token_index,
|
||||
|
|
|
@ -974,12 +974,12 @@ impl Bank {
|
|||
staleness_slot: Option<u64>,
|
||||
) -> Result<I80F48> {
|
||||
let primary_price = self.oracle_price(oracle_acc, staleness_slot);
|
||||
if primary_price.is_ok() || fallback_oracle_acc_opt.is_none() {
|
||||
primary_price
|
||||
} else {
|
||||
if primary_price.is_oracle_error() && fallback_oracle_acc_opt.is_some() {
|
||||
let fallback_oracle_acc = fallback_oracle_acc_opt.unwrap();
|
||||
require_keys_eq!(self.fallback_oracle, *fallback_oracle_acc.key());
|
||||
self.oracle_price_inner(fallback_oracle_acc, staleness_slot)
|
||||
} else {
|
||||
primary_price
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue