Received confusing error `query returned more than 10000 results`

The purpose of the function below is to track USDT that is transferred to and from Yearn and Fulcrum.

When I call search_liquidity(_toBlock), I get an error that says Returned error: query returned more than 10000 results . This error is confusing to me because I even get this error when I query USDT transactions between Yearn and Fulcrum from a single block.

Are there situations where Infura returns this error even though the query did not return more than 10000 results? Is this a problem with the Fulcrum address I selected?

let search_liquidity = async(_toBlock) => {
        try {
            withdraw_events = await USDT_contract_interface.getPastEvents('Transfer', 
                {
                    filter: {
                        src: '0xE6354ed5bC4b393a5Aad09f21c46E101e692d447', // Yearn sender and receiver address for USDT
                        dst: '0xf013406a0b1d544238083df0b93ad0d2cbe0f65f' // what I suspect to be the sender and receiver address for USDT for Fulcrum
                    }, 
                    fromBlock: yearn_liquidity_transfer_addresses.starter_block, 
                    toBlock: _toBlock 
                }
            )

            deposit_events = await USDT_contract_interface.getPastEvents('Transfer', 
                {
                    filter: {
                        src: '0xf013406a0b1d544238083df0b93ad0d2cbe0f65f', 
                        dst: '0xE6354ed5bC4b393a5Aad09f21c46E101e692d447'
                    }, 
                    fromBlock: yearn_liquidity_transfer_addresses.starter_block, 
                    toBlock: _toBlock 
                }
            )

            events.push(...withdraw_events,...deposit_events)
        }
        catch(error) {
            console.log(error)
        }
    } 

The sounds like the value of fromBlock and toBlock aren’t the same block. If you really want to query a single block, it might be better to use blockHash instead if you have it available, otherwise you should ensure that fromBlock and toBlock are the same value.

1 Like

Thanks for the response Ryan. I figured it out!

So the indexed event parameters for the Transfer Event for USDT is actually from and to instead of src and dst. When I switched to the correct parameters, I started receiving a normal quantity of events. When I failed to use the filters correctly, it just sent me every Transfer event in the contract.

I thought that all ERC20 tokens would have the same indexed parameters for this, but this is not the case. DAI uses src and dst.