Solidity call pancakeswap v3 contract exception

26 views Asked by At

any one can help to point out why below code have execution reverted exception? i deploy on BSC and call with 0x36696169C63e42cd08ce11f5deeBbCeBae652050 thank you in advance.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
import ‘@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol’;

contract BulkChecker {
function getETHPrice(address pool) public view returns (uint160) {
(uint160 sqrtPriceX96,) =IUniswapV3Pool(pool).slot0();
return sqrtPriceX96;
}
}

code run well and return sqrtPriceX96;

1

There are 1 answers

1
Zayd On

Hi so basically your contract is importing from @uniswap/v3-core, which is a protocol that primarily operates on the Ethereum network. Binance Smart Chain, despite being EVM-compatible, does not natively support Uniswap V3 pools. Instead, BSC has its own decentralized exchanges that’s first and second wrong interface import. Since you are working on BSC, you should use the interfaces provided by the DEX that operates on BSC which is PancakeSwap

Here is an example

// SPDX-License-Identifier: MIT pragma solidity ^0.8.25;

// Import PancakeSwap interfaces import "<appropriate_path>/IPancakeSwapPool.sol";