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

FXPool support on Arbitrum #552

Closed
wants to merge 1 commit into from

Conversation

schystz
Copy link
Contributor

@schystz schystz commented Jan 25, 2024

Description

Adds FXPoolDeployer address on Arbitrum, which should enable FXPools to be discovered on Arbitrum network

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency changes
  • Code refactor / cleanup
  • Documentation or wording changes
  • Other

How should this be tested?

yarn codegen should generate the updated manifest for arbitrum with the FXPoolDeployer section added

Checklist:

  • I have performed a self-review of my own code
  • I have requested at least 1 review (If the PR is significant enough, use best judgement here)
  • I have commented my code where relevant, particularly in hard-to-understand areas

dev -> master

  • I have checked that all beta deployments have synced
  • I have checked that the earliest block in the polygon pruned deployment is block, date/time
    • The earliest block is more than 24 hours old
  • I have checked that core metrics are the same in the beta and production deployments

Merges to dev

  • I have checked that the graft base is not a pruned deployment

Copy link
Member

@mendesfabio mendesfabio left a comment

Choose a reason for hiding this comment

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

LGTM, but do you have any FX pool planned for Arbitrum? if so worth going ahead and adding fxAssetAggregators to assets/arbitrum.json - otherwise, we'll have to re-deploy it in the future

@schystz
Copy link
Contributor Author

schystz commented Jan 29, 2024

LGTM, but do you have any FX pool planned for Arbitrum? if so worth going ahead and adding fxAssetAggregators to assets/arbitrum.json - otherwise, we'll have to re-deploy it in the future

Hey @mendesfabio, thanks for the heads up! With the new FXPoolDeployer however, we no longer have to rely on fxAssetAggregators as the handler fetches the fx aggregator address dynamically and saves it to FXOracle entity. See

// For FXPoolDeployer (permissionless), fetch the aggregator address dynamically
let poolContract = FXPool.bind(poolAddress);
for (let i = 0; i < tokensAddresses.length; i++) {
let tokenAddress = tokensAddresses[i];
let assimCall = poolContract.try_assimilator(tokenAddress);
if (assimCall.reverted) continue;
let assimContract = Assimilator.bind(assimCall.value);
let oracleCall = assimContract.try_oracle();
if (oracleCall.reverted) continue;
let oracleContract = ChainlinkPriceFeed.bind(oracleCall.value);
let aggregatorCall = oracleContract.try_aggregator();
if (aggregatorCall.reverted) continue;
// Create OffchainAggregator template
let aggregatorAddress = aggregatorCall.value;
OffchainAggregator.create(aggregatorAddress);
// Update FXOracle supported tokens
let oracle = getFXOracle(aggregatorAddress);
let tokenAddresses = oracle.tokens;
const tokenExists = tokenAddresses.includes(tokenAddress);
if (!tokenExists) {
tokenAddresses.push(tokenAddress);
}
oracle.tokens = tokenAddresses;
oracle.save();

On the price update part, the handler just checks FXOracle:

// Also check if aggregator exists from FXOracle entity (FXPoolDeployer version)
let oracle = FXOracle.load(aggregatorAddress.toHexString());
if (oracle) {
for (let i = 0; i < oracle.tokens.length; i++) {
const tokenAddress = Address.fromBytes(oracle.tokens[i]);
const tokenExists = tokenAddressesToUpdate.includes(tokenAddress);
if (!tokenExists) {
tokenAddressesToUpdate.push(tokenAddress);
}
}
}

So I think we don't have to worry about the fxAssetAggregators at all for Arbitrum.

@mendesfabio
Copy link
Member

ah, that's true, sorry @schystz! we'll merge this PR today, keep you guys posted =)

@schystz
Copy link
Contributor Author

schystz commented Jan 29, 2024

ah, that's true, sorry @schystz! we'll merge this PR today, keep you guys posted =)

No worries at all! Glad that we both agreed :) Thank you!

@mendesfabio
Copy link
Member

@schystz closing this PR in favor of #556 -- had to change the grafting params to speed up the syncing

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