Skip to content
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

Draft
wants to merge 4 commits into
base: LISK-1155-Set-up-RedStone-Push-Oracle-contracts
Choose a base branch
from

Conversation

Incede
Copy link
Member

@Incede Incede commented Oct 23, 2024

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

@Incede Incede requested a review from matjazv October 23, 2024 14:12
@Incede Incede self-assigned this Oct 23, 2024
Comment on lines +64 to +66
# Provider url for testing web3 function with
PROVIDER_URLS=http://localhost:8546

Copy link
Contributor

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?

Copy link
Member Author

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)

hardhat.config.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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).

Copy link
Member Author

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.

Copy link
Contributor

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",
Copy link
Contributor

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?

Copy link
Member Author

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 ?

Copy link
Contributor

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?

package.json Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants