Skip to content

Instantly share code, notes, and snippets.

View kendricktan's full-sized avatar

Kendrick Tan kendricktan

View GitHub Profile
@kendricktan
kendricktan / .bashrc
Last active December 18, 2021 23:34
dapptools macos
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
# if PATH does *not* contain `~/.nix-profile/bin`
if [ -n "${PATH##*.nix-profile/bin*}" ]; then
# If this flag is set, `nix-daemon.sh` returns early
# https://issueexplorer.com/issue/NixOS/nix/5298
unset __ETC_PROFILE_NIX_SOURCED
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
@kendricktan
kendricktan / sshfs
Created September 2, 2021 03:43
SSHFS
sudo sshfs -o allow_other,default_permissions [name]@[ip]:[remote-dir] [local-dir]
@kendricktan
kendricktan / mount.sh
Created September 1, 2021 21:32
AWS Mount Drive
lsblk
sudo mkfs -t ext4 /dev/nvme1n1
sudo mkdir ~/.data
sudo mount /dev/nvme1n1 ~/.data
sudo chmod 666 ~/.data
@kendricktan
kendricktan / index.js
Created April 11, 2021 21:58
node-js-http-proxy
var proxy = require('express-http-proxy');
var app = require('express')();
var cors = require('cors')
var morgan = require('morgan')
app.use(cors())
app.use(morgan('combined'))
app.use('/', proxy('google.com'));
$ ganache-cli --mnemonic "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"
Ganache CLI v6.9.1 (ganache-core: 2.10.2)
Available Accounts
==================
(0) 0x627306090abaB3A6e1400e9345bC60c78a8BEf57 (100 ETH)
(1) 0xf17f52151EbEF6C7334FAD080c5704D77216b732 (100 ETH)
(2) 0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef (100 ETH)
(3) 0x821aEa9a577a9b44299B9c15c88cf3087F3b5544 (100 ETH)
(4) 0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2 (100 ETH)
@kendricktan
kendricktan / dfx-supply.js
Last active November 8, 2021 18:20
Balancer Supply Liquidity for DFX
const { ethers } = require("hardhat");
const { provider } = ethers;
const { parseUnits, formatUnits } = ethers.utils;
const FiatTokenV1ABI = JSON.parse(
'[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint8"},{"name":"_masterMinter","type":"address"},{"name":"_pauser","type":"address"},{"name":"_blacklister","type":"address"},{"name":"_owner","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenAddress","type":"address"}],"name":"reclaimToken","outputs":[],"payable
@kendricktan
kendricktan / dsd-utils.js
Created December 29, 2020 07:53
Extract DSD Data
const ethers = require('ethers')
const path = require('path')
const fs = require('fs')
const { parseEther, formatEther } = ethers.utils
const { critical, info } = require('./logging')
const fetch = require('node-fetch')
const {
BOND_EVENT_DAO,
BOND_EVENT_LP,
UNBOND_EVENT,
@kendricktan
kendricktan / mint.json
Created December 16, 2020 04:09
mint-abi
[
{
"constant": false,
"inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "mint",
"payable": true,
"stateMutability": "payable",
@kendricktan
kendricktan / depends-CMakeLists.txt
Created November 11, 2020 16:42
libff cmakefile
if(${CURVE} STREQUAL "BN128")
include_directories(ate-pairing/include)
include_directories(xbyak)
add_library(
zm
SHARED
ate-pairing/src/zm.cpp
ate-pairing/src/zm2.cpp
)
@kendricktan
kendricktan / solc-input.json
Created October 15, 2020 11:59
shortdai solc-input.json
{
"language": "Solidity",
"sources": {
"contracts/CloseShortDAI.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.7.0;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\n\nimport \"./weth/WETH.sol\";\n\nimport \"./dydx/DydxFlashloanBase.sol\";\nimport \"./dydx/IDydx.sol\";\n\nimport \"./maker/IDssCdpManager.sol\";\nimport \"./maker/IDssProxyActions.sol\";\nimport \"./maker/DssActionsBase.sol\";\n\nimport \"./curve/ICurveFiCurve.sol\";\n\nimport \"./Constants.sol\";\n\ncontract CloseShortDAI is ICallee, DydxFlashloanBase, DssActionsBase {\n struct CSDParams {\n uint256 cdpId; // CdpId to close\n address curvePool; // Which curve pool to use\n uint256 mintAmountDAI; // Amount of DAI to mint\n uint256 withdrawAmountUSDC; // Amount of USDC to withdraw from vault\n uint256 flashloanAmountWETH; // Amount of WETH flashloaned\n }\n\n function callFunction(\n address sender,\n