Skip to content

Commit

Permalink
Basic action exit deltaDebt fix (#674)
Browse files Browse the repository at this point in the history
* fixed issue with basic actions exiting deltaDebt instead of DelatWad.  add .nvmrc to the gitignore because I'm sure I'm the only one using that file.

* linted
  • Loading branch information
MrDeadCe11 authored May 3, 2024
1 parent c14764f commit 58b698e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
yarn-error.log
node_modules
.DS_STORE
.nvmrc

# Foundry files
cache
Expand All @@ -21,6 +22,7 @@ lcov.info
!/**/.gitkeep
.vscode/


# Docs build files
docs/book
docs/src/src/
Expand Down
36 changes: 36 additions & 0 deletions script/mainnet/GenerateDebt.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {MainnetScripts} from '@script/mainnet/MainnetScripts.s.sol';
import {BasicActions} from '@contracts/proxies/actions/BasicActions.sol';
import {WSTETH, ARB, RETH} from '@script/MainnetParams.s.sol';
import {IERC20} from '@openzeppelin/token/ERC20/IERC20.sol';
import 'forge-std/console2.sol';
// ANVIL
// source .env && anvil --rpc-url $ARB_MAINNET_RPC
// source .env && forge script TestGenerate --with-gas-price 2000000000 -vvvvv --rpc-url $ANVIL_RPC --unlocked

contract TestGenerate is MainnetScripts {
function run() public {
vm.startBroadcast(USER1);
address proxy = address(deployOrFind(USER1));
basicActions = new BasicActions();

//open safe one
uint256 safeId = openSafe(RETH, proxy);
IERC20(_reth_Address).approve(proxy, type(uint256).max);
depositCollatAndGenDebt(RETH, safeId, 10 ether, 1000 ether, proxy);
// open safe 2 to get more OD
// uint256 safeId2 = openSafe(RETH, proxy);
// depositCollatAndGenDebt(RETH, safeId2, 150 ether, 200 ether, proxy);
uint256 balance = systemCoin.balanceOf(USER1);
console2.log('Ending balance: ', balance);
// assert(balance == 200 ether);

vm.stopBroadcast();
}
}

/**
* 0xEff45E8e2353893BD0558bD5892A42786E9142F1::modifySAFECollateralization(0x5245544800000000000000000000000000000000000000000000000000000000, SAFEHandler: [0xD79b87bc3EB61B086d647c42EA7c1d70952c0c50], SAFEHandler: [0xD79b87bc3EB61B086d647c42EA7c1d70952c0c50], SAFEHandler: [0xD79b87bc3EB61B086d647c42EA7c1d70952c0c50], 0, -199987022715481439548 [-1.999e20])
*/
2 changes: 1 addition & 1 deletion script/mainnet/MainnetScripts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ contract MainnetScripts is MainnetDeployment, Script, Test {
bytes memory payload = abi.encodeWithSelector(basicActions.openSAFE.selector, address(safeManager), _cType, _proxy);
bytes memory _safeData = ODProxy(_proxy).execute(address(basicActions), payload);
_safeId = abi.decode(_safeData, (uint256));
console2.log(IERC20(_reth_Address).balanceOf(USER1));
console2.log('RETH BALANCE USER!: ', IERC20(_reth_Address).balanceOf(USER1));
}

function depositCollatAndGenDebt(
Expand Down
6 changes: 2 additions & 4 deletions src/contracts/proxies/actions/BasicActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ contract BasicActions is CommonActions, IBasicActions {
_modifySAFECollateralization(_manager, _safeId, 0, deltaDebt, false);

// Moves the COIN amount to user's address
// deltaDebt should always be positive, but we use SafeCast as an extra guard
_collectAndExitCoins(_manager, _coinJoin, _safeId, deltaDebt.toUint256());
_collectAndExitCoins(_manager, _coinJoin, _safeId, _deltaWad);
}

/**
Expand Down Expand Up @@ -170,8 +169,7 @@ contract BasicActions is CommonActions, IBasicActions {
_modifySAFECollateralization(_manager, _safeId, _collateralAmount.toInt(), deltaDebt, false);

// Exits and transfers COIN amount to the user's address
// deltaDebt should always be positive, but we use SafeCast as an extra guard
_collectAndExitCoins(_manager, _coinJoin, _safeId, deltaDebt.toUint256());
_collectAndExitCoins(_manager, _coinJoin, _safeId, _deltaWad);
}

/**
Expand Down

0 comments on commit 58b698e

Please sign in to comment.