pancake-v3-contracts's Issues
exactInputSingle not pulling amountIn requested
Is there any situation where the amountIn specified for an exactInputSingle trade through the router would pull in less than the specified amount in?
I am seeing a situation where in 1 trade I specify 2 USDC to be traded and the protocol only took in 1.4. And in the trade right before it took in the full 2 in order to swap for WBNB.
Why is this?
Thank you
This is the decoded trade params from a successful trade.
Here are my types
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
web3.eth.abi.decodeParameters(swapExactSingleHopTypes, message)
Result {
'0': '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
'1': '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
'2': '500',
'3': '1686366905',
'4': '2000000000000000000',
'5': '0',
'6': '4866947334823928207218049024',
__length__: 7
}
And the trade where it only put in 1.4 USDC
web3.eth.abi.decodeParameters(swapExactSingleHopTypes, message)
Result {
'0': '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
'1': '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
'2': '500',
'3': '1686367115',
'4': '2000000000000000000',
'5': '0',
'6': '4866947334823928207218049024',
__length__: 7
}
So in short the only difference is the deadline at index 3.
What is the address for Quoter.sol, cant seem to find it? Is it not being used?
Is there a list on the differences between pancake v3 and uniswap v3?
We have a protocol that works very well in uniswap v3.
But it is quite tough to make it also work in pancake swap v3.
Here are some our findings:
- The pool address derivation is different: pancake has a separate pool deployer.
- The
slot0
is incompatible with uniswap v3, this ruined my afternoon. 😭- We use the Uniswap V3 Pool interface to interact with a pancake pool, it reverts without any message. It turned out this reverts on the compiler generated validation code. As the returned data from
slot0
is abi encoded, the returned data from either uniswap v3 or pancake v3 pool has the same length (i.e, uint8 or uint32 are both encoded as a 32-byte word in the return data). However, When I use the Uniswap v3 pool interface, the compiler would check the returnedfeeProtocol
is less than unit8.Max, if it is greater than that, it would revert without any messages. It takes me a whole afternoon to find clues in the op codes.
- We use the Uniswap V3 Pool interface to interact with a pancake pool, it reverts without any message. It turned out this reverts on the compiler generated validation code. As the returned data from
I am wondering if there is a complete list on the differences between pancake v3 and uniswap v3?
This would make the developers who wants to integrate your protocol much easier.
Can you add scripts to deploy v2 contracts?
It seems the v3 contracts are depending on the v2 contracts. Could you add a script to deploy the v2 contracts?
V3-lm-pool
IPancakeV3LmPoolDeveloper.sol missing
Error invoking quoteExactInput
Have a problem invoking this code fragment in ethers/JS:
const routerABI = '[{"inputs":[{"internalType":"address","name":"_deployer","type":"address"},{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH9","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"pancakeV3SwapCallback","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"quoteExactInput","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint160[]","name":"sqrtPriceX96AfterList","type":"uint160[]"},{"internalType":"uint32[]","name":"initializedTicksCrossedList","type":"uint32[]"},{"internalType":"uint256","name":"gasEstimate","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct IQuoterV2.QuoteExactInputSingleParams","name":"params","type":"tuple"}],"name":"quoteExactInputSingle","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint160","name":"sqrtPriceX96After","type":"uint160"},{"internalType":"uint32","name":"initializedTicksCrossed","type":"uint32"},{"internalType":"uint256","name":"gasEstimate","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"quoteExactOutput","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint160[]","name":"sqrtPriceX96AfterList","type":"uint160[]"},{"internalType":"uint32[]","name":"initializedTicksCrossedList","type":"uint32[]"},{"internalType":"uint256","name":"gasEstimate","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"}],"internalType":"struct IQuoterV2.QuoteExactOutputSingleParams","name":"params","type":"tuple"}],"name":"quoteExactOutputSingle","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint160","name":"sqrtPriceX96After","type":"uint160"},{"internalType":"uint32","name":"initializedTicksCrossed","type":"uint32"},{"internalType":"uint256","name":"gasEstimate","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]';
const routerContract = new ethers.Contract(
"0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997",
routerABI,
provider);
const poolData = [
{
tokenA: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
tokenB: '0xdac17f958d2ee523a2206206994597c13d831ec7',
fee: 500
}
];
// Encode the pool data into bytes
const encodePool = (data) => {
const encoded = ethers.utils.defaultAbiCoder.encode(
[
'address tokenA',
'address tokenB',
'uint24 fee'
],
[
data.tokenA,
data.tokenB,
data.fee,
]
);
return encoded;
};
// Create an array to hold the encoded pool data
const pathData = poolData.map(encodePool);
// Concatenate the encoded pool data into a single bytes string
const pathBytes = ethers.utils.hexConcat(pathData);
try {
[amountOut,,,] = await routerContract.callStatic.quoteExactInput(pathBytes, tradeAmount.toString());
console.log("\amountOut:", amountOut);
} catch (error) {
console.log("\nError invoking quoteExactInput:", error);
amountOut = 0;
}
Keeps spitting out this same error every time I attempt to invoke quoteExactInput contract method:
code: 'CALL_EXCEPTION',
method: 'quoteExactInput(bytes,uint256)',
data: '0x',
errorArgs: null,
errorName: null,
errorSignature: null,
address: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997',
args: [
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000001f4',
'100000000000000000000'
],
transaction: {
data: '0xcdca175300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000001f4',
to: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997'
}
I´ve tried consulting with chatGPT/other web communities and have attempted other approaches to no avail.
FYI, this quoteExactInput method relates to V2Quoter.sol smart contract in PancakeSwap v3
Appreciate your help as been bugging me for a few days now.
thanks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.