Skip to content

Commit

Permalink
feat: FP deployment with ERC20Permit extension
Browse files Browse the repository at this point in the history
  • Loading branch information
xtools-at committed Feb 28, 2024
1 parent ac3916b commit 3c6e22b
Show file tree
Hide file tree
Showing 15 changed files with 9,466 additions and 18 deletions.
4 changes: 2 additions & 2 deletions constants/tokenConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
symbol: "DOMI",
withFee: true,
},
FpOFT: {
ForgottenPlaylandOFT: {
name: "Forgotten Playland",
symbol: "FP",
withFee: true,
Expand Down Expand Up @@ -120,7 +120,7 @@ module.exports = {
withFee: true,
minGas: 10000000,
},
FpProxyOFT: {
ForgottenPlaylandProxyOFT: {
address: "0xEeee2A2E650697d2A8e8BC990C2f3d04203bE06f",
withFee: true,
minGas: 10000000,
Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts-upgradable/examples/FP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity ^0.8.18;

import "../token/oft/v2/fee/OFTWithFeeUpgradeable.sol";
import "../token/oft/v2/fee/OFTWithFeePermitUpgradeable.sol";
import "../token/oft/v2/fee/ProxyOFTWithFeeUpgradeable.sol";

contract FpOFT is OFTWithFeeUpgradeable {}
contract ForgottenPlaylandOFT is OFTWithFeePermitUpgradeable {}

contract FpProxyOFT is ProxyOFTWithFeeUpgradeable {}
contract ForgottenPlaylandProxyOFT is ProxyOFTWithFeeUpgradeable {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ contract OFTWithFeePermitUpgradeable is Initializable, BaseOFTWithFeeUpgradeable
_disableInitializers();
}

function initialize(string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint) public virtual initializer {
__OFTWithFeeUpgradeable_init(_name, _symbol, _sharedDecimals, _lzEndpoint);
function initialize(
string memory _name,
string memory _symbol,
uint8 _sharedDecimals,
address _lzEndpoint
) public virtual initializer {
__OFTWithFeePermitUpgradeable_init(_name, _symbol, _sharedDecimals, _lzEndpoint);
}

function __OFTWithFeeUpgradeable_init(
function __OFTWithFeePermitUpgradeable_init(
string memory _name,
string memory _symbol,
uint8 _sharedDecimals,
Expand All @@ -32,13 +37,13 @@ contract OFTWithFeePermitUpgradeable is Initializable, BaseOFTWithFeeUpgradeable
__ERC20_init_unchained(_name, _symbol);
__ERC20Permit_init_unchained(_name);

__OFTWithFeeUpgradeable_init_unchained(_sharedDecimals);
__OFTWithFeePermitUpgradeable_init_unchained(_sharedDecimals);
}

function __OFTWithFeeUpgradeable_init_unchained(uint8 _sharedDecimals) internal onlyInitializing {
function __OFTWithFeePermitUpgradeable_init_unchained(uint8 _sharedDecimals) internal onlyInitializing {
uint8 decimals = decimals();
require(_sharedDecimals <= decimals, "OFTWithFee: sharedDecimals must be <= decimals");
ld2sdRate = 10 ** (decimals - _sharedDecimals);
ld2sdRate = 10**(decimals - _sharedDecimals);
}

/************************************************************************
Expand All @@ -55,19 +60,32 @@ contract OFTWithFeePermitUpgradeable is Initializable, BaseOFTWithFeeUpgradeable
/************************************************************************
* internal functions
************************************************************************/
function _debitFrom(address _from, uint16, bytes32, uint _amount) internal virtual override returns (uint) {
function _debitFrom(
address _from,
uint16,
bytes32,
uint _amount
) internal virtual override returns (uint) {
address spender = _msgSender();
if (_from != spender) _spendAllowance(_from, spender, _amount);
_burn(_from, _amount);
return _amount;
}

function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns (uint) {
function _creditTo(
uint16,
address _toAddress,
uint _amount
) internal virtual override returns (uint) {
_mint(_toAddress, _amount);
return _amount;
}

function _transferFrom(address _from, address _to, uint _amount) internal virtual override returns (uint) {
function _transferFrom(
address _from,
address _to,
uint _amount
) internal virtual override returns (uint) {
address spender = _msgSender();
// if transfer from this contract, no need to check allowance
if (_from != address(this) && _from != spender) _spendAllowance(_from, spender, _amount);
Expand Down
2 changes: 1 addition & 1 deletion deploy/FpOFT.js → deploy/ForgottenPlaylandOFT.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const LZ_ENDPOINTS = require("../constants/layerzeroEndpoints.json")
const TOKEN_CONFIG = require("../constants/tokenConfig")

const CONTRACT_NAME = "FpOFT"
const CONTRACT_NAME = "ForgottenPlaylandOFT"

module.exports = async function ({ deployments, getNamedAccounts }) {
const { deploy } = deployments
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const LZ_ENDPOINTS = require("../constants/layerzeroEndpoints.json")
const TOKEN_CONFIG = require("../constants/tokenConfig")

const CONTRACT_NAME = "FpProxyOFT"
const CONTRACT_NAME = "ForgottenPlaylandProxyOFT"

module.exports = async function ({ deployments, getNamedAccounts }) {
const { deploy } = deployments
Expand Down
Loading

0 comments on commit 3c6e22b

Please sign in to comment.