Skip to content

added oracle limit support#36

Closed
santy311 wants to merge 15 commits intomainfrom
santhosh/oracle-limit
Closed

added oracle limit support#36
santy311 wants to merge 15 commits intomainfrom
santhosh/oracle-limit

Conversation

@santy311
Copy link
Collaborator

@santy311 santy311 commented Jun 9, 2025

No description provided.

@santy311 santy311 changed the title WIP: added oracle limit support added oracle limit support Jun 13, 2025
Copy link
Contributor

@austbot austbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


// Feed id
let mut feed_id_array = [0u8; 32];
feed_id_array.copy_from_slice(&price_update_data[41..73]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can surely do a zero copy lookup

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added direct unchecked data read in commit
18d01c0

) -> 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] => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the love of God use the pubkey! macro in pinnochio_pubkey

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an oracle that lets use derive the feed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

#[repr(C, align(8))]
#[derive(Debug, NoPadding)]
pub struct OracleTokenLimit {
/// The current remaining amount that can be used (in base asset lamports)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not lamports if its not sol :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 Fixed it.

/// 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@santy311 santy311 requested a review from austbot June 15, 2025 14:25
@santy311
Copy link
Collaborator Author

santy311 commented Jul 9, 2025

Closing the PR as the oracle logic is changed to scope agg:

#73

@santy311 santy311 closed this Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants