Skip to main content

P12CoinFactoryUpgradeable

P12CoinFactoryUpgradeable

setDev

function setDev(address newDev) external virtual

set dev address

NameTypeDescription
newDevaddressnew dev address

setP12Mine

function setP12Mine(contract IP12MineUpgradeable newP12Mine) external virtual

set p12mine contract address

NameTypeDescription
newP12Minecontract IP12MineUpgradeablenew p12mine address

setGaugeController

function setGaugeController(contract IGaugeController newGaugeController) external virtual

set gaugeController contract address

NameTypeDescription
newGaugeControllercontract IGaugeControllernew gaugeController address

setP12Token

function setP12Token(address newP12Token) external virtual

set p12Token address reserved only during development

NameTypeDescription
newP12Tokenaddressnew p12Token address

setUniswapFactory

function setUniswapFactory(contract IUniswapV2Factory newUniswapFactory) external virtual

set uniswapFactory address reserved only during development

NameTypeDescription
newUniswapFactorycontract IUniswapV2Factorynew UniswapFactory address

setUniswapRouter

function setUniswapRouter(contract IUniswapV2Router02 newUniswapRouter) external virtual

set uniswapRouter address reserved only during development

NameTypeDescription
newUniswapRoutercontract IUniswapV2Router02new uniswapRouter address

register

function register(string gameId, address developer) external virtual

create binding between game and developer, only called by p12 backend

NameTypeDescription
gameIdstringgame id
developeraddressdeveloper 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

NameTypeDescription
namestringnew game coin's name
symbolstringgame coin's symbol
gameIdstringthe game's id
gameCoinIconUrlstringgame coin icon's url
amountGameCoinuint256how many coin first mint
amountP12uint256how many P12 coin developer would stake
NameTypeDescription
gameCoinAddresscontract IP12GameCointhe 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

NameTypeDescription
gameIdstringgame's id
gameCoinAddresscontract IP12GameCoingame coin's address
amountGameCoinuint256how 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

NameTypeDescription
gameCoinAddresscontract IP12GameCoinaddress of the game coin
mintIdbytes32a unique id to identify a mint, developer can get it after declare
NameTypeDescription
[0]boolbool 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

NameTypeDescription
userAddressaddressuser's address
gameCoinAddresscontract IP12GameCoingameCoin's address
amountGameCoinuint256how 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

NameTypeDescription
newDelayKuint256new K parameter

setDelayB

function setDelayB(uint256 newDelayB) public virtual returns (bool)

set linear function's B parameter

NameTypeDescription
newDelayBuint256new 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

NameTypeDescription
namestringgame coin name
symbolstringgame coin symbol
gameIdstringgame id
gameCoinIconUrlstringgame coin icon's url
amountGameCoinuint256how 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

NameTypeDescription
gameCoinAddresscontract IP12GameCoingame coin address
declareraddressaddress which declare to mint game coin
amountuint256how much to mint
timestampuint256time when declare
saltbytes32a random bytes32
NameTypeDescription
hashbytes32mintId

_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)