The _processProtocolFeeViaTransfer function attempts to transfer collateralProtocolFeeAmount to the collateralTreasury. However, since _handleCollateralTokensBeforeBuy transfers all the funds to the project treasury, no collateral remains in the funding manager, causing _buyOrder to revert.
|
( |
|
uint netDeposit, |
|
uint collateralProtocolFeeAmount, |
|
uint projectFeeAmount |
|
) = _calculateNetAndSplitFees( |
|
_depositAmount, collateralBuyFeePercentage, buyFee |
|
); |
|
|
|
// collateral Fee Amount is the combination of protocolFeeAmount plus the projectFeeAmount |
|
collateralFeeAmount = collateralProtocolFeeAmount + projectFeeAmount; |
|
|
|
// Calculate token amount based on upstream formula |
|
uint issuanceTokenAmount = _issueTokensFormulaWrapper(netDeposit); |
|
totalIssuanceTokenMinted = issuanceTokenAmount; |
|
|
|
// Get net amount, protocol and project fee amounts. Currently there is no issuance project |
|
// fee enabled |
|
uint issuanceProtocolFeeAmount; |
|
( |
|
issuanceTokenAmount, |
|
issuanceProtocolFeeAmount, /* projectFeeAmount */ |
|
) = _calculateNetAndSplitFees( |
|
issuanceTokenAmount, issuanceBuyFeePercentage, 0 |
|
); |
|
|
|
// Revert if the token amount is lower than the minimum amount the user expects |
|
if (issuanceTokenAmount < _minAmountOut) { |
|
revert Module__BondingCurveBase__InsufficientOutputAmount(); |
|
} |
|
|
|
// ------------------------------------------------------------ |
|
// Interactions |
|
|
|
// Handle collateral tokens before buy |
|
_handleCollateralTokensBeforeBuy(_msgSender(), _depositAmount); |
|
|
|
// Process protocol fee on incoming collateral tokens |
|
_processProtocolFeeViaTransfer( |
|
collateralTreasury, collateralToken, collateralProtocolFeeAmount |
|
); |
|
/// @inheritdoc BondingCurveBase_v1 |
|
/// @dev Implementation transfer collateral tokens to the project treasury. |
|
function _handleCollateralTokensBeforeBuy(address _provider, uint _amount) |
|
internal |
|
virtual |
|
override |
|
{ |
|
IERC20(token()).safeTransferFrom(_provider, _projectTreasury, _amount); |
|
} |
The _processProtocolFeeViaTransfer function attempts to transfer collateralProtocolFeeAmount to the collateralTreasury. However, since _handleCollateralTokensBeforeBuy transfers all the funds to the project treasury, no collateral remains in the funding manager, causing _buyOrder to revert.
contracts/src/modules/fundingManager/bondingCurve/abstracts/BondingCurveBase_v1.sol
Lines 258 to 297 in 33c7565
contracts/src/modules/fundingManager/oracle/FM_PC_Oracle_Redeeming_v1.sol
Lines 1049 to 1057 in 33c7565