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 priceOracle to appconfig, add defillama price oracle, and selector #1651

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

DannyDelott
Copy link
Contributor

Related to #1629

This PR introduces a new priceOracle field to the TokenConfig interface and defines a PriceOracleFn function type. This uses a strategy pattern (similar to what we're doing for rewards), so that it's easy to add new price oracle functions.

At the moment, we only need defillama strategy, but a TODO has been added to provide a uniswapv3 oracle function to handle zappable tokens in the near future.

Copy link

changeset-bot bot commented Nov 14, 2024

⚠️ No Changeset found

Latest commit: 2c27830

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hyperdrive-mainnet-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2024 1:02am
hyperdrive-sepolia-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2024 1:02am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
hyperdrive-js ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 1:02am
hyperdrive-mainnet-production ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 1:02am
hyperdrive-sepolia-production ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 1:02am
testnet-v1 ⬜️ Ignored (Inspect) Nov 14, 2024 1:02am
testnet-v1.0.6 ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 1:02am
trading-competition ⬜️ Ignored (Inspect) Visit Preview Nov 14, 2024 1:02am

appConfig,
});
let alreadyExists = false;
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why we need the try catch here. Since getToken returns undefined can we just look at the variable to determine if it exists?

const alreadyExists = !!getToken({
  chainId: reward.chainId,
  tokenAddress: reward.tokenAddress,
  appConfig,
});

if (alreadyExists) {
  return;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getToken will throw an error now if you call it and it doesn't find a token. This is the behavior we want because it's a sign that the appconfig is malformed. In this case, though, since we're calling it before the reward tokens are included, we'll get an error thrown at us.

@DannyDelott DannyDelott merged commit fd25556 into main Nov 14, 2024
14 checks passed
@DannyDelott DannyDelott deleted the danny-move-fiat-price-into-appconfig branch November 14, 2024 03:03
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