diff --git a/contracts/permit/EIP2612PermitAndDeposit.sol b/contracts/permit/EIP2612PermitAndDeposit.sol index 3d32f1f0..26496f78 100644 --- a/contracts/permit/EIP2612PermitAndDeposit.sol +++ b/contracts/permit/EIP2612PermitAndDeposit.sol @@ -28,7 +28,6 @@ contract EIP2612PermitAndDeposit { /** * @notice Permits this contract to spend on a user's behalf, and deposits into the prize pool. * @dev The `spender` address required by the permit function is the address of this contract. - * @param _token Address of the EIP-2612 token to approve and deposit * @param _owner Token owner's address (Authorizer) * @param _amount Amount of tokens to deposit * @param _deadline Timestamp at which the signature expires @@ -36,23 +35,23 @@ contract EIP2612PermitAndDeposit { * @param _delegateSignature Delegate signature * @param _prizePool Address of the prize pool to deposit into * @param _to Address that will receive the tickets - * @param _ticket Address of the prize pool ticket * @param _delegate The address to delegate the prize pool tickets to */ function permitAndDepositToAndDelegate( - address _token, address _owner, uint256 _amount, uint256 _deadline, Signature calldata _permitSignature, Signature calldata _delegateSignature, - address _prizePool, + IPrizePool _prizePool, address _to, - ITicket _ticket, address _delegate ) external { require(msg.sender == _owner, "EIP2612PermitAndDeposit/only-signer"); + ITicket _ticket = _prizePool.getTicket(); + address _token = _prizePool.getToken(); + IERC20Permit(_token).permit( _owner, address(this), @@ -63,7 +62,7 @@ contract EIP2612PermitAndDeposit { _permitSignature.s ); - _depositTo(_token, _owner, _amount, _prizePool, _to); + _depositTo(_token, _owner, _amount, address(_prizePool), _to); _ticket.delegateWithSignature( _owner, diff --git a/test/permit/EIP2612PermitAndDeposit.test.ts b/test/permit/EIP2612PermitAndDeposit.test.ts index 1699f4f9..196a4f0c 100644 --- a/test/permit/EIP2612PermitAndDeposit.test.ts +++ b/test/permit/EIP2612PermitAndDeposit.test.ts @@ -34,7 +34,6 @@ describe('EIP2612PermitAndDeposit', () => { fromWallet?: SignerWithAddress; to: string; amount: string; - ticketAddress: string; delegateAddress: string; }; @@ -43,8 +42,7 @@ describe('EIP2612PermitAndDeposit', () => { fromWallet, to, amount, - ticketAddress, - delegateAddress + delegateAddress, }: EIP2612PermitAndDepositToAndDelegate) { if (!fromWallet) { fromWallet = wallet; @@ -77,19 +75,16 @@ describe('EIP2612PermitAndDeposit', () => { const permitSignature = splitSignature(permit.sig); - return permitAndDeposit - .permitAndDepositToAndDelegate( - usdc.address, - user, - amount, - deadline, - permitSignature, - delegateSign, - prizePool, - to, - ticketAddress, - delegate - ); + return permitAndDeposit.permitAndDepositToAndDelegate( + user, + amount, + deadline, + permitSignature, + delegateSign, + prizePool, + to, + delegate, + ); } beforeEach(async () => { @@ -112,12 +107,7 @@ describe('EIP2612PermitAndDeposit', () => { permitAndDeposit = await EIP2612PermitAndDeposit.deploy(); const Ticket = await getContractFactory('TicketHarness'); - ticket = await Ticket.deploy( - 'PoolTogether Usdc Ticket', - 'PcUSDC', - 18, - prizePool.address, - ); + ticket = await Ticket.deploy('PoolTogether Usdc Ticket', 'PcUSDC', 18, prizePool.address); await prizePool.setTicket(ticket.address); await prizePool.setPrizeStrategy(prizeStrategyManager.address); @@ -135,8 +125,7 @@ describe('EIP2612PermitAndDeposit', () => { prizePool: prizePool.address, to: wallet.address, amount: '100000000000000000000', - ticketAddress: ticket.address, - delegateAddress: wallet.address + delegateAddress: wallet.address, }); expect(await usdc.balanceOf(prizePool.address)).to.equal(amount); @@ -156,8 +145,7 @@ describe('EIP2612PermitAndDeposit', () => { prizePool: prizePool.address, to: wallet.address, amount: '100000000000000000000', - ticketAddress: ticket.address, - delegateAddress: wallet2.address + delegateAddress: wallet2.address, }); expect(await usdc.balanceOf(prizePool.address)).to.equal(amount); @@ -181,8 +169,7 @@ describe('EIP2612PermitAndDeposit', () => { to: wallet2.address, fromWallet: wallet2, amount: '100000000000000000000', - ticketAddress: ticket.address, - delegateAddress: wallet2.address + delegateAddress: wallet2.address, }), ).to.be.revertedWith('EIP2612PermitAndDeposit/only-signer'); });