Token in pancakeswap trade status

which api can get the token trade status in pancakeswap . for example 。some token in pancakeswap status is price impact too high

I don’t know of an api to return that status. Maybe you can get that status by making a query on chain?

let me have a try tks

1 Like

@fansdm if panckae swap works like uniswap they handle the state of transactions with redux and local storage via the front end. in uniswap every time you make a transaction as soon as you accept the wallet popup the tx gets appended to this global redux object state and you can see it in the applications local storage. the way that the tx updates is that they use the state of the transactions tx hash. which gets returned as soon as a user initiates a trasnasction. using the hash you can call a function in ethers i think its library.getTransaction(txHash), to see if it has been confirmed yet based on if the return details of this call have a defined block number

whenever the tx is first minted the blockNumber for the tx is undefined because it hasnt been confirmed. so with uniswap they use a function to get the tx details from the tx hash thats returned when the tx is first executed, then they listen for when this tx asociated with the tx hash has a defined blocknumber, when this happens they update the redux local storage state.

if you clone uniswap v3. look at the Transaction.tsx in the accountDetails component and the useAllTransactions Hook in hooks.

you could use the same conxept yoursswlf if your able to somehow get the txHash of your trade immediately when its executed.

if your using ethers and web3 react this function here will get you the tx details provided the hash

 library.getTransaction(currentHash).then((result) => {
        if(result.blockNumber) {
              //do something