Skip to content

Commit 23ce64e

Browse files
committed
feat: operator reclaims rent from user_unclaimed_fee
1 parent 4e40252 commit 23ce64e

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

programs/dynamic-fee-sharing/src/instructions/ix_claim_unclaimed_fee.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
99
#[event_cpi]
1010
#[derive(Accounts)]
1111
pub struct ClaimUnclaimedFeeCtx<'info> {
12-
#[account(has_one = token_mint, has_one = owner, has_one = token_vault)]
12+
#[account(has_one = token_mint, has_one = operator, has_one = token_vault)]
1313
pub fee_vault: AccountLoader<'info, FeeVault>,
1414

1515
/// CHECK: fee vault authority
@@ -23,7 +23,7 @@ pub struct ClaimUnclaimedFeeCtx<'info> {
2323

2424
#[account(
2525
mut,
26-
close = owner,
26+
close = operator,
2727
seeds = [
2828
USER_UNCLAIMED_FEE_PREFIX,
2929
fee_vault.key().as_ref(),
@@ -37,9 +37,9 @@ pub struct ClaimUnclaimedFeeCtx<'info> {
3737
#[account(mut)]
3838
pub user_token_vault: Box<InterfaceAccount<'info, TokenAccount>>,
3939

40-
/// CHECK: fee vault owner, receives rent from closed account
40+
/// CHECK: fee vault operator, receives rent from closed account
4141
#[account(mut)]
42-
pub owner: UncheckedAccount<'info>,
42+
pub operator: UncheckedAccount<'info>,
4343

4444
pub user: Signer<'info>,
4545

tests/common/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ export async function claimUnclaimedFee(params: {
454454
feeVault: PublicKey;
455455
tokenMint: PublicKey;
456456
user: Keypair;
457-
owner: PublicKey;
457+
operator: PublicKey;
458458
}) {
459-
const { svm, program, feeVault, tokenMint, user, owner } = params;
459+
const { svm, program, feeVault, tokenMint, user, operator } = params;
460460

461461
const feeVaultAuthority = deriveFeeVaultAuthorityAddress();
462462
const tokenVault = deriveTokenVaultAddress(feeVault);
@@ -475,7 +475,7 @@ export async function claimUnclaimedFee(params: {
475475
tokenVault,
476476
userUnclaimedFee,
477477
userTokenVault,
478-
owner,
478+
operator,
479479
user: user.publicKey,
480480
tokenProgram: TOKEN_PROGRAM_ID,
481481
})

tests/fee_sharing.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ async function fullFlow(
641641

642642
console.log("claim unclaimed fee");
643643
svm.expireBlockhash();
644-
const ownerBalanceBefore = svm.getBalance(vaultOwner.publicKey);
644+
const operatorBalanceBefore = svm.getBalance(operator.publicKey);
645645
const userTokenBefore = getTokenBalance(
646646
svm,
647647
getOrCreateAtA(svm, users[0], tokenMint, users[0].publicKey),
@@ -653,7 +653,7 @@ async function fullFlow(
653653
feeVault: feeVault.publicKey,
654654
tokenMint,
655655
user: users[0],
656-
owner: vaultOwner.publicKey,
656+
operator: operator.publicKey,
657657
});
658658
expect(claimRes instanceof TransactionMetadata).to.be.true;
659659

@@ -668,9 +668,9 @@ async function fullFlow(
668668
const closedUserUnclaimedFee = svm.getAccount(userUnclaimedFee);
669669
expect(closedUserUnclaimedFee.lamports).eq(0);
670670

671-
// owner should have received rent back from removed user token vault
672-
const ownerBalanceAfter = svm.getBalance(vaultOwner.publicKey);
673-
expect(ownerBalanceAfter > ownerBalanceBefore).to.be.true;
671+
// operator should have received rent back from removed user token vault
672+
const operatorBalanceAfter = svm.getBalance(operator.publicKey);
673+
expect(operatorBalanceAfter > operatorBalanceBefore).to.be.true;
674674

675675
console.log("add new user after removing user[0]");
676676
svm.expireBlockhash();

tests/fee_sharing_pda.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ async function fullFlow(
654654

655655
console.log("claim unclaimed fee");
656656
svm.expireBlockhash();
657-
const ownerBalanceBefore = svm.getBalance(vaultOwner.publicKey);
657+
const operatorBalanceBefore = svm.getBalance(operator.publicKey);
658658
const userTokenBefore = getTokenBalance(
659659
svm,
660660
getOrCreateAtA(svm, users[0], tokenMint, users[0].publicKey),
@@ -666,7 +666,7 @@ async function fullFlow(
666666
feeVault,
667667
tokenMint,
668668
user: users[0],
669-
owner: vaultOwner.publicKey,
669+
operator: operator.publicKey,
670670
});
671671
expect(claimRes instanceof TransactionMetadata).to.be.true;
672672

@@ -680,9 +680,9 @@ async function fullFlow(
680680
const closedUserUnclaimedFee = svm.getAccount(userUnclaimedFee);
681681
expect(closedUserUnclaimedFee.lamports).eq(0);
682682

683-
// owner should have received rent back from removed user token vault
684-
const ownerBalanceAfter = svm.getBalance(vaultOwner.publicKey);
685-
expect(ownerBalanceAfter > ownerBalanceBefore).to.be.true;
683+
// operator should have received rent back from removed user token vault
684+
const operatorBalanceAfter = svm.getBalance(operator.publicKey);
685+
expect(operatorBalanceAfter > operatorBalanceBefore).to.be.true;
686686

687687
console.log("add new user after removing user[0]");
688688
svm.expireBlockhash();

0 commit comments

Comments
 (0)