Skip to content

Instantly share code, notes, and snippets.

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';
@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;