Skip to content

Instantly share code, notes, and snippets.

View sunnyRK's full-sized avatar
🎯
Focusing

Sunny Radadiya sunnyRK

🎯
Focusing
View GitHub Profile
@sunnyRK
sunnyRK / deploy_local.ts
Created December 8, 2021 11:16
Deploy_local.ts for perpetual
import { MockContract, smockit } from "@eth-optimism/smock"
import { ethers, waffle } from "hardhat"
import {
AccountBalance,
BaseToken,
// ChainlinkPriceFeed,
ClearingHouse,
ClearingHouseConfig,
Exchange,
InsuranceFund,
@sunnyRK
sunnyRK / AATranche.sol
Created September 29, 2021 11:21
IdleCDOContainer-Main
pragma solidity 0.8.7;
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
contract AATranche is ERC20Upgradeable {
function __AA__ERC20_init(string memory name_, string memory symbol_) internal {
__ERC20_init(name_, symbol_);
}
@sunnyRK
sunnyRK / IYearnVault.sol
Created September 17, 2021 06:55
Idle Tranche yearn yield-source
// SPDX-License-Identifier: Apache-2.0
/**
* @title: Idle Token interface
* @author: Idle Labs Inc., idle.finance
*/
pragma solidity 0.8.7;
import "./IERC20Detailed.sol";
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
/**
* a contract must implement this interface in order to support relayed transaction.
* It is better to inherit the BaseRelayRecipient as its implementation.
*/
@sunnyRK
sunnyRK / BiconomyMetaTx.ts
Created July 10, 2021 05:39
BiconomySwapper
const approveBiconomySwapperV3 = async () => {
let maxValue =
"115792089237316195423570985008687907853269984665640564039457584007913129639935";
let domainData
let tokenPermitOptions
let permitTx
let WETHTokenContractInstance = new web3.eth.Contract(
DAI_kovan_contract.abi,
'0xd0A1E359811322d97991E03f863a0C30C2cF029C' // WETH
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol";
interface ISafeEngine {
function transferInternalCoins(address src, address dst, uint256 rad) external;
}
contract LiquidationPool is ReentrancyGuard {
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "hardhat/console.sol";
interface ISafeEngine {
function transferInternalCoins(address src, address dst, uint256 rad) external;
function coinBalance(address src) external view returns(uint256);
function approveSAFEModification(address account) external;
const getFlashBotProvider = async () => {
const provider = new ethers.providers.JsonRpcProvider({ url: 'https://goerli.infura.io/v3/<<Key>>' })
const authSigner = new ethers.Wallet('private-key')
const wallet = Wallet.createRandom().connect(provider)
const targetBlockNumber = (await provider.getBlockNumber()) + 2
const flashbotsProvider = await FlashbotsBundleProvider.create(provider, authSigner, 'https://relay-goerli.epheph.com/')
console.log('flashbotsProvider-: ', flashbotsProvider);
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol";
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
/**
* @title: BackStop DAI wrapper
* @summary: Used for interacting with Backstop Protocol. Has
* a common interface with all other protocol wrappers.
* This contract holds assets only during a tx, after tx it should be empty
* @author: Idle Labs Inc., idle.finance
*/
pragma solidity 0.5.16;
pragma experimental ABIEncoderV2;