Oracle Price

Introducing AlcorSwap v2 price oracles
Price oracle is a mechanism that provides asset prices to blockchain. Since blockchains are isolated ecosystems, there is no direct way of querying external data, and there are difficulties in ensuring data validity and authenticity. DelphiOracle is presented as one of the first working solutions to these problems on EOSIO(Antelope). It runs a decentralized network of oracles that fetch asset prices from centralized exchanges via APIs, average them, and provide them on-chain. DelphiOracle is essentially a smart contracts with one state variable, asset price, that can be read by anyone but can only be written to by oracles. However DelphiOracle only provides the last price while the Defi Dapp needs the price by timestamp for various purposes.
AlcorSwap v2 facilitated the creation of on-chain price oracles known as time-weighted average price (TWAP) oracles. These oracles are highly decentralized and provide a solution for many of the challenges involved in creating robust blockchain protocols. Manipulation on most AlcorSwap v2 TWAP oracles isn’t currently feasible, because bad actors both need to source incredibly high levels of capital and then need to make enough money back to make up for money lost to fees. Make sure that your Dapps use a rolling time window for TWAP to calculate the price because spot prices are easy and relatively cheap to manipulate.
Historical price data is stored as an array of observations. Initially, each pool tracks only one observation, overwriting it as new blocks are added. As a result, the data can only be accessed for a limited period. However, any party can expand the period of data availability by paying RAM to increase the number of tracked observations and the maximum of observations is unlimited. For example, If a user want to have the price data availability to be 3 hours, each row need 160 bytes RAM. Hence they need to pay up to 160*3*60*60*2 = 3.456 MB.