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 FeePricer to quoter #1684

Merged
merged 29 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
84d0761
Chore: bump go.mod to 1.21
dwasse Dec 19, 2023
2d4f17d
WIP: fee pricer skeleton
dwasse Dec 19, 2023
ad735b6
WIP: impl GetOriginFee()
dwasse Dec 20, 2023
a7ef20a
WIP: impl fee calcs
dwasse Dec 20, 2023
ef58bc0
WIP: impl getGasPrice()
dwasse Dec 20, 2023
bafd335
WIP: getTokenPrice() impl
dwasse Dec 20, 2023
c734165
WIP: remove coingecko price fetching for now; add TokenConfig with US…
dwasse Dec 20, 2023
5c2b9b5
WIP: add caching logic for gas price
dwasse Dec 20, 2023
b33204e
WIP: fee_pricer_test setup
dwasse Dec 20, 2023
d1b8c27
WIP: move pricer to its own package, replace omniClient with
dwasse Dec 20, 2023
66fe894
WIP: getNativeToken() impl
dwasse Dec 20, 2023
3d7300d
WIP: getTokenDecimals() impl
dwasse Dec 20, 2023
eb7fc05
Feat: working TestGetOriginFee
dwasse Dec 20, 2023
a486c3f
Feat: working TestGetDestinationFee
dwasse Dec 20, 2023
41dcfe1
Cleanup: move redundant logic into getFee()
dwasse Dec 20, 2023
1b9354d
Feat: add TestGetTotalFee
dwasse Dec 20, 2023
45eda1a
Feat: add TestGetGasPrice
dwasse Dec 20, 2023
b96a771
Cleanup: TTL -> TTLSeconds
dwasse Dec 20, 2023
9e3aa5a
Feat: set FixedFee in GenerateQuotes() func
dwasse Dec 20, 2023
8c076a6
Feat: consider fees in ShouldProcess() logic
dwasse Dec 20, 2023
583da87
Feat: add TestGenerateQuotes
dwasse Dec 20, 2023
23d2838
Feat: add TestShouldProcess
dwasse Dec 20, 2023
8b2be89
Cleanup: usage of TokenID -> TokenName to avoid confusion
dwasse Dec 20, 2023
b3c95fe
Cleanup: typo
dwasse Dec 21, 2023
2dbed75
WIP: attempt to fix e2e test
dwasse Dec 21, 2023
21350c3
Cleanup: add quoting description in readme
dwasse Dec 21, 2023
54e546e
update string literals (from #1687)
trajan0x Dec 21, 2023
701116d
have SubmitAllQuotes respect context (from #1687)
trajan0x Dec 21, 2023
59a5c47
fix e2e (from #1687)
trajan0x Dec 21, 2023
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
2 changes: 1 addition & 1 deletion agents/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/agents

go 1.20
go 1.21

require (
github.com/BurntSushi/toml v1.2.1
Expand Down
2 changes: 1 addition & 1 deletion contrib/git-changes-action/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/git-changes-action

go 1.20
go 1.21

replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
2 changes: 1 addition & 1 deletion contrib/promexporter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/promexporter

go 1.20
go 1.21

replace (
github.com/Yamashou/gqlgenc => github.com/synapsecns/gqlgenc v0.10.0-hotfix
Expand Down
2 changes: 1 addition & 1 deletion contrib/release-copier-action/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/release-copier-action

go 1.20
go 1.21

require (
github.com/brianvoe/gofakeit/v6 v6.20.1
Expand Down
2 changes: 1 addition & 1 deletion contrib/terraform-provider-helmproxy/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/terraform-provider-helmproxy

go 1.20
go 1.21

replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
2 changes: 1 addition & 1 deletion contrib/terraform-provider-iap/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/terraform-provider-iap

go 1.20
go 1.21

require (
github.com/google/uuid v1.5.0
Expand Down
2 changes: 1 addition & 1 deletion contrib/terraform-provider-kubeproxy/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/terraform-provider-kubeproxy

go 1.20
go 1.21

require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand Down
2 changes: 1 addition & 1 deletion contrib/tfcore/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/contrib/tfcore

go 1.20
go 1.21

require (
cloud.google.com/go/bigtable v1.10.1
Expand Down
2 changes: 1 addition & 1 deletion core/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/core

go 1.20
go 1.21

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand Down
2 changes: 1 addition & 1 deletion ethergo/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/ethergo

go 1.20
go 1.21

require (
cloud.google.com/go/kms v1.15.0
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.20
go 1.21

// note: new paths should be added as flags to the .codecov.yaml
use (
Expand Down
2 changes: 1 addition & 1 deletion services/cctp-relayer/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/services/cctp-relayer

go 1.20
go 1.21

require (
github.com/Flaque/filet v0.0.0-20201012163910-45f684403088
Expand Down
2 changes: 1 addition & 1 deletion services/explorer/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/services/explorer

go 1.20
go 1.21

replace (
github.com/Yamashou/gqlgenc => github.com/synapsecns/gqlgenc v0.10.0-hotfix
Expand Down
2 changes: 1 addition & 1 deletion services/omnirpc/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/services/omnirpc

go 1.20
go 1.21

replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
44 changes: 39 additions & 5 deletions services/rfq/e2e/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package e2e_test

import (
"fmt"
"github.com/ethereum/go-ethereum/common"
"math/big"
"net/http"
"slices"
"strconv"
"sync"

"github.com/Flaque/filet"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand All @@ -26,11 +33,6 @@ import (
"github.com/synapsecns/sanguine/services/rfq/relayer/relconfig"
"github.com/synapsecns/sanguine/services/rfq/relayer/service"
"github.com/synapsecns/sanguine/services/rfq/testutil"
"math/big"
"net/http"
"slices"
"strconv"
"sync"
)

func (i *IntegrationSuite) setupAPI() {
Expand Down Expand Up @@ -194,10 +196,24 @@ func (i *IntegrationSuite) setupRelayer() {
originBackendChainID: {
Bridge: i.manager.Get(i.GetTestContext(), i.originBackend, testutil.FastBridgeType).Address().String(),
Confirmations: 0,
Tokens: map[string]relconfig.TokenConfig{
"ETH": relconfig.TokenConfig{
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we actually need gas token symbol here, but ok.

Think the reality is, before e deploy (or slightly after) config is going to need a complete overhaul in #1650, just don't think this pr is the appropriate place to do that.

My recommendations or how to go about this is:

  1. Convert all current references to pieces of the Config struct to Getters similiar to Submitter IConfig
  2. Reference those
  3. Rewrite the configs
  4. Fix the e2e tests

PriceUSD: 2000,
Decimals: 18,
},
},
NativeToken: "ETH",
},
destBackendChainID: {
Bridge: i.manager.Get(i.GetTestContext(), i.destBackend, testutil.FastBridgeType).Address().String(),
Confirmations: 0,
Tokens: map[string]relconfig.TokenConfig{
"MATIC": relconfig.TokenConfig{
PriceUSD: 0.5,
Decimals: 18,
},
},
NativeToken: "MATIC",
},
},
OmniRPCURL: i.omniServer,
Expand All @@ -213,6 +229,12 @@ func (i *IntegrationSuite) setupRelayer() {
Type: signerConfig.FileType.String(),
File: filet.TmpFile(i.T(), "", i.relayerWallet.PrivateKeyHex()).Name(),
},
FeePricer: relconfig.FeePricerConfig{
GasPriceCacheTTLSeconds: 60,
TokenPriceCacheTTLSeconds: 60,
OriginGasEstimate: 500000,
DestinationGasEstimate: 1000000,
},
}

// in the first backend, we want to deploy a bunch of different tokens
Expand All @@ -224,9 +246,21 @@ func (i *IntegrationSuite) setupRelayer() {
tokenAddress := i.manager.Get(i.GetTestContext(), backend, tokenType).Address().String()
quotableTokenID := fmt.Sprintf("%d-%s", backend.GetChainID(), tokenAddress)

tokenCaller, err := ierc20.NewIerc20Ref(common.HexToAddress(tokenAddress), backend)
i.NoError(err)

decimals, err := tokenCaller.Decimals(&bind.CallOpts{Context: i.GetTestContext()})
i.NoError(err)

// first the simple part, add the token to the token map
cfg.Tokens[int(backend.GetChainID())] = append(cfg.Tokens[int(backend.GetChainID())], tokenAddress)

cfg.Bridges[int(backend.GetChainID())].Tokens[tokenType.Name()] = relconfig.TokenConfig{
Address: tokenAddress,
Decimals: decimals,
PriceUSD: 1, // TODO: this will break on non-stables
}

compatibleTokens := []contracts.ContractType{tokenType}
// DAI/USDT are fungible
if tokenType == testutil.DAIType || tokenType == testutil.USDCType {
Expand Down
2 changes: 1 addition & 1 deletion services/rfq/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/synapsecns/sanguine/services/rfq

go 1.20
go 1.21

require (
github.com/Flaque/filet v0.0.0-20201012163910-45f684403088
Expand Down
4 changes: 4 additions & 0 deletions services/rfq/relayer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ The relayer consists of two main loops that contain the entire business logic of
### Quote Posting

The quote posting process is rather rudimentary. The relayer continously fetches a list of its on chain balances and subtraces any open commitments.

Currently, the quotes are standalone; that is, they are not responding to any client requests. The quoter specifies a `FixedFee` parameter that is meant to account for the gas costs associated with executing transactions on the origin and destinations chains.

In a future version, quotes may be issued in a more classic RFQ-style, where they are posted in response to a client request. In that case we can incorporate more precise pricing logic.
9 changes: 5 additions & 4 deletions services/rfq/relayer/inventory/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package inventory
import (
"context"
"fmt"
"math/big"
"sync"
"time"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -22,9 +26,6 @@ import (
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sync/errgroup"
"math/big"
"sync"
"time"
)

// Manager is the interface for the inventory manager.
Expand Down Expand Up @@ -316,7 +317,7 @@ func (i *inventoryManagerImpl) refreshBalances(ctx context.Context) error {
defer wg.Done()
err = chainClient.BatchWithContext(ctx, deferredCalls...)
if err != nil {
logger.Warnf("coulld not refresh balances on %d: %v", chainID, err)
logger.Warnf("could not refresh balances on %d: %v", chainID, err)
}
}()
}
Expand Down
Loading
Loading