Skip to content

Instantly share code, notes, and snippets.

// 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 / 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)
@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 / 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 / fetchOHLCV_test.py
Last active February 2, 2023 04:57
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 / 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")
@yuyasugano
yuyasugano / lambda_function.py
Created October 14, 2020 10:55
image tweet with S3 in Lambda
import os
import sys
import uuid
import boto3
import tweepy
from urllib.parse import unquote_plus
# Twitter authentication variables
consumer_key = os.environ.get('TWITTER_CONSUMER_KEY', 'ap-northeast-1')
consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET', 'ap-northeast-1')
@yuyasugano
yuyasugano / getProfit.sol
Created November 14, 2022 04:33
getProfit modification
/// @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;