MoxieBondingCurveV2.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
Name | Type | Description |
---|---|---|
_feeInput | FeeInput | Feeinput struct. |
updateFormula
Update formula to _formula
. It can be done by UPDATE_FORMULA_ROLE.
function updateFormula(
address _formula
) external onlyRole(UPDATE_FORMULA_ROLE)
Parameters
Name | Type | Description |
---|---|---|
_formula | address | The 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
Name | Type | Description |
---|---|---|
_feeBeneficiary | address | The 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,
address _platformReferrer
) external whenNotPaused returns (bool)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_reserveRatio | uint32 | Initial supply of subject tokens at the time of bonding curve initialization. |
_initialSupply | uint256 | reserve ratio of subject for bonding curve. |
_reserveAmount | uint256 | Initial reserve amount. |
_platformReferrer | address | The referrer address that will be rewarded for onboarding a new valid subject to the Moxie protocol. |
Return Value
Name | Type | Description |
---|---|---|
isInitialized | bool | true if bonding curve is initialized. Otherwise, false . |
buySharesForV2
Buy shares of subject on behalf of a third party addresss _onBehalfOf
and reward the referral fees to the _orderReferrer
.
function buySharesForV2(
address _subject,
uint256 _depositAmount,
address _onBehalfOf,
uint256 _minReturnAmountAfterFee,
address _orderReferrer
) external whenNotPaused whenNotTradingPaused(_subject) returns (uint256 shares_) {
shares_ = _buySharesInternal(_subject, _depositAmount, _onBehalfOf, _minReturnAmountAfterFee, _orderReferrer);
}
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_depositAmount | uint256 | Amount of deposit to buy shares. |
_onBehalfOf | address | Address of beneficiary. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
_orderReferrer | address | Address of order referrer. |
Return Value
Name | Type | Description |
---|---|---|
shares_ | uint256 | Number of shares. |
buySharesV2
Buy shares of subject for msg.sender
and reward the referral fees to the _orderReferrer
.
function buySharesV2(
address _subject,
uint256 _depositAmount,
uint256 _minReturnAmountAfterFee,
address _orderReferrer
) external whenNotPaused whenNotTradingPaused(_subject) returns (uint256 shares_) {
shares_ = _buySharesInternal(_subject, _depositAmount, msg.sender, _minReturnAmountAfterFee, _orderReferrer);
}
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_depositAmount | uint256 | Amount of deposit to buy shares. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
_orderReferrer | address | Address of order referrer. |
Return Value
Name | Type | Description |
---|---|---|
shares_ | uint256 | Number of shares. |
sellSharesForV2
Sell shares of a subject on behalf of a third party address _onBehalfOf
and reward the referral fees to the _orderReferrer
.
function sellSharesForV2(
address _subject,
uint256 _sellAmount,
address _onBehalfOf,
uint256 _minReturnAmountAfterFee,
address _orderReferrer
) external whenNotPaused whenNotTradingPaused(_subject) returns (uint256 returnAmount_) {
returnAmount_ =
_sellSharesInternal(_subject, _sellAmount, _onBehalfOf, _minReturnAmountAfterFee, _orderReferrer);
}
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_sellAmount | uint256 | Amount of subject shares to sell. |
_onBehalfOf | address | Address of buy token beneficiary. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
_orderReferrer | address | Address of order referrer. |
Return Value
Name | Type | Description |
---|---|---|
returnAmount_ | uint256 | Amount received in MOXIE from selling subject shares. |
sellSharesV2
Sell shares of a subject and reward the referral fees to the _orderReferrer
.
function sellSharesV2(
address _subject,
uint256 _sellAmount,
uint256 _minReturnAmountAfterFee,
address _orderReferrer
) external whenNotPaused whenNotTradingPaused(_subject) returns (uint256 returnAmount_) {
returnAmount_ = _sellSharesInternal(_subject, _sellAmount, msg.sender, _minReturnAmountAfterFee, _orderReferrer);
}
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_sellAmount | uint256 | Amount of subject shares to sell. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
_orderReferrer | address | Address of order referrer. |
Return Value
Name | Type | Description |
---|---|---|
returnAmount_ | uint256 | Amount received in MOXIE from selling subject shares. |
buySharesFor
Buy shares of a subject on behalf of a beneficiary.
If you're looking to earn referral rewards from every buy transaction, use the buySharesForV2
function instead.
function buySharesFor(
address _subject,
uint256 _depositAmount,
address _onBehalfOf,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 shares_)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_depositAmount | uint256 | Amount of deposit to buy shares. |
_onBehalfOf | address | Address of beneficiary. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
Return Value
Name | Type | Description |
---|---|---|
shares_ | uint256 | Number of shares. |
buyShares
Buy shares of a subject.
If you're looking to earn referral rewards from every buy transaction, use the buySharesV2
function instead.
function buyShares(
address _subject,
uint256 _depositAmount,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 shares_)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_depositAmount | uint256 | Amount of deposit to buy shares. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
Return Value
Name | Type | Description |
---|---|---|
shares_ | uint256 | Number of shares. |
sellSharesFor
Sell shares of a subject on behalf of a beneficiary.
If you're looking to earn referral rewards from every sell transaction, use the sellSharesForV2
function instead.
function sellSharesFor(
address _subject,
uint256 _sellAmount,
address _onBehalfOf,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 returnAmount_)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_sellAmount | uint256 | Amount of subject shares to sell. |
_onBehalfOf | address | Address of buy token beneficiary. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
Return Value
Name | Type | Description |
---|---|---|
returnAmount_ | uint256 | Amount received in MOXIE from selling subject shares. |
sellShares
Sell shares of a subject.
If you're looking to earn referral rewards from every sell transaction, use the sellSharesForV2
function instead.
function sellShares(
address _subject,
uint256 _sellAmount,
uint256 _minReturnAmountAfterFee
) external whenNotPaused returns (uint256 returnAmount_)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_sellAmount | uint256 | Amount of subject shares to sell. |
_minReturnAmountAfterFee | uint256 | Minimum number of shares that must be received. |
Return Value
Name | Type | Description |
---|---|---|
returnAmount_ | uint256 | Amount 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
);
UpdateReferralFees
event UpdateReferralFees(
uint256 _platformReferrerBuyFeePct,
uint256 _platformReferrerSellFeePct,
uint256 _orderReferrerBuyFeePct,
uint256 _orderReferrerSellFeePct
);
SubjectReserveRatioUpdated
event SubjectReserveRatioUpdated(
address _subject,
uint32 _oldReserveRatio,
uint32 _newReserveRatio
);
TradingPaused
event TradingPaused(
address _subject,
bool _isPaused
);
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();
MoxieBondingCurve_InvalidAmount
error MoxieBondingCurve_InvalidAmount();
MoxieBondingCurve_InvalidProtocolRewardAddress
error MoxieBondingCurve_InvalidProtocolRewardAddress();
MoxieBondingCurve_InvalidSubjectRewardAddress
error MoxieBondingCurve_SubjectNotPaused();
MoxieBondingCurve_TradingPaused
error MoxieBondingCurve_TradingPaused();