Skip to content

Instantly share code, notes, and snippets.

@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';
@yuyasugano
yuyasugano / .env.template
Created Oct 3, 2021
.env.template for PancakeSwap
View .env.template
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 Aug 9, 2021
Sanmonella contract _transfer function
View salmonella.sol
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 Jul 28, 2021
techflare prod smart contract example
View TechFlareConsumerProd.sol
// 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 Jul 27, 2021
techflare staging smart contract example
View TechFlareConsumer.sol
// 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 Jul 27, 2021
techflare external adapter example 2
View techflare_query_btc_h_filter.sh
$ 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 Jul 27, 2021
techflare external adapter example
View techflare_query_btch.sh
$ 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": {