P12CoinFactoryUpgradeable
P12CoinFactoryUpgradeable
setDev
function setDev(address newDev) external virtual
set dev address
Name | Type | Description |
---|---|---|
newDev | address | new dev address |
setP12Mine
function setP12Mine(contract IP12MineUpgradeable newP12Mine) external virtual
set p12mine contract address
Name | Type | Description |
---|---|---|
newP12Mine | contract IP12MineUpgradeable | new p12mine address |
setGaugeController
function setGaugeController(contract IGaugeController newGaugeController) external virtual
set gaugeController contract address
Name | Type | Description |
---|---|---|
newGaugeController | contract IGaugeController | new gaugeController address |
setP12Token
function setP12Token(address newP12Token) external virtual
set p12Token address reserved only during development
Name | Type | Description |
---|---|---|
newP12Token | address | new p12Token address |
setUniswapFactory
function setUniswapFactory(contract IUniswapV2Factory newUniswapFactory) external virtual
set uniswapFactory address reserved only during development
Name | Type | Description |
---|---|---|
newUniswapFactory | contract IUniswapV2Factory | new UniswapFactory address |
setUniswapRouter
function setUniswapRouter(contract IUniswapV2Router02 newUniswapRouter) external virtual
set uniswapRouter address reserved only during development
Name | Type | Description |
---|---|---|
newUniswapRouter | contract IUniswapV2Router02 | new uniswapRouter address |
register
function register(string gameId, address developer) external virtual
create binding between game and developer, only called by p12 backend
Name | Type | Description |
---|---|---|
gameId | string | game id |
developer | address | developer address, who own this game |
create
function create(string name, string symbol, string gameId, string gameCoinIconUrl, uint256 amountGameCoin, uint256 amountP12) external virtual returns (contract IP12GameCoin gameCoinAddress)
developer first create their game coin
Name | Type | Description |
---|---|---|
name | string | new game coin's name |
symbol | string | game coin's symbol |
gameId | string | the game's id |
gameCoinIconUrl | string | game coin icon's url |
amountGameCoin | uint256 | how many coin first mint |
amountP12 | uint256 | how many P12 coin developer would stake |
Name | Type | Description |
---|---|---|
gameCoinAddress | contract IP12GameCoin | the address of the new game coin |
queueMintCoin
function queueMintCoin(string gameId, contract IP12GameCoin gameCoinAddress, uint256 amountGameCoin) external virtual returns (bool success)
if developer want to mint after create coin, developer must declare first
Name | Type | Description |
---|---|---|
gameId | string | game's id |
gameCoinAddress | contract IP12GameCoin | game coin's address |
amountGameCoin | uint256 | how many developer want to mint |
executeMintCoin
function executeMintCoin(contract IP12GameCoin gameCoinAddress, bytes32 mintId) external virtual returns (bool)
when time is up, anyone can call this function to make the mint executed
Name | Type | Description |
---|---|---|
gameCoinAddress | contract IP12GameCoin | address of the game coin |
mintId | bytes32 | a unique id to identify a mint, developer can get it after declare |
Name | Type | Description |
---|---|---|
[0] | bool | bool whether the operation success |
withdraw
function withdraw(address userAddress, contract IP12GameCoin gameCoinAddress, uint256 amountGameCoin) external virtual returns (bool)
called when user want to withdraw his game coin from custodian address
Name | Type | Description |
---|---|---|
userAddress | address | user's address |
gameCoinAddress | contract IP12GameCoin | gameCoin's address |
amountGameCoin | uint256 | how many user want to withdraw |
pause
function pause() public
unpause
function unpause() public
initialize
function initialize(address owner_, address p12_, contract IUniswapV2Factory uniswapFactory_, contract IUniswapV2Router02 uniswapRouter_, uint256 effectiveTime_, bytes32 initHash_) public
setDelayK
function setDelayK(uint256 newDelayK) public virtual returns (bool)
set linear function's K parameter
Name | Type | Description |
---|---|---|
newDelayK | uint256 | new K parameter |
setDelayB
function setDelayB(uint256 newDelayB) public virtual returns (bool)
set linear function's B parameter
Name | Type | Description |
---|---|---|
newDelayB | uint256 | new B parameter |
setTokenName
function setTokenName(contract IP12GameCoin token, string newName) public
setTokenSymbol
function setTokenSymbol(contract IP12GameCoin token, string newSymbol) public
setTokenIconUrl
function setTokenIconUrl(contract IP12GameCoin token, string newUrl) public
getMintFee
function getMintFee(contract IP12GameCoin gameCoinAddress, uint256 amountGameCoin) public view virtual returns (uint256 amountP12)
calculate the MintFee in P12
getMintDelay
function getMintDelay(contract IP12GameCoin gameCoinAddress, uint256 amountGameCoin) public view virtual returns (uint256 time)
linear function to calculate the delay time
delayB is the minimum delay period, even someone mint zero token,
there still be delayB period before someone can really mint zero token
delayK is the parameter to take the ratio of new amount in to account
For example, the initial supply of Game Coin is 100k. If developer want
to mint 100k, developer needs to real mint it after delayK + delayB
. If
developer want to mint 200k, developer has to real mint it after 2DelayK +
delayB
.
^
t + /
| /
| /
2k+b| /
| /
k+b| /
|/
b|
0----p---2p---------> amount
_create
function _create(string name, string symbol, string gameId, string gameCoinIconUrl, uint256 amountGameCoin) internal virtual returns (contract P12GameCoin gameCoinAddress)
function to create a game coin contract
Name | Type | Description |
---|---|---|
name | string | game coin name |
symbol | string | game coin symbol |
gameId | string | game id |
gameCoinIconUrl | string | game coin icon's url |
amountGameCoin | uint256 | how many for first mint |
_hashOperation
function _hashOperation(contract IP12GameCoin gameCoinAddress, address declarer, uint256 amount, uint256 timestamp, bytes32 salt) internal virtual returns (bytes32 hash)
hash function to general mintId
Name | Type | Description |
---|---|---|
gameCoinAddress | contract IP12GameCoin | game coin address |
declarer | address | address which declare to mint game coin |
amount | uint256 | how much to mint |
timestamp | uint256 | time when declare |
salt | bytes32 | a random bytes32 |
Name | Type | Description |
---|---|---|
hash | bytes32 | mintId |
_authorizeUpgrade
function _authorizeUpgrade(address newImplementation) internal
upgrade function
_getBlockTimestamp
function _getBlockTimestamp() internal view virtual returns (uint256)
get current block's timestamp
_verifyDev
function _verifyDev() internal view
_verifyGameDev
function _verifyGameDev(contract IP12GameCoin token) internal view
_compareStrings
function _compareStrings(string a, string b) internal pure virtual returns (bool)
compare two string and judge whether they are the same
onlyDev
modifier onlyDev()
onlyGameDev
modifier onlyGameDev(contract IP12GameCoin token)