Giter VIP home page Giter VIP logo

protocol's Introduction

Pickle Protocol

circleci

Solidity files relating to the PICKLE protocol.

Getting Started

We're using dapp-tools to compile, and test contracts. To get the dapp binary, you'll first need to install Nix.

# Install Nix
curl -L https://nixos.org/nix/install | sh

# Install dapp-tools
curl https://dapp.tools/install | sh
git clone [email protected]:pickle-finance/protocol.git
cd protocol
dapp update
dapp build

Dev

# Using ganche as a caching layer
ganache-cli -f https://mainnet.infura.io/v3/<URL>

DAPP_TEST_NUMBER=$(seth block-number) DAPP_TEST_TIMESTAMP=$(date +%s) DAPP_TEST_BALANCE_CREATE=10000000000000000000000000 dapp test --rpc-url http://localhost:8545 -m <test to run> -vv

# Dapp tools cli args
# -vv - Verbose (Show stacktraces if fail)
# -vv - Very verbose (ALWAYS show stacktraces)
# -m  - Only runs tests whos regex matches this string

Deploy

Via Remix

# Flatten
hevm flatten --source-file src/<sol> --json-file out/dapp.sol.json

# Deploy file via remix

Via JavaScript

export SOLC_FLAGS="--optimize --optimize-runs 200"

dapp build

# Export keys
export DEPLOYER_PRIVATE_KEY=<PRIVATE_KEY>
export PROVIDER_URL=<RPC_URL>

# You'll need to edit the deploy.js to fit your needs
node scripts/deploy.js

protocol's People

Contributors

0xpenguin avatar amatureape avatar bayesianmind avatar bigbrainbriner avatar cipioo avatar copypastachef avatar eip1599 avatar janklimo avatar larrythecucumber321 avatar magic990619 avatar manymoneymanny avatar midaseth avatar mistermard avatar okjintao avatar pfarmer avatar shing-ho avatar shortstackdev avatar soloph1 avatar uravgdeveloper avatar worldarchi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protocol's Issues

Use Local Memory Type Variable Instead of Global Storage Type Variable in Event to Save Gas

Hi, we recently have conducted a systematic study about Solidity event usage, evolution, and impact, and we are attempting to build a tool to improve the practice of Solidity event use based on our findings. We have tried our prototype tool on some of the most popular GitHub Solidity repositories, and for your repository, we find a potential optimization of gas consumption arisen from event use.

The point is that when we use emit operation to store the value of a certain variable, local memory type variable would be preferable to global storage type (state) variable if they hold the same value. The reason is that an extra SLOAD operation would be needed to access the variable if it is storage type, and the SLOAD operation costs 800 gas.

For your repository, we find that the following event use can be improved:

  • staking-rewards.sol
    function name:setRewardsDuration
    event name:  RewardsDurationUpdated
    variable:    rewardsDuration->_rewardsDuration
    function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
        require(
            block.timestamp > periodFinish,
            "Previous rewards period must be complete before changing the duration for the new period"
        );
        rewardsDuration = _rewardsDuration;
        emit RewardsDurationUpdated(rewardsDuration);
    }

Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!

Strategy withdrawals + harvest could save gas with 0 checks.

The strategy base currently doesn't check if fees are 0 before doing transfers. This really racks up gas - the 0 value transfer is way more expensive than a "if 0, skip" check.
These two withdrawal fees are currently 0, and seems like they plan to stay that way: (I personally hope so, I HATE withdrawal fees):

uint256 _feeDev = _amount.mul(withdrawalDevFundFee).div(
withdrawalDevFundMax
);
IERC20(want).safeTransfer(IController(controller).devfund(), _feeDev);
uint256 _feeTreasury = _amount.mul(withdrawalTreasuryFee).div(
withdrawalTreasuryMax
);
IERC20(want).safeTransfer(
IController(controller).treasury(),
_feeTreasury
);

Your farmer could save gas on harvest by checking for 0 in performanceDevFee (which is 0, the performanceTreasuryFee is the one set now):

_want.mul(performanceDevFee).div(performanceDevMax)

This would require a contract upgrade, but if changed now can at least be in effect for all new strategies going forward.
ERC20 transfers are between 50k - 105k gas each, so every user withdrawal could be 100k - 210k gas cheaper.

If you look at the treasury you can see a LOT of 0 value ERC20 transfers, this bug is one reason why. https://etherscan.io/address/0x066419eaef5de53cc5da0d8702b990c5bc7d1ab3#tokentxns

Migrate Saddle D4 contract to Gauge System

Pickle Discord mod Sevenz has discovered that the Saddle D4 jar's harvestable amount is no longer increasing
image

Saddle has migrated their farms to a gauge system and Pickle will need to perform this migration to continue earning rewards for the $20k deposits currently in the Jar.

[10] Launch Symbiotic Alchemix Pickle Jar

Intro

Alchemix is a new DeFi protocol which allows for the creation of synthetic tokens representing future yield of a deposit. Essentially, a user can deposit DAI to mint alUSD, with the underlying DAI being invested in a yield-generating Yearn vault. ALCX is used to incentivize users who stake certain assets on their platform. For example, users who stake alUSD-3CRV Curve metapool tokens are rewarded with ALCX.

Alchemix has expressed a desire for Pickle to develop a symbiotic PickleJar for them. This is advantageous to Pickle for the cross-promotion opportunities and the high farming yields from which Pickle can earn fees.

Requirements

There are 2 Jars that we want developed for farming on top of Alchemix:

  1. ALCX/ETH compounding LP Jar
  2. alUSD-3CRV symbiotic Jar

1. ALCX/ETH

This one is straightforward - a user deposits ALCX/ETH Sushiswap LP tokens and we sell the earned ALCX rewards to increase the LP position in the Jar. An example strategy is the MIR-UST strategy here or in this PR #34.

2. alUSD-3CRV

This one is a bit more interesting in that it departs from our typical Jar strategy. The Jar strategy should work as follows:

  1. accept deposits of alUSD-3CRV LP tokens
  2. stake in Alchemix farm - this is an adaptation of masterchef
  3. harvest ALCX rewards (from both the alUSD-3CRV and ALCX farms)
  4. stake ALCX rewards (in the same farm contract above but with a different poolID). For reference, Yearn has developed their own ALCX staking strategy, but this doesn't need to be followed.

When users withdraw, they should receive their pro-rata share of alUSD-3CRV and ALCX tokens per their pToken balance.

Frontend

A new Jar and Farm should be added for both of these Jars on the frontend. Multiple examples can be found in our frontend repo.

Badger/WBTC LP Strategies

Intro

Badger is a DeFi protocol dedicated to accelerating the growth and usage of Bitcoin in DeFi. Badger's main product is the Sett Vault. The vaults take WBTC and LP pairs involving different types of BTC (WBTC, crvBTC, etc), and LP pairs involving their native tokens BADGER and DIGG. The vaults pay rewards in up to 3 different tokens (xSUSHI, BADGER, and DIGG) which have to be manually claimed.

I would like to take on the role of community pickle jar strategist, and develop 2 jars for the BADGER/WBTC LP pair that autocompound manually claimable rewards from Badger's Sett Vaults:

  1. BADGER/WBTC compounding Uniswap LP Jar
  2. BADGER/WBTC compounding Sushiswap LP Jar

Requirements

I am in touch with the Badger team, and will be working closely with them to ensure things go smoothly. Badger requires whitelisting, and I will arrange for Pickle to be whitelisted with their Vaults. The team also expressed a desire to have a symbiotic component in the Jars, which I will discuss and develop.

Target TVL

The TVL of the BADGER/WBTC Sett Vault is $10.6m for the Sushi LP, and $5.3m for the Uni LP. The combined TVL is ~16m. Pickle should aim to capture at least a third of this: ~$5m.

(The TVL of Badger as a whole used to be over $1B just two months ago, whereas it has now dropped to around $450m. During favorable market conditions, the TVL of BADGER/WBTC should be $50m+)

Long term, I envision this strategy capturing $20m+ of TVL.

Target APY

Taking the Sushi LP Sett Vault as an example:
image

You can see that only 10.39% is from autocompounding by Badger. This leaves 36.79% paid out in rewards that the user has to manually claim and compound. Compounded once per week, this translates to an APY of 44.3%. Adding in the 10.39% from badger's side, this jar would have an APY of 54.7%

Pickle would claim it's 20% performance fee from the base APR of 36.79%:

So the base APR available for us to compound is 36.79%. After the 20% perfromance fee, this becomes 29%. Compounded weekly, it's 33.5%. Adding in the 10.39% from badger's side, the APY of the jar after Pickle's performance fees is ~44%. With pickle rewards on top (assume ~20%), the user gets an APY of 65%, which is extremely lucrative compared to the 47% APY available through badger alone.

Badger Fees

Badger has 0 withrawal/performance fees for the BADGER/WBTC Vaults. Only the Sushi LP vault has a minor fee where 20% of the xSUSHI rewards are sent to the badger treasury. This is already accounted for in the vault APR.

(https://badger-finance.gitbook.io/badger-finance/fees)

Pickle Strategist Fee

My proposed duties:

  1. Get Pickle whitelisted with Badger's vaults
  2. Create 2 pickle jar strategies (one uni one sushi) that autocompound up to 3 reward tokens with a lucrative APY
  3. Arrange for possible symbiosis with badger within the strategy

For this, I propose the standard strategist fee of 7.5%.

Conclusion

BADGER/WBTC strategies would be a great addition to Pickle's offering. There's a great APR from which to extract performance fees, significant TVL to be attracted, relationship building between Pickle and Badger through whitelisting and Symbiosis, and a great product for users. I envision that with pickle rewards, the farm would have an APY of up to 80% which makes it a way better option for staking than Badger's native app.

Users are unable to withdraw from TRI/AURORA

User is complaining that they are unable to withdraw their tokens from the TRI/AURORA jar.

User mentioned "I've had 3 IPs banned from aurora yesterday when trying to withdraw from the aurora-tri jar, maybe that's why?"

Please investigate

(mainnet) SLP SUSHI-ETH rewards will move to Curve V2 / Convex SPELL-ETH

SLP SUSHI-ETH: https://etherscan.io/address/0x1aE9938040852172F7588BBbe32CdB0867790591 will cease to receive $SPELL rewards.

Curve V2 pool is now live on Convex.
Screenshot 2022-01-16 at 2 45 53 PM

Convex contracts:

We will need to:

  • make a new Convex jar to auto-compound $CRV, $CVX, and any additional $SPELL rewards.
  • remove SPELL-ETH SLP from /farms voting UI.

Balancer jars

Arbitrum:

  • Pickle-Eth.
  • Bal-Eth.

Mainnet:

  • Bal-Eth.
  • Gno-Eth.
  • Eth-Dai.

#138

InstaDapp INST/ETH Strategy

Intro

InstaDApp is a smart wallet with an intuitive interface built on top of popular DeFi projects like MakerDAO, Compound, Uniswap, etc. for managing assets. It’s optimized for users lacking advanced technical or financial experience.

InstaDApp was release very recently, and has quickly climbed to #3 on defi pulse with $8B in TVL.

The INST token is their native governance token. The liquidity for INST is on uni v3, in an INST/ETH pair.

Strategy

  1. User deposits ETH and INST on Pickle
  2. Pickle takes the ETH and INST and deposits it in the InstaDApp protocol, which puts it in the automatically managed INST/ETH v3 LP.
  3. Rewards are paid out once a week by InstaDApp. Pickle harvests rewards.
  4. Pickle sells half of INST rewards for ETH, deposits into InstaDApp again.

APY and target TVL

INST reward APR (paid out weekly) is currently 334%. With Pickle’s 20% performance fee and a Strategist fee of 7.5%, the base APR after accounting for fees is:

334*(1-0.275) = 242% Base APR

Compounded weekly, the APY comes out to 964%

The TVL of the INST/ETH pool is $9m. This is expected to grow, as InstaDApp has only launched recently. With a good marketing push, this jar can target to have a TVL of $1-2m.

Looking forward to hear what you guys think!

Illiquid trades for Saddle D4 Strategy

Issue

The most recent harvest transaction for the Saddle D4 jar presents a couple problems. https://etherscan.io/tx/0x4a3f79b7a711add58dfdb641e784ea733207e79011f2cf37718bf6c98883e485. A summary of the swap is below
image

Each of the reward tokens are sold in the following manner:

  • _swapUniswap(fxs, frax, _fxs); which trades with the path FXS -> WETH -> FRAX

Step 1: reward token to ETH

  • each of the FXS, TRIBE, LQTY and ALCX rewards are swapped to ETH on Uni v2 (with the exception of ALCX on Sushi).
  • With the exception of LQTY, these swap routes are pretty optimal
  • A total of 5.92 ETH was gained -> $21k USD at current prices

Step 2: ETH to Stablecoin

  • The problem is starts here, where buying the D4-constituent stablecoins with ETH mostly involve illiquid pairs
    | Path | Liquidity | Improvement |
    | ----------- | ----------- | ----------- |
    | WETH -> FRAX | $1.5M | Direct FXS->FRAX ($43M) |

So... after all this, the issue doesn't seem to be as bad as I thought, and it's really only some weird MEV shennanigans that was going on with the WETH-FXS route.
image

Conclusion

A very simple fix is swapping with the exact FXS -> FRAX path to make sure this doesn't happen again in the future

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.