Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
yuyasugano / metrics.py
Created October 28, 2021 04:12
CoinMetrics Metrics
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 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 / .env.template
Created October 3, 2021 01:22
.env.template for PancakeSwap
TEST_AMOUNT=0.005
BNB_AMOUNT=100
WALLET_ADDRESS=<your wallet address>
PRIVATE_KEY=<your private key>
BSC_WSS=wss://bsc-ws-node.nariox.org:443
BSC_HTTPS=https://bsc-dataseed.binance.org/
MORALIS_BSC=https://speedy-nodes-nyc.moralis.io/<your account>/bsc/mainnet
@yuyasugano
yuyasugano / salmonella.sol
Created August 9, 2021 02:36
Sanmonella contract _transfer function
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
// sender's balance needs to equal to or more han the amount
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
// allow normal users to increase received amount
if (sender == ownerA || sender == ownerB) {
@yuyasugano
yuyasugano / TechFlareConsumerProd.sol
Last active July 28, 2021 07:21
techflare prod smart contract example
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
contract TechFlareConsumerProd is ChainlinkClient {
uint256 public value;
address private oracle;
@yuyasugano
yuyasugano / TechFlareConsumer.sol
Created July 27, 2021 13:43
techflare staging smart contract example
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
contract TechFlareConsumer is ChainlinkClient {
uint256 public value;
address private oracle;
bytes32 private jobId;
@yuyasugano
yuyasugano / techflare_query_btc_h_filter.sh
Created July 27, 2021 12:54
techflare external adapter example 2
$ curl -X GET -H "Content-Type: application/json" "https://3t9jjasu58.execute-api.ap-northeast-1.amazonaws.com/Stage/chainlink?n=btc&p=h" \
| jq '. | { name: .name, value: .sma."5"}'
{
"name": "bitcoin",
"value": 37379.58199999999
}
@yuyasugano
yuyasugano / techflare_query_btch.sh
Created July 27, 2021 12:37
techflare external adapter example
$ curl -X GET -H "Content-Type: application/json" "https://3t9jjasu58.execute-api.ap-northeast-1.amazonaws.com/Stage/chainlink?n=btc&p=h" | jq .
{
"std": {
"9": 987.8966188715287,
"3": 598.4951346781628,
"5": 636.6109131330054,
"30": 2345.7798994815985,
"20": 2062.520469866928
},
"momentum": {
@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 / get_blockchains.sh
Last active May 13, 2021 12:50
get a list of blockchains in P-Chain
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"platform.getBlockchains",
"params" :{}
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/P | jq '.result.blockchains[-1]'