User Methods

ITO V1 contract user methods

Methods

Supply

function supply(
        address _downsideToken,
        address _upsideToken,
        uint256 _upsideTokenAmount,
        uint256 _exchangeRate,
        uint32 _startDate,
        uint32 _endDate,
        uint16 _feeBp
    ) external

Description: Allows anyone to create a position to supply tokens for sale

Inputs:

  • _downsideToken - Address of the only token that can be used to buy the upside tokens

  • _upsideToken - Address of the tokens that will be deposited for sale

  • _upsideTokenAmount - Total number of tokens that will be removed from supplier's wallet and deposited into ITO protocol to be supplied in this newly created position

  • _exchangeRate - How many upside tokens can be purchased for 1 downside token.

    • This value should be computed like so: ((upsideAmountWei / downsideAmountWei) * 10**18)

  • _startDate - Upside tokens can only be purchased on or after this timestamp

  • _endDate - Upside tokens can no longer be purchased, and untake() can no longer be called for this position, after this timestamp. All acquired downside tokens can be withdrawn by the supplier after this date.

  • _feeBp - The supply fee provided as a value between 0 and 4999. Example: 125 means 1.25% fee.

Note: A new positionId value will be created associated with this supply position.

Remove

function remove(
        uint256 _positionId, 
        uint256 _upsideTokenAmount, 
        uint256 _downsideTokenAmount
    ) external

Description: Allows suppliers to remove unused tokens from their position

Inputs:

  • _positionId - The ID of the position you want to remove from

  • _upsideTokenAmount - The number of upside tokens to remove from the position

  • _downsideTokenAmount - The number of downside tokens to remove from the position

Notes:

  • The downside tokens cannot be withdrawn until the end date of the position has been reached

  • This can be used to only remove upside tokens or only remove downside tokens if providing a value of 0 for the amount of the other.

ComputeFee

function computeFee(
        uint256 _positionId,
        uint256 _downsideTokenAmount
    ) public

Description: Returns the exact token amounts taken as protocolFee and lpFee given a downside amount

Inputs:

  • _positionId - The ID of the position you want to remove from

  • _downsideTokenAmount - The number of downside tokens you want to calculate fees for

Take

function take(
        uint256 _positionId,
        uint256 _maxDownsideTokenIn,
        uint256 _minUpsideTokenOut,
        uint256 _maxProtocolFeeBp
    ) external

Description: Allows takers to take the supply of a position, partially or fully

Inputs:

  • _positionId - The ID of the position you want to interact with

  • _maxDownsideTokenIn - The maximum number of downside tokens you wish to provide to this position

  • _minUpsideTokenOut - The minimum number of upside tokens to receive before reverting. This can be set to 0 to always partial fill if necessary.

  • _maxProtocolFeeBp - The maximum protocol fee BP you wish to accept before reverting. This should typically be set to the current protocol fee.

Note: None of these params determine exchange rate. Exchange rate is set by supplier of position.

Untake

function untake(
        uint256 _positionId, 
        uint256 _downsideTokenAmount
    ) external

Description: Allows users to return upside tokens (even partially) for a specified number of downsideTokens

Inputs:

  • _positionId - The ID of the position you want to interact with

  • _downsideTokenAmount - The number of downside tokens to return

Note: Cannot be called once the position has ended

ClaimProtocolFees

function claimProtocolFees(
        address[] calldata _tokenAddresses, 
        uint256[] calldata _amounts
    ) external

Description: Allows anyone to process protocol fees for a given token address

Inputs:

  • _tokenAddresses - List of the addresses of tokens to claim

  • _amounts - List of the number of tokens to claim

Note: Fees are sent to the protocolFeeRecipientAddress

ClaimPositionFees

function claimPositionFees(
        address[] calldata _tokenAddresses, 
        uint256[] calldata _tokenAmounts, 
        address _recipient
    ) external

Description: Allows user to claim position fees owed to them of multiple tokens (partial or full)

Inputs:

  • _tokenAddresses - List of the addresses of tokens to claim

  • _tokenAmounts - List of the number of tokens to claim

  • _recipient - The address where these claimed fees should be sent to

Last updated