Skip to main content

PrimitiveFactory.sol

Read code on GitHub

No access controls are available to deployer

Details

Deploy new PrimitiveEngine contracts

Methods

MIN_LIQUIDITY_FACTOR

Used to scale the minimum amount of liquidity to lowest precision

Solidity
function MIN_LIQUIDITY_FACTOR() external view returns (uint256)
Details

E.g. if the lowest decimal token is 6, min liquidity w/ 18 decimals cannot be 1000 wei, therefore the token decimals divided by the min liquidity factor is the amount of minimum liquidity MIN_LIQUIDITY = 10 ^ (Decimals / MIN_LIQUIDITY_FACTOR)

Returns

NameTypeDescription
_0uint256undefined

args

Called within Engine constructor so Engine can set immutable variables without constructor args

Solidity
function args() external view returns (address factory, address risky, address stable, uint256 scaleFactorRisky, uint256 scaleFactorStable, uint256 minLiquidity)

Returns

NameTypeDescription
factoryaddressSmart contract deploying the Engine contract
riskyaddressRisky token
stableaddressStable token
scaleFactorRiskyuint256Scale factor of the risky token, 10^(18 - riskyTokenDecimals)
scaleFactorStableuint256Scale factor of the stable token, 10^(18 - stableTokenDecimals)
minLiquidityuint256Minimum amount of liquidity on pool creation

deploy

Deploys a new Engine contract and sets the getEngine mapping for the tokens

Solidity
function deploy(address risky, address stable) external nonpayable returns (address engine)

Parameters

NameTypeDescription
riskyaddressRisky token, the underlying token
stableaddressStable token, the quote token

Returns

NameTypeDescription
engineaddressundefined

deployer

Deployer does not have any access controls to wield

Solidity
function deployer() external view returns (address)

Returns

NameTypeDescription
_0addressDeployer of this factory contract

getEngine

Fetches engine address of a token pair which has been deployed from this factory

Solidity
function getEngine(address, address) external view returns (address)

Parameters

NameTypeDescription
_0addressundefined
_1addressundefined

Returns

NameTypeDescription
_0addressengine Engine address for a risky and stable token

Events

DeployEngine

Created a new engine contract!

Solidity
event DeployEngine(address indexed from, address indexed risky, address indexed stable, address engine)

Parameters

NameTypeDescription
from indexedaddressundefined
risky indexedaddressundefined
stable indexedaddressundefined
engineaddressundefined

Errors

DecimalsError

Thrown on attempting to deploy a pool using a token with unsupported decimals

Solidity
error DecimalsError(uint256 decimals)

Parameters

NameTypeDescription
decimalsuint256undefined

DeployedError

Thrown on attempting to deploy an already deployed Engine

Solidity
error DeployedError()

SameTokenError

Thrown when the risky and stable tokens are the same

Solidity
error SameTokenError()

ZeroAddressError

Thrown when the risky or the stable token is 0x0...

Solidity
error ZeroAddressError()