Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 81586e7

Browse files
authored
lending: remove unnecessary PDA (#2212)
1 parent 31603ed commit 81586e7

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

token-lending/js/src/instructions/depositObligationCollateral.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const depositObligationCollateralInstruction = (
1919
depositReserve: PublicKey,
2020
obligation: PublicKey,
2121
lendingMarket: PublicKey,
22-
lendingMarketAuthority: PublicKey,
2322
obligationOwner: PublicKey,
2423
transferAuthority: PublicKey
2524
): TransactionInstruction => {
@@ -38,7 +37,6 @@ export const depositObligationCollateralInstruction = (
3837
{ pubkey: depositReserve, isSigner: false, isWritable: false },
3938
{ pubkey: obligation, isSigner: false, isWritable: true },
4039
{ pubkey: lendingMarket, isSigner: false, isWritable: false },
41-
{ pubkey: lendingMarketAuthority, isSigner: false, isWritable: false },
4240
{ pubkey: obligationOwner, isSigner: true, isWritable: false },
4341
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
4442
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },

token-lending/program/src/instruction.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,10 @@ pub enum LendingInstruction {
168168
/// 2. `[]` Deposit reserve account - refreshed.
169169
/// 3. `[writable]` Obligation account.
170170
/// 4. `[]` Lending market account.
171-
/// 5. `[]` Derived lending market authority.
172-
/// 6. `[signer]` Obligation owner.
173-
/// 7. `[signer]` User transfer authority ($authority).
174-
/// 8. `[]` Clock sysvar.
175-
/// 9. `[]` Token program id.
171+
/// 5. `[signer]` Obligation owner.
172+
/// 6. `[signer]` User transfer authority ($authority).
173+
/// 7. `[]` Clock sysvar.
174+
/// 8. `[]` Token program id.
176175
DepositObligationCollateral {
177176
/// Amount of collateral tokens to deposit
178177
collateral_amount: u64,
@@ -789,10 +788,6 @@ pub fn deposit_obligation_collateral(
789788
obligation_owner_pubkey: Pubkey,
790789
user_transfer_authority_pubkey: Pubkey,
791790
) -> Instruction {
792-
let (lending_market_authority_pubkey, _bump_seed) = Pubkey::find_program_address(
793-
&[&lending_market_pubkey.to_bytes()[..PUBKEY_BYTES]],
794-
&program_id,
795-
);
796791
Instruction {
797792
program_id,
798793
accounts: vec![
@@ -801,7 +796,6 @@ pub fn deposit_obligation_collateral(
801796
AccountMeta::new_readonly(deposit_reserve_pubkey, false),
802797
AccountMeta::new(obligation_pubkey, false),
803798
AccountMeta::new_readonly(lending_market_pubkey, false),
804-
AccountMeta::new_readonly(lending_market_authority_pubkey, false),
805799
AccountMeta::new_readonly(obligation_owner_pubkey, true),
806800
AccountMeta::new_readonly(user_transfer_authority_pubkey, true),
807801
AccountMeta::new_readonly(sysvar::clock::id(), false),

token-lending/program/src/processor.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,6 @@ fn process_deposit_obligation_collateral(
817817
let deposit_reserve_info = next_account_info(account_info_iter)?;
818818
let obligation_info = next_account_info(account_info_iter)?;
819819
let lending_market_info = next_account_info(account_info_iter)?;
820-
let lending_market_authority_info = next_account_info(account_info_iter)?;
821820
let obligation_owner_info = next_account_info(account_info_iter)?;
822821
let user_transfer_authority_info = next_account_info(account_info_iter)?;
823822
let clock = &Clock::from_account_info(next_account_info(account_info_iter)?)?;
@@ -879,19 +878,6 @@ fn process_deposit_obligation_collateral(
879878
return Err(LendingError::InvalidSigner.into());
880879
}
881880

882-
let authority_signer_seeds = &[
883-
lending_market_info.key.as_ref(),
884-
&[lending_market.bump_seed],
885-
];
886-
let lending_market_authority_pubkey =
887-
Pubkey::create_program_address(authority_signer_seeds, program_id)?;
888-
if &lending_market_authority_pubkey != lending_market_authority_info.key {
889-
msg!(
890-
"Derived lending market authority does not match the lending market authority provided"
891-
);
892-
return Err(LendingError::InvalidMarketAuthority.into());
893-
}
894-
895881
obligation
896882
.find_or_add_collateral_to_deposits(*deposit_reserve_info.key)?
897883
.deposit(collateral_amount)?;

0 commit comments

Comments
 (0)