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

feat: add interceptors for http and graphql client to support multiple subgraph api keys #669

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

minhnhathoang
Copy link
Member

Why did we need it?

Related Issue

Release Note

How Has This Been Tested?

Screenshots (if appropriate):

@minhnhathoang minhnhathoang changed the title feat: Custom callbacks for graphql client Custom callbacks for graphql client Dec 26, 2024
@kyber-ci-bot
Copy link

kyber-ci-bot commented Dec 26, 2024

Test coverage changes:
Package Before After Diff
github.com/KyberNetwork/kyberswap-dex-lib/pkg/entity 26.30% 26.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/algebra/integral 32.60% 32.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/algebra/v1 17.80% 17.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/ambient 17.90% 17.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/balancer-v1 42.80% 42.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/balancer-v2/composable-stable 48.70% 48.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/balancer-v2/math 49.00% 49.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/balancer-v2/stable 33.80% 33.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/balancer-v2/weighted 44.90% 44.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/bancor-v21 31.70% 31.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/bancor-v3 51.20% 51.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/bebop 26.40% 26.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/bedrock/unieth 16.90% 16.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/beets-ss 25.50% 25.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/clipper 50.00% 50.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/curve/plain 59.30% 59.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/curve/stable-meta-ng 41.40% 41.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/curve/stable-ng 37.70% 37.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/curve/tricrypto-ng 62.30% 62.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/curve/twocrypto-ng 61.10% 61.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dai-usds 21.90% 21.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/deltaswap-v1 46.50% 46.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dexalot 45.10% 45.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dodo/classical 59.10% 59.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dodo/dpp 38.50% 38.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dodo/dsp 41.00% 41.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dodo/dvm 49.50% 49.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dodo/libv1 73.30% 73.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/dodo/libv2 37.60% 37.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/ethena/susde 27.10% 27.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/ether-vista 2.30% 2.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/etherfi/eeth 16.00% 16.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/etherfi/vampire 27.10% 27.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/etherfi/weeth 12.30% 12.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/fluid/dex-t1 72.50% 72.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/fluid/vault-t1 17.70% 17.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/frax/sfrxeth 18.00% 18.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/frax/sfrxeth-convertor 37.50% 37.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/generic-simple-rate 32.90% 32.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/gyroscope/2clp 42.30% 42.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/gyroscope/3clp 43.90% 43.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/gyroscope/eclp 58.80% 58.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/gyroscope/math 14.30% 14.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/hashflow-v3 74.30% 74.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/integral 35.70% 35.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/kelp/rseth 11.80% 11.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/lo1inch 84.10% 84.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/mantle/meth 28.10% 28.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/mkr-sky 29.70% 29.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/mx-trading 72.00% 72.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/native-v1 69.20% 69.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/nomiswap/nomiswapstable 83.10% 83.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/ondo-usdy 23.90% 23.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/puffer/pufeth 22.80% 22.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/renzo/ezeth 9.40% 9.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/ringswap 10.70% 10.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/rocketpool/reth 26.10% 26.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/solidly-v2 39.90% 39.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/staderethx 28.00% 28.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/swaap-v2 56.40% 56.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/swell/rsweth 6.20% 6.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/swell/sweth 6.20% 6.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/syncswapv2/aqua 22.60% 22.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/syncswapv2/classic 32.30% 32.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/syncswapv2/stable 40.50% 40.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/uniswap-v1 14.10% 14.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/uniswap-v2 8.30% 8.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/usd0pp 27.30% 27.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/velocore-v2/cpmm 54.50% 54.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/velocore-v2/math 16.80% 16.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/velocore-v2/math/sd59x18 51.90% 51.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/velocore-v2/wombat-stable 30.40% 30.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/velodrome-v1 35.30% 35.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/velodrome-v2 40.30% 40.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/virtual-fun 39.10% 39.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/woofi-v2 55.20% 55.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/woofi-v21 57.50% 57.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/algebrav1 17.80% 17.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/balancer-composable-stable 55.40% 55.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/balancer/stable 78.10% 78.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/balancer/weighted 56.60% 56.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/camelot 38.70% 38.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/aave 70.70% 70.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/base 43.50% 43.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/compound 75.40% 75.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/meta 87.00% 87.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/plain-oracle 38.50% 38.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/tricrypto 70.30% 70.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/curve/two 29.20% 29.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/dmm 33.30% 33.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/dodo 36.40% 36.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/equalizer 28.80% 28.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/fraxswap 23.90% 23.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/fulcrom 31.40% 31.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/fxdx 20.90% 20.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/gmx 27.60% 27.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/gmx-glp 26.30% 26.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/iziswap 25.20% 25.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/kokonut-crypto 55.50% 55.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/kyber-pmm 38.50% 38.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/lido 22.80% 22.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/lido-steth 33.30% 33.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/limitorder 51.80% 51.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/liquiditybookv20 38.60% 38.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/liquiditybookv21 48.30% 48.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/madmex 25.10% 25.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/makerpsm 37.30% 37.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/mantisswap 53.10% 53.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/maverickv1 70.70% 70.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/metavault 28.40% 28.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/nuriv2 22.40% 22.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pancakev3 47.40% 47.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/platypus 25.90% 26.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/pol-matic 18.90% 18.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/quickperps 23.90% 23.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/ramsesv2 22.00% 22.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/saddle 64.00% 64.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/slipstream 21.10% 21.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/smardex 46.20% 46.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/solidly-v3 28.40% 28.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/swapbased-perp 31.40% 31.40% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/syncswap/syncswapclassic 68.30% 68.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/syncswap/syncswapstable 82.50% 82.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/synthetix 38.00% 38.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/traderjoev20 12.80% 12.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/traderjoev21 12.20% 12.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswap 17.00% 17.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/uniswapv3 45.00% 45.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/usdfi 44.10% 44.10% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/velocimeter 46.60% 46.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/velodrome 44.90% 44.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/velodromev2 45.60% 45.60% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/vooi 36.90% 36.90% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/wombat/wombatlsd 55.30% 55.30% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/wombat/wombatmain 56.50% 56.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/source/woofiv2 54.70% 54.70% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/util 4.50% 4.50% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/abi 75.00% 75.00% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/bignumber 14.80% 14.80% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql 0.00% 24.20% ✔️
github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/http 0.00% 100.00% ✔️

@minhnhathoang minhnhathoang force-pushed the feat/multiple-thegraph-api-keys branch 3 times, most recently from 9c9f537 to 9cc5946 Compare January 1, 2025 23:11
@minhnhathoang minhnhathoang changed the title Custom callbacks for graphql client feat: add interceptors for http and graphql client to support multiple subgraph api keys Jan 2, 2025
@minhnhathoang minhnhathoang force-pushed the feat/multiple-thegraph-api-keys branch from 1166e3a to 2049ee5 Compare January 2, 2025 06:23
@minhnhathoang minhnhathoang force-pushed the feat/multiple-thegraph-api-keys branch from 2049ee5 to 95d706c Compare January 3, 2025 00:09
@minhnhathoang minhnhathoang marked this pull request as ready for review January 3, 2025 00:32
}

func NewPoolsListUpdater(
cfg *Config,
graphqlClient *graphqlpkg.Client,
graphqlClientCfg *graphqlpkg.Config,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this graphqlClientCfg being used anywhere in this file

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, graphqlClient is initialized with config from pool-service. I removed redundant code


var response struct {
Pools []SubgraphPool `json:"pools"`
}

if err := d.graphqlClient.Run(ctx, req, &response); err != nil {
if err, _ := d.graphqlClient.Run(ctx, req, &response); err != nil {
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're more familiar with convention of returning the error at the last position image

"github.com/pkg/errors"
)

type IClient interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this interface complete with all the required methods ?

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.

3 participants