-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0704280
commit 4c3bf1c
Showing
5 changed files
with
777 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract PositionBUSDBonus is ERC20, Ownable { | ||
mapping(address => bool) public _transferableContracts; | ||
mapping(address => bool) internal _whitelistAddresses; | ||
|
||
event TransferableContractsUpdated(address transferableContract,bool isTransferableContract); | ||
event WhitelistAddressesUpdated(address whitelistAddress, bool isWhitelistAddress); | ||
|
||
modifier onlyWhitelist(address _address) { | ||
require(isWhitelistAddress(_address), "Only Whitelist"); | ||
_; | ||
} | ||
|
||
constructor(string memory name, string memory symbol) ERC20(name, symbol) { | ||
updateWhitelist(msg.sender,true); | ||
} | ||
|
||
function mint(address recipient, uint256 amount) public onlyWhitelist(msg.sender){ | ||
_mint(recipient,amount); | ||
} | ||
|
||
function _spendAllowance( | ||
address owner, | ||
address spender, | ||
uint256 amount | ||
) internal override virtual { | ||
require(isTransferableContract(spender), "Only Insurance Fund"); | ||
} | ||
|
||
function allowance(address owner, address spender) public view virtual override returns (uint256) { | ||
return 1; | ||
} | ||
|
||
function _beforeTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 amount | ||
) internal override virtual { | ||
if (from != address(0)) { | ||
require(isTransferableContract(from) || isTransferableContract(to), "Only Insurance Fund"); | ||
} | ||
} | ||
|
||
function updateWhitelist(address _address, bool _isWhitelist) public onlyOwner | ||
{ | ||
_whitelistAddresses[_address] = _isWhitelist; | ||
emit WhitelistAddressesUpdated(_address, _isWhitelist); | ||
} | ||
|
||
function updateTransferableContracts(address _address, bool _isTransferable) public onlyOwner | ||
{ | ||
_transferableContracts[_address] = _isTransferable; | ||
emit TransferableContractsUpdated(_address, _isTransferable); | ||
} | ||
|
||
function isTransferableContract(address _address) public view returns (bool) | ||
{ | ||
return _transferableContracts[_address]; | ||
} | ||
|
||
function isWhitelistAddress(address _address) public view returns (bool) | ||
{ | ||
return _whitelistAddresses[_address]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {MigrationContext, MigrationDefinition} from "../types"; | ||
import {verifyContract} from "../../scripts/utils"; | ||
|
||
const migrations: MigrationDefinition = { | ||
getTasks: (context: MigrationContext) => ({ | ||
'deploy position busd bonus token': async () => { | ||
const name = '' | ||
const symbol = '' | ||
const creditToken = await context.hre.ethers.getContractFactory('PositionBUSDBonus') | ||
if(await context.db.findAddressByKey(symbol) ) return; | ||
const deployTx = await creditToken.deploy(name, symbol) | ||
await deployTx.deployTransaction.wait(3) | ||
await verifyContract(context.hre, deployTx.address, [name, symbol]) | ||
await context.db.saveAddressByKey(symbol, deployTx.address) | ||
}, | ||
}) | ||
} | ||
|
||
export default migrations |
Oops, something went wrong.