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: Mellow LRTs on balancer #21

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/spot_prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func (c *Client) QueryBalancerSpotPrice(p pool.Pool, blockNum uint64) indexer.Sp
c.reportError(fmt.Errorf("error initializing %s pool caller: %w", p.ExchangePair(), err))
return indexer.SpotPrice{}
}
poolRate, err := poolCaller.GetRate(nil)
poolRate, err := poolCaller.GetTokenRate(nil, common.HexToAddress(p.TokenAddress))
if err != nil {
c.reportError(fmt.Errorf("error getting %s pool balance: %w", p.ExchangePair(), err))
c.reportError(fmt.Errorf("error getting %s token rate from pool: %w", p.ExchangePair(), err))
return indexer.SpotPrice{}
}
return indexer.SpotPrice{
Expand Down
16 changes: 3 additions & 13 deletions client/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,13 @@ func (c *Client) WatchBalancerSwapEvent(p pool.Pool) error {
return err
}

// retreive token addresses of pool
vaultCaller, err := vault.NewPoolCaller(vaultAddress, c.ethClient)
if err != nil {
return err
}
poolTokens, err := vaultCaller.GetPoolTokens(nil, poolId)
if err != nil {
return err
}

// build parameters for swap event subscription
poolIdParam := make([][32]byte, 1)
poolIdParam[0] = poolId
tokenInParam := make([]common.Address, 1)
tokenInParam[0] = poolTokens.Tokens[0]
tokenInParam[0] = common.HexToAddress(p.TokenAddress)
tokenOutParam := make([]common.Address, 1)
tokenOutParam[0] = poolTokens.Tokens[1]
tokenOutParam[0] = common.HexToAddress(p.TokenAddress)

vaultFilterer, err := vault.NewPoolFilterer(vaultAddress, c.ethClient)
if err != nil {
Expand Down Expand Up @@ -173,7 +163,7 @@ func (c *Client) WatchBalancerSwapEvent(p pool.Pool) error {

swap := p.ConvertBalancerEventToSwap(event, poolRate)
spotPrice := p.ConvertBalancerEventToSpotPrice(event, poolRate)
c.logger.Info().Interface("balancer swap", swap).Msg("algebra swap event received")
c.logger.Info().Interface("balancer swap", swap).Msg("balancer swap event received")
c.indexer.AddSwap(swap)
c.indexer.AddPrice(spotPrice)
}
Expand Down
1 change: 1 addition & 0 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type Pool struct {
Address string `yaml:"address"`
TokenAddress string `yaml:"token_address"`
Base string `yaml:"base"`
Quote string `yaml:"quote"`
BaseDecimal uint64 `yaml:"base_decimal"`
Expand Down
7 changes: 4 additions & 3 deletions sample-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ exchanges:
node_urls:
- "wss://mainnet.infura.io/ws/v3/6849a09aeeb044b592d46bcdce07ccef"
pools:
- address: "0x596192bB6e41802428Ac943D2f1476C1Af25CC0E"
base: "EZETH"
quote: "WETH"
- address: "0x4216d5900a6109bba48418b5e2AB6cc4e61Cf477"
token_address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a"
base: "RE7LRT"
quote: "ETH"
base_decimal: 18
quote_decimal: 18
invert_price: false
Expand Down
Loading