Skip to content

Commit

Permalink
Merge pull request #1684 from synapsecns/fix/new-rfq-fixed-fee-logic
Browse files Browse the repository at this point in the history
Add `FeePricer` to quoter
  • Loading branch information
trajan0x authored Dec 21, 2023
2 parents 90d47cc + 59a5c47 commit 2d03e70
Show file tree
Hide file tree
Showing 32 changed files with 738 additions and 69 deletions.
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{
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)

Check warning on line 320 in services/rfq/relayer/inventory/manager.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/inventory/manager.go#L320

Added line #L320 was not covered by tests
}
}()
}
Expand Down
Loading

0 comments on commit 2d03e70

Please sign in to comment.