Skip to content

Commit

Permalink
swapr strategies finished and deployed successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
amatureApe committed May 20, 2022
1 parent 51d64e7 commit 7caf506
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 73 deletions.
82 changes: 21 additions & 61 deletions scripts/degenApe.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const { sleep, fastVerifyContracts, slowVerifyContracts } = require("./degenUtil
// Script configs
const sleepConfig = { sleepToggle: true, sleepTime: 10000 };
const callAttempts = 3;
const generatePfcore = true;
const generatePfcore = false;

// Pf-core generation configs
const outputFolder = "scripts/degenApeOutputs";
const outputFolder = "scripts/degenApe/degenApeOutputs";

// These arguments need to be set manually before the script can make pf-core
// @param - chain: The chain on which the script is running
Expand All @@ -34,19 +34,11 @@ const outputFolder = "scripts/degenApeOutputs";
// by the script from the strategy address.
// @param - componentAddresses: The underlying token addresses of the lp. These will be added
const pfcoreArgs = {
<<<<<<< HEAD
chain: "optimism",
protocols: ["zipswap"],
extraTags: [],
liquidityURL: "https://zipswap.fi/#/add/",
rewardTokens: ["zip", "gohm"],
=======
chain: "gnosis",
protocols: ["swapr"],
extraTags: [],
liquidityURL: "https://zipswap.fi/#/add/",
rewardTokens: ["swapr", "gno"],
>>>>>>> 231245f (add swapr jar)
jarCode: "1e",
farmAddress: "",
componentNames: [],
Expand All @@ -56,37 +48,16 @@ const pfcoreArgs = {
// Addresses & Contracts
const governance = "0x4204FDD868FFe0e62F57e6A626F8C9530F7d5AD1";
const strategist = "0x4204FDD868FFe0e62F57e6A626F8C9530F7d5AD1";
<<<<<<< HEAD
const controller = "0xc335740c951F45200b38C5Ca84F0A9663b51AEC6";
=======
const controller = "0xe5E231De20C68AabB8D669f87971aE57E2AbF680";
>>>>>>> 231245f (add swapr jar)
const timelock = "0x4204FDD868FFe0e62F57e6A626F8C9530F7d5AD1";
const harvester = ["0x0f571D2625b503BB7C1d2b5655b483a2Fa696fEf"];

const contracts = [
<<<<<<< HEAD
<<<<<<< HEAD
"src/strategies/optimism/zipswap/strategy-zip-$gohm-$weth-lp.sol:StrategyZipEthGohmLp"
];

const testedStrategies = [];

const executeTx = async (calls, fn, ...args) => {
let transaction;
await sleep(sleepConfig);
try {
transaction = await fn(...args);

=======
"src/strategies/gnosis/swapr/strategy-swapr-weth-wbtc-lp.sol:StrategySwaprWethWbtcLp"
=======
"src/strategies/gnosis/swapr/strategy-swapr-$cow-$weth-lp.sol:StrategySwaprCowWethLp"
>>>>>>> f9a9216 (swapr multi-rewards WIP)
];

const testedStrategies = [

"0x6C1A93162cFa01C1071f3186d8b32B216800aa18"
];

const executeTx = async (calls, fn, ...args) => {
Expand All @@ -95,7 +66,6 @@ const executeTx = async (calls, fn, ...args) => {
try {
transaction = await fn(...args);

>>>>>>> 231245f (add swapr jar)
// If deployTransaction property is empty, call normal wait()
if (transaction.deployTransaction) {
await transaction.deployTransaction.wait();
Expand Down Expand Up @@ -212,6 +182,24 @@ const deployContractsAndGeneratePfcore = async () => {

if (ratio.gt(BigNumber.from(parseEther("1")))) {
console.log(`✔️ Harvest was successful, ending ratio of ${ratio.toString()} `);

//Pf-core Generation
if (generatePfcore) {
// Regex targets all items that start with $ and end with -
const regex = /(?<=\$).*?(?=-)/g;
pfcoreArgs.componentNames = contract.match(regex);

// pfcoreArgs.componentNames.forEach((x, i) => {
// const token = await txRefs['want'].getToken(i);
// pfcoreArgs.componentAddresses.push(token);
// });

await outputFolderSetup();
await incrementJar(pfcoreArgs.jarCode, jarIndex);
await generateJarBehaviorDiscovery(pfcoreArgs);
await generateJarsAndFarms(pfcoreArgs, jar.address, jar.blockNumber, want, controller);
await generateImplementations(pfcoreArgs);
}
} else {
console.log(`❌ Harvest failed, ending ratio of ${ratio.toString()} `);
}
Expand All @@ -231,24 +219,6 @@ ratio: ${ratio.toString()}
`;
console.log(report);
allReports.push(report);

//Pf-core Generation
if (generatePfcore) {
// Regex targets all items that start with $ and end with -
const regex = /(?<=\$).*?(?=-)/g;
pfcoreArgs.componentNames = contract.match(regex);

// pfcoreArgs.componentNames.forEach((x, i) => {
// const token = await txRefs['want'].getToken(i);
// pfcoreArgs.componentAddresses.push(token);
// });

await outputFolderSetup(outputFolder, pfcoreArgs);
await incrementJar(pfcoreArgs.jarCode, jarIndex);
await generateJarBehaviorDiscovery(pfcoreArgs, outputFolder);
await generateJarsAndFarms(pfcoreArgs, jar.address, jar.blockNumber, want, controller);
await generateImplementations(pfcoreArgs);
}
} catch (e) {
console.log(`Oops something went wrong...`);
console.error(e);
Expand All @@ -268,19 +238,9 @@ ratio: ${ratio.toString()}
};

const main = async () => {
<<<<<<< HEAD
<<<<<<< HEAD
await deployContractsAndGeneratePfcore();
// await fastVerifyContracts(testedStrategies);
await slowVerifyContracts(testedStrategies);
=======
// await deployContractsAndGeneratePfcore();
=======
await deployContractsAndGeneratePfcore();
>>>>>>> f9a9216 (swapr multi-rewards WIP)
// await fastVerifyContracts(testedStrategies);
await slowVerifyContracts(testedStrategies, governance, strategist, controller, timelock);
>>>>>>> 231245f (add swapr jar)
};

main()
Expand Down
18 changes: 7 additions & 11 deletions src/strategies/gnosis/strategy-swapr-base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ abstract contract StrategySwaprFarmBase is StrategyBase {

uint256 j;
for (uint256 i = 0; i < _claimableRewards.length; i++) {
if (rewardRoutes[rewardTokens[i]].length > 0) {
PendingRewards[j] = _claimableRewards[i];
j++;
}
PendingRewards[j] = _claimableRewards[i];
j++;
}
return PendingRewards;
}
Expand Down Expand Up @@ -100,7 +98,7 @@ abstract contract StrategySwaprFarmBase is StrategyBase {
address[] memory rewardTokens = ISwaprRewarder(rewarder).getRewardTokens();
for (uint256 i = 0; i > rewardTokens.length; i++) {
uint256 _rewardToken = IERC20(rewardTokens[i]).balanceOf(address(this));
if (rewardRoutes[rewardTokens[i]].length > 1) {
if (rewardRoutes[rewardTokens[i]].length > 1 && _rewardToken > 0) {
_swap(swaprRouter, rewardRoutes[rewardTokens[i]], _rewardToken);
}
}
Expand All @@ -112,14 +110,12 @@ abstract contract StrategySwaprFarmBase is StrategyBase {

_gno = IERC20(gno).balanceOf(address(this));

if (gno == token0 || gno == token1) {
if (_gno > 0) {
if (_gno > 0) {
if (gno == token0 || gno == token1) {
address toToken = gno == token0 ? token1 : token0;
_swap(swaprRouter, swapRoutes[toToken], _gno.div(2));
}
} else {
// Swap GNO to token0 & token1
if (_gno > 0) {
} else {
// Swap GNO to token0 & token1
uint256 _toToken0 = _gno.div(2);
uint256 _toToken1 = _gno.sub(_toToken0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ contract StrategySwaprCowGnoLp is StrategySwaprFarmBase {
_timelock
)
{
rewardRoutes[swapr] = [swapr, xdai, gno];
rewardRoutes[cow] = [cow, gno];
rewardRoutes[gno] = [gno];
swapRoutes[gno] = [swapr, xdai, gno];
swapRoutes[cow] = [gno, weth, cow];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ contract StrategySwaprCowWethLp is StrategySwaprFarmBase {
// **** Views ****

function getName() external pure override returns (string memory) {
return "StrategySwaprGnoWethLp";
return "StrategySwaprCowWethLp";
}
}
40 changes: 40 additions & 0 deletions src/strategies/gnosis/swapr/strategy-swapr-gno-dxd-lp.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;

import "../strategy-swapr-base.sol";

contract StrategySwaprDxdGnoLp is StrategySwaprFarmBase {
// Token addresses
address public swapr_dxd_gno_lp = 0x558d777B24366f011E35A9f59114D1b45110d67B;
address public rewarderContract = 0x6148399F63c3dfdDf33A77c63A87C54e597D80E5;
uint256 public rewards = 2;
address public dxd = 0xb90D6bec20993Be5d72A5ab353343f7a0281f158;

constructor(
address _governance,
address _strategist,
address _controller,
address _timelock
)
public
StrategySwaprFarmBase(
rewarderContract,
rewards,
swapr_dxd_gno_lp,
_governance,
_strategist,
_controller,
_timelock
)
{
rewardRoutes[swapr] = [swapr, xdai, gno];
rewardRoutes[gno] = [gno];
swapRoutes[dxd] = [gno, dxd];
}

// **** Views ****

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

0 comments on commit 7caf506

Please sign in to comment.