Skip to content

Commit db457ee

Browse files
committed
fix: imports for tests
1 parent 481e5b8 commit db457ee

9 files changed

+378
-42
lines changed

.env.example

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
REPORT_GAS=false
2+
PRODUCTION=false
3+
ENVIRONMENT=local
4+
OWNER_ADDRESS=0x48aB8AdF869Ba9902Ad483FB1Ca2eFDAb6eabe92
5+
FOUNDRY_EXPORTS_OVERWRITE_LATEST=true
6+
RUST_BACKTRACE=full
7+
FOUNDRY_PROFILE=localdev
8+
TENDERLY_PROJECT_SLUG=v1
9+
TENDERLY_ACCOUNT_ID=superform
10+
WALLET_TYPE=keystore
11+
MNEMONIC_INDEX=0
12+
DEBUG_MODE=false

Makefile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# include .env file and export its env vars
2+
# (-include to ignore error if it does not exist)
3+
-include .env
4+
5+
6+
# only export these env vars if ENVIRONMENT = local
7+
ifeq ($(ENVIRONMENT), local)
8+
export ETHEREUM_RPC_URL = $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/ETHEREUM_RPC_URL/credential)
9+
export BSC_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/BSC_RPC_URL/credential)
10+
export AVALANCHE_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/AVALANCHE_RPC_URL/credential)
11+
export POLYGON_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/POLYGON_RPC_URL/credential)
12+
export ARBITRUM_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/ARBITRUM_RPC_URL/credential)
13+
export OPTIMISM_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/OPTIMISM_RPC_URL/credential)
14+
export BASE_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/BASE_RPC_URL/credential)
15+
export FANTOM_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/FANTOM_RPC_URL/credential)
16+
export LINEA_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/LINEA_RPC_URL/credential)
17+
export BLAST_RPC_URL := $(shell op read op://5ylebqljbh3x6zomdxi3qd7tsa/BLAST_RPC_URL/credential)
18+
endif
19+
20+
# deps
21+
install:; forge install
22+
update:; forge update
23+
24+
# Build & test
25+
build :; FOUNDRY_PROFILE=production forge build
26+
build-sizes :; FOUNDRY_PROFILE=production forge build --sizes
27+
test-vvv :; forge test --match-test test_xChainWithdrawFromVault_InvalidChainId --evm-version cancun -vv --decode-internal
28+
ftest :; forge test --evm-version cancun
29+
coverage :; forge coverage --evm-version cancun --report lcov
30+
clean :; forge clean
31+
snapshot :; forge snapshot
32+
fmt :; forge fmt && forge fmt test/

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ Contributions are welcome! Please fork the repository and submit a pull request
3838

3939
## License
4040

41-
[MIT License](LICENSE)

LICENSE Yearn-LICENSE

File renamed without changes.

foundry.toml

+17-9
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,27 @@ out = "out"
1212
script = "script"
1313
src = "src"
1414
test = "test"
15-
auto_detect_remappings = false
16-
assertions_revert = false # see https://t.me/foundry_rs/36706
17-
legacy_assertions = true # see https://t.me/foundry_rs/36706
18-
gas_limit = "18446744073709551615" # see https://t.me/foundry_rs/36706
15+
auto_detect_remappings = true
16+
assertions_revert = true # see https://t.me/foundry_rs/36706
17+
legacy_assertions = false # see https://t.me/foundry_rs/36706
1918
remappings = [
2019
'forge-std/=lib/forge-std/src/',
21-
'@openzeppelin/=lib/tokenized-strategy/lib/openzeppelin-contracts/',
22-
'openzeppelin-contracts/contracts=lib/tokenized-strategy/lib/openzeppelin-contracts/contracts',
23-
'tokenized-strategy=lib/tokenized-strategy/src/',
24-
'superform-core=lib/superform-core/src/',
25-
'ERC1155A=lib/superform-core/lib/ERC1155A/src/',
20+
'openzeppelin/=lib/tokenized-strategy/lib/openzeppelin-contracts/',
21+
'@openzeppelin/=lib/superform-core/lib/ERC1155A/lib/openzeppelin-contracts/',
22+
'openzeppelin-contracts/=lib/superform-core/lib/ERC1155A/lib/openzeppelin-contracts/',
23+
'tokenized-strategy/=lib/tokenized-strategy/src/',
24+
'superform-core/=lib/superform-core/',
25+
'ERC1155A/=lib/superform-core/lib/ERC1155A/src/',
26+
'pigeon/=lib/superform-core/lib/pigeon/src/',
27+
'solady/=lib/superform-core/lib/pigeon/lib/solady/',
2628
]
2729

30+
[profile.production]
31+
out = 'out' # separates optimized build folder (default profile) from localdev folder. Faster to build and deploy
32+
src = 'src'
33+
test = 'src'
34+
script = 'script'
35+
2836

2937
[fmt]
3038
bracket_spacing = true

src/SuperVault.sol

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.23;
33

4-
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
5-
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
6-
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7-
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
8-
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
9-
import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol";
10-
import { ISuperPositions } from "superform-core/interfaces/ISuperPositions.sol";
11-
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
4+
import { Address } from "openzeppelin/contracts/utils/Address.sol";
5+
import { Math } from "openzeppelin/contracts/utils/math/Math.sol";
6+
import { SafeERC20 } from "openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7+
import { ERC20 } from "openzeppelin/contracts/token/ERC20/ERC20.sol";
8+
import { IERC165 } from "openzeppelin/contracts/utils/introspection/IERC165.sol";
9+
import { IERC4626 } from "openzeppelin/contracts/interfaces/IERC4626.sol";
10+
import { IERC1155Receiver } from "openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
11+
import { SingleDirectMultiVaultStateReq, MultiVaultSFData, LiqRequest } from "superform-core/src/types/DataTypes.sol";
12+
import { ISuperPositions } from "superform-core/src/interfaces/ISuperPositions.sol";
13+
import { DataLib } from "superform-core/src/libraries/DataLib.sol";
14+
import { IBaseForm } from "superform-core/src/interfaces/IBaseForm.sol";
15+
import { IBaseRouter } from "superform-core/src/interfaces/IBaseRouter.sol";
16+
import { ISuperformRouterPlus } from "superform-core/src/interfaces/ISuperformRouterPlus.sol";
17+
import { ISuperRegistry } from "superform-core/src/interfaces/ISuperRegistry.sol";
1218
import { BaseStrategy } from "./vendor/BaseStrategy.sol";
13-
import { SingleDirectMultiVaultStateReq, MultiVaultSFData, LiqRequest } from "superform-core/types/DataTypes.sol";
14-
import { DataLib } from "superform-core/libraries/DataLib.sol";
15-
import { IBaseForm } from "superform-core/interfaces/IBaseForm.sol";
16-
import { IBaseRouter } from "superform-core/interfaces/IBaseRouter.sol";
17-
import { ISuperformRouterPlus } from "superform-core/interfaces/ISuperformRouterPlus.sol";
18-
import { ISuperRegistry } from "superform-core/interfaces/ISuperRegistry.sol";
1919

2020
contract SuperVault is BaseStrategy, IERC1155Receiver {
2121
using Math for uint256;
@@ -112,6 +112,10 @@ contract SuperVault is BaseStrategy, IERC1155Receiver {
112112
//////////////////////////////////////////////////////////////
113113
// EXTERNAL FUNCTIONS //
114114
//////////////////////////////////////////////////////////////
115+
// 3 superformsIds in this vault
116+
// 2 rebalanceFrom
117+
// 1 rebalanceTo
118+
// 1000 USDC
115119

116120
function rebalance(
117121
uint256[] memory superformIdsRebalanceFrom,

src/vendor/BaseStrategy.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: AGPL-3.0
22
pragma solidity >=0.8.18;
33

4-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
4+
import { ERC20 } from "openzeppelin/contracts/token/ERC20/ERC20.sol";
55

66
// TokenizedStrategy interface used for internal view delegateCalls.
7-
import {ITokenizedStrategy} from "tokenized-strategy/interfaces/ITokenizedStrategy.sol";
7+
import { ITokenizedStrategy } from "tokenized-strategy/interfaces/ITokenizedStrategy.sol";
88

99
/**
1010
* @title YearnV3 Base Strategy
@@ -246,7 +246,7 @@ abstract contract BaseStrategy {
246246
*
247247
* @param _totalIdle The current amount of idle funds that are available to deploy.
248248
*/
249-
function _tend(uint256 _totalIdle) internal virtual {}
249+
function _tend(uint256 _totalIdle) internal virtual { }
250250

251251
/**
252252
* @dev Optional trigger to override if tend() will be used by the strategy.
@@ -341,7 +341,7 @@ abstract contract BaseStrategy {
341341
*
342342
* @param _amount The amount of asset to attempt to free.
343343
*/
344-
function _emergencyWithdraw(uint256 _amount) internal virtual {}
344+
function _emergencyWithdraw(uint256 _amount) internal virtual { }
345345

346346
/*//////////////////////////////////////////////////////////////
347347
TokenizedStrategy HOOKS

src/vendor/TokenizedStrategy.sol

+46-14
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ pragma solidity >=0.8.18;
4848
* $$$$$$$$$$$$$$$$$$$$$$$$$%zt-+>iiiiiiiiiiiiiiiiiiiiiiiiiiiii+_tc%$$$$$$$$$$$$$$$$$$$$$$$$$
4949
* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$W#u/|{+~>iiiiiiiiiiii><+{|/n#W$$$$$$$$$$$$$$$$$$$$$$$$$$$$
5050
*/
51-
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
52-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
53-
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
51+
import { Math } from "openzeppelin/contracts/utils/math/Math.sol";
52+
import { ERC20 } from "openzeppelin/contracts/token/ERC20/ERC20.sol";
53+
import { SafeERC20 } from "openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5454

55-
import {IFactory} from "tokenized-strategy/interfaces/IFactory.sol";
56-
import {IBaseStrategy} from "tokenized-strategy/interfaces/IBaseStrategy.sol";
55+
import { IFactory } from "tokenized-strategy/interfaces/IFactory.sol";
56+
import { IBaseStrategy } from "tokenized-strategy/interfaces/IBaseStrategy.sol";
5757

5858
/**
5959
* @title Yearn Tokenized Strategy
@@ -193,7 +193,8 @@ contract TokenizedStrategy {
193193
bytes32 INITIAL_DOMAIN_SEPARATOR; // The domain separator used for permits on the initial chain.
194194
mapping(address => uint256) nonces; // Mapping of nonces used for permit functions.
195195
mapping(address => uint256) balances; // Mapping to track current balances for each account that holds shares.
196-
mapping(address => mapping(address => uint256)) allowances; // Mapping to track the allowances for the strategies shares.
196+
mapping(address => mapping(address => uint256)) allowances; // Mapping to track the allowances for the
197+
// strategies shares.
197198
// We manually track `totalAssets` to prevent PPS manipulation through airdrops.
198199
uint256 totalAssets;
199200
// Variables for profit reporting and locking.
@@ -318,7 +319,7 @@ contract TokenizedStrategy {
318319
uint8 internal constant NOT_ENTERED = 1;
319320

320321
/// @notice Maximum in Basis Points the Performance Fee can be set to.
321-
uint16 public constant MAX_FEE = 5_000; // 50%
322+
uint16 public constant MAX_FEE = 5000; // 50%
322323

323324
/// @notice Used for fee calculations.
324325
uint256 internal constant MAX_BPS = 10_000;
@@ -402,7 +403,9 @@ contract TokenizedStrategy {
402403
address _management,
403404
address _performanceFeeRecipient,
404405
address _keeper
405-
) external {
406+
)
407+
external
408+
{
406409
// Cache storage pointer.
407410
StrategyData storage S = _strategyStorage();
408411

@@ -508,7 +511,12 @@ contract TokenizedStrategy {
508511
* @param maxLoss The amount of acceptable loss in Basis points.
509512
* @return shares The actual amount of shares burnt.
510513
*/
511-
function withdraw(uint256 assets, address receiver, address owner, uint256 maxLoss)
514+
function withdraw(
515+
uint256 assets,
516+
address receiver,
517+
address owner,
518+
uint256 maxLoss
519+
)
512520
public
513521
nonReentrant
514522
returns (uint256 shares)
@@ -547,7 +555,12 @@ contract TokenizedStrategy {
547555
* @param maxLoss The amount of acceptable loss in Basis points.
548556
* @return . The actual amount of underlying withdrawn.
549557
*/
550-
function redeem(uint256 shares, address receiver, address owner, uint256 maxLoss)
558+
function redeem(
559+
uint256 shares,
560+
address receiver,
561+
address owner,
562+
uint256 maxLoss
563+
)
551564
public
552565
nonReentrant
553566
returns (uint256)
@@ -735,7 +748,11 @@ contract TokenizedStrategy {
735748
}
736749

737750
/// @dev Internal implementation of {convertToShares}.
738-
function _convertToShares(StrategyData storage S, uint256 assets, Math.Rounding _rounding)
751+
function _convertToShares(
752+
StrategyData storage S,
753+
uint256 assets,
754+
Math.Rounding _rounding
755+
)
739756
internal
740757
view
741758
returns (uint256)
@@ -751,7 +768,11 @@ contract TokenizedStrategy {
751768
}
752769

753770
/// @dev Internal implementation of {convertToAssets}.
754-
function _convertToAssets(StrategyData storage S, uint256 shares, Math.Rounding _rounding)
771+
function _convertToAssets(
772+
StrategyData storage S,
773+
uint256 shares,
774+
Math.Rounding _rounding
775+
)
755776
internal
756777
view
757778
returns (uint256)
@@ -863,7 +884,10 @@ contract TokenizedStrategy {
863884
uint256 assets,
864885
uint256 shares,
865886
uint256 maxLoss
866-
) internal returns (uint256) {
887+
)
888+
internal
889+
returns (uint256)
890+
{
867891
require(receiver != address(0), "ZERO ADDRESS");
868892
require(maxLoss <= MAX_BPS, "exceeds MAX_BPS");
869893

@@ -1746,7 +1770,15 @@ contract TokenizedStrategy {
17461770
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
17471771
* section].
17481772
*/
1749-
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
1773+
function permit(
1774+
address owner,
1775+
address spender,
1776+
uint256 value,
1777+
uint256 deadline,
1778+
uint8 v,
1779+
bytes32 r,
1780+
bytes32 s
1781+
)
17501782
external
17511783
{
17521784
require(deadline >= block.timestamp, "ERC20: PERMIT_DEADLINE_EXPIRED");

0 commit comments

Comments
 (0)