Skip to content

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