-
Notifications
You must be signed in to change notification settings - Fork 176
Wphan/builder codes #1805
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
base: master
Are you sure you want to change the base?
Wphan/builder codes #1805
Conversation
…n place_signed_msg_taker_order
programs/drift/src/state/builder.rs
Outdated
pub authority: Pubkey, | ||
pub total_referrer_rewards: i64, | ||
pub total_builder_rewards: i64, | ||
// might need padding for the len 4 bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need padding here?
|
||
#[account(zero_copy(unsafe))] | ||
#[derive(Eq, PartialEq, Debug, Default)] | ||
pub struct Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it less confusing if we call this referrer instead of builder?
pub authority: Pubkey, | ||
pub total_referrer_rewards: u64, | ||
pub total_builder_rewards: u64, | ||
pub padding: [u8; 18], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idt you need this padding?
/// the index of the BuilderEscrow.approved_builders list, that this order's fee will settle to. Ignored | ||
/// if bit_flag = Referral. | ||
pub builder_idx: u8, | ||
pub padding0: [u8; 7], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you order the fields from largest size to smallest size, it's guranteed to minimize padding. I think if you move builder_idx to bottom, you can get rid of this extra padding
/// Checks if the order can be merged with another order. Merged orders track cumulative fees accrued | ||
/// and are settled together, making more efficient use of the orders list. | ||
pub fn is_mergeable(&self, other: &BuilderOrder) -> bool { | ||
!self.is_referral_order() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can referrer orders be merged together?
|
||
/// Returns two distinct mutable references to orders by indices in one borrow of `self`. | ||
/// Either index may be None. If both Some, they must be distinct. | ||
pub fn get_two_orders_mut_by_indices( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gnarly, might be good to have unit test for this just to make sure each case works
builder.authority = ctx.accounts.authority.key(); | ||
builder.total_referrer_rewards = 0; | ||
builder.total_builder_rewards = 0; | ||
builder.padding = [0; 18]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you dont have to set this
)] | ||
pub builder_escrow: Box<Account<'info, BuilderEscrow>>, | ||
/// CHECK: The auth owning this account, payer of builder/ref fees | ||
pub authority: Signer<'info>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if you need to force the authority to sign?
) -> Result<()> { | ||
let state = &mut ctx.accounts.state; | ||
if !state.builder_referral_enabled() { | ||
if state.admin != ctx.accounts.payer.key() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob want this to be allowed to be hot wallet?
)] | ||
pub builder: AccountLoader<'info, Builder>, | ||
/// CHECK: The builder and/or referrer authority, beneficiary of builder/ref fees | ||
pub authority: Signer<'info>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if this need to sign
} else { | ||
0 | ||
}; | ||
let user_fee = fee.safe_add(builder_fee)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might mess with accounting we do, also dont you already add it before calling update_quote_asset_and_break_even_amount, so it'd be double counting?
unsafe impl Zeroable for MarketType {} | ||
unsafe impl Pod for MarketType {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed it for MarketType to work in zerocopy
No description provided.