Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#62-#74
Browse files Browse the repository at this point in the history
* develop:
  Fix chart, in case no order has been placed (#83)
  Changing contract to newest version, supporting allowLists (#86)
  addingg .env back (#87)
  Add improvement with useMemo (#81)

# Conflicts:
#	src/components/AuctionDetails/index.tsx
#	src/components/OrderbookBtn.tsx
#	src/components/OrderbookChart.tsx
#	src/components/OrderbookChartSmall.tsx
#	src/constants/index.ts
#	src/hooks/usePlaceOrderCallback.ts
  • Loading branch information
gabitoesmiapodo committed Feb 19, 2021
2 parents 1610fec + bba45ed commit fa57fbe
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REACT_APP_CHAIN_ID=4
REACT_APP_NETWORK_URL=https://rinkey.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847
REACT_APP_ADDITIONAL_SERVICES_API_URL=https://ido-v1-api-rinkeby.dev.gnosisdev.com/
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ package-lock.json
cypress/videos
cypress/screenshots
cypress/fixtures/example.json

.env
28 changes: 16 additions & 12 deletions src/components/AuctionDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,27 @@ export default function AuctionDetails() {
)

const clearingPriceInfo = useClearingPriceInfo()
const clearingPriceInfoAsSellorder =
clearingPriceInfo &&
orderToSellOrder(clearingPriceInfo.clearingOrder, biddingToken, auctioningToken)
let clearingPriceNumber = orderToPrice(clearingPriceInfoAsSellorder)?.toSignificant(4)

if (clearingPrice) {
clearingPriceNumber = clearingPrice && clearingPrice.toSignificant(4)
}
const biddingTokenDisplay = useMemo(() => getTokenDisplay(biddingToken), [biddingToken])

const auctioningTokenDisplay = useMemo(() => getTokenDisplay(auctioningToken), [auctioningToken])

const clearingPriceDisplay = clearingPriceNumber
? `${clearingPriceNumber} ${getTokenDisplay(biddingToken)} per ${getTokenDisplay(
auctioningToken,
)}`
: '-'
const clearingPriceDisplay = useMemo(() => {
const clearingPriceInfoAsSellOrder =
clearingPriceInfo &&
orderToSellOrder(clearingPriceInfo.clearingOrder, biddingToken, auctioningToken)
let clearingPriceNumber = orderToPrice(clearingPriceInfoAsSellOrder)?.toSignificant(4)

if (clearingPrice) {
clearingPriceNumber = clearingPrice && clearingPrice.toSignificant(4)
}

return clearingPriceNumber
? `${clearingPriceNumber} ${getTokenDisplay(biddingToken)} per ${getTokenDisplay(
auctioningToken,
)}`
: '-'
}, [auctioningToken, biddingToken, clearingPrice, clearingPriceInfo])

const titlePrice = useMemo(
() =>
Expand Down
1 change: 0 additions & 1 deletion src/components/OrderbookBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const Wrapper = styled.div`
display: block;
`

// const ModalWrapper = styled(ModalBodyWrapper)`
const ModalWrapper = styled.div`
display: flex;
text-align: center;
Expand Down
3 changes: 3 additions & 0 deletions src/components/OrderbookChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export const createChart = (chartElement: HTMLElement): am4charts.XYChart => {
chart.cursor.lineY.strokeOpacity = 0.6
chart.cursor.lineY.strokeDasharray = '4'

// Add default empty data array
chart.data = []

return chart
}

Expand Down
9 changes: 3 additions & 6 deletions src/components/OrderbookChartSmall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ const OrderBookChartSmall: React.FC<OrderBookChartProps> = (props: OrderBookChar
}, [])

useEffect(() => {
if (!chartRef.current || data === null) return
if (!chartRef.current) return

if (data.length === 0) {
chartRef.current.data = []
return
if (data && data.length !== 0) {
chartRef.current.data = data
}

// go on with the update when data is ready
Expand All @@ -103,8 +102,6 @@ const OrderBookChartSmall: React.FC<OrderBookChartProps> = (props: OrderBookChar
quoteToken,
networkId,
})

chartRef.current.data = data
}, [baseToken, networkId, quoteToken, data])

return <Wrapper ref={mountPoint}>Show order book for this auction</Wrapper>
Expand Down
40 changes: 40 additions & 0 deletions src/constants/abis/easyAuction/easyAuction.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
"internalType": "uint256",
"name": "minFundingThreshold",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "allowListManager",
"type": "address"
}
],
"name": "NewAuction",
Expand Down Expand Up @@ -259,6 +265,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "auctionAccessManager",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "auctionCounter",
Expand Down Expand Up @@ -537,6 +562,11 @@
"internalType": "bool",
"name": "isAtomicClosureAllowed",
"type": "bool"
},
{
"internalType": "address",
"name": "allowListManager",
"type": "address"
}
],
"name": "initiateAuction",
Expand Down Expand Up @@ -597,6 +627,11 @@
"internalType": "bytes32[]",
"name": "_prevSellOrders",
"type": "bytes32[]"
},
{
"internalType": "bytes",
"name": "allowListCallData",
"type": "bytes"
}
],
"name": "placeSellOrders",
Expand Down Expand Up @@ -712,6 +747,11 @@
"internalType": "bytes32[]",
"name": "_prevSellOrder",
"type": "bytes32[]"
},
{
"internalType": "bytes",
"name": "allowListCallData",
"type": "bytes"
}
],
"name": "settleAuctionAtomically",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const EASY_AUCTION_NETWORKS: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: '0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441',
[ChainId.ROPSTEN]: '0x53C43764255c17BD724F74c4eF150724AC50a3ed',
[ChainId.KOVAN]: '0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A',
[ChainId.RINKEBY]: '0xdC5f67d34aB3489b5bfD34645B7271615FAcdfA2',
[ChainId.RINKEBY]: '0x99e63218201e44549AB8a6Fa220e1018FDB48f79',
[ChainId.GÖRLI]: '0x732ed4E98f7906B81eb8ECD5269952DCEd966A0f',
}
// used for display in the default list when adding liquidity
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/usePlaceOrderCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function usePlaceOrderCallback(
order: {
buyAmount: buyAmountScaled,
sellAmount: sellAmountScaled,
userId: BigNumber.from(0),
userId: BigNumber.from(0), // This could be optimized
},
})
let estimate,
Expand All @@ -83,6 +83,7 @@ export function usePlaceOrderCallback(
[buyAmountScaled.toString()],
[sellAmountScaled.toString()],
[previousOrder],
'0x',
]
value = null
}
Expand Down Expand Up @@ -112,7 +113,7 @@ export function usePlaceOrderCallback(
const order = {
buyAmount: buyAmountScaled,
sellAmount: sellAmountScaled,
userId: BigNumber.from(userId),
userId: BigNumber.from(userId), // If many people are placing orders, this might be incorrect
}
onNewOrder([
{
Expand Down

0 comments on commit fa57fbe

Please sign in to comment.