MoxieBondingCurveV3.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] |
updateDefaultGraduationMarketCap
Update the default graduation market cap.
function updateDefaultGraduationMarketCap(
uint256 _defaultGraduationMarketCap
) external onlyRole(UPDATE_GRADUATION_MARKET_CAP_ROLE)
Parameters
Name | Type | Description |
---|---|---|
_defaultGraduationMarketCap | uint256 | The new default graduation market cap. |
updateGraduationMarketCap
Update the graduation market cap for a specific reserve ratio.
function updateGraduationMarketCap(
uint32 _reserveRatio,
uint256 _newGraduationMarketCap
) external onlyRole(UPDATE_GRADUATION_MARKET_CAP_ROLE)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
_reserveRatio | uint32 | Initial supply of subject tokens at the time of bonding curve initialization. |
initializeSubjectBondingCurve
Initialize Bonding curve for subject, it's called by subject factory.
If the creator coin have reached a certain market cap to be eligible for graduation, the creator coin will automatically graduate to Uniswap V4.
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
.
For creator coins that have graduated, this function will buy creator coin directly from the Uniswap V4 pool.
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
.
For creator coins that have graduated, this function will buy creator coin directly from the Uniswap V4 pool.
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
.
For creator coins that have graduated, this function will sell creator coin directly to the Uniswap V4 pool.
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
.
For creator coins that have graduated, this function will sell creator coin directly to the Uniswap V4 pool.
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.
For creator coins that have graduated, this function will buy creator coin directly from the Uniswap V4 pool.
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.
For creator coins that have graduated, this function will buy creator coin directly from the Uniswap V4 pool.
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.
For creator coins that have graduated, this function will sell creator coin directly to the Uniswap V4 pool.
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.
For creator coins that have graduated, this function will sell creator coin directly to the Uniswap V4 pool.
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. |
subjectGraduated
Check if a subject has graduated.
function subjectGraduated(address _subject) public view returns (bool)
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
Return Value
Name | Type | Description |
---|---|---|
isGraduated | bool | true if the subject has graduated. Otherwise, false . |
graduationMarketCap
Get the graduation market cap for a specific reserve ratio.
function graduationMarketCap(
uint32 _reserveRatio
) public view returns (uint256)
Parameters
Name | Type | Description |
---|---|---|
_reserveRatio | uint32 | Initial supply of subject tokens at the time of bonding curve initialization. |
Return Value
Name | Type | Description |
---|---|---|
_graduationMarketCap | uint256 | The graduation market cap for the specific reserve ratio. |
distributeSwapFee
Distribute the swap fee to the protocol and subject.
function distributeSwapFee(address _subject) external
Parameters
Name | Type | Description |
---|---|---|
_subject | address | Address of subject. |
Events
UpdateFees
event UpdateFees(
uint256 _protocolBuyFeePct,
uint256 _protocolSellFeePct,
uint256 _subjectBuyFeePct,
uint256 _subjectSellFeePct,
uint256 _swapFeeRatioProtocolPct
);
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
);
DefaultGraduationMarketCapUpdated
event DefaultGraduationMarketCapUpdated(
uint256 _oldDefaultGraduationMarketCap,
uint256 _newDefaultGraduationMarketCap
);
GraduationMarketCapUpdated
event GraduationMarketCapUpdated(
uint32 indexed _reserveRatio,
uint256 _oldGraduationMarketCap,
uint256 _newGraduationMarketCap,
bool _isDefault
);
SubjectGraduated
event SubjectGraduated(
address indexed _subject,
PoolId _poolId,
uint256 _tokenId
);
Swap
event Swap(
address indexed _sender,
address indexed _subject,
bool _buySubject,
uint256 _amountIn,
uint256 _amountOut
);
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();
MoxieBondingCurve_SubjectAlreadyGraduated
error MoxieBondingCurve_SubjectAlreadyGraduated();
MoxieBondingCurve_SubjectReadyForGraduation
error MoxieBondingCurve_SubjectReadyForGraduation();
MoxieBondingCurve_SubjectNotReadyForGraduation
error MoxieBondingCurve_SubjectNotReadyForGraduation();
MoxieBondingCurve_SubjectNotGraduated
error MoxieBondingCurve_SubjectNotGraduated();