Skip to content

Instantly share code, notes, and snippets.

@amazingandyyy
Created February 10, 2022 01:59
Show Gist options
  • Save amazingandyyy/58395de02e4f931d520a4cf3901d3cf3 to your computer and use it in GitHub Desktop.
Save amazingandyyy/58395de02e4f931d520a4cf3901d3cf3 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
// contract C {
// uint private data;
// uint public info;
// constructor() {
// info = 10;
// }
// function increment(uint a) private pure returns (uint result) {
// result = a + 1;
// }
// function dupdateData(uint a) public {
// data = a;
// }
// function getData() public view returns (uint) {
// return data;
// }
// function compute(uint a, uint b) internal pure returns (uint) {
// return a + b;
// }
// }
// contract D{
// C c = new C();
// function readInfo() public view returns (uint) {
// return c.info();
// }
// }
// contract E is C {
// uint private result;
// C private c;
// constructor() {
// c = new C();
// }
// function getComputedResult() public pure returns (uint) {
// return compute(23, 5);
// }
// function getResult() public view returns (uint) {
// return result;
// }
// function getInfo() public view returns (uint) {
// return c.info();
// }
// }
// 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
interface UniswapV2Factory {
function getPair(address tokenA, address tokenB) external view returns (address pair);
}
interface UniswapV2Pair {
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
}
contract Play {
address UniswapV2FactoryAddress = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
// address BNBAddress = 0xB8c77482e45F1F44dE1745F52C74426C631bDD52;
address UNIAddress = 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984;
address USDCAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address PairAddress; // 0xEBFb684dD2b01E698ca6c14F10e4f289934a54D6
function getPairAddress() internal {
PairAddress = UniswapV2Factory(UniswapV2FactoryAddress).getPair(USDCAddress,UNIAddress);
}
function findReserve() public view returns (uint112 reserve0, uint112 reserve1) {
(uint112 UNIAddress, uint112 USDCReserve,) = UniswapV2Pair(PairAddress).getReserves();
reserve0 = UNIAddress;
reserve1 = USDCReserve;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment