diff --git a/src/ERC721TokenVault.sol b/src/ERC721TokenVault.sol index cebfabe9..90aeae82 100644 --- a/src/ERC721TokenVault.sol +++ b/src/ERC721TokenVault.sol @@ -75,6 +75,12 @@ contract TokenVault is ERC20Upgradeable, ERC721HolderUpgradeable { /// @notice a mapping of users to their desired token price mapping(address => uint256) public userPrices; + /// @notice array of all addresses with bids + address[] addressArray; + + /// @notice array of all the bids + uint256[] prices; + /// ------------------------ /// -------- EVENTS -------- /// ------------------------ @@ -127,9 +133,57 @@ contract TokenVault is ERC20Upgradeable, ERC721HolderUpgradeable { /// -------------------------------- /// -------- VIEW FUNCTIONS -------- /// -------------------------------- + /// @notice sort prices array + /// @param arr the new curator + + function sort(uint256[] memory arr) public returns(uint256[] memory) { + quickSort(arr, int(0), int(arr.length - 1)); + return arr; + } + + function quickSort(uint[] memory arr, int left, int right) internal{ + int i = left; + int j = right; + if(i == j){ + return; + } + uint pivot = arr[uint(left + (right - left) / 2)]; + while (i <= j) { + while(arr[uint(i)] < pivot){ + i++; + } + while (pivot < arr[uint(j)]){ + j--; + } + if (i <= j) { + (arr[uint(i)], arr[uint(j)]) = (arr[uint(j)], arr[uint(i)]); + i++; + j--; + } + } + if (left < j) + quickSort(arr, left, j); + if (i < right) + quickSort(arr, i, right); + } + + function reservePrice() public returns(uint256) { + delete prices; + for(uint256 i=0; i