diff --git a/nest/src/token/BoringVaultAdapter.sol b/nest/src/token/BoringVaultAdapter.sol index a039969..ead4d21 100644 --- a/nest/src/token/BoringVaultAdapter.sol +++ b/nest/src/token/BoringVaultAdapter.sol @@ -138,6 +138,16 @@ abstract contract BoringVaultAdapter is $.asset = asset_; $.version = 1; // Set initial version + + // Set approvals for the underlying asset + SafeERC20.forceApprove(asset_, vault_, type(uint256).max); + SafeERC20.forceApprove(asset_, teller_, type(uint256).max); + SafeERC20.forceApprove(asset_, atomicQueue_, type(uint256).max); + + // Set approvals for the pUSD token itself + _approve(address(this), vault_, type(uint256).max); + _approve(address(this), teller_, type(uint256).max); + _approve(address(this), atomicQueue_, type(uint256).max); } function reinitialize( @@ -148,7 +158,7 @@ abstract contract BoringVaultAdapter is address atomicQueue_, address lens_, address accountant_ - ) public onlyRole(UPGRADER_ROLE) { + ) public virtual onlyRole(UPGRADER_ROLE) { // Reinitialize as needed if ( owner == address(0) || address(asset_) == address(0) || vault_ == address(0) || teller_ == address(0) @@ -167,6 +177,16 @@ abstract contract BoringVaultAdapter is $.boringVault.lens = ILens(lens_); $.boringVault.accountant = IAccountantWithRateProviders(accountant_); + // Set approvals for the underlying asset + SafeERC20.forceApprove(asset_, vault_, type(uint256).max); + SafeERC20.forceApprove(asset_, teller_, type(uint256).max); + SafeERC20.forceApprove(asset_, atomicQueue_, type(uint256).max); + + // Set approvals for the pUSD token itself + _approve(address(this), vault_, type(uint256).max); + _approve(address(this), teller_, type(uint256).max); + _approve(address(this), atomicQueue_, type(uint256).max); + emit Reinitialized($.version); } diff --git a/nest/test/pUSDPlume.t.sol b/nest/test/pUSDPlume.t.sol index c93bbcf..6e2fbf9 100644 --- a/nest/test/pUSDPlume.t.sol +++ b/nest/test/pUSDPlume.t.sol @@ -97,21 +97,6 @@ contract pUSDPlumeTest is Test { vm.startPrank(user1); - // Approve both token and vault - asset.approve(address(token), type(uint256).max); - asset.approve(address(vault), type(uint256).max); - asset.approve(TELLER_ADDRESS, type(uint256).max); - - // Additional approval needed for the vault to transfer from pUSD - vm.stopPrank(); - - // Add approval from pUSD to vault - vm.startPrank(address(token)); - asset.approve(address(vault), type(uint256).max); - vm.stopPrank(); - - vm.startPrank(user1); - console.log("Asset balance before deposit:", asset.balanceOf(user1)); console.log("Asset allowance for token:", asset.allowance(user1, address(token))); console.log("Asset allowance for vault:", asset.allowance(user1, address(vault)));