-
Notifications
You must be signed in to change notification settings - Fork 33
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(rfq-relayer): apply zap fee to dest amount for active quotes [SLT-465] #3395
Changes from 4 commits
765a5f8
61b1b9a
868c213
1caa62c
40eb027
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/ipfs/go-log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/synapsecns/sanguine/core/metrics" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/synapsecns/sanguine/services/rfq/contracts/fastbridgev2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/synapsecns/sanguine/services/rfq/relayer/pricer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/synapsecns/sanguine/services/rfq/relayer/relconfig" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/synapsecns/sanguine/services/rfq/relayer/reldb" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -338,7 +339,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// getActiveRFQ handles an active RFQ message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//nolint:nilnil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (m *Manager) generateActiveRFQ(ctx context.Context, msg *model.ActiveRFQMessage) (resp *model.ActiveRFQMessage, err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ctx, span := m.metricsHandler.Tracer().Start(ctx, "generateActiveRFQ", trace.WithAttributes( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
attribute.String("op", msg.Op), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
attribute.String("content", string(msg.Content)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -379,11 +380,38 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DestBalance: inv[rfqRequest.Data.DestChainID][common.HexToAddress(rfqRequest.Data.DestTokenAddr)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OriginAmountExact: originAmountExact, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if rfqRequest.Data.ZapNative != "" || rfqRequest.Data.ZapData != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
zapNative, ok := new(big.Int).SetString(rfqRequest.Data.ZapNative, 10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if !ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("invalid zap native amount: %s", rfqRequest.Data.ZapNative) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
quoteInput.QuoteRequest = &reldb.QuoteRequest{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Transaction: fastbridgev2.IFastBridgeV2BridgeTransactionV2{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZapNative: zapNative, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZapData: []byte(rfqRequest.Data.ZapData), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+383
to
+394
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect conversion of The code converts Apply this diff to fix the issue: +import (
+ "encoding/hex"
+ "strings"
+)
...
if rfqRequest.Data.ZapNative != "" || rfqRequest.Data.ZapData != "" {
zapNative, ok := new(big.Int).SetString(rfqRequest.Data.ZapNative, 10)
if !ok {
return nil, fmt.Errorf("invalid zap native amount: %s", rfqRequest.Data.ZapNative)
}
+ zapDataBytes, err := hex.DecodeString(strings.TrimPrefix(rfqRequest.Data.ZapData, "0x"))
+ if err != nil {
+ return nil, fmt.Errorf("invalid zap data: %s", rfqRequest.Data.ZapData)
+ }
quoteInput.QuoteRequest = &reldb.QuoteRequest{
Transaction: fastbridgev2.IFastBridgeV2BridgeTransactionV2{
ZapNative: zapNative,
- ZapData: []byte(rfqRequest.Data.ZapData),
+ ZapData: zapDataBytes,
},
}
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rawQuote, err := m.generateQuote(ctx, quoteInput) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("error generating quote: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// adjust dest amount by fixed fee | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
destAmountBigInt, ok := new(big.Int).SetString(rawQuote.DestAmount, 10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if !ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("invalid dest amount: %s", rawQuote.DestAmount) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fixedFeeBigInt, ok := new(big.Int).SetString(rawQuote.FixedFee, 10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if !ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("invalid fixed fee: %s", rawQuote.FixedFee) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
destAmountAdj := new(big.Int).Sub(destAmountBigInt, fixedFeeBigInt) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if destAmountAdj.Sign() < 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
destAmountAdj = big.NewInt(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rawQuote.DestAmount = destAmountAdj.String() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
span.SetAttributes(attribute.String("dest_amount", rawQuote.DestAmount)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rfqResp := model.WsRFQResponse{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Missing test coverage for zap fee calculations
The test coverage for the
addZapFees
functionality is incomplete. While there are tests for general fee calculations infee_pricer_test.go
, there are no specific test cases for:getZapGasEstimate
)Required test additions:
fee_pricer_test.go
foraddZapFees
with various zap data scenarios🔗 Analysis chain
Verify test coverage for the new functionality.
Since this is a test export, ensure that comprehensive tests are implemented for the underlying
generateActiveRFQ
method, particularly around the new zap fee calculations mentioned in the PR title.Let me gather more information about the test coverage by checking the actual test implementations.
Let me check for specific test coverage of the zap fee calculations.
Let me check for tests in the pricer package since that's where the zap fee implementation is located.
Let me check the actual content of the fee pricer test files to verify the test coverage.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 950
Script:
Length of output: 29647
Script:
Length of output: 2280
Script:
Length of output: 785
Script:
Length of output: 20603