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 / 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;
@yuyasugano
yuyasugano / hex-to-weth.json
Created November 7, 2022 11:04
pending-sumulation example
{
"status": "pending-simulation",
"monitorId": "Geth_1_F_PROD",
"monitorVersion": "0.117.1",
"pendingTimeStamp": "2022-11-07T10:47:51.244Z",
"pendingBlockNumber": 15917644,
"hash": "0x4d3ba81f78b1da44994b7d0a36a2b074cb502b01bc3890a34285131abbde17d2",
"from": "0x4065149108A615930114Bb511818fc0909AA9269",
"to": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
"value": "0",
@yuyasugano
yuyasugano / hardhat.config.ts
Created October 30, 2022 02:15
amm-arbitrageur hardhat.config.ts
import { task, HardhatUserConfig } from 'hardhat/config';
import '@typechain/hardhat';
import '@nomiclabs/hardhat-waffle';
import deployer from './.secret';
require("dotenv").config();
const BSC_ENDPOINT = process.env.BSC_ENDPOINT;
const config: HardhatUserConfig = {
@yuyasugano
yuyasugano / hardhat.config.js
Created August 6, 2022 12:58
bsc-arbitrageur
/**
* @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 April 3, 2022 07:49
New Flashswap code for BSC
// 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';
@yuyasugano
yuyasugano / authorizer.py
Created February 15, 2022 07:31
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 December 19, 2021 23:51
MLC-FlashLoanDemo Example
// 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 December 19, 2021 06:22
MLC-FlashloanDemo Example
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;