Skip to content

Instantly share code, notes, and snippets.

View kassandraoftroy's full-sized avatar
🏴
OIMOI TALAINA

κασσάνδρα.eth kassandraoftroy

🏴
OIMOI TALAINA
View GitHub Profile
Verifying my Blockstack ID is secured with the address 1Kc17BnwonodXeZwy6jfJxaYSURV44LreD https://explorer.blockstack.org/address/1Kc17BnwonodXeZwy6jfJxaYSURV44LreD

Keybase proof

I hereby claim:

  • I am superarius on github.
  • I am superarius (https://keybase.io/superarius) on keybase.
  • I have a public key ASD3josUqOa4_DsOIwGeLlwLdvMazaRtK16PbWEfc9XTDAo

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.0;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.0;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
@kassandraoftroy
kassandraoftroy / TickMath.sol
Created June 18, 2021 04:06
0.8 compatible TickMath
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
/// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
int24 internal constant MIN_TICK = -887272;
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
@kassandraoftroy
kassandraoftroy / gist:785e0ad88f62e741db12e0e615e416f5
Created June 18, 2021 04:47
0.8 compatibility, uniswap v3 oracle
function _checkSlippage(uint160 _swapThresholdPrice, bool zeroForOne)
private
view
{
uint32[] memory secondsAgo = new uint32[](2);
secondsAgo[0] = _observationSeconds;
secondsAgo[1] = 0;
(int56[] memory tickCumulatives, ) = pool.observe(secondsAgo);
@kassandraoftroy
kassandraoftroy / IGUniPool.sol
Created June 21, 2021 20:59
GUniPool Interface
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {
IUniswapV3Pool
} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
interface IGUniPool {
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")));
@kassandraoftroy
kassandraoftroy / getParams.ts
Created July 7, 2021 14:00
get executive rebalance params
import {ethers} from 'ethers';
const x60 = ethers.BigNumber.from('2').pow(ethers.BigNumber.from('60'));
const ALCHEMY_ID = 'YOUR_ALCHEMY_ID';
const op = async () => {
const guniPoolAddress = "0x288a17459b5d0ecc401f5ECdC166F447ea3Da13a";
const libAddress = "0xc2D8196DbcC92E8C5F372e58B8dbFDF2ac129057";
const provider = new ethers.providers.JsonRpcProvider(`https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`)
const gelatoUniV3Pool = new ethers.Contract(