Skip to content

Instantly share code, notes, and snippets.

View barrasso's full-sized avatar
🎯
Focusing

meb barrasso

🎯
Focusing
View GitHub Profile
@barrasso
barrasso / SnxFlashLoan.sol
Last active March 6, 2024 17:06
simple aave flash loan contract to pay off snx debt position on v2x
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import "https://github.com/aave/aave-v3-core/blob/master/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol";
import "https://github.com/aave/aave-v3-core/blob/master/contracts/interfaces/IPoolAddressesProvider.sol";
import "https://github.com/aave/aave-v3-core/blob/master/contracts/dependencies/openzeppelin/contracts/IERC20.sol";
import "https://github.com/Synthetixio/synthetix/blob/develop/contracts/interfaces/ISynthetix.sol";
import "https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISwapRouter.sol";
contract SnxFlashLoan is FlashLoanSimpleReceiverBase {
@barrasso
barrasso / snx-futures-settings.sql
Created December 5, 2022 04:41
snx futures settings dune query
select
replace(encode("marketKey", 'escape'), '\000', '') as market,
replace(encode("parameter", 'escape'), '\000', '') as setting,
(
array_agg(
value
order by
evt_block_time desc
)
) [1] / 1e18 as value,
@barrasso
barrasso / generate-eth-account.js
Created December 5, 2022 04:37
create ETH wallet
const Web3 = require('web3');
const provider = new Web3.providers.HttpProvider('https://mainnet.infura.io/v3/YOUR_API_KEY');
const web3 = new Web3(provider);
// Generate a new Ethereum account
const account = web3.eth.accounts.create();
console.log('Your Ethereum wallet address is:', account.address);
console.log('Your private key is:', account.privateKey);
@barrasso
barrasso / update-ovm-bytecode.js
Created December 1, 2021 15:13
Used to cleanup the deployment.json files for both kovan-ovm and mainnet-ovm after the OVM regenesis had occurred.
const fs = require('fs');
const path = require('path');
const axios = require('axios');
const { table } = require('table');
require('dotenv').config();
const DEPLOYMENT_FILENAME = 'deployment.json';
const NETWORK = 'mainnet';
@barrasso
barrasso / exfil-dydx.js
Created November 6, 2021 20:51
Exfiltrate funds from a isolated-margin position on DYDX Solo (L1).
const { ethers } = require("ethers");
const { wei } = require("@synthetixio/wei");
const { Solo, Networks } = require("@dydxprotocol/solo");
require("dotenv").config();
// Init DYDX Solo instance.
const solo = new Solo(
"http://YOUR_PROVIDER_URL",
Networks.MAINNET,
@barrasso
barrasso / Deed.sol
Last active November 6, 2021 20:56
Deed contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
@barrasso
barrasso / CompletionExample.swift
Created December 31, 2020 02:59
Completion handler example
//
// Function definition
//
class func saveCardInfo(id: String, completion: (NSDictionary?, NSError?) -> Void) -> NSURLSessionTask {
// Prepare the request parameters.
let email = form["email"] as! String
let cardNumber = form["card"] as! String
let expiration = form["expiration"] as! String
let cvc = form["cvc"] as! String
import UIKit
extension UIView {
func startRotating(duration: Double = 1.0) {
let kAnimationKey = "rotation"
if self.layer.animation(forKey: kAnimationKey) == nil {
let animate = CABasicAnimation(keyPath: "transform.rotation")
animate.duration = duration
animate.repeatCount = Float.infinity
animate.fromValue = 0.0
@barrasso
barrasso / PrintFonts.swift
Created October 25, 2018 01:19
Getting the names of available UIFonts
for family: String in UIFont.familyNames
{
print(family)
for names: String in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}
pragma solidity ^0.4.0;
/*
Temporary Hash Registrar
========================
This is a simplified version of a hash registrar. It is purporsefully limited:
names cannot be six letters or shorter, new auctions will stop after 4 years.