PTokenFactory

Introduction

The PTokenFactory contract is for creating new pools.

Create pToken

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.

PTokenFactory

function createPToken(address underlying_) external returns (uint)
  • underlying_: The underlying asset address.

  • RETURN: 0 on success, otherwise an Error code

Solidity

Erc20 underlying = Erc20(0xToken...);
PTokenFactory factory = PTokenFactory(0xABCD...);
require(factory.createPToken(address(underlying)) == 0, "something went wrong");

Web3 1.0

const underlying = "0xToken..."
const factory = PTokenFactory.at(0x3FDB...);
factory.methods.createPToken(underlying).send({from: ...});

Checking asset liquidity

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.

PTokenFactory

function checkPair(address asset) public view returns (bool)
  • asset: The underlying asset address.

  • RETURN: true or false

Solidity

Erc20 underlying = Erc20(0xToken...);
PTokenFactory factory = PTokenFactory(0xABCD...);
require(factory.checkPair(address(underlying)) == 0, "not enough liquidity");

Web3 1.0

const underlying = "0xToken..."
const factory = PTokenFactory.at(0x3FDB...);
factory.methods.checkPair(underlying).call();

Last updated