Skip to content

Instantly share code, notes, and snippets.

@kassandraoftroy
Created June 24, 2021 19:54
Show Gist options
  • Save kassandraoftroy/633a13f8ae747404be4da9a68feb5e32 to your computer and use it in GitHub Desktop.
Save kassandraoftroy/633a13f8ae747404be4da9a68feb5e32 to your computer and use it in GitHub Desktop.
swapThreshold
import { ethers } from "ethers";
const op = async () => {
const pool = new ethers.Contract(
ADDRESS,
["function slot0() external returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked"],
PROVIDER
);
const { sqrtPriceX96 } = await pool.slot0();
const threshold = sqrtPriceX96.add(sqrtPriceX96.div(ethers.BigNumber.from("2")));
console.log(threshold.toString());
}
(async () => {
await op();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment