PTokenFactory
The PTokenFactory contract is for creating new pools.
Before creating a new pToken, the factory will check the conditions necessary to create a new pool, and if the asset meets all the conditions, the pToken will be created, otherwise, the function will return an error.
function createPToken(address underlying_) external returns (uint)
underlying_
: The underlying asset address.RETURN
: 0 on success, otherwise an Error code
Erc20 underlying = Erc20(0xToken...);
PTokenFactory factory = PTokenFactory(0xABCD...);
require(factory.createPToken(address(underlying)) == 0, "something went wrong");
const underlying = "0xToken..."
const factory = PTokenFactory.at(0x3FDB...);
factory.methods.createPToken(underlying).send({from: ...});
One of the main requirements for creating a new pToken is the availability of sufficient liquidity on Uniswap v2 or other DEX (clones Uniswap v2). This function checks liquidity and returns
true
if it is greater than or equal to the minUniswapLiquidity
parameter.function checkPair(address asset) public view returns (bool)
- asset: The underlying asset address.
RETURN
: true or false
Erc20 underlying = Erc20(0xToken...);
PTokenFactory factory = PTokenFactory(0xABCD...);
require(factory.checkPair(address(underlying)) == 0, "not enough liquidity");
const underlying = "0xToken..."
const factory = PTokenFactory.at(0x3FDB...);
factory.methods.checkPair(underlying).call();
Last modified 2yr ago