Skip to content

Commit

Permalink
Merge pull request #469 from equilibria-xyz/ed/fix-extension-unit-tests
Browse files Browse the repository at this point in the history
Resolve extension test failure
  • Loading branch information
EdNoepel authored Oct 11, 2024
2 parents 640fe2e + e712453 commit fecc233
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/perennial-extensions/contracts/MultiInvoker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ contract MultiInvoker is IMultiInvoker, Kept {

/// @notice withdraw DSU or unwrap DSU to withdraw USDC from this address to `account`
/// @param account Account to claim fees for
/// @param unwrap Wheather to wrap/unwrap collateral on withdrawal
/// @param unwrap Whether to wrap/unwrap collateral on withdrawal
function claim(address account, bool unwrap) external onlyOperator(account, msg.sender) {
UFixed6 claimableAmount = claimable[account];
claimable[account] = UFixed6Lib.ZERO;
Expand Down Expand Up @@ -325,6 +325,7 @@ contract MultiInvoker is IMultiInvoker, Kept {
/// @notice Claims market fees, unwraps DSU, and pushes USDC to fee earner
/// @param market Market from which fees should be claimed
/// @param account Address of the user who earned fees
/// @param unwrap Set true to unwrap DSU to USDC when withdrawing
function _claimFee(address account, IMarket market, bool unwrap) internal isMarketInstance(market) {
UFixed6 claimAmount = market.claimFee(account);
_withdraw(account, claimAmount, unwrap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,6 @@ export function RunMultiInvokerTests(name: string, setup: () => Promise<void>):
const feeAmt = collateral.div(10)
const feeAmt2 = collateral.div(20)

usdc.balanceOf.returnsAtCall(0, 0)
usdc.balanceOf.returnsAtCall(1, feeAmt)

usdc.balanceOf.returnsAtCall(2, 0)
usdc.balanceOf.returnsAtCall(3, feeAmt2)

await expect(
invoke(
buildUpdateMarket({
Expand All @@ -472,10 +466,19 @@ export function RunMultiInvokerTests(name: string, setup: () => Promise<void>):
.to.emit(multiInvoker, 'InterfaceFeeCharged')
.withArgs(user.address, market.address, [feeAmt2, user2.address])

usdc.balanceOf.returnsAtCall(0, 0)
usdc.balanceOf.returnsAtCall(1, feeAmt)
await expect(multiInvoker.connect(owner).claim(owner.address, true)).to.not.be.reverted
expect(reserve.redeem).to.have.been.calledWith(collateral.div(10).mul(1e12))
expect(usdc.transfer).to.have.been.calledWith(owner.address, collateral.div(10))
usdc.balanceOf.reset()

usdc.balanceOf.returnsAtCall(0, 0)
usdc.balanceOf.returnsAtCall(1, feeAmt2)
await expect(multiInvoker.connect(user2).claim(user2.address, true)).to.not.be.reverted
expect(reserve.redeem).to.have.been.calledWith(collateral.div(20).mul(1e12))
expect(usdc.transfer).to.have.been.calledWith(user2.address, collateral.div(20))
usdc.balanceOf.reset()
})

it('charges multiple interface fees on deposit, unwraps one to USDC, and pushes to receive', async () => {
Expand Down

0 comments on commit fecc233

Please sign in to comment.