Technical Docs
PositionFactory

PositionFactory

Description

The PositionFactory contract is responsible for creating Position contracts.

Write Functions

createPosition

Deploys a Position contract for msg.sender, given a _cToken, _dToken, and _bToken.

function createPosition(
    address _cToken,
    address _dToken,
    address _bToken
) external payable returns (address position);

Input Parameters

Parameter NameTypeDescription
_cTokenaddressThe collateral token:

The address of the ERC-20 token to be used as collateral.
_dTokenaddressThe debt token:

The address of the ERC-20 token to borrow. This is the token the user wants to short.
_bTokenaddressThe base token:

The address of the ERC-20 token to hold. This is the token the user wants to long.

Output Parameters

Parameter NameTypeDescription
positionaddressThe address of the Position contract created.

Read Functions

getPositions

Returns a list of Position contract addresses for the given _positionOwner, which represents all of the owner's positions.

function getPositions(
    address _positionOwner
) external view returns (address[] memory);

Input Parameters

Parameter NameTypeDescription
_positionOwneraddressThe address of a Pesto user's account.

Output Parameters

Parameter NameTypeDescription
positionsaddress[]The addresses of all the Position contracts that _positionOwner owns.

positions

Returns the address of a Position contract given an _owner, _cToken, _dToken, and _bToken.

function positions(
    address _owner,
    address _cToken,
    address _dToken,
    address _bToken
) external view returns (address);

Input Parameters

Parameter NameTypeDescription
_owneraddressThe address of the Position contract owner.
_cTokenaddressThe collateral token:

The address of the ERC-20 token that was used as collateral.
_dTokenaddressThe debt token:

The address of the ERC-20 token was borrowed. This is the token the user shorted.
_bTokenaddressThe base token:

The address of the ERC-20 token held. This is the token the user longed.

Output Parameters

Parameter NameTypeDescription
positionaddressThe address of the Position contract.

owner

Returns the owner of the PositionFactory contract.

function owner() external view returns (address);

Output Parameters

Parameter NameTypeDescription
owneraddressThe address of the account that has owner privileges on the PositionFactory contract.