To submit a quote to the orderbook, POST quotes can be used. In the background, we will take this quote an submit an event on Arbitrum Nova on the users behalf. One the quote event is generated on Arbitrum Nova, it will be added to the orderbook.
// Javascript Sample Codeconst { fetch } =require ('cross-fetch')const { parseEther } =require("ethers");consturl='https://test.orderbook.premia.finance/quotes'// Free or Paid Tier API KEYconstMOCK_API_KEY='3423ee2bfd89491f82b351404ea8c3b7'// object array of one or more quotesconstmockQuotes= [{ poolKey: { base:'0x9f5D1212514Ac88E26c523387C60F87B67AD1130', quote:'0x53421DB1f41368E028A4239954feB5033C7B3729', oracleAdapter:'0xB89756634Bae979d13721d9883e67CF22cc31D6b', strike:parseEther('2900').toString(), maturity:1688716800, isCallPool:false }, chainId:'421613' provider: '0x9E600587b9035a8C1254E8256F4E588CC33B8467', taker:'0x0000000000000000000000000000000000000000', price:parseEther('.195').toString(), size:parseEther('1').toString(), isBuy:false, deadline:1686592096, salt:1686584896, signature: { r:'0x7feff79a77a023fd8e034066c5bdb78e9b9e5e3804dfc02c0d5b3979b5be8324', s:'0x58229484d69566752b48c49326e6eaca2b4fba5372ba638870bda5b58b4fb25e', v:28 }}]async publishQuote(quotes) {constresponse=awaitfetch(url, { method:'POST', headers: {'Content-Type':'application/json','x-apikey':MOCK_API_KEY, }, body:JSON.stringify(quotes), })if (!response.ok) {console.error('Request failed: ',awaitresponse.json())thrownewError(`Failed to publish quotes: ${response.statusText}`) }returnresponse.json()}publishQuote(mockQuotes)
Get Quotes
When using GET quotes, orders are returned based on the params details provided. quotes endpoint is ideal for determining which order(s) will satisfy a specific order size and side. The returned quotes are ordered by price, and only the order(s) that satisfy the size (cumulatively) will be returned.
Additionally, it is possible to receive RFQ quotes along with public quotes by specifying a taker address. The allows users to find the best possible public/private quote combination for a particular quote size.
// Javascript Sample Codeconst { fetch } =require ('cross-fetch')const { parseEther } =require("ethers");constbaseUrl='https://test.orderbook.premia.finance'// Free or Paid Tier API KEYconstMOCK_API_KEY='3423ee2bfd89491f82b351404ea8c3b7'// ParamsconstpoolAddress='0xb9e594644D3BB24cfcBa3FA0289F18dB7cf81573'constsize=parseEther('5').toString()constside='bid'//Side is 'ask'('bid') if the intention is to buy(sell). constchainId='421613'async getQuotes(_addr, _size, _side, _chainId){consturl=`${baseUrl}/quotes?poolAddress=${_addr}&size=${_size}&side=${_side}&chainId=${_chainId}`constresponse=awaitfetch(url, { headers: {'Content-Type':'application/json','x-apikey':MOCK_API_KEY } })if (!response.ok) {console.error('Request failed: ',awaitresponse.json())thrownewError(`Failed to fetch quote: ${response.statusText}`) }constquotes=awaitresponse.json() return quotes}getQuotes(poolAddress, size, side, chainId)
Get rfq_quotes
When publishing an RFQ, users can listen for quotes via WEBSOCKET or use the rfq_quotes endpoint to retrieve only RFQ quotes via REST API.
GET orders is a general purpose query of orders in the orderbook. Many of the params are optional to suit the needs of the query. Orders are returned in descending order based on the timestamp in which they were created.
Good To Know: size param in GET orders is not the same as size param in GET quotes. See param descriptions.