octopus-network / solana-flux-aggregator Goto Github PK
View Code? Open in Web Editor NEWSolana Flux Aggregator
Solana Flux Aggregator
Choose at least 5:
Binance TUSD
Binance USDC
Bitstamp USD
Bittrex USD
Coinbase USD
Coinbase USDC
Kraken USD
Okex USDC
FTX USD
FTXUS USD
Then take the median as the submission value.
This is how Uniswap's price oracle works:
They provides exponential price average, which allows users to calculate an average price for any arbitrary elapsed time (1h, 1 day, 1week) to track the exponential moving average, uniswap records price * seconds:
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
and to calculate moving average for a period, a smart contract can record the difference between the price cumulatives, and divide by the time period, like this:
price0Average = FixedPoint.uq112x112(
uint224((price0Cumulative - price0CumulativeLast) / timeElapsed)
);
We noticed an issue while running the aggregator, that keeps causing maintenance on our end. Basically the websocket might get locked in a weird state, when the RPC endpoint goes down for maintenance. The error looked like this:
ws error: connect ECONNREFUSED xxx:443
ws error: connect ECONNREFUSED xxx:443
ws error: connect ECONNREFUSED xxx:443
At some point the socket stopped trying to reconnect and I had to manually restart the oracle to make it work again.
Ideally the code would just allow us to specify a preference of rpc nodes and switch to a different one, in case the primary one becomes unavailable. Also it should switch back, when the primary one becomes available and is ready to accept transactions Could you look into that?
I need to be able to load this account from my program. A simple
impl BorshState for AggregatorConfig {}
is enough I think.
Hi I am wondering can this aggregator get the TWAP price for say 1 hour?
I'm having issues deploying a new aggregator using the instructions in the README.
dd@dd-p53:~/solana-flux-aggregator$ yarn solink add-aggregator --feedName btc:usd --submitInterval 6 --minSubmissionValue 0 --maxSubmissionValue 18446744073709551615
yarn run v1.22.5
$ ts-node src/cli.ts add-aggregator --feedName btc:usd --submitInterval 6 --minSubmissionValue 0 --maxSubmissionValue 18446744073709551615
Transaction simulation failed: Error processing Instruction 1: invalid instruction data
Program 11111111111111111111111111111111 invoke [1]
Program 11111111111111111111111111111111 success
Program F3W3N9iZy3ZLZkYFUFRmGPVneBrHoE6gveVyjPPqn825 invoke [1]
Program log: Error: InvalidInstructionData
Program F3W3N9iZy3ZLZkYFUFRmGPVneBrHoE6gveVyjPPqn825 consumed 1839 of 200000 compute units
Program F3W3N9iZy3ZLZkYFUFRmGPVneBrHoE6gveVyjPPqn825 failed: invalid instruction data
(node:128389) UnhandledPromiseRejectionWarning: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: invalid instruction data
at Connection._callee53$ (/home/dd/solana-flux-aggregator/node_modules/solray/node_modules/@solana/web3.js/src/connection.js:2957:13)
at tryCatch (/home/dd/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/home/dd/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:293:22)
at Generator.next (/home/dd/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:118:21)
at asyncGeneratorStep (/home/dd/solana-flux-aggregator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/home/dd/solana-flux-aggregator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:128389) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:128389) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hi, I'm getting an error when observing any oracles Error: Expected buffer length 32 isn't within bounds: answerSubmissions
- do you have any suggestions?
OS: Mac OS X
Cargo: 1.51.0
Rustup: 1.23.1
gets stuck here even after price moves a lot
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"eth:usd-test","round":"631"}
info: Starting a new round {"aggregator":"btc:usd-test","round":"1205"}
I get this error, after running yarn install
in a clean checkout:
$ yarn solink generate-wallet
yarn run v1.22.10
$ ts-node src/cli.ts generate-wallet
/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:513
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
src/cli.ts:9:8 - error TS2307: Cannot find module 'solray' or its corresponding type declarations.
9 } from "solray"
~~~~~~~~
at createTSError (/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:513:12)
at reportTSError (/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:517:19)
at getOutput (/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:752:36)
at Object.compile (/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:968:32)
at Module.m._compile (/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:1056:42)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/Users/max/Code/solana/solana-flux-aggregator/node_modules/ts-node/src/index.ts:1059:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Following the readme verbatim, I run into this error:
On the command: yarn solink deploy-program
patrick@iMac: [~/code/solana-chainlink/solana-flux-aggregator - (master)] $ yarn solink deploy-program
yarn run v1.22.10
$ ts-node src/cli.ts deploy-program
deploying /Users/patrick/code/solana-chainlink/solana-flux-aggregator/build/flux_aggregator.so...
(node:53116) UnhandledPromiseRejectionWarning: Error: Transaction was not confirmed in 10.01 seconds
at Connection._callee20$ (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/solray/node_modules/@solana/web3.js/src/connection.js:2227:13)
at tryCatch (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:293:22)
at Generator.next (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:118:21)
at asyncGeneratorStep (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
(node:53116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:53116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 13.94s.
OS: MacOS BigSur
Node: 12.20.0, 14.15.2
npm: 6.14.9
rustup: 1.23.1
solana-cli: 1.5.2
we are using Borsch now, don't need Pack/Seal
It would be useful for developers if you guys published a working program id and the pubkey of a couple of price aggregators in devnet (e.g. btc:usd and eth:usd)
Following the README verbatim to deploy an oracle, I run into the following.
On adding an oracle:
yarn solink add-oracle \
--index 0 \
--feedAddress 8ox6rTwuVEeKRgkVTr1tdzyjpGNLAt2W6NT63zubcWiM \
--oracleName solink-test \
--oracleOwner Ea36cguU9E1p6FBYfikzhMTfG4ekY7WDK8HwUBvV2P3A
I get:
add oracle...
Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction
Program 11111111111111111111111111111111 invoke [1]
Program 11111111111111111111111111111111 success
Program 3wEiZwdEygZisYbaDCe3bMztMVBbo3rK4X3bHs52Xc5F invoke [1]
Program log: Instruction: AddOracle
Program log: Error: InvalidAccountData
Program 3wEiZwdEygZisYbaDCe3bMztMVBbo3rK4X3bHs52Xc5F consumed 12260 of 200000 compute units
Program 3wEiZwdEygZisYbaDCe3bMztMVBbo3rK4X3bHs52Xc5F failed: invalid account data for instruction
(node:43280) UnhandledPromiseRejectionWarning: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction
at Connection._callee53$ (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/solray/node_modules/@solana/web3.js/src/connection.js:2957:13)
at tryCatch (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:293:22)
at Generator.next (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/regenerator-runtime/runtime.js:118:21)
at asyncGeneratorStep (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/patrick/code/solana-chainlink/solana-flux-aggregator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:43280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:43280) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 7.99s.
OS: MacOS BigSur
Node: 12.20.0, 14.15.2
npm: 6.14.9
rustup: 1.23.1
solana-cli: 1.5.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.