Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
yuyasugano / FlashExecution.sol
Created July 14, 2020 03:17
aave flash loan example by using OrFeed arb function to perform trianglular arbitrage.
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;
import "./aave/FlashLoanReceiverBase.sol";
import "./aave/ILendingPoolAddressesProvider.sol";
import "./aave/ILendingPool.sol";
import "./IKyberNetworkProxy.sol";
import "./IUniswapExchange.sol";
import "./IUniswapFactory.sol";
@yuyasugano
yuyasugano / fetchOHLCV_test.py
Last active October 2, 2025 12:23
ccxt library in Python to fetch OHLCV data test
#!/usr/bin/python
import ccxt
import calendar
from datetime import datetim
binance = ccxt.binance()
now = datetime.utcnow()
unixtime = calendar.timegm(now.utctimetuple())
since = (unixtime - 60*60) * 1000 # UTC timestamp in milliseconds
@yuyasugano
yuyasugano / get_node_id.sh
Created May 13, 2021 03:07
get your node ID in Avalanche
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "info.getNodeID",
"params":{},
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/info
{"jsonrpc":"2.0","result":{"nodeID":"NodeID-EggGmnQFaTffeRNG1Kzs9dXJzFGdxac3D"},"id":1}
@yuyasugano
yuyasugano / flashbots_goerli.js
Created May 27, 2021 01:18
flashbots sample
const ethers = require('ethers');
const { FlashbotsBundleProvider} = require('@flashbots/ethers-provider-bundle')
// Standard json rpc provider directly from ethers.js. For example you can use Infura, Alchemy, or your own node.
// This sample uses one of the default provider goerli
const provider = new ethers.getDefaultProvider("goerli");
// `authSigner` is an Ethereum private key that does NOT store funds and is NOT your bot's primary key.
// This is an identifying key for signing payloads to establish reputation and whitelisting
const authSigner = new ethers.Wallet(
@yuyasugano
yuyasugano / ema_backtesting.py
Created August 1, 2020 09:13
backtesting.py ema strategy
from backtesting import Strategy
from backtesting.lib import crossover
def EMA_Backtesting(values, n):
"""
Return exponential moving average of `values`, at
each step taking into account `n` previous values.
"""
close = pd.Series(values)
return talib.EMA(close, timeperiod=n)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC721, ERC721URIStorage, ERC721Burnable, Ownable {
constructor(address initialOwner)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract Marketplace is ReentrancyGuard, Ownable {
using Counters for Counters.Counter;
@yuyasugano
yuyasugano / Flashswap.sol
Created October 3, 2021 06:55
Modified Flashswap.sol for PancakeSwap & ApeSwap
// 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';
@yuyasugano
yuyasugano / flashswaps.sol
Created April 3, 2021 00:39
Flash Swaps arbitrage
function startArbitrage(
address token0,
address token1,
uint amount0,
uint amount1
) external {
address pairAddress = IUniswapV2Factory(pancakeFactory).getPair(token0, token1);
require(pairAddress != address(0), 'This pool does not exist');
IUniswapV2Pair(pairAddress).swap(
@yuyasugano
yuyasugano / Matplotlib Ichimoku
Created August 18, 2019 05:10
Matplotlib Ichimoku sample
def Ichimoku(df):
df1 = df.copy()
max_9 = df1.high.rolling(window=9).max()
min_9 = df1.high.rolling(window=9).min()
df1["tenkan"] = (max_9+min_9)/2
df1["base"] = (df1.high.rolling(window=26).max()+df1.high.rolling(window=26).min())/2
xdate = [x.date() for x in df1.index]
plt.figure(figsize=(15,5))
plt.grid()
plt.plot(xdate, df1.close, color="b", lw=1, linestyle="dotted", label="original")