Skip to main content

MoxieBondingCurve.sol

Bonding curve contract which enables subject onboarding, buy & sell of subject shares.

Functions

updateFees

Update fee only be called by role UPDATE_FEES_ROLE.

function updateFees(
FeeInput memory _feeInput
) external onlyRole(UPDATE_FEES_ROLE)

Parameters

NameTypeDescription
_feeInputFeeInputFeeinput struct.

updateFormula

Update formula to _formula. It can be done by UPDATE_FORMULA_ROLE.

function updateFormula(
address _formula
) external onlyRole(UPDATE_FORMULA_ROLE)

Parameters

NameTypeDescription
_formulaaddressThe address of the new BancorFormula [computation] contract

updateFeeBeneficiary

Update beneficiary to `_beneficiary. It can be done by UPDATE_BENEFICIARY_ROLE.

function updateFeeBeneficiary(
address _feeBeneficiary
) external onlyRole(UPDATE_BENEFICIARY_ROLE)

Parameters

NameTypeDescription
_feeBeneficiaryaddressThe address of the new beneficiary [to whom fees are to be sent]

initializeSubjectBondingCurve

Initialize Bonding curve for subject, it's called by subject factory.

function initializeSubjectBondingCurve(
address _subject,
uint32 _reserveRatio,
uint256 _initialSupply,
uint256 _reserveAmount
) external whenNotPaused returns (bool)

Parameters

NameTypeDescription
_subjectaddressAddress of subject.
_reserveRatiouint32Initial supply of subject tokens at the time of bonding curve initialization.
_initialSupplyuint256reserve ratio of subject for bonding curve.
_reserveAmountuint256Initial reserve amount.

Return Value

NameTypeDescription
isInitializedbooltrue if bonding curve is initialized. Otherwise, false.

buySharesFor

Buy shares of a subject on behalf of a beneficiary.

function buySharesFor(
address _subject,
uint256 _depositAmount,
address _onBehalfOf,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 shares_)

Parameters

NameTypeDescription
_subjectaddressAddress of subject.
_depositAmountuint256Amount of deposit to buy shares.
_onBehalfOfaddressAddress of beneficiary.
_minReturnAmountAfterFeeuint256Minimum number of shares that must be received.

Return Value

NameTypeDescription
shares_uint256Number of shares.

buyShares

Buy shares of a subject.

function buyShares(
address _subject,
uint256 _depositAmount,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 shares_)

Parameters

NameTypeDescription
_subjectaddressAddress of subject.
_depositAmountuint256Amount of deposit to buy shares.
_minReturnAmountAfterFeeuint256Minimum number of shares that must be received.

Return Value

NameTypeDescription
shares_uint256Number of shares.

sellSharesFor

Sell shares of a subject on behalf of a beneficiary.

function sellSharesFor(
address _subject,
uint256 _sellAmount,
address _onBehalfOf,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 returnAmount_)

Parameters

NameTypeDescription
_subjectaddressAddress of subject.
_sellAmountuint256Amount of subject shares to sell.
_onBehalfOfaddressAddress of buy token beneficiary.
_minReturnAmountAfterFeeuint256Minimum number of shares that must be received.

Return Value

NameTypeDescription
returnAmount_uint256Amount received in MOXIE from selling subject shares.

sellShares

Sell shares of a subject.

function sellShares(
address _subject,
uint256 _sellAmount,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 returnAmount_)

Parameters

NameTypeDescription
_subjectaddressAddress of subject.
_sellAmountuint256Amount of subject shares to sell.
_minReturnAmountAfterFeeuint256Minimum number of shares that must be received.

Return Value

NameTypeDescription
returnAmount_uint256Amount received in MOXIE from selling subject shares.

Events

UpdateFees

event UpdateFees(
uint256 _protocolBuyFeePct,
uint256 _protocolSellFeePct,
uint256 _subjectBuyFeePct,
uint256 _subjectSellFeePct
);

UpdateBeneficiary

event UpdateBeneficiary(address _beneficiary);

UpdateFormula

event UpdateFormula(address _formula);

BondingCurveInitialized

event BondingCurveInitialized(
address _subject,
address _subjectToken,
uint256 _initialSupply,
uint256 _reserve,
uint32 _reserveRatio
);

SubjectSharePurchased

event SubjectSharePurchased(
address _subject,
address _sellToken,
uint256 _sellAmount,
address _buyToken,
uint256 _buyAmount,
address _beneficiary
);

SubjectShareSold

event SubjectShareSold(
address \_subject,
address \_sellToken,
uint256 \_sellAmount,
address \_buyToken,
uint256 \_buyAmount,
address \_beneficiary
);

Errors

MoxieBondingCurve_InvalidToken

error MoxieBondingCurve_InvalidToken();

MoxieBondingCurve_InvalidVault

error MoxieBondingCurve_InvalidVault();

MoxieBondingCurve_InvalidBeneficiary

error MoxieBondingCurve_InvalidBeneficiary();

MoxieBondingCurve_InvalidFeePercentage

error MoxieBondingCurve_InvalidFeePercentage();

MoxieBondingCurve_InvalidFormula

error MoxieBondingCurve_InvalidFormula();

MoxieBondingCurve_InvalidTokenManager

error MoxieBondingCurve_InvalidTokenManager();

MoxieBondingCurve_InvalidOwner

error MoxieBondingCurve_InvalidOwner();

MoxieBondingCurve_InvalidSubjectFactory

error MoxieBondingCurve_InvalidSubjectFactory();

MoxieBondingCurve_OnlySubjectFactory

error MoxieBondingCurve_OnlySubjectFactory();

MoxieBondingCurve_InvalidReserveRation

error MoxieBondingCurve_InvalidReserveRation();

MoxieBondingCurve_SubjectAlreadyInitialized

error MoxieBondingCurve_SubjectAlreadyInitialized();

MoxieBondingCurve_SubjectNotInitialized

error MoxieBondingCurve_SubjectNotInitialized();

MoxieBondingCurve_InvalidSubjectSupply

error MoxieBondingCurve_InvalidSubjectSupply();

MoxieBondingCurve_InvalidSubject

error MoxieBondingCurve_InvalidSubject();

MoxieBondingCurve_InvalidDepositAmount

error MoxieBondingCurve_InvalidDepositAmount();

MoxieBondingCurve_InvalidSubjectToken

error MoxieBondingCurve_InvalidSubjectToken();

MoxieBondingCurve_SlippageExceedsLimit

error MoxieBondingCurve_SlippageExceedsLimit();

MoxieBondingCurve_InvalidSellAmount

error MoxieBondingCurve_InvalidSellAmount();