Skip to content

Commit

Permalink
config => rate limiter config
Browse files Browse the repository at this point in the history
  • Loading branch information
0xripleys committed Jan 31, 2023
1 parent 275e509 commit ebec41a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 10 additions & 2 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ pub fn process_instruction(
msg!("Instruction: Init Lending Market");
process_init_lending_market(program_id, owner, quote_currency, accounts)
}
LendingInstruction::SetLendingMarketOwnerAndConfig { new_owner, config } => {
LendingInstruction::SetLendingMarketOwnerAndConfig {
new_owner,
rate_limiter_config,
} => {
msg!("Instruction: Set Lending Market Owner");
process_set_lending_market_owner_and_config(program_id, new_owner, config, accounts)
process_set_lending_market_owner_and_config(
program_id,
new_owner,
rate_limiter_config,
accounts,
)
}
LendingInstruction::InitReserve {
liquidity_amount,
Expand Down
2 changes: 1 addition & 1 deletion token-lending/program/tests/set_lending_market_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async fn test_owner_not_signer() {
],
data: LendingInstruction::SetLendingMarketOwnerAndConfig {
new_owner,
config: RateLimiterConfig::default(),
rate_limiter_config: RateLimiterConfig::default(),
}
.pack(),
}],
Expand Down
17 changes: 12 additions & 5 deletions token-lending/sdk/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum LendingInstruction {
/// The new owner
new_owner: Pubkey,
/// The new config
config: RateLimiterConfig,
rate_limiter_config: RateLimiterConfig,
},

// 2
Expand Down Expand Up @@ -487,7 +487,7 @@ impl LendingInstruction {
let (max_outflow, _rest) = Self::unpack_u64(rest)?;
Self::SetLendingMarketOwnerAndConfig {
new_owner,
config: RateLimiterConfig {
rate_limiter_config: RateLimiterConfig {
window_duration,
max_outflow,
},
Expand Down Expand Up @@ -709,7 +709,10 @@ impl LendingInstruction {
buf.extend_from_slice(owner.as_ref());
buf.extend_from_slice(quote_currency.as_ref());
}
Self::SetLendingMarketOwnerAndConfig { new_owner, config } => {
Self::SetLendingMarketOwnerAndConfig {
new_owner,
rate_limiter_config: config,
} => {
buf.push(1);
buf.extend_from_slice(new_owner.as_ref());
buf.extend_from_slice(&config.window_duration.to_le_bytes());
Expand Down Expand Up @@ -885,15 +888,19 @@ pub fn set_lending_market_owner_and_config(
lending_market_pubkey: Pubkey,
lending_market_owner: Pubkey,
new_owner: Pubkey,
config: RateLimiterConfig,
rate_limiter_config: RateLimiterConfig,
) -> Instruction {
Instruction {
program_id,
accounts: vec![
AccountMeta::new(lending_market_pubkey, false),
AccountMeta::new_readonly(lending_market_owner, true),
],
data: LendingInstruction::SetLendingMarketOwnerAndConfig { new_owner, config }.pack(),
data: LendingInstruction::SetLendingMarketOwnerAndConfig {
new_owner,
rate_limiter_config,
}
.pack(),
}
}

Expand Down

0 comments on commit ebec41a

Please sign in to comment.