CRYPTO NEWS

how to get the reserves of all coin pairs at once on pancakeSwap

I am trying to query the pancakeSwap token pair contract for the reserves, and since I am trying to get it for 10000 tokens at a single time.

My current solution is to basically loop over the 10000 tokens and query each smart contract of that coin pair to get the reserves which happen to be very consuming in physical resources.

Is there a way to get all the reserves in a single smart contract query?

My smart contract is not working! Can you please help. At the end of the round it should distribute the money and set state back to inActive. It doesn

//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Fomo3D { enum State { INACTIVE, ACTIVE } State public currentState = State.INACTIVE; address payable public king; uint public start; uint public end; uint public hardEnd; uint public pot; uint public houseFee = 2; uint public initialKeyPrice; uint public totalKeys; address payable[] public keyHolders; mapping(address => uint) public keys;::Listen

//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Fomo3D { enum State { INACTIVE, ACTIVE } State public currentState = State.INACTIVE; address payable public king; uint public start; uint public end; uint public hardEnd; uint public pot; uint public houseFee = 2; uint public initialKeyPrice; uint public totalKeys; address payable[] public keyHolders; mapping(address => uint) public keys;

function kickStart()      external      inState(State.INACTIVE) {     currentState = State.ACTIVE;     _createRound(); }  function bet()      external      payable      inState(State.ACTIVE) {     if(block.timestamp > hardEnd) {         payable(msg.sender).transfer(msg.value);         _distribute();         _createRound();         currentState = State.INACTIVE;         return;     }          //Keys     uint keyCount = msg.value / getKeyPrice();     keys[msg.sender] += keyCount;     totalKeys += keyCount;     bool alreadyAdded = false;     for(uint i = 0; i < keyHolders.length; i++) {         if(keyHolders[i] == msg.sender) {             alreadyAdded = true;         }     }     if(alreadyAdded == false) {         keyHolders.push(payable(msg.sender));     }          //Other     pot += msg.value;     end = end + 30 > hardEnd ? hardEnd : end + 30; }  function getKeyPrice() view public returns(uint) {     uint periodCount = (block.timestamp - start) / 30;     return initialKeyPrice + periodCount * 0.01 ether; }  function _distribute() internal {     uint netPot = pot * (100 - houseFee) / 100;     uint lastIndex = keyHolders.length - 1;     king = keyHolders[lastIndex];     king.transfer((netPot * 50) / 100);      for(uint i = 0; i < keyHolders.length; i++) {         address payable keyHolder = keyHolders[i];         if(keyHolder != keyHolders[lastIndex]) {             (keyHolder).transfer(((netPot * 50) / 100) * (keys[keyHolder] / totalKeys));         }     } }  function getStamp() public view returns(uint){     return block.timestamp; }      function _createRound() internal  {     for(uint i = 0; i < keyHolders.length; i++) {         delete keys[keyHolders[i]];     }     delete keyHolders;     totalKeys = 0;     start = block.timestamp;     end = block.timestamp + 30;     hardEnd = block.timestamp + 30;     initialKeyPrice = 1 ether; }  modifier inState(State state) {     require(currentState == state, 'not possible in current state');     _; } 

}

how to get the reserves of all coin pairs at once on pancakeSwap

Shopping cart
There are no products in the cart!
Continue shopping
0