Skip to content

Commit

Permalink
Fix SWB pull oracle program id (#237)
Browse files Browse the repository at this point in the history
* Was incorrectly using V2 (switchboard_on_demand::SWITCHBOARD_PROGRAM_ID) instead of on_demand (switchboard_on_demand::SWITCHBOARD_ON_DEMAND_PROGRAM_ID), now hardcoded in local constants to avoid ambiguity.

* Fixes CI config so unit tests can run again.

---------

Co-authored-by: J <[email protected]>
  • Loading branch information
jgur-psyops and jkbpvsc authored Aug 19, 2024
1 parent 9eae066 commit f0feb6e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release-program.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:
- "testest-program-*"

env:
RUST_TOOLCHAIN: 1.71.0
SOLANA_CLI_VERSION: 1.16.20
ANCHOR_CLI_VERSION: 0.29.0
ANCHOR_SHA: fc9fd6d24b9be84abb2f40e47ed3faf7b11864ae
RUST_TOOLCHAIN: 1.75.0
SOLANA_CLI_VERSION: 1.18.15
ANCHOR_CLI_VERSION: 0.30.1
ANCHOR_SHA: e6d7dafe12da661a36ad1b4f3b5970e8986e5321
CARGO_TERM_COLOR: always

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
test-unit:
name: Rust Unit Tests
runs-on: ubuntu-latest
env:
RUSTUP_TOOLCHAIN: stable
# env:
# RUSTUP_TOOLCHAIN: stable
steps:
- uses: actions/checkout@v3

Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ anchor-client = { git = "https://github.com/mrgnlabs/anchor.git", rev = "fdcf299
pyth-sdk-solana = "=0.10.1"
pyth-solana-receiver-sdk = "0.3.0"
switchboard-solana = "0.29.0"
switchboard-on-demand = "0.1.13"
switchboard-on-demand = "0.1.14"
borsh = "0.10.3"

[profile.release]
Expand Down
8 changes: 8 additions & 0 deletions programs/marginfi/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ cfg_if::cfg_if! {
}
}

cfg_if::cfg_if! {
if #[cfg(feature = "devnet")] {
pub const SWITCHBOARD_PULL_ID: Pubkey = pubkey!("Aio4gaXjXzJNVLtzwtNVmSqGKpANtXhybbkhtAC94ji2");
} else {
pub const SWITCHBOARD_PULL_ID: Pubkey = pubkey!("SBondMDrcV3K4kxZR1HNVT7osZxAHVHgYXL5Ze1oMUv");
}
}

/// TODO: Make these variable per bank
pub const LIQUIDATION_LIQUIDATOR_FEE: I80F48 = I80F48!(0.025);
pub const LIQUIDATION_INSURANCE_FEE: I80F48 = I80F48!(0.025);
Expand Down
8 changes: 4 additions & 4 deletions programs/marginfi/src/state/price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
check,
constants::{
CONF_INTERVAL_MULTIPLE, EXP_10, EXP_10_I80F48, MAX_CONF_INTERVAL,
MIN_PYTH_PUSH_VERIFICATION_LEVEL, PYTH_ID, STD_DEV_MULTIPLE,
MIN_PYTH_PUSH_VERIFICATION_LEVEL, PYTH_ID, STD_DEV_MULTIPLE, SWITCHBOARD_PULL_ID,
},
debug, math_error,
prelude::*,
Expand Down Expand Up @@ -320,7 +320,7 @@ impl SwitchboardPullPriceFeed {
let ai_data = ai.data.borrow();

check!(
ai.owner.eq(&switchboard_on_demand::SWITCHBOARD_PROGRAM_ID),
ai.owner.eq(&SWITCHBOARD_PULL_ID),
MarginfiError::InvalidOracleAccount
);

Expand All @@ -342,7 +342,7 @@ impl SwitchboardPullPriceFeed {
let ai_data = ai.data.borrow();

check!(
ai.owner.eq(&switchboard_on_demand::SWITCHBOARD_PROGRAM_ID),
ai.owner.eq(&SWITCHBOARD_PULL_ID),
MarginfiError::InvalidOracleAccount
);

Expand Down Expand Up @@ -1210,7 +1210,7 @@ mod tests {
Account {
lamports: 1_000_000,
data,
owner: switchboard_on_demand::SWITCHBOARD_PROGRAM_ID,
owner: SWITCHBOARD_PULL_ID,
executable: false,
rent_epoch: 361,
}
Expand Down
3 changes: 2 additions & 1 deletion test-utils/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anchor_lang::prelude::*;
use anchor_lang_29::Discriminator;
use anchor_spl::token_2022::spl_token_2022::extension::transfer_fee::MAX_FEE_BASIS_POINTS;
use marginfi::constants::PYTH_ID;
use marginfi::constants::SWITCHBOARD_PULL_ID;
use pyth_sdk_solana::state::{
AccountType, PriceInfo, PriceStatus, Rational, SolanaPriceAccount, MAGIC, VERSION_2,
};
Expand Down Expand Up @@ -152,7 +153,7 @@ pub fn create_switch_pull_oracle_account_from_bytes(data: Vec<u8>) -> Account {
Account {
lamports: 1_000_000,
data,
owner: switchboard_on_demand::SWITCHBOARD_PROGRAM_ID,
owner: SWITCHBOARD_PULL_ID,
executable: false,
rent_epoch: 361,
}
Expand Down

0 comments on commit f0feb6e

Please sign in to comment.