Skip to content

Instantly share code, notes, and snippets.

@TheSavageTeddy
Created April 21, 2024 08:31
Show Gist options
  • Save TheSavageTeddy/f5756c1505477380ea61aa2a652c995b to your computer and use it in GitHub Desktop.
Save TheSavageTeddy/f5756c1505477380ea61aa2a652c995b to your computer and use it in GitHub Desktop.
DYAD - cant add kerosine vault POC
// SPDX-License-Identifier: MIT
pragma solidity =0.8.17;
import "forge-std/console.sol";
import "forge-std/Test.sol";
import {DeployV2, Contracts} from "../../script/deploy/Deploy.V2.s.sol";
import {Licenser} from "../../src/core/Licenser.sol";
import {Parameters} from "../../src/params/Parameters.sol";
import "../../src/core/Vault.kerosine.unbounded.sol";
import {VaultManagerTestHelper} from "../VaultManagerHelper.t.sol";
import {DNft} from "../../src/core/DNft.sol";
interface IERC20Minimal {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract V2Test is Test, Parameters {
Contracts contracts;
function setUp() public {
// deploy the new contracts
contracts = new DeployV2().run();
}
error VaultNotLicensed();
function testAddKerosineVault() public {
// license the new vaults
vm.prank(contracts.vaultLicenser.owner());
contracts.vaultLicenser.add(address(contracts.wstEth));
// create DNFT for myself
DNft dNft = DNft(MAINNET_DNFT);
uint id = dNft.mintNft{value: 1 ether}(address(this));
// add new wstETH vault to my dNFT position
contracts.vaultManager.add(id, address(contracts.wstEth));
// try to add unbounded kerosine vault to my dNFT position
// reverts since the vault is not licensed by keroseneManager
vm.expectRevert(VaultNotLicensed.selector);
contracts.vaultManager.addKerosene(id, address(contracts.unboundedKerosineVault));
// license the kerosene vault by kerosene manager,
// which we are not supposed to do since kerosene manager
// should only license non-kerosene vaults
vm.prank(contracts.kerosineManager.owner());
contracts.kerosineManager.add(address(contracts.unboundedKerosineVault));
// now we can add kerosene vault
contracts.vaultManager.addKerosene(id, address(contracts.unboundedKerosineVault));
// however, this bricks the unbounded kerosine vault as it is missing the
// variable `oracle`.
// adding kerosine vault to kerosine manager is definetly not a solution, as
// the TVL used in kerosine price calculation must not contain the TVL of kerosine
vm.expectRevert();
contracts.unboundedKerosineVault.assetPrice();
}
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external pure returns (bytes4) {
return 0x150b7a02;
}
receive() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment