Skip to content

Commit

Permalink
Update ERC20 contract and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisPosition committed Jun 30, 2022
1 parent 2d61f7e commit 8c8af5b
Show file tree
Hide file tree
Showing 4 changed files with 626 additions and 57 deletions.
25 changes: 14 additions & 11 deletions contracts/protocol/PositionCreditBUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ contract PositionCreditBUSD is ERC20, Ownable {

event InsuranceFundTransferred(address indexed previousAddress, address indexed newAddress);

modifier onlyInsuranceFund() {
require(_msgSender() == _insuranceFundContract, "Only Insurance Fund");
_;
}

constructor(string memory name, string memory symbol, address _insuranceFundAddress) ERC20(name, symbol) {
_setInsuranceFundAddress(_insuranceFundAddress);
}
Expand All @@ -21,14 +16,22 @@ contract PositionCreditBUSD is ERC20, Ownable {
_mint(recipient,amount);
}

function transfer(address recipient, uint256 amount) public override onlyInsuranceFund returns (bool){
_transfer(_msgSender(), recipient, amount);
return true;
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal override virtual {
require(spender == _insuranceFundContract, "Only Insurance Fund");
}

function transferFrom(address sender, address recipient, uint256 amount) public override onlyInsuranceFund returns (bool) {
_transfer(sender, recipient, amount);
return true;
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override virtual {
if (from != address(0)) {
require(from == _insuranceFundContract || to == _insuranceFundContract, "Only Insurance Fund");
}
}

function transferInsuranceFund(address _newAddress) public onlyOwner {
Expand Down
Loading

0 comments on commit 8c8af5b

Please sign in to comment.