diff --git a/src/DelegatedVesting.sol b/src/DelegatedVesting.sol index 5bffc81..e4300ea 100755 --- a/src/DelegatedVesting.sol +++ b/src/DelegatedVesting.sol @@ -1,8 +1,8 @@ pragma solidity 0.8.0; -import "./interfaces/IERC20.sol"; -import "./interfaces/IStaking.sol"; -import "./interfaces/IGovernance.sol"; +import "@openzeppelin/token/ERC20/IERC20.sol"; +import "@interfaces/IStaking.sol"; +import "@interfaces/IGovernance.sol"; contract DelegatedInstance { diff --git a/src/LiquidityManagement.sol b/src/LiquidityManagement.sol index db46f4b..e621b96 100755 --- a/src/LiquidityManagement.sol +++ b/src/LiquidityManagement.sol @@ -1,83 +1,79 @@ pragma solidity 0.8.0; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; - -// https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02 -// https://github.com/Uniswap/v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol -import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; +import "@openzeppelin/token/ERC20/IERC20.sol"; +import "@interfaces/IUniswapV2Router02.sol"; contract LiquidityManagement { + + address constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F; + address constant TORN_ADDRESS = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C; + address constant ETH_TORN_ADDRESS = 0x0C722a487876989Af8a05FFfB6e32e45cc23FB3A; + address constant DAI_TORN_ADDRESS = 0xb9C6f39dB4e81DB44Cf057C7D4d8e3193745101E; + address constant UNIV2_ROUTER02_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; + address constant TORN_TREASURY = 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce; - address constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F; - address constant TORN_ADDRESS = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C; - address constant ETH_TORN_ADDRESS = 0x0C722a487876989Af8a05FFfB6e32e45cc23FB3A; - address constant DAI_TORN_ADDRESS = 0xb9C6f39dB4e81DB44Cf057C7D4d8e3193745101E; - address constant UNIV2_ROUTER02_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; - address constant TORN_TREASURY = 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce; + IERC20 DAI; + IERC20 TORN; + IERC20 UNIV2_DAI_TORN; + IERC20 UNIV2_ETH_TORN; + IUniswapV2Router02 UNIV2_ROUTER; - IERC20 DAI; - IERC20 TORN; - IERC20 UNIV2_DAI_TORN; - IERC20 UNIV2_ETH_TORN; - IUniswapV2Router02 UNIV2_ROUTER; + constructor() public { + IERC20 DAI = IERC20(DAI_ADDRESS); + IERC20 TORN = IERC20(TORN_ADDRESS); + IERC20 UNIV2_DAI_TORN = IERC20(DAI_TORN_ADDRESS); + IERC20 UNIV2_ETH_TORN = IERC20(ETH_TORN_ADDRESS); + IUniswapV2Router02 UNIV2_ROUTER = IUniswapV2Router02(UNIV2_ROUTER02_ADDRESS); + } - constructor() { - IERC20 DAI = IERC20(DAI_ADDRESS); - IERC20 TORN = IERC20(TORN_ADDRESS); - IERC20 UNIV2_DAI_TORN = IERC20(DAI_TORN_ADDRESS); - IERC20 UNIV2_ETH_TORN = IERC20(ETH_TORN_ADDRESS); - IUniswapV2Router02 UNIV2_ROUTER = IUniswapV2Router02(UNIV2_ROUTER02_ADDRESS); - } + // Add liquidity to the DAI/TORN and ETH/TORN pools + function addLiquidityAndWithdrawToTreasury( + uint256 amountETH, + uint256 amountDAI, + uint256 amountTORN, + uint256 slippageETH, + uint256 slippageTORN, + uint256 slippageDAI + ) public returns (bool) { + // transfer tokens from the user to the contract + require(DAI.transferFrom(msg.sender, address(this), amountDAI)); + require(TORN.transferFrom(msg.sender, address(this), amountTORN)); + require(msg.value == amountETH); - // Add liquidity to the DAI/TORN and ETH/TORN pools - function addLiquidityAndWithdrawToTreasury( - uint256 amountETH, - uint256 amountDAI, - uint256 amountTORN, - uint256 slippageETH, - uint256 slippageTORN, - uint256 slippageDAI - ) public returns (bool) { - // transfer tokens from the user to the contract - require(DAI.transferFrom(msg.sender, address(this), amountDAI)); - require(TORN.transferFrom(msg.sender, address(this), amountTORN)); - require(msg.value == amountETH); + // deadline for the transaction to be mined (10 minutes) + uint256 deploymentDeadline = block.timestamp + 10 minutes; + // Split the TORN amount in half for the two liquidity pools + uint256 amountSeedTORN = amountTORN / 2; + // configure slippage + uint256 minimumAmountDAI = amountDAI - slippageDAI; + uint256 minimumAmountETH = amountETH - slippageETH; + uint256 minimumAmountTORN = amountSeedTORN - slippageTORN; - // deadline for the transaction to be mined (10 minutes) - uint256 deploymentDeadline = block.timestamp + 10 minutes; - // Split the TORN amount in half for the two liquidity pools - uint256 amountSeedTORN = amountTORN / 2; - // configure slippage - uint256 minimumAmountDAI = amountDAI - slippageDAI; - uint256 minimumAmountETH = amountETH - slippageETH; - uint256 minimumAmountTORN = amountSeedTORN - slippageTORN; + // DAI/TORN + DAI.approve(UNIV2_ROUTER02_ADDRESS, amountDAI); + UNIV2_ROUTER.addLiquidity( + DAI_ADDRESS, // tokenA address + TORN_ADDRESS, // tokenB address + amountDAI, // tokenA amount + amountSeedTORN, // tokenB amount + minimumAmountDAI, // minimum tokenA amount + minimumAmountTORN, // minimum tokenB amount + TORN_TREASURY, // to + deploymentDeadline, // deadline + ); + // ETH/TORN + TORN.approve(UNIV2_ROUTER02_ADDRESS, amountTORN); + UNIV2_ROUTER.addLiquidityETH( + TORN_ADDRESS, // token address + amountSeedTORN, // token amount + minimumAmountTORN, // minimum token amount + minimumAmountETH, // minimum eth amount + TORN_TREASURY, // to + deploymentDeadline, // deadline + ); - // DAI/TORN - DAI.approve(UNIV2_ROUTER02_ADDRESS, amountDAI); - UNIV2_ROUTER.addLiquidity( - DAI_ADDRESS, // tokenA address - TORN_ADDRESS, // tokenB address - amountDAI, // tokenA amount - amountSeedTORN, // tokenB amount - minimumAmountDAI, // minimum tokenA amount - minimumAmountTORN, // minimum tokenB amount - TORN_TREASURY, // to - deploymentDeadline, // deadline - ); - - // ETH/TORN - TORN.approve(UNIV2_ROUTER02_ADDRESS, amountTORN); - UNIV2_ROUTER.addLiquidityETH( - TORN_ADDRESS, // token address - amountSeedTORN, // token amount - minimumAmountTORN, // minimum token amount - minimumAmountETH, // minimum eth amount - TORN_TREASURY, // to - deploymentDeadline, // deadline - ); - - return true; - } - + return true; + } + } diff --git a/src/Proposal.sol b/src/Proposal.sol index 37be621..f075466 100644 --- a/src/Proposal.sol +++ b/src/Proposal.sol @@ -1,36 +1,36 @@ pragma solidity 0.8.0; -import "@root/interfaces/IERC20.sol"; -import "@root/interfaces/IRollingDutchAuction.sol"; +import "@openzeppelin/token/ERC20/IERC20.sol"; +import "@interfaces/IRDA.sol"; contract Proposal { function executeProposal() external { - uint256 AUCTION_START_TS = block.timestamp; - uint256 AUCTION_END_TS = AUCTION_START_TS + 1 week; - uint256 AUCTION_ORIGIN_PRICE = 4172000 gwei; - uint256 AUCTION_RESERVE_AMOUNT = 100000 ether; - uint256 AUCTION_MINIMUM_AMOUNT = 1 ether; - uint256 AUCTION_WINDOW_LENGTH = 8 hours; + uint256 AUCTION_START_TS = block.timestamp; + uint256 AUCTION_END_TS = AUCTION_START_TS + 1 week; + uint256 AUCTION_ORIGIN_PRICE = 4172000 gwei; + uint256 AUCTION_RESERVE_AMOUNT = 100000 ether; + uint256 AUCTION_MINIMUM_AMOUNT = 1 ether; + uint256 AUCTION_WINDOW_LENGTH = 8 hours; - address wethAddress; - address tokenAddress; - address governanceAddress; - address auctionAddress; - address vestingAddress; + address wethAddress; + address tokenAddress; + address governanceAddress; + address auctionAddress; + address vestingAddress; - IRollingDutchAuction(auctionAddress).createAuction( - vestingAddress, - governanceAddress, - tokenAddress, - wethAddress, - AUCTION_RESERVE_AMOUNT, - AUCTION_MINIMUM_AMOUNT, - AUCTION_ORIGIN_PRICE, - AUCTION_START_TS, - AUCTION_END_TS, - AUCTION_WINDOW_LENGTH - ); + IRDA(auctionAddress).createAuction( + vestingAddress, + governanceAddress, + tokenAddress, + wethAddress, + AUCTION_RESERVE_AMOUNT, + AUCTION_MINIMUM_AMOUNT, + AUCTION_ORIGIN_PRICE, + AUCTION_START_TS, + AUCTION_END_TS, + AUCTION_WINDOW_LENGTH + ); } } diff --git a/src/RollingDutchAuction.sol b/src/RDA.sol similarity index 75% rename from src/RollingDutchAuction.sol rename to src/RDA.sol index 7712b6d..0554ba5 100755 --- a/src/RollingDutchAuction.sol +++ b/src/RDA.sol @@ -1,18 +1,20 @@ pragma solidity 0.8.13; import { UD60x18 } from "@prb/math/UD60x18.sol"; -import { IERC20 } from "@root/interfaces/IERC20.sol"; -import { IVesting } from "@root/interfaces/IVesting.sol"; -import { inv, add, sub, mul, exp, ln, wrap, unwrap, gte, mod, div } from "@prb/math/UD60x18.sol"; +import { IRDA } from "@interfaces/IRDA.sol"; +import { IVesting } from "@interfaces/IVesting.sol"; +import { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol"; + +import { add, sub, mul, wrap, unwrap, gt, mod, div } from "@prb/math/UD60x18.sol"; /* - * @title Rolling Dutch Auction - * @author Samuel JJ Gosling - * @description A dutch auction derivative with composite logarithimic decay + * @title Rolling Dutch Auction (RDA) + * @author Samuel JJ Gosling (@deomaius) + * @description A dutch auction derivative with composite decay */ -contract RollingDutchAuction { +contract RDA is IRDA { /* @dev Address mapping for an auction's redeemable balances */ mapping(address => mapping(bytes => bytes)) public _claims; @@ -27,11 +29,10 @@ contract RollingDutchAuction { mapping(bytes => uint256) public _windows; struct Auction { - address vestingAddress; uint256 windowDuration; /* @dev Unix time window duration */ uint256 windowTimestamp; /* @dev Unix timestamp for window start */ uint256 startTimestamp; /* @dev Unix auction start timestamp */ - uint256 endTimestamp; /* @dev Unix auction end timestamp */ + uint256 endTimestamp; /* @dev Unix auction end timestamp */ uint256 duration; /* @dev Unix time auction duration */ uint256 proceeds; /* @dev Auction proceeds balance */ uint256 reserves; /* @dev Auction reserves balance */ @@ -126,7 +127,7 @@ contract RollingDutchAuction { uint256 startTimestamp, uint256 endTimestamp, uint256 windowDuration - ) public returns (bytes memory) { + ) external returns (bytes memory) { bytes memory auctionId = abi.encode( operatorAddress, reserveToken, @@ -137,18 +138,20 @@ contract RollingDutchAuction { Auction storage state = _auctions[auctionId]; - require(state.price == 0, "AUCTION EXISTS"); + if (state.price != 0) { + revert AuctionExists(); + } IERC20(reserveToken).transferFrom(msg.sender, address(this), reserveAmount); - state.vestingAddress = vestingAddress; state.duration = endTimestamp - startTimestamp; state.windowDuration = windowDuration; state.windowTimestamp = startTimestamp; state.startTimestamp = startTimestamp; state.endTimestamp = endTimestamp; - state.price = startingOriginPrice; state.reserves = reserveAmount; + state.price = startingOriginPrice; + state.vesting = vestingAddress; emit NewAuction(auctionId, reserveToken, reserveAmount, startingOriginPrice, endTimestamp); @@ -163,46 +166,40 @@ contract RollingDutchAuction { (,,, minimumAmount,) = abi.decode(auctionId, (address, address, address, uint256, bytes)); } - /* - * @dev Helper to view an auction's maximum order reserve amount - * @param a͟u͟c͟t͟i͟o͟n͟I͟d͟ Encoded auction parameter identifier - */ - function maximumPurchase(bytes memory auctionId) public view returns (uint256) { - return unwrap(inv(scalarPrice(auctionId))); - } - /* * @dev Helper to view an auction's active scalar price formatted to uint256 * @param a͟u͟c͟t͟i͟o͟n͟I͟d͟ Encoded auction parameter identifier */ - function scalarPriceUint(bytes memory auctionId) public view returns (uint256) { + function scalarPriceUint(bytes calldata auctionId) external returns (uint256) { return unwrap(scalarPrice(auctionId)); } /* - * @dev Active price decay following time delta (x) between the current - * timestamp and the window's start timestamp or if the window is expired; time - * delta between the window's expiration. Which is the applied as the exponent - * of Euler's number and subject to the natural logarithim. Finally applied as - * as a product to the origin price (y) and substracted from itself + * @dev Active price decay proportional to time delta (t) between the current + * timestamp and the window's start timestamp or if the window is expired; + * the window's expiration. Time remaining (t_r) since the predefined + * timestamp until the auctions conclusion, is subtracted from t and applied + * as modulo to t subject to addition of itself. The resultant is divided by t_r + * to compute elapsed progress (x) from the last timestamp, x is multipled by + * the origin price (y) and subtracted by y to result the decayed price * @param a͟u͟c͟t͟i͟o͟n͟I͟d͟ Encoded auction parameter identifier */ function scalarPrice(bytes memory auctionId) public view returns (UD60x18) { Auction storage state = _auctions[auctionId]; - Window storage w = _window[auctionId][_windows[auctionId]]; + Window storage window = _window[auctionId][_windows[auctionId]]; - bool isInitialised = w.expiry != 0; - bool isExpired = w.expiry < block.timestamp && isInitialised; + bool isInitialised = window.expiry != 0; + bool isExpired = window.expiry < block.timestamp && isInitialised; - uint256 timestamp = isExpired ? w.expiry : state.windowTimestamp; + uint256 timestamp = isExpired ? window.expiry : state.windowTimestamp; UD60x18 t = wrap(block.timestamp - timestamp); - UD60x18 t_r = wrap(state.endTimestamp - timestamp); + UD60x18 t_r = wrap(state.duration - elapsedTime(auctionId, timestamp)); UD60x18 x = div(add(t, mod(t, sub(t_r, t))), t_r); - UD60x18 y = !isInitialised ? wrap(state.price) : wrap(w.price); + UD60x18 y = !isInitialised ? wrap(state.price) : wrap(window.price); - return sub(y, mul(ln(exp(x)), y)); + return sub(y, mul(y, x)); } /* @@ -213,33 +210,40 @@ contract RollingDutchAuction { */ function commitBid(bytes memory auctionId, uint256 price, uint256 volume) activeAuction(auctionId) - public returns (bytes memory) { - Window storage w = _window[auctionId][_windows[auctionId]]; + external returns (bytes memory) { + Window storage window = _window[auctionId][_windows[auctionId]]; - require(minimumPurchase(auctionId) <= volume, "INSUFFICIENT VOLUME"); + if (volume < minimumPurchase(auctionId)) { + revert InvalidPurchaseVolume(); + } bool hasExpired; - if (w.expiry != 0) { + if (window.expiry != 0) { if (remainingWindowTime(auctionId) > 0) { - if (w.price < price) { - require(w.volume <= volume, "INSUFFICIENT WINDOW VOLUME"); + if (window.price < price) { + if (volume < window.volume) { + revert InvalidWindowVolume(); + } } else { - require(w.price < price, "INVALID WINDOW PRICE"); + revert InvalidWindowPrice(); } } else { hasExpired = true; } } - if (w.price == 0 || hasExpired) { - require(gte(wrap(price), scalarPrice(auctionId)), "INVALID CURVE PRICE"); + if (window.price == 0 || hasExpired) { + if (gt(scalarPrice(auctionId), wrap(price))) { + revert InvalidScalarPrice(); + } } IERC20(purchaseToken(auctionId)).transferFrom(msg.sender, address(this), volume); - require(_auctions[auctionId].reserves >= (volume / price), "INSUFFICIENT RESERVES"); - require(maximumPurchase(auctionId) >= (volume / price), "INVALID VOLUME"); + if (_auctions[auctionId].reserves < (volume / price)) { + revert InsufficientReserves(); + } bytes memory bidId = abi.encode(auctionId, msg.sender, price, volume); @@ -248,17 +252,17 @@ contract RollingDutchAuction { _claims[msg.sender][auctionId] = abi.encode(refund + volume, claim); if (hasExpired) { - w = _window[auctionId][windowExpiration(auctionId)]; + window = _window[auctionId][windowExpiration(auctionId)]; } _auctions[auctionId].windowTimestamp = block.timestamp; - w.expiry = block.timestamp + _auctions[auctionId].windowDuration; - w.volume = volume; - w.price = price; - w.bidId = bidId; + window.expiry = block.timestamp + _auctions[auctionId].windowDuration; + window.volume = volume; + window.price = price; + window.bidId = bidId; - emit Offer(auctionId, msg.sender, w.bidId, w.expiry); + emit Offer(auctionId, msg.sender, window.bidId, window.expiry); return bidId; } @@ -272,8 +276,6 @@ contract RollingDutchAuction { uint256 auctionElapsedTime = elapsedTime(auctionId, block.timestamp); uint256 auctionRemainingTime = _auctions[auctionId].duration - auctionElapsedTime; - bytes memory winningBidId = _window[auctionId][windowIndex].bidId; - _auctions[auctionId].endTimestamp = block.timestamp + auctionRemainingTime; _auctions[auctionId].price = _window[auctionId][windowIndex].price; @@ -281,7 +283,7 @@ contract RollingDutchAuction { fulfillWindow(auctionId, windowIndex); - emit Expiration(auctionId, winningBidId, windowIndex); + emit Expiration(auctionId, _window[auctionId][windowIndex].bidId, windowIndex); return windowIndex + 1; } @@ -291,24 +293,28 @@ contract RollingDutchAuction { * @param a͟u͟c͟t͟i͟o͟n͟I͟d͟ Encoded auction parameter identifier */ function fulfillWindow(bytes memory auctionId, uint256 windowId) public { - Window storage w = _window[auctionId][windowId]; + Window storage window = _window[auctionId][windowId]; - require(w.expiry < block.timestamp, "WINDOW UNEXPIRED"); - require(!w.processed, "WINDOW ALREADY FUFILLED"); + if (window.expiry > block.timestamp) { + revert WindowUnexpired(); + } + if (window.processed) { + revert WindowFulfilled(); + } - (, address bidder, uint256 price, uint256 volume) = abi.decode(w.bidId, (bytes, address, uint256, uint256)); + (, address bidder, uint256 price, uint256 volume) = abi.decode(window.bidId, (bytes, address, uint256, uint256)); (uint256 refund, uint256 claim) = balancesOf(_claims[bidder][auctionId]); delete _claims[bidder][auctionId]; - w.processed = true; + window.processed = true; _auctions[auctionId].reserves -= volume / price; _auctions[auctionId].proceeds += volume; _claims[bidder][auctionId] = abi.encode(refund - volume, claim + (volume / price)); - emit Fufillment(auctionId, w.bidId, windowId); + emit Fulfillment(auctionId, window.bidId, windowId); } /* @@ -332,10 +338,10 @@ contract RollingDutchAuction { function remainingWindowTime(bytes memory auctionId) public view returns (uint256) { uint256 expiryTimestamp = _window[auctionId][_windows[auctionId]].expiry; - if (expiryTimestamp == 0 || block.timestamp > expiryTimestamp) { - return 0; - } else { + if (expiryTimestamp > 0 && block.timestamp < expiryTimestamp) { return expiryTimestamp - block.timestamp; + } else { + return 0; } } @@ -345,9 +351,14 @@ contract RollingDutchAuction { */ function elapsedTime(bytes memory auctionId, uint256 timestamp) public view returns (uint256) { uint256 windowIndex = _windows[auctionId] + 1; + uint256 auctionElapsedTime = timestamp - _auctions[auctionId].startTimestamp; uint256 windowElapsedTime = _auctions[auctionId].windowDuration * windowIndex; - return timestamp - _auctions[auctionId].startTimestamp - windowElapsedTime; + if (auctionElapsedTime > windowElapsedTime) { + return auctionElapsedTime - windowElapsedTime; + } else { + return auctionElapsedTime; + } } /* @@ -356,7 +367,7 @@ contract RollingDutchAuction { */ function withdraw(bytes memory auctionId) inactiveAuction(auctionId) - public { + external { uint256 proceeds = _auctions[auctionId].proceeds; uint256 reserves = _auctions[auctionId].reserves; @@ -379,8 +390,9 @@ contract RollingDutchAuction { */ function redeem(address bidder, bytes memory auctionId) inactiveAuction(auctionId) - public { + external { bytes memory claimHash = _claims[bidder][auctionId]; + address vestingAddress = _auctions[auctionId].vesting; (uint256 refund, uint256 claim) = balancesOf(claimHash); @@ -390,23 +402,10 @@ contract RollingDutchAuction { IERC20(purchaseToken(auctionId)).transfer(bidder, refund); } if (claim > 0) { - IVesting(_auctions[auctionId].vestingAddress).makeCommitment(bidder, claim); + IVesting(vestingAddress).makeCommitment(bidder, claim); } emit Claim(auctionId, claimHash); } - event NewAuction( - bytes indexed auctionId, address reserveToken, uint256 reserves, uint256 price, uint256 endTimestamp - ); - - event Offer(bytes indexed auctionId, address indexed owner, bytes indexed bidId, uint256 expiry); - - event Fufillment(bytes indexed auctionId, bytes indexed bidId, uint256 windowId); - - event Expiration(bytes indexed auctionId, bytes indexed bidId, uint256 windowId); - - event Claim(bytes indexed auctionId, bytes indexed bidId); - - event Withdraw(bytes indexed auctionId); } diff --git a/src/interfaces/IERC20.sol b/src/interfaces/IERC20.sol index 2b1ce04..294db0e 100755 --- a/src/interfaces/IERC20.sol +++ b/src/interfaces/IERC20.sol @@ -2,12 +2,12 @@ pragma solidity 0.8.0; interface IERC20 { - function transferFrom(address from, address to, uint256 amount) external returns (bool); + function transferFrom(address from, address to, uint256 amount) external returns (bool); - function transfer(address to, uint256 amount) external returns (bool); + function transfer(address to, uint256 amount) external returns (bool); - function balanceOf(address owner) external view returns (uint256); + function balanceOf(address owner) external view returns (uint256); - function approve(address spender, uint256 amount) external; + function approve(address spender, uint256 amount) external; } diff --git a/src/interfaces/IGovernance.sol b/src/interfaces/IGovernance.sol index 6f03d6a..62cf4b9 100755 --- a/src/interfaces/IGovernance.sol +++ b/src/interfaces/IGovernance.sol @@ -2,21 +2,14 @@ pragma solidity 0.8.0; interface IGovernance { - function lock( - address owner, - uint256 amount, - uint256 deadline, - uint8 v, - bytes32 r, - bytes32 s - ) external; + function lock(address owner, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; - function delegate(address to) external; + function delegate(address to) external; - function undelegate() external; + function undelegate() external; - function unlock(uint256 amount) external; + function unlock(uint256 amount) external; - function Staking() external returns (address); + function Staking() external returns (address); } diff --git a/src/interfaces/IRDA.sol b/src/interfaces/IRDA.sol new file mode 100644 index 0000000..51abc76 --- /dev/null +++ b/src/interfaces/IRDA.sol @@ -0,0 +1,51 @@ +pragma solidity 0.8.13; + +interface IRDA { + + error InvalidPurchaseVolume(); + + error InvalidWindowVolume(); + + error InvalidWindowPrice(); + + error InsufficientReserves(); + + error InvalidScalarPrice(); + + error WindowUnexpired(); + + error WindowFulfilled(); + + error AuctionExists(); + + function createAuction( + address operatorAddress, + address reserveToken, + address purchaseToken, + uint256 reserveAmount, + uint256 minimumPurchaseAmount, + uint256 startingOriginPrice, + uint256 startTimestamp, + uint256 endTimestamp, + uint256 windowDuration + ) external returns (bytes memory); + + function withdraw(bytes memory auctionId) external; + + function redeem(address bidder, bytes memory auctionId) external; + + event NewAuction( + bytes indexed auctionId, address reserveToken, uint256 reserves, uint256 price, uint256 endTimestamp + ); + + event Offer(bytes indexed auctionId, address indexed owner, bytes indexed bidId, uint256 expiry); + + event Fulfillment(bytes indexed auctionId, bytes indexed bidId, uint256 windowId); + + event Expiration(bytes indexed auctionId, bytes indexed bidId, uint256 windowId); + + event Claim(bytes indexed auctionId, bytes indexed bidId); + + event Withdraw(bytes indexed auctionId); + +} diff --git a/src/interfaces/IRollingDutchAuction.sol b/src/interfaces/IRollingDutchAuction.sol deleted file mode 100644 index ba93105..0000000 --- a/src/interfaces/IRollingDutchAuction.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity 0.8.0; - -interface IRollingDutchAuction { - - function createAuction( - address vestingAddress, - address operatorAddress, - address reserveToken, - address purchaseToken, - uint256 reserveAmount, - uint256 minimumPurchaseAmount, - uint256 startingOriginPrice, - uint256 startTimestamp, - uint256 endTimestamp, - uint256 windowDuration - ) external returns (bytes memory); - - function withdraw(bytes memory auctionId) external; - - function redeem(address bidder, bytes memory auctionId external); - -} diff --git a/src/interfaces/IStaking.sol b/src/interfaces/IStaking.sol index d6f4061..c770795 100644 --- a/src/interfaces/IStaking.sol +++ b/src/interfaces/IStaking.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.0; interface IStaking { - function checkReward(address owner) external returns (uint256); + function checkReward(address owner) external returns (uint256); - function getReward() external; + function getReward() external; } diff --git a/src/interfaces/IUniswapV2Router02.sol b/src/interfaces/IUniswapV2Router02.sol index 4083d57..2cdf756 100755 --- a/src/interfaces/IUniswapV2Router02.sol +++ b/src/interfaces/IUniswapV2Router02.sol @@ -2,57 +2,57 @@ pragma solidity >=0.6.2; interface IUniswapV2Router02 { - function addLiquidity( - address tokenA, - address tokenB, - uint amountADesired, - uint amountBDesired, - uint amountAMin, - uint amountBMin, - address to, - uint deadline - ) external returns ( - uint amountA, - uint amountB, - uint liquidity - ); + function addLiquidity( + address tokenA, + address tokenB, + uint amountADesired, + uint amountBDesired, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns ( + uint amountA, + uint amountB, + uint liquidity + ); - function addLiquidityETH( - address token, - uint amountTokenDesired, - uint amountTokenMin, - uint amountETHMin, - address to, - uint deadline - ) external returns ( - uint amountToken, - uint amountETH, - uint liquidity - ); + function addLiquidityETH( + address token, + uint amountTokenDesired, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns ( + uint amountToken, + uint amountETH, + uint liquidity + ); - function removeLiquidity( - address tokenA, - address tokenB, - uint liquidity, - uint amountAMin, - uint amountBMin, - address to, - uint deadline - ) external returns ( - uint amountA, - uint amountB - ); + function removeLiquidity( + address tokenA, + address tokenB, + uint liquidity, + uint amountAMin, + uint amountBMin, + address to, + uint deadline + ) external returns ( + uint amountA, + uint amountB + ); - function removeLiquidityETH( - address token, - uint liquidity, - uint amountTokenMin, - uint amountETHMin, - address to, - uint deadline - ) external returns ( - uint amountToken, - uint amountETH - ); + function removeLiquidityETH( + address token, + uint liquidity, + uint amountTokenMin, + uint amountETHMin, + address to, + uint deadline + ) external returns ( + uint amountToken, + uint amountETH + ); } diff --git a/src/interfaces/IVesting.sol b/src/interfaces/IVesting.sol index 718f03a..eab4103 100644 --- a/src/interfaces/IVesting.sol +++ b/src/interfaces/IVesting.sol @@ -2,6 +2,6 @@ pragma solidity 0.8.0; interface IVesting { - function makeCommitment(address stakeholder, uint256 amount) external; + function makeCommitment(address stakeholder, uint256 amount) external; }