Skip to content

Commit

Permalink
fix tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
killroy192 committed Mar 8, 2024
1 parent 8f8a0a1 commit 01fc779
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
26 changes: 16 additions & 10 deletions src/OpenRDA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/RDABase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 01fc779

Please sign in to comment.