diff --git a/src/OpenRDA.sol b/src/OpenRDA.sol index 7b78730..c1cf147 100644 --- a/src/OpenRDA.sol +++ b/src/OpenRDA.sol @@ -13,11 +13,15 @@ interface RDAEvents { event AuctionEnds(bytes32 indexed id); } +struct AuctionTokens { + address redeemToken; + address swapToken; +} + contract OpenRDA is RDA, RDAEvents { using SafeERC20 for IERC20; - address redeemToken; - address swapToken; + mapping(bytes32 => AuctionTokens) private auctionTokens; constructor() RDA() {} @@ -28,13 +32,13 @@ contract OpenRDA is RDA, RDAEvents { function begin( bytes32 id, uint256 amountToCollect, - address swapToken_, + address swapToken, uint256 amountToDistribute, - address redeemToken_ + address redeemToken ) external onlyOwner { _begin(id, amountToCollect, amountToDistribute); - redeemToken = redeemToken_; - swapToken = swapToken_; + auctionTokens[id].redeemToken = redeemToken; + auctionTokens[id].swapToken = swapToken; IERC20(redeemToken).safeTransferFrom(msg.sender, address(this), amountToDistribute); emit AuctionBegins(id, block.number); } @@ -55,13 +59,15 @@ contract OpenRDA is RDA, RDAEvents { if (autoClose) _close(id); - IERC20(swapToken).safeTransferFrom(msg.sender, address(this), bid.toSwap); - IERC20(redeemToken).safeTransfer(msg.sender, bid.toRedeem); + AuctionTokens memory tokens = auctionTokens[id]; + + IERC20(tokens.swapToken).safeTransferFrom(msg.sender, address(this), bid.toSwap); + IERC20(tokens.redeemToken).safeTransfer(msg.sender, bid.toRedeem); if (autoClose) { - IERC20(swapToken).safeTransfer(owner(), auction.stats.collected); + IERC20(tokens.swapToken).safeTransfer(owner(), auction.stats.collected); if (toDistribute > 0) { - IERC20(redeemToken).safeTransfer(owner(), toDistribute); + IERC20(tokens.redeemToken).safeTransfer(owner(), toDistribute); } emit AuctionEnds(id); } diff --git a/src/RDABase.sol b/src/RDABase.sol index 6b7e14d..672c1cf 100644 --- a/src/RDABase.sol +++ b/src/RDABase.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.20; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; -import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {RDAMathLib} from "src/RDAMathLib.sol";