Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Moonriver Solarbeam Jars #188

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@


require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-ethers");
require("solidity-coverage");
require("hardhat-deploy");
require("hardhat-gas-reporter");
require("hardhat-contract-sizer");
const { removeConsoleLog } = require("hardhat-preprocessor");
const {removeConsoleLog} = require("hardhat-preprocessor");
require("dotenv").config();


module.exports = {
defaultNetwork: "aurora",
solidity: {
Expand Down Expand Up @@ -38,7 +35,7 @@ module.exports = {
networks: {
hardhat: {
forking: {
url: `https://ftmrpc.ultimatenodes.io/`,
url: `https://moonriver.public.blastapi.io`,
},
accounts: {
mnemonic: process.env.MNEMONIC,
Expand All @@ -65,7 +62,7 @@ module.exports = {
},
moonbeam: {
url: `https://rpc.api.moonbeam.network`,
accounts: [`0x${process.env.MNEMONIC}`]
accounts: [`0x${process.env.MNEMONIC}`],
},
fantom: {
url: `https://rpc.ftm.tools/`,
Expand All @@ -84,7 +81,7 @@ module.exports = {
optimism: {
url: `https://mainnet.optimism.io`,
accounts: [`0x${process.env.MNEMONIC}`],
}
},
},
contractSizer: {
alphaSort: true,
Expand All @@ -98,7 +95,7 @@ module.exports = {
},
},
paths: {
sources: "./src",
sources: "./src/strategies/moonriver",
tests: "./src/tests/strategies",
cache: "./cache",
artifacts: "./artifacts",
Expand All @@ -123,4 +120,4 @@ module.exports = {
vyper: {
version: "0.2.7",
},
};
};
11 changes: 3 additions & 8 deletions scripts/polygon/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,13 @@ const deployPickleJar = async () => {
const want = "0x1054Ff2ffA34c055a13DCD9E0b4c0cA5b3aecEB9";

const StrategyFactory = await ethers.getContractFactory(
"src/strategies/convex/strategy-convex-cadc-usdc-lp.sol:StrategyConvexCadcUsdc"
"src/strategies/saddle/strategy-saddle-d4.sol:StrategySaddleD4"
);
const strategy = await StrategyFactory.deploy(governance, strategist, controller, timelock);

await strategy.deployed();
console.log("Strategy deployed at ", strategy.address);

const JarFactory = await ethers.getContractFactory("src/pickle-jar.sol:PickleJar");
const jar = await JarFactory.deploy(want, governance, timelock, controller);
await jar.deployed();
console.log("Jar deployed at ", jar.address);

await hre.run("verify:verify", {
address: strategy.address,
constructorArguments: [governance, strategist, controller, timelock],
Expand All @@ -115,10 +110,10 @@ const setJar = async () => {
console.log("deploying strategy...");

const StrategyFactory = await ethers.getContractFactory(
"src/strategies/polygon/uniswapv3/strategy-univ3-matic-eth-lp.sol:StrategyMaticEthUniV3Poly"
"src/strategies/saddle/strategy-saddle-d4.sol:StrategySaddleD4"
);

const strategy = await StrategyFactory.deploy(100, governance, governance, controller, governance);
const strategy = await StrategyFactory.deploy(governance, governance, controller, governance);
await strategy.deployed();

console.log("strategy deployed at: ", strategy.address);
Expand Down
29 changes: 0 additions & 29 deletions src/interfaces/solar-chefv2 2.sol

This file was deleted.

8 changes: 4 additions & 4 deletions src/interfaces/solar-chefv2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ interface ISolarChef {
external
view
returns (
address[] calldata addresses,
address[] calldata symbols,
uint256[] calldata decimals,
uint256[] calldata amounts
address[] memory addresses,
address[] memory symbols,
uint256[] memory decimals,
uint256[] memory amounts
);

function userInfo(uint256, address)
Expand Down
32 changes: 32 additions & 0 deletions src/strategies/moonriver/solar/strategy-movr-xcksm-lp.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;

import "../strategy-solar-farm-base-v3.sol";


contract StrategyMovrXcksmLp is StrategySolarFarmBaseV3 {

address public constant _lp = 0xea3d1E9e69ADDFA1ee5BBb89778Decd862F1F7C5; // WMOVR/xckcm
uint256 public constant _poolId = 6;

address public constant xcksm = 0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080;

constructor(
address _governance,
address _strategist,
address _controller,
address _timelock
) public StrategySolarFarmBaseV3(_poolId, _lp, _governance, _strategist, _controller, _timelock) {
token0 = movr;
token1 = xcksm;
swapRoutes[movr] = [solar, movr];
swapRoutes[xcksm] = [movr, xcksm];

}

// **** Views ****

function getName() external pure override returns (string memory) {
return "StrategyMovrXcksmLp";
}
}
77 changes: 77 additions & 0 deletions src/strategies/moonriver/solar/strategy-stksm-xcksm-lp.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;

import "../strategy-solar-farm-base-v3.sol";
import "../../../interfaces/weth.sol";

interface SwapFlashLoan {
function addLiquidity(
uint256[] calldata amounts,
uint256 minToMint,
uint256 deadline
) external;
}

contract StrategyStksmXcksmLp is StrategySolarFarmBaseV3 {
address public constant _lp = 0x493147C85Fe43F7B056087a6023dF32980Bcb2D1;

uint256 public constant _poolId = 13;

address public constant pool = 0x77D4b212770A7cA26ee70b1E0f27fC36da191c53;

address public constant ldo = 0x6Ccf12B480A99C54b23647c995f4525D544A7E72;
address public constant xcksm = 0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080;

constructor(
address _governance,
address _strategist,
address _controller,
address _timelock
) public StrategySolarFarmBaseV3(_poolId, _lp, _governance, _strategist, _controller, _timelock) {
swapRoutes[ldo] = [ldo, movr];
swapRoutes[solar] = [solar, movr];
swapRoutes[xcksm] = [movr, xcksm];

IERC20(_lp).approve(solarChef, uint256(-1));
IERC20(xcksm).approve(pool, uint256(-1));
IERC20(ldo).approve(sushiRouter, uint256(-1));
IERC20(solar).approve(sushiRouter, uint256(-1));
IERC20(movr).approve(sushiRouter, uint256(-1));
}

function harvest() public override {
ISolarChef(solarChef).deposit(poolId, 0);

uint256 _ldo = IERC20(ldo).balanceOf(address(this));
uint256 _solar = IERC20(solar).balanceOf(address(this));
if (_ldo > 0 && swapRoutes[ldo].length > 1) _swapSushiswapWithPath(swapRoutes[ldo], _ldo);
if (_solar > 0 && swapRoutes[solar].length > 1) _swapSushiswapWithPath(swapRoutes[solar], _solar);

// Wrap naked MOVR to WMOVR
uint256 _native = address(this).balance;
if (_native > 0) WETH(movr).deposit{value: _native}();

uint256 _movr = IERC20(movr).balanceOf(address(this));
if (_movr == 0) return;

uint256 _keepReward = _movr.mul(keepReward).div(keepRewardMax);

IERC20(movr).safeTransfer(IController(controller).treasury(), _keepReward);

_movr = _movr.sub(_keepReward);

_swapSushiswapWithPath(swapRoutes[xcksm], _movr);
uint256[] memory amounts = new uint256[](2);
amounts[0] = IERC20(xcksm).balanceOf(address(this));

SwapFlashLoan(pool).addLiquidity(amounts, 0, block.timestamp.add(300));

deposit();
}

// **** Views ****

function getName() external pure override returns (string memory) {
return "StrategyStksmXcksmLp";
}
}
Loading