From 4db5f58a2e85e6c54cf389ffed48e47ea2a88486 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Thu, 25 Jan 2024 15:40:18 -0700 Subject: [PATCH] fix: transfer to specific address --- src/Auctions/Auction.sol | 19 +++++++++++++++++-- src/swappers/AuctionSwapper.sol | 3 +-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Auctions/Auction.sol b/src/Auctions/Auction.sol index 56107d1..e5d1d9e 100644 --- a/src/Auctions/Auction.sol +++ b/src/Auctions/Auction.sol @@ -46,6 +46,7 @@ contract Auction is Governance { uint256 initialAvailable; uint256 currentAvailable; uint256 minimumPrice; + address receiver; bool active; } @@ -196,7 +197,16 @@ contract Auction is Governance { address _from, address _to, uint256 _minimumPrice - ) external virtual onlyGovernance returns (bytes32 _auctionId) { + ) external virtual returns (bytes32) { + return enableAuction(_from, _to, _minimumPrice, governance); + } + + function enableAuction( + address _from, + address _to, + uint256 _minimumPrice, + address _receiver + ) public virtual onlyGovernance returns (bytes32 _auctionId) { require(_from != address(0) && _to != address(0), "ZERO ADDRESS"); require(_from != address(this) && _to != address(this), "SELF"); @@ -212,6 +222,7 @@ contract Auction is Governance { initialAvailable: 0, currentAvailable: 0, minimumPrice: _minimumPrice, + receiver: address, active: true }); @@ -306,7 +317,11 @@ contract Auction is Governance { auctions[_id].currentAvailable = left; // Pull token in. - ERC20(auction.toToken).transferFrom(msg.sender, address(this), needed); + ERC20(auction.toToken).transferFrom( + msg.sender, + auction.receiver, + needed + ); // Transfer from token out. ERC20(auction.fromToken).transfer(_receiver, _amountTaken); diff --git a/src/swappers/AuctionSwapper.sol b/src/swappers/AuctionSwapper.sol index ad4b2ef..5978d49 100644 --- a/src/swappers/AuctionSwapper.sol +++ b/src/swappers/AuctionSwapper.sol @@ -43,7 +43,7 @@ contract AuctionSwapper { auction = _auction; } // Enable new auction. - Auction(_auction).enableAuction(_from, _to, _minimumPrice); + Auction(_auction).enableAuction(_from, _to, _minimumPrice, receiver); } function _disableAuction(address _from, address _to) internal virtual { @@ -76,7 +76,6 @@ contract AuctionSwapper { address _token, uint256 _newAmount ) external virtual onlyAuction { - ERC20(_token).transferFrom(auction, address(this), _newAmount); _postTake(_token, _newAmount); }