-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Gelato web3 function deployment script for redstone oracles #208
base: LISK-1155-Set-up-RedStone-Push-Oracle-contracts
Are you sure you want to change the base?
Conversation
# Provider url for testing web3 function with | ||
PROVIDER_URLS=http://localhost:8546 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this URL be different than what is L2_RPC_URL
? Can we just use L2_RPC_URL
without having a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it would be same. I am not sure where or which library picks this env var and we might have to change the lib code so maybe better to keep it separate (for now)
web3-functions/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requirements are:
- Update LSK/USD and USDT/USD pairs if price deviation is more than 0.5%
- Update price every 6h if there is no price update before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web3Function.onRun
could be used to prevent price update (eg. if price deviation is less than 0.5%) but not sure if there is a way to trigger w3f from the code.
Gelato dashboard has the option to trigger w3f function based on time interval or onchain events. So one way to achieve the 1st bullet point would be deploy a contract that checks and compares the prices from our oracle and source and triggers an onchain event that could be consumed by Gelato API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use like it's currently implemented
const livePrice: BigNumber = await wrappedOracle.getLivePrice();
const storedPrice: BigNumber = await wrappedOracle.getStoredPrice();
to get live and stored price and compare them to see if update is needed?
For 6 hours interval, we'll probably need to store timestamp of last price update and compare it each time w3f is executed to check if it's more than 6 hours from last price update.
w3f will always be executed every 30 or 60 seconds (we still need to decide on this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I understand what you mean now. Your previous comment implied that the code must trigger w3f once certain conditions are met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W3f will be executed every 30 or 60 seconds.
Logic inside it which creates a transaction to update token pair price will be triggered when certain conditions are met.
package.json
Outdated
@@ -3,17 +3,10 @@ | |||
"version": "0.0.1", | |||
"description": "Smart Oracle that pushes prices online every hour or when the price difference with the last price is greater or equal than 2%", | |||
"scripts": { | |||
"build": "yarn install && yarn compile && npx tsc", | |||
"clean": "yarn hardhat clean && rm -rf node_modules && rm -rf dist", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should rm -rf node_modules && rm -rf dist
still be present to be able to properly clean TS files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep rm -rf node_modules
but there is no dist
. A folder .tmp
and yarn.lock
are also generated as part of the process, should we remove them as part of clean
too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should then remove node_modules
and .tmp
folders. Not sure if yarn.lock needs to be removed. Isn't it usually also commited and part of the repository?
What was the problem?
This PR resolves LISK-1156
How was it solved?
Add script to deploy w3f code on IPFS
How was it tested?
yarn
cp .env.testnet .env
yarn w3f:deploy