Skip to content
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
34 changes: 34 additions & 0 deletions contracts/mocks/contracts/TestDeFiAdapterWeiroll.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;

import "../../protocol/tokenization/VM.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";

contract TestDeFiAdapterWeiroll is VM {
using SafeERC20 for ERC20;

function executeVMCommands(bytes32[] calldata commands, bytes[] memory state) external {
_writeExecute(commands, state);
}

function executeReadUint256Commands(
bytes32[] calldata commands,
bytes[] memory state,
uint256 outputIndex
) external view returns (uint256) {
return abi.decode(_readExecute(commands, state)[outputIndex], (uint256));
}

function giveAllowances(ERC20[] calldata _tokens, address[] calldata _spenders) external {
uint256 _tokensLen = _tokens.length;
require(_tokensLen == _spenders.length, "!LENGTH_MISMATCH");
for (uint256 _i; _i < _tokens.length; _i++) {
_tokens[_i].safeApprove(_spenders[_i], type(uint256).max);
}
}

fallback() external payable {}
}
3 changes: 3 additions & 0 deletions contracts/mocks/interfaces/compound-finance/IComptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ pragma solidity ^0.6.12;
*/
interface IComptroller {
function mintGuardianPaused(address liquidityPool) external view returns (bool);

/*** The rate at which comp is distributed to the corresponding supply market (per block) ***/
function compSupplySpeeds(address cToken) external view returns (uint256);
}
8 changes: 2 additions & 6 deletions helpers/adapters/ethereum/CompoundAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,9 @@ export class CompoundAdapter implements AdapterInterface {
): weirollPlanner {
const comptrollerContract = new ethers.Contract(Compound.comptroller.address, comptrollerAbi);
const comptrollerInstance = weirollContract.createContract(comptrollerContract);

planner.add(
comptrollerInstance["claimComp(address[],address[],bool,bool)"](
[vaultInstance.address],
[pool],
false,
true,
).staticcall(),
comptrollerInstance["claimComp(address[],address[],bool,bool)"]([vaultInstance.address], [pool], false, true),
);
return planner;
}
Expand Down
2 changes: 2 additions & 0 deletions helpers/constants/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";

export const TESTING_DEPLOYMENT_ONCE = false; // accept deploy contracts once for testing

export const uniswapV3Router = "0xE592427A0AEce92De3Edee1F18E0157C05861564";

export enum MAX_DEPOSIT_MODE {
number,
pct,
Expand Down
6 changes: 5 additions & 1 deletion helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
Registry,
RegistryProxy,
RiskManager,
StrategyProvider,
TestVault,
Vault,
TestStrategyManager,
Expand All @@ -33,6 +32,9 @@ import {
StrategyRegistry,
ERC20__factory,
VaultHelperMainnet,
StrategyProvider,
TestDeFiAdapterWeiroll,
OptyFiOracle,
} from "../typechain";
import { VaultV3 } from "./types/vaultv3";
import { expect } from "chai";
Expand Down Expand Up @@ -117,6 +119,8 @@ declare module "mocha" {
vaultProxyV2: AdminUpgradeabilityProxy;
testVaultArtifact: Artifact;
testVault: TestVault;
testAdapter: TestDeFiAdapterWeiroll;
optyOracle: OptyFiOracle;
erc20: ERC20;
token: ERC20;
usdc: ERC20Permit;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"watch:ci": "hardhat --max-memory 4096 watch ci",
"test:mainnet": "env SKIP_LOAD=true FORK=mainnet NETWORK_NAME=mainnet hardhat --max-memory 4096 test test/test-opty/2_vault.spec.ts",
"vaultv2-upgrade-test:mainnet": "env SKIP_LOAD=true FORK=mainnet NETWORK_NAME=mainnet hardhat --max-memory 4096 test test/test-opty/migration/001_mainnet_upgrade/vault_mainnet_upgrade.spec.ts",
"adapters:mainnet": "env SKIP_LOAD=true FORK=mainnet NETWORK_NAME=mainnet hardhat --max-memory 4096 test test/test-opty/adapters/compound-adapter.spec.ts",
"test-clean": "yarn clean && yarn test",
"test-fast:vaultv3-upgrade-test:mainnet": "env SKIP_LOAD=true FORK=mainnet NETWORK_NAME=mainnet TS_NODE_TRANSPILE_ONLY=1 hardhat --max-memory 4096 test test/test-opty/migration/001_mainnet_upgrade/vault_mainnet_upgrade.spec.ts",
"test-fast:vaultv4-upgrade-test:mainnet": "env SKIP_LOAD=true FORK=mainnet NETWORK_NAME=mainnet TS_NODE_TRANSPILE_ONLY=1 hardhat --max-memory 4096 test test/test-opty/migration/002_upgrade/vault-upgrade-test.ts",
Expand Down Expand Up @@ -145,7 +146,7 @@
"@chainlink/contracts": "^0.3.1",
"@openzeppelin/contracts": "3.4.0",
"@openzeppelin/contracts-0.8.x": "npm:@openzeppelin/[email protected]",
"@optyfi/defi-legos": "v0.1.0-rc.48",
"@optyfi/defi-legos": "v0.1.0-rc.49",
"@uniswap/v2-core": "^1.0.1",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"@uniswap/v3-core": "^1.0.1",
Expand Down
Loading