Skip to content

Commit

Permalink
chore: add natspec comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xp3th1um committed Feb 10, 2025
1 parent 8cffeb8 commit 81f1899
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/DssBlow2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,73 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.24;

interface ERC20Like {
function balanceOf(address) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function approve(address usr, uint256 wad) external returns (bool);
}

interface DaiJoinLike {
function dai() external view returns (address);
function join(address, uint256) external;
function join(address usr, uint256 wad) external;
}

interface UsdsJoinLike is DaiJoinLike {
function usds() external view returns (address);
}

/// @title DssBlow2
/// @notice This contract acts as a bridge to incorporate any available Dai or USDS
/// balances into the protocol's Surplus Buffer by invoking the appropriate join adapters.
/// @dev The contract automatically approves the maximum token amount for both join adapters during construction.
contract DssBlow2 {
/// @notice The address of the Vow contract that receives tokens.
address public immutable vow;

/// @notice The ERC20 token representing Dai.
ERC20Like public immutable dai;

/// @notice The ERC20 token representing USDS.
ERC20Like public immutable usds;

/// @notice The adapter for joining Dai into the protocol.
DaiJoinLike public immutable daiJoin;

/// @notice The adapter for joining USDS into the protocol.
UsdsJoinLike public immutable usdsJoin;

/// @notice Emitted when tokens are transferred into the protocol.
/// @param token The address of the token (Dai or USDS) that was transferred.
/// @param amount The amount of tokens that was transferred.
event Blow(address indexed token, uint256 amount);

/// @notice Initializes the DssBlow2 contract.
/// @param daiJoin_ The address of the DaiJoin contract.
/// @param usdsJoin_ The address of the UsdsJoin contract.
/// @param vow_ The address of the Vow contract.
constructor(address daiJoin_, address usdsJoin_, address vow_) {
daiJoin = DaiJoinLike(daiJoin_);
dai = ERC20Like(daiJoin.dai());
usdsJoin = UsdsJoinLike(usdsJoin_);
usds = ERC20Like(usdsJoin.usds());
vow = vow_;

// Approve the maximum uint256 amount for both join adapters.
dai.approve(daiJoin_, type(uint256).max);
usds.approve(usdsJoin_, type(uint256).max);
}

/// @notice Transfers any available Dai and USDS balances from this contract to the protocol's Surplus Buffer.
/// @dev For each token, if the balance is greater than zero, the respective join adapter's join function is called.
function blow() public {
uint256 daiBalance = dai.balanceOf(address(this));
if (daiBalance > 0) {
daiJoin.join(vow, daiBalance);
emit Blow(address(dai), daiBalance);
}

uint256 usdsBalance = usds.balanceOf(address(this));
if (usdsBalance > 0) {
usdsJoin.join(vow, usdsBalance);
Expand Down

0 comments on commit 81f1899

Please sign in to comment.