Skip to content

Instantly share code, notes, and snippets.

View DanielZlotin's full-sized avatar

DanielZlotin DanielZlotin

View GitHub Profile
0x6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b506101076102
@DanielZlotin
DanielZlotin / UniswapV2.sol
Created February 26, 2023 11:04
AMM Function
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
@DanielZlotin
DanielZlotin / readStake.ts
Created January 3, 2023 13:07
Read historical staked ORBS in Staking Contract
const team = "0xC200f98F3C088B868D80d8eb0aeb9D7eE18d604B";
const date = new Date(Date.UTC(2022, 11, 31, 23, 59, 59));
console.log(date);
const block = await findBlock(date.getTime());
await resetNetworkFork(block.number);
const c = contract(abi as any, "0x01D59Af68E2dcb44e04C50e05F62E7043F2656C3"); //ETH
// const c = contract(abi as any, "0xEeAE6791F684117B7028b48Cb5dD21186dF80B9c");//POLY
@DanielZlotin
DanielZlotin / example.js
Created February 24, 2021 13:09
[web3] reproduction of runtime error when passing bn.js values inside structs or arrays
const { BN } = require("bn.js");
const Web3 = require("web3");
const web3 = new Web3();
const value = new BN("12345");
console.log(
web3.eth.abi.encodeParameters(
[{ internalType: "uint256", name: "input1", type: "uint256" }],
[value]
import React, { Component } from 'react';
import {
Text,
View,
StyleSheet,
ListView,
ActivityIndicator,
Button,
} from 'react-native';
import { Constants } from 'expo';
@DanielZlotin
DanielZlotin / yarn-binfix.js
Created October 18, 2016 15:11
puts all executables from node_modules into .bin, as npm usually does
const cp = require('child_process');
const _ = require('lodash');
const p = require('path');
const fs = require('fs');
const nodeModules = p.join(process.cwd(), 'node_modules');
const bin = p.join(nodeModules, '.bin');
cp.execSync(`mkdir ${bin} || true`);