-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adaptation of Subgraph for Saucerswap v2 #41
Conversation
f136d9c
to
d6d983c
Compare
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.
Looking good.
Some comments
subgraphs/saucerswap/v2/package.json
Outdated
"create": "graph create saucerswap-v2 --node http://127.0.0.1:8020", | ||
"deploy-local": "graph deploy saucerswap-v2 --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020", | ||
"deploy-stg": "graph deploy saucerswap-v2 --debug --ipfs https://api.thegraph.com/ipfs/ --node http://127.0.0.1:8020", | ||
"remove": "graph remove saucerswap-v2 --node http://127.0.0.1:8020" |
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.
Q: should we have a watch
?
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 have not consider it, will investigate and get back 👍
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.
What the --watch flag does, it that the graph-cli
will keep watching the files, and when detecting a change, it will automatically redeploy to the server.
I don't think we need it, since is useful only during intensive development and test phases, but is not recommended for production environment.
import { convertTokenToDecimal, loadTransaction } from '../utils' | ||
|
||
const excludedBlocks: BigInt[] = [ |
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.
Q: do we still need to exclude and if so we should say why these blocks are being excluded.
Could the missing blocks ever be reindexed?
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 can try after the improvements we've done to see if we don't need this anymore. 👍
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 did took another look at this and was able to find the culprit of some blocks failing, the issue was fixed on this PR of the relay:
hashgraph/hedera-json-rpc-relay#2333
It was deployed to mainnet
and I have re-indexed the subgraph and now is working without the need to hardcode "faulty" blocks.
✅ Fixed!
@@ -3,7 +3,7 @@ import { BigInt, BigDecimal, Address } from '@graphprotocol/graph-ts' | |||
import { Factory as FactoryContract } from '../types/templates/Pool/Factory' | |||
|
|||
export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' | |||
export const FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984' | |||
export const FACTORY_ADDRESS = '0x00000000000000000000000000000000003c3951' |
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.
Q: which env is this for and is it reliably going to be that address?
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.
This is for mainnet, but I will provide a way to parametrized it based on .env
configuration and using envsub
to substitute those fields.
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.
✅ Completed
@@ -4,42 +4,28 @@ import { Bundle, Pool, Token } from './../types/schema' | |||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts' | |||
import { exponentToBigDecimal, safeDiv } from '../utils/index' | |||
|
|||
const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' | |||
const USDC_WETH_03_POOL = '0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8' | |||
const WHBAR_ADDRESS = '0x0000000000000000000000000000000000163b5a' |
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'm guessing this is mainnet?
Do we need to support testnet or how might we configure 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.
Yes is mainnet, will work on .env
file that provides this values based on network chosen
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've done the needed changes so based on the deployed network: mainnet
or testnet
it takes some or other values, all is done by .env
on the subgraph yaml creation using a template, and on constants.ts
file based on the network the constants are populated with their respective networks, effectively making this subgraph multi-network.
✅ Completed!
if (usdcPool !== null) { | ||
return usdcPool.token0Price | ||
return usdcPool.token0Price //? maybe is token1? |
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.
Q: were you able to confirm?
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.
Yes. I were able to confirm, is not, is token0 👍
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 remove the comment 👍
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.
✅ removed!
if (feeTier.equals(BigInt.fromI32(10000))) { | ||
return BigInt.fromI32(200) | ||
} | ||
if (feeTier.equals(BigInt.fromI32(3000))) { | ||
return BigInt.fromI32(60) | ||
} | ||
if (feeTier.equals(BigInt.fromI32(1500))) { |
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.
Q: why the need for the extra tier?
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.
That is a change that saucerswap confirmed they introduced.
…racts and ecosystem Signed-off-by: Alfredo Gutierrez <[email protected]>
Signed-off-by: Alfredo Gutierrez <[email protected]>
Signed-off-by: Alfredo Gutierrez <[email protected]>
… improving on the check condition. Signed-off-by: Alfredo Gutierrez <[email protected]>
…ing recognized by thegraph node. Signed-off-by: Alfredo Gutierrez <[email protected]>
…at is no longer needed Signed-off-by: Alfredo Gutierrez <[email protected]>
…ent. also added .env example for both mainnet and testnet Signed-off-by: Alfredo Gutierrez <[email protected]>
Signed-off-by: Alfredo Gutierrez <[email protected]>
Signed-off-by: Alfredo Gutierrez <[email protected]>
0ea4887
to
89c826c
Compare
Description:
Changed the original for and adapted it to support saucerswap v2 contracts and ecosystem
Related issue(s):
Fixes #30
Notes for reviewer:
Checklist