Skip to content

Instantly share code, notes, and snippets.

@jac18281828
Last active June 28, 2024 18:04
Show Gist options
  • Save jac18281828/9fc54a89debada89e80503962c8c214a to your computer and use it in GitHub Desktop.
Save jac18281828/9fc54a89debada89e80503962c8c214a to your computer and use it in GitHub Desktop.
How to call 'updateRate()' on ETHxRateProvider

UpdateRate must be called from time to time on Stader ETHxRateProvider, an L2 Rate Oracle for ETHx. The following steps demonstrate how to do this.

Deployment address – Ethereum mainnet:

ETHX_RATE_PROVIDER=0x0B2fAadfe75fE6507Dc8F81f8331198C65cA2C24

1. Check LayerZero fee for sending rate information.

$ cast call 0x0B2fAadfe75fE6507Dc8F81f8331198C65cA2C24 "estimateTotalFee()" --rpc-url ${MAINNET_URL} --legacy
0x000000000000000000000000000000000000000000000000000104cdb2b763a5

2. Convert the calldata response to a decimal value

$ cast to-base
0x000000000000000000000000000000000000000000000000000104cdb2b763a5
10
286756489880485

3. Submit the call to updateRate including value equal to the requirement quoted by LayerZero above

cast send 0x0B2fAadfe75fE6507Dc8F81f8331198C65cA2C24 "updateRate()" --rpc-url ${MAINNET_URL} --legacy --private-key ${PRIVATE_KEY} --value 286756489880485

blockNumber             20191801                   
status                  1 (success)
transactionHash         0xa8ba9eee9a8a6ccaba24db8dc7e6af363b23db3a133ed35c5456d7d426599ad9
to                      0x0B2fAadfe75fE6507Dc8F81f8331198C65cA2C24

ETHx rate is now updated across supported implementations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment