Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Paul Razvan Berg paulrberg

💭
I may be slow to respond.
View GitHub Profile
@paulrberg
paulrberg / liquidator.rs
Last active Jan 15, 2021
Source code for StackOverflow question
View liquidator.rs
//! Liquidator Module
//!
//! This module is responsible for triggering liquidations.
use crate::{escalator::GeometricGasPrice, vault::Vault, HifiResult};
use ethers::{
core::abi::{self, Tokenize},
prelude::*,
};
use hifi_liquidator_bindings::{FyToken, UniswapV2Pair};
View generate-dsproxy-calldata.js
const ethers = require("ethers");
const DSProxyAbi = require("../abis/DSProxy.json");
const TargetContractAbi = require("../abis/TargetContract.json");
const defaultProvider = ethers.getDefaultProvider("kovan");
const dsProxyAddress = "0xa92Bed719071A4d33B0B348513E7e866a6ff6B3F";
const dsProxy = new ethers.Contract(dsProxyAddress, DSProxyAbi, defaultProvider);
const targetContractAddress = "0xE3CD2e7a628b57d3e50c5f7B921182f676721bDF";
const targetContract = new ethers.Contract(targetContractAddress, TargetContractAbi, defaultProvider);
View 3boxVerification.txt
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:3:bafyreibj65scex56egywsjogkoymcirx4epjlrpwlzmwuqbkgy3toyxe6y ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
@paulrberg
paulrberg / typechain-v4-error.txt
Created Nov 9, 2020
TypeChain v4 error in solidity-template repo
View typechain-v4-error.txt
Compiling...
Compiled 2 contracts successfully
Creating TypeChain artifacts in directory typechain for target ethers-v5
An unexpected error occurred:
SyntaxError: '=' expected. (8:15)
6 | import { Contract, ContractFactory, Overrides } from "@ethersproject/contracts";
7 |
> 8 | import type { Greeter } from "./Greeter";
| ^
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@paulrberg
paulrberg / CarefulMath.sol
Created Aug 14, 2020
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.10+commit.00c0fcaf.js&optimize=true&gist=
View CarefulMath.sol
/* SPDX-License-Identifier: LGPL-3.0-or-later */
pragma solidity ^0.6.10;
/**
* @title CarefulMath
* @author Compound
* @notice Exponential module for storing fixed-precision decimals.
* @dev Derived from OpenZeppelin's SafeMath library
*/
abstract contract CarefulMath {
@paulrberg
paulrberg / testotron.ts
Created Aug 13, 2020
Logging block timestamps
View testotron.ts
import { BigNumber } from "@ethersproject/bignumber";
import { Signer } from "@ethersproject/abstract-signer";
import { waffle } from "@nomiclabs/buidler";
import { expect } from "chai";
export function shouldBehaveLikeGreeter(_signers: Signer[]): void {
describe("1st Block", function () {
beforeEach(async function () {
await waffle.provider.send("evm_setNextBlockTimestamp", [1597348800]);
const blockTimestamp: BigNumber = await this.testotron.getBlockTimestamp();
@paulrberg
paulrberg / augmentations.d.ts
Created Jul 29, 2020
Augmenting the Context type used by Mocha in beforeEach, it, etc.
View augmentations.d.ts
import { Erc20 } from "../typechain/Erc20";
declare module "mocha" {
export interface Context {
token: Token;
}
}
View rebalancePseudocode.sol
function rebalance(address user) returns (bool) {
uint currentTimestamp = block.timestamp;
if (currentTimestamp == priorRebalanceTimestamp) {
return true;
}
uint incomingDelta = 0;
for (incomingStream in incomingStreamsOf(user)) {
rebalance(incomingStream.sender);
uint streamBalanceOfRecipient = streamBalanceOfRecipient(incomingStream.id);
View call-exception.log
Greeter
greet
Deploying a Greeter with greeting: Hello from greeter!
✓ should return the greeting (42ms)
getBlockNumber
Deploying a Greeter with greeting: Hello from greeter!
✓ should sum up the number
ChildGreeter
getBlockNumber
You can’t perform that action at this time.