Conversation
austbot
left a comment
There was a problem hiding this comment.
In general this is going in the right direction, lets get the zero copy on the oracle data and lets see if we can remove the big list of pairs by using an oracle that we can derive the feed accounts based on the base asset and the other side of the pair Sol, or tokens.
also on the fall through I need to think about this, it seems good, but we also dont have any of this OR semantic anywhere, but maybe we need it.
program/src/util/mod.rs
Outdated
|
|
||
| // Feed id | ||
| let mut feed_id_array = [0u8; 32]; | ||
| feed_id_array.copy_from_slice(&price_update_data[41..73]); |
There was a problem hiding this comment.
we can surely do a zero copy lookup
There was a problem hiding this comment.
Added direct unchecked data read in commit
18d01c0
state-x/src/action/oracle_limits.rs
Outdated
| ) -> Result<([u8; 32], u8), SwigStateError> { | ||
| match token_mint { | ||
| // "SOL/USD" | ||
| [252, 209, 65, 233, 131, 44, 175, 16, 173, 145, 116, 149, 202, 15, 39, 27, 91, 41, 60, 212, 112, 39, 234, 115, 112, 7, 237, 64, 235, 57, 160, 189] => { |
There was a problem hiding this comment.
For the love of God use the pubkey! macro in pinnochio_pubkey
There was a problem hiding this comment.
Removed and added a cleaner approach for getting the feed_id
02d2d9c
| /// - The oracle feed ID as a 32-byte array | ||
| /// - The token's mint decimal precision | ||
| /// * `Err(SwigStateError)` - If the token mint is not recognized | ||
| pub fn get_feed_id_and_decimal_from_mint( |
There was a problem hiding this comment.
is there an oracle that lets use derive the feed?
There was a problem hiding this comment.
At the moment I am using the sponsored feed accounts from here:
https://docs.pyth.network/price-feeds/sponsored-feeds/solana
Or we can also run our own oracle feeds where we can support more base assets
state-x/src/action/oracle_limits.rs
Outdated
| #[repr(C, align(8))] | ||
| #[derive(Debug, NoPadding)] | ||
| pub struct OracleTokenLimit { | ||
| /// The current remaining amount that can be used (in base asset lamports) |
There was a problem hiding this comment.
its not lamports if its not sol :)
| /// The current remaining amount that can be used (in base asset lamports) | ||
| pub value_limit: u64, | ||
| /// The base asset type used to denominate the limit (e.g. USDC) | ||
| pub base_asset_type: u8, |
There was a problem hiding this comment.
I initially want to say NOOOO, we need to support any base asset, but the reality is that we really only need a few, what I think is more likeley is that we need to support any pair of the base asset that we can derive and oracle data from.
There was a problem hiding this comment.
It finally comes down to the oracle support or we have to internally calculate all the oracle pricing like
Bonk -> EUR by Bonk -> USD then USD -> EUR.
| pub base_asset_type: u8, | ||
| /// The passthrough flag, it will check the remaining actions | ||
| /// and not just stop with oracle limit check | ||
| pub passthrough_check: bool, |
There was a problem hiding this comment.
this is an interesting modifier, this would be like you can transfer $100 of value and up to 5 sol.
I need to think about this.
|
Closing the PR as the oracle logic is changed to scope agg: |
No description provided.