Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zerofi integration #1407

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

zerofi integration #1407

wants to merge 3 commits into from

Conversation

zer0fi
Copy link

@zer0fi zer0fi commented Dec 27, 2024

Adds fulfillment via zerofi:

  • new instructions: InitializeZerofiFulfillmentConfig, UpdateZerofiFulfillmentConfig
  • SpotFulfillmentType::Zerofi supported in spot fill instructions
  • typescript support in adminClient and driftClient
  • tests based on fixtures


#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
#[repr(C)]
pub struct Market {
Copy link
Member

Choose a reason for hiding this comment

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

would be good to preface this we ZerofiMarket so its clear what it's used for (there are multiple Market accounts in this program)

let market: Ref<Market> = Ref::map(data, |data| {
bytemuck::from_bytes(&data[..std::mem::size_of::<Market>()])
});
if market.discriminator != 4 {
Copy link
Member

Choose a reason for hiding this comment

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

dont you have to check owner program id?

/// CHECK: checked in ix
pub zerofi_program: AccountInfo<'info>,
/// CHECK: checked in ix
pub zerofi_market: AccountInfo<'info>,
Copy link
Member

Choose a reason for hiding this comment

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

would assert the owner

};

Ok(ExternalSpotFill {
base_asset_amount_filled,
Copy link
Member

Choose a reason for hiding this comment

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

need to make sure this is a multiple of step size

let max_quote_in = taker_quote_asset_amount.min(taker_max_quote_asset_amount);
(max_quote_in, taker_base_asset_amount)
} else {
(taker_base_asset_amount, taker_quote_asset_amount)
Copy link
Member

Choose a reason for hiding this comment

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

why dont you need to account for taker_max_quote_asset_amount in this block?

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