IBondingCurveBase_v1.sol

Git Source

Functions

buyFor

Buy tokens on behalf of a specified receiver address.

Redirects to the internal function _buyOrder by passing the receiver address and deposit amount.

function buyFor(address _receiver, uint _depositAmount, uint _minAmountOut)
    external;

Parameters

Name
Type
Description

_receiver

address

The address that will receive the bought tokens.

_depositAmount

uint256

The amount of collateral token deposited.

_minAmountOut

uint256

The minimum acceptable amount the user expects to receive from the transaction.

buy

Buy tokens for the sender's address.

Redirects to the internal function _buyOrder by passing the sender's address and deposit amount.

function buy(uint _depositAmount, uint _minAmountOut) external;

Parameters

Name
Type
Description

_depositAmount

uint256

The amount of collateral token depoisited.

_minAmountOut

uint256

The minimum acceptable amount the user expects to receive from the transaction.

openBuy

Opens the buying functionality for the token.

Only callable by the {Orchestrator_v1} admin. Reverts if buying is already open.

function openBuy() external;

closeBuy

Closes the buying functionality for the token.

Only callable by the {Orchestrator_v1} admin. Reverts if buying is already closed.

function closeBuy() external;

setBuyFee

Sets the fee percentage for buying tokens, payed in collateral.

Only callable by the {Orchestrator_v1} admin. The fee cannot exceed 10000 basis points. Reverts if an invalid fee is provided.

function setBuyFee(uint _fee) external;

Parameters

Name
Type
Description

_fee

uint256

The fee in basis points.

getStaticPriceForBuying

Calculates and returns the static price for buying the issuance token.

function getStaticPriceForBuying() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

uint The static price for buying the issuance token.

calculatePurchaseReturn

Calculates the amount of tokens to be minted based on a given deposit amount.

This function takes into account any applicable buy fees before computing the token amount to be minted. Revert when _depositAmount is zero.

function calculatePurchaseReturn(uint _depositAmount)
    external
    returns (uint mintAmount);

Parameters

Name
Type
Description

_depositAmount

uint256

The amount of tokens deposited by the user.

Returns

Name
Type
Description

mintAmount

uint256

The amount of new tokens that will be minted as a result of the deposit.

withdrawProjectCollateralFee

Withdraw project collateral fee to the receiver address.

function withdrawProjectCollateralFee(address _receiver, uint _amount)
    external;

Parameters

Name
Type
Description

_receiver

address

The address that will receive the fee.

_amount

uint256

The amount of fee to withdraw.

projectCollateralFeeCollected

Returns the amount of fee in collateral token collected by the project.

function projectCollateralFeeCollected() external view returns (uint);

getIssuanceToken

Returns the address of the issuance token.

function getIssuanceToken() external view returns (address);

Events

BuyingEnabled

Event emitted when buying is opened.

event BuyingEnabled();

BuyingDisabled

Event emitted when buying is closed.

event BuyingDisabled();

BuyFeeUpdated

Event emitted when buy fee is updated.

event BuyFeeUpdated(uint newBuyFee, uint oldBuyFee);

IssuanceTokenSet

Event emitted when the issuance token is updated.

event IssuanceTokenSet(address indexed issuanceToken, uint8 decimals);

ProjectCollateralFeeWithdrawn

Event emitted when project collateral fee is withdrawn.

event ProjectCollateralFeeWithdrawn(address receiver, uint amount);

ProjectCollateralFeeAdded

Event emitted when project collateral fee is added.

event ProjectCollateralFeeAdded(uint amount);

TokensBought

Event emitted when tokens have been succesfully issued.

event TokensBought(
    address indexed receiver,
    uint depositAmount,
    uint receivedAmount,
    address buyer
);

Parameters

Name
Type
Description

receiver

address

The address that will receive the issued tokens.

depositAmount

uint256

The amount of collateral token deposited.

receivedAmount

uint256

The amount of issued token received.

buyer

address

The address that initiated the buy order.

TokenDecimalsUpdated

Event emitted when the decimals of the issuance token are updated.

event TokenDecimalsUpdated(uint8 oldDecimals, uint8 newDecimals);

Parameters

Name
Type
Description

oldDecimals

uint8

The old decimals of the issuance token.

newDecimals

uint8

The new decimals of the issuance token.

ProtocolFeeMinted

Event emitted when protocol fee has been minted to the treasury.

event ProtocolFeeMinted(
    address indexed token, address indexed treasury, uint feeAmount
);

Parameters

Name
Type
Description

token

address

The token minted as protocol fee.

treasury

address

The protocol treasury address receiving the token fee amount.

feeAmount

uint256

The fee amount minted to the treasury.

Errors

Module__BondingCurveBase__InvalidFeePercentage

Percentage amount is bigger than 100%, i.e. 10_000.

error Module__BondingCurveBase__InvalidFeePercentage();

Module__BondingCurveBase__InvalidDepositAmount

Deposit amount has to be larger than zero.

error Module__BondingCurveBase__InvalidDepositAmount();

Module__BondingCurveBase__BuyingFunctionaltiesClosed

Buying functionalities are set to closed.

error Module__BondingCurveBase__BuyingFunctionaltiesClosed();

Module__BondingCurveBase__InvalidRecipient

Receiver address can not be zero address or. Bonding Curve Funding Manager itself.

error Module__BondingCurveBase__InvalidRecipient();

Module__BondingCurveBase__InsufficientOutputAmount

Actual buy amount is lower than the minimum acceptable amount.

error Module__BondingCurveBase__InsufficientOutputAmount();

Module__BondingCurveBase__FeeAmountToHigh

The combination of protocol fee and workflow fee cant be higher than 100%.

error Module__BondingCurveBase__FeeAmountToHigh();

Module__BondingCurveBase__InvalidWithdrawAmount

Withdrawl amount is bigger than project fee collected.

error Module__BondingCurveBase__InvalidWithdrawAmount();

Module__BondingCurveBase__TradeAmountTooLow

Buy amount in relation to fee percentage to small, results in round down fee amount to zero.

error Module__BondingCurveBase__TradeAmountTooLow();

Module__BondingCurveBase__InvalidMinAmountOut

The minimum amount out cannot be zero.

error Module__BondingCurveBase__InvalidMinAmountOut();

Structs

IssuanceToken

Struct used to store information about the issuance token.

struct IssuanceToken {
    string name;
    string symbol;
    uint8 decimals;
    uint maxSupply;
}

Properties

Name
Type
Description

name

string

The name of the issuance token.

symbol

string

The symbol of the issuance token.

decimals

uint8

The decimals used within the issuance token.

maxSupply

uint256

The maximum supply of the issuance token.

Last updated