diff --git a/packages/perennial/contracts/Market.sol b/packages/perennial/contracts/Market.sol index 4829d5608..f7c42d039 100644 --- a/packages/perennial/contracts/Market.sol +++ b/packages/perennial/contracts/Market.sol @@ -130,7 +130,7 @@ contract Market is IMarket, Instance, ReentrancyGuard { function claimFee() external { Global memory newGlobal = _global.read(); - if (_claimFee(address(factory()), newGlobal.protocolFee)) newGlobal.protocolFee = UFixed6Lib.ZERO; + if (_claimFee(factory().owner(), newGlobal.protocolFee)) newGlobal.protocolFee = UFixed6Lib.ZERO; if (_claimFee(address(IMarketFactory(address(factory())).oracleFactory()), newGlobal.oracleFee)) newGlobal.oracleFee = UFixed6Lib.ZERO; if (_claimFee(coordinator, newGlobal.riskFee)) newGlobal.riskFee = UFixed6Lib.ZERO; @@ -139,7 +139,7 @@ contract Market is IMarket, Instance, ReentrancyGuard { _global.store(newGlobal); } - /// @notice Helper function to handle a singular fee claim + /// @notice Helper function to handle a singular fee claim. /// @param receiver The address to receive the fee /// @param fee The amount of the fee to claim function _claimFee(address receiver, UFixed6 fee) private returns (bool) { diff --git a/packages/perennial/contracts/MarketFactory.sol b/packages/perennial/contracts/MarketFactory.sol index b2acc4f56..d60a13d2b 100644 --- a/packages/perennial/contracts/MarketFactory.sol +++ b/packages/perennial/contracts/MarketFactory.sol @@ -81,11 +81,4 @@ contract MarketFactory is IMarketFactory, Factory { emit MarketCreated(newMarket, definition); } - - /// @notice Claims the protocol's fee from the given market - /// @param market The market to claim from - function fund(IMarket market) external { - if (!instances(IInstance(address(market)))) revert FactoryNotInstanceError(); - market.claimFee(); - } } diff --git a/packages/perennial/contracts/interfaces/IMarketFactory.sol b/packages/perennial/contracts/interfaces/IMarketFactory.sol index c22111275..b07e57713 100644 --- a/packages/perennial/contracts/interfaces/IMarketFactory.sol +++ b/packages/perennial/contracts/interfaces/IMarketFactory.sol @@ -25,5 +25,4 @@ interface IMarketFactory is IFactory { function updateParameter(ProtocolParameter memory newParameter) external; function updateOperator(address operator, bool newEnabled) external; function create(IMarket.MarketDefinition calldata definition) external returns (IMarket); - function fund(IMarket market) external; } diff --git a/packages/perennial/test/unit/market/Market.test.ts b/packages/perennial/test/unit/market/Market.test.ts index 0ca26c5e4..5a5ec6f98 100644 --- a/packages/perennial/test/unit/market/Market.test.ts +++ b/packages/perennial/test/unit/market/Market.test.ts @@ -13054,11 +13054,11 @@ describe('Market', () => { }) it('claims fee (protocol)', async () => { - dsu.transfer.whenCalledWith(factory.address, PROTOCOL_FEE.mul(1e12)).returns(true) + dsu.transfer.whenCalledWith(owner.address, PROTOCOL_FEE.mul(1e12)).returns(true) - await expect(market.connect(factorySigner).claimFee()) + await expect(market.connect(owner).claimFee()) .to.emit(market, 'FeeClaimed') - .withArgs(factory.address, PROTOCOL_FEE) + .withArgs(owner.address, PROTOCOL_FEE) expect((await market.global()).protocolFee).to.equal(0) expect((await market.global()).oracleFee).to.equal(ORACLE_FEE) diff --git a/packages/perennial/test/unit/marketfactory/MarketFactory.test.ts b/packages/perennial/test/unit/marketfactory/MarketFactory.test.ts index c09ab47f0..2521a52f8 100644 --- a/packages/perennial/test/unit/marketfactory/MarketFactory.test.ts +++ b/packages/perennial/test/unit/marketfactory/MarketFactory.test.ts @@ -227,36 +227,4 @@ describe('MarketFactory', () => { expect(await factory.operators(user.address, owner.address)).to.equal(false) }) }) - - describe('#fund', async () => { - let marketAddress: string - let fakeMarket: FakeContract - - beforeEach(async () => { - const marketDefinition = { - token: dsu.address, - oracle: oracle.address, - payoff: constants.AddressZero, - } - - oracleFactory.instances.whenCalledWith(oracle.address).returns(true) - - marketAddress = await factory.callStatic.create(marketDefinition) - await factory.connect(owner).create(marketDefinition) - fakeMarket = await smock.fake('IMarket', { address: marketAddress }) - }) - - it('claims its fees', async () => { - await factory.connect(user).fund(marketAddress) - - expect(fakeMarket.claimFee).to.have.been.called - }) - - it('reverts if not an instance', async () => { - await expect(factory.connect(user).fund(user.address)).to.be.revertedWithCustomError( - factory, - 'FactoryNotInstanceError', - ) - }) - }) })