Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
yuyasugano / getProfit.sol
Created Nov 14, 2022
getProfit modification
View getProfit.sol
/// @notice Calculate how much profit we can by arbitraging between two pools
function getProfit(address pool0, address pool1, address adjustedpair, address adjustedtoken, uint256 adjustment0, uint256 adjustment1) external view returns (uint256 profit, address baseToken) {
(bool baseTokenSmaller, , ) = isbaseTokenSmaller(pool0, pool1);
baseToken = baseTokenSmaller ? IUniswapV2Pair(pool0).token0() : IUniswapV2Pair(pool0).token1();
Adjustments memory adj;
adj.adjustmentPool = adjustedpair;
adj.adjustmentToken = adjustedtoken;
adj.adjustment0 = adjustment0;
adj.adjustment1 = adjustment1;
@yuyasugano
yuyasugano / hex-to-weth.json
Created Nov 7, 2022
pending-sumulation example
View hex-to-weth.json
{
"status": "pending-simulation",
"monitorId": "Geth_1_F_PROD",
"monitorVersion": "0.117.1",
"pendingTimeStamp": "2022-11-07T10:47:51.244Z",
"pendingBlockNumber": 15917644,
"hash": "0x4d3ba81f78b1da44994b7d0a36a2b074cb502b01bc3890a34285131abbde17d2",
"from": "0x4065149108A615930114Bb511818fc0909AA9269",
"to": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
"value": "0",
@yuyasugano
yuyasugano / hardhat.config.ts
Created Oct 30, 2022
amm-arbitrageur hardhat.config.ts
View hardhat.config.ts
import { task, HardhatUserConfig } from 'hardhat/config';
import '@typechain/hardhat';
import '@nomiclabs/hardhat-waffle';
import deployer from './.secret';
require("dotenv").config();
const BSC_ENDPOINT = process.env.BSC_ENDPOINT;
const config: HardhatUserConfig = {
View hardhat.config.js
/**
* @type import('hardhat/config').HardhatUserConfig
*/
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-etherscan");
require("dotenv").config();
const mainnetEndpoint = process.env.MAINNET_ENDPOINT;
@yuyasugano
yuyasugano / Flashswap.sol
Created Apr 3, 2022
New Flashswap code for BSC
View Flashswap.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.6 <0.8.0;
import './UniswapV2Library.sol';
import './interfaces/IERC20.sol';
import './interfaces/IUniswapV2Pair.sol';
import './interfaces/IUniswapV2Factory.sol';
import './interfaces/IUniswapV2Router02.sol';
View authorizer.py
def lambda_handler(event, context):
token = event['authorizationToken']
effect = 'Deny'
if token == 'cs':
effect = 'Allow'
return {
'principalId': '*',
'policyDocument': {
'Version': '2012-10-17',
@yuyasugano
yuyasugano / flashloan.js
Created Dec 19, 2021
MLC-FlashLoanDemo Example
View flashloan.js
// test a flashloan in Multipler V1
require('dotenv').config();
const Web3 = require('web3');
const BigNumber = require('bignumber.js');
const abis = require('./abis');
const instance = require('./build/contracts/Flashloan.json');
const web3 = new Web3(
new Web3.providers.HttpProvider(process.env.BSC_HTTPS)
);
@yuyasugano
yuyasugano / Flashloan.sol
Created Dec 19, 2021
MLC-FlashloanDemo Example
View Flashloan.sol
pragma solidity ^0.5.0;
import "./base/FlashLoanReceiverBase.sol";
import "./interfaces/ILendingPoolAddressesProvider.sol";
import "./interfaces/ILendingPool.sol";
contract Flashloan is FlashLoanReceiverBase {
address public receiver = address(this);
address public constant BNB_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
@yuyasugano
yuyasugano / metrics.py
Created Oct 28, 2021
CoinMetrics Metrics
View metrics.py
import json
import requests
headers = {'Content-Type': 'application/json'}
url = "https://community-api.coinmetrics.io/v2/metrics"
m = requests.get(url, headers=headers)
metrics = json.loads(m.text)['metrics']
print("Metrics: {}".format(len(metrics)))
Metrics: 145
@yuyasugano
yuyasugano / Flashswap.sol
Created Oct 3, 2021
Modified Flashswap.sol for PancakeSwap & ApeSwap
View Flashswap.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.6 <0.8.0;
import './utils/SafeMath.sol';
import './UniswapV2Library.sol';
import './interfaces/IERC20.sol';
import './interfaces/IUniswapV2Pair.sol';
import './interfaces/IUniswapV2Factory.sol';
import './interfaces/IUniswapV2Router02.sol';