Skip to content

Instantly share code, notes, and snippets.

View JTraversa's full-sized avatar

Julian Traversa JTraversa

View GitHub Profile
@JTraversa
JTraversa / gist:fae47e0ca66f6f7a2aa0a2a8b5ad7dd8
Created April 7, 2023 06:07
YearnSpace-TV _wrapPreview
function _wrapPreview(
uint256 base_
) internal view virtual override returns (uint256 shares) {
IYVToken yvToken = IYVToken(address(sharesToken));
uint256 DEGRADATION_COEFFICIENT = 10 ** 18;
uint256 freeFunds = yvToken.totalAssets();
uint256 lockedProfit = yvToken.lockedProfit();
if (lockedProfit > 0) {
uint256 lockedFundsRatio = (block.timestamp -
@JTraversa
JTraversa / YieldPool...Pool.sol
Created September 21, 2022 23:48
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.8.14+commit.80d49f37.js&optimize=true&runs=2000&gist=
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.14;
import "./IERC20.sol";
import "./IERC20Metadata.sol";
import "./MinimalTransferHelper.sol";
import "./CastU256U128.sol";
import "./CastU256U112.sol";
import "./CastU256I256.sol";
import "./CastU128U112.sol";
@JTraversa
JTraversa / LibCompound2.sol
Last active August 4, 2022 15:47
LibCompound -- Compound Math
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.4;
import {FixedPointMathLib} from "./Marketplace/FixedPointMathLib.sol";
import "./ExponentialNoError.sol";
import "./Marketplace/Interfaces.sol";
/// @notice Get up to date cToken data without mutating state.
/// @author Transmissions11 (https://github.com/transmissions11/libcompound)
library LibCompound {
[
{
"market": {
"underlying": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"maturity": "1648177200"
},
"users": [
{
"user": "0xe6d79FD38ad0b7C9be78F03f8fBe4CF01B49a559",
"amounts": {
@JTraversa
JTraversa / gist:40ab855c58bc2e24cdcfe2cf729a4faf
Created July 19, 2022 08:29
Rinkeby DAI market Vault balances
This file has been truncated, but you can view the full file.
{
"market": {
"underlying": "0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa",
"maturity": "1669957199"
},
"users": [
{
"user": "0x7111F9Aeb2C1b9344EC274780dc9e3806bdc60Ef",
"amounts": {
"notional": "111522090989082212503037",
@JTraversa
JTraversa / gist:c5fdba51286d30643b056d671f6accc6
Last active July 19, 2022 08:28
Listen in batches of 10k blocks, dedupe, read vault for balances
web3 = Web3(Web3.HTTPProvider(infura))
swivelcontract = create_contract(web3, False, contract_abi, swivel)
marketplacecontract = create_contract(web3, False, marketplace_abi, marketplace)
vault = marketplacecontract.functions.markets('0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa',1669957199).call()[2]
vaultcontract = create_contract(web3, False, vaulttracker_abi, vault)
exits =[]
[
{
"market": {
"underlying": "0x4DBCdF9B62e891a7cec5A2568C3F4FAF9E8Abe2b",
"maturity": "1639112399"
},
"users": [
{
"user": "0x3f60008Dfd0EfC03F476D9B489D6C5B13B3eBF2C",
"amounts": {
@JTraversa
JTraversa / vault-balances
Last active July 17, 2022 22:26
vault-balances
from web3._utils.events import get_event_data
from web3._utils.filters import construct_event_filter_params
import requests
import json
from web3 import Web3
import math
_cache = dict()
def truncate(number, digits) -> float:
@JTraversa
JTraversa / comparison
Last active July 17, 2022 22:28
comparison
[
{
"market": {
"underlying": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"maturity": "1648177200"
},
"users": [
{
"user": "0xe6d79FD38ad0b7C9be78F03f8fBe4CF01B49a559",
"amounts": {
{
"0xC7D2c67bC38b0E8b15B632c19Ef629022FD56543": 100000000000000000000,
"0x01628A344a6E8Db2aa3E0954BC2C2D1e26444f9D": 3600000000000000000000,
"0xF72F3240728C65F04948bC28a7F6772B590cb56F": 5937007874015748300000,
"0xCc8c3176C69e8cbb60903cFC91Afd383eB6739d7": 2100000000000000000000,
"0x94F5C85ee0233F8D053126cA71d7F4A51101db40": 4800000000000000000000,
"0x512aaD1d0E1492a9C4075aBa58cE1a944A74f973": 5937007874015748300000,
"0xC487f60b6fA6d7CC1e51908b383385CbfC6c30B5": 4000000000000000000000,
"0x570Ad1a6011c6F8d86BB688eD6fD10d55d0DD809": 4000000000000000000000,
"0x84817254031e40aA1Ee5c0b144118eF9A029cEAc": 3800000000000000000000,