You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function_createExchange(PoolExchangecalldata_exchange)internalreturns(bytes32exchangeId){PoolExchangememoryexchange=_exchange;validateExchange(exchange);// slither-disable-next-line encode-packed-collisionexchangeId=keccak256(abi.encodePacked(IERC20(exchange.reserveAsset).symbol(),IERC20(exchange.tokenAddress).symbol()));require(exchanges[exchangeId].reserveAsset==address(0),"Exchange already exists");uint256reserveAssetDecimals=IERC20(exchange.reserveAsset).decimals();uint256tokenDecimals=IERC20(exchange.tokenAddress).decimals();require(reserveAssetDecimals<=18,"Reserve asset decimals must be <= 18");require(tokenDecimals<=18,"Token decimals must be <= 18");tokenPrecisionMultipliers[exchange.reserveAsset]=10**(18-uint256(reserveAssetDecimals));tokenPrecisionMultipliers[exchange.tokenAddress]=10**(18-uint256(tokenDecimals));exchanges[exchangeId]=exchange;exchangeIds.push(exchangeId);emitExchangeCreated(exchangeId,exchange.reserveAsset,exchange.tokenAddress);}
functionaddExchangeProvider(addressexchangeProvider,addressreserve)publicoverride(IBroker,IBrokerAdmin)onlyOwnerreturns(uint256index){require(!isExchangeProvider[exchangeProvider],"ExchangeProvider already exists in the list");require(exchangeProvider!=address(0),"ExchangeProvider address can't be 0");require(reserve!=address(0),"Reserve address can't be 0");exchangeProviders.push(exchangeProvider);isExchangeProvider[exchangeProvider]=true;exchangeReserve[exchangeProvider]=reserve;emitExchangeProviderAdded(exchangeProvider);emitReserveSet(exchangeProvider,reserve);index=exchangeProviders.length-1;}
From the code, it can be seen that there is no transfer of reserve tokens during the creation of the Exchange or its addition to the Broker, resulting in the reserve token balance in the reserve contract being zero. Additionally, the specified reserve token parameter _exchange.reserveBalance in the creation process does not actually transfer this amount of tokens to the reserve contract.
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
In the early stages of the Exchange, users can only purchase GoodDollar and cannot sell it.
PoC
No response
Mitigation
Transfer the amount of reserve tokens specified by _exchange.reserveBalance to the reserve contract.
The text was updated successfully, but these errors were encountered:
sherlock-admin3
changed the title
Silly Mulberry Chinchilla - The createExchange() process lacks the step of transferring reserve tokens to the reserve contract.
ZeroTrust - The createExchange() process lacks the step of transferring reserve tokens to the reserve contract.
Nov 5, 2024
ZeroTrust
Medium
The createExchange() process lacks the step of transferring reserve tokens to the reserve contract.
Summary
The createExchange() process lacks the step of transferring reserve tokens to the reserve contract.
Root Cause
https://github.com/sherlock-audit/2024-10-mento-update/blob/098b17fb32d294145a7f000d96917d13db8756cc/mento-core/contracts/goodDollar/BancorExchangeProvider.sol#L227
https://github.com/sherlock-audit/2024-10-mento-update/blob/098b17fb32d294145a7f000d96917d13db8756cc/mento-core/contracts/swap/Broker.sol#L84
From the code, it can be seen that there is no transfer of reserve tokens during the creation of the Exchange or its addition to the Broker, resulting in the reserve token balance in the reserve contract being zero. Additionally, the specified reserve token parameter _exchange.reserveBalance in the creation process does not actually transfer this amount of tokens to the reserve contract.
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
In the early stages of the Exchange, users can only purchase GoodDollar and cannot sell it.
PoC
No response
Mitigation
Transfer the amount of reserve tokens specified by _exchange.reserveBalance to the reserve contract.
The text was updated successfully, but these errors were encountered: