Skip to content

Commit

Permalink
removes need for approval
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Sep 8, 2024
1 parent 99054c1 commit d64144b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/L2YnERC20Upgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ contract L2YnERC20Upgradeable is ERC20Upgradeable, AccessControlUpgradeable, IMi
_mint(_to, _amount);
}

function burnFrom(address _from, uint256 _amount) public onlyRole(MINTER_ROLE) {
_spendAllowance(_from, _msgSender(), _amount);
function burn(address _from, uint256 _amount) public onlyRole(MINTER_ROLE) {
_burn(_from, _amount);
}
}
9 changes: 4 additions & 5 deletions src/L2YnOFTAdapterUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ contract L2YnOFTAdapterUpgradeable is OFTAdapterUpgradeable, AccessControlUpgrad
* @return requiresApproval Needs approval of the underlying token implementation.
*
* @dev In the case of default OFTAdapter, approval is required.
* @dev In non-default OFTAdapter contracts with something like mint and burn privileges, it may not need approval.
* @dev In our case, we need approval since we use burnFrom to burn tokens, which requires approval.
* @dev In non-default OFTAdapter contracts with something like mint and burn privileges, it does NOT need approval.
*/
function approvalRequired() external pure virtual override returns (bool) {
return true;
return false;
}

/**
Expand All @@ -76,8 +75,8 @@ contract L2YnOFTAdapterUpgradeable is OFTAdapterUpgradeable, AccessControlUpgrad
// @dev In NON-default OFT, amountSentLD could be 100, with a 10% fee, the amountReceivedLD amount is 90,
// therefore amountSentLD CAN differ from amountReceivedLD.

// @dev OFT burns on src. Requires approval.
IMintableBurnableERC20(address(innerToken)).burnFrom(_msgSender(), amountSentLD);
// @dev OFT burns on src
IMintableBurnableERC20(address(innerToken)).burn(_msgSender(), amountSentLD);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IMintableBurnableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pragma solidity ^0.8.24;

interface IMintableBurnableERC20 {
function mint(address _to, uint256 _amount) external;
function burnFrom(address _from, uint256 _amount) external;
function burn(address _from, uint256 _amount) external;
}
4 changes: 2 additions & 2 deletions test/OFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ contract OFTTest is TestHelper {
assertEq(aERC20.balanceOf(userA), initialBalance - tokensToSend);

vm.startPrank(userB);
bERC20.approve(address(bOFTAdapter), tokensToSend);
// bERC20.approve(address(bOFTAdapter), tokensToSend);
bOFTAdapter.send{value: receiveFee.nativeFee}(receiveParam, receiveFee, payable(address(this)));
vm.stopPrank();
verifyPackets(aEid, addressToBytes32(address(aOFTAdapter)));
Expand Down Expand Up @@ -431,7 +431,7 @@ contract OFTTest is TestHelper {
cOFTAdapter.debitView(amountToSendLD, minAmountToCreditLD + 1, dstEid);

vm.startPrank(userC);
cERC20.approve(address(cOFTAdapter), amountToSendLD);
// cERC20.approve(address(cOFTAdapter), amountToSendLD);
(uint256 amountDebitedLD, uint256 amountToCreditLD) =
cOFTAdapter.debit(amountToSendLD, minAmountToCreditLD, dstEid);
vm.stopPrank();
Expand Down

0 comments on commit d64144b

Please sign in to comment.