Open trajan0x opened 10 months ago
To address the issues mentioned:
Case Sensitivity: Ensure that all token addresses are consistently formatted. Modify the SanitizeTokenID
function in relconfig/config.go
to handle this. Use this function wherever token IDs are processed.
// relconfig/config.go
func SanitizeTokenID(id string) (sanitized string, err error) {
split := strings.Split(id, tokenIDDelimiter)
if len(split) != 2 {
return sanitized, fmt.Errorf("invalid token ID: %s", id)
}
chainID, err := strconv.Atoi(split[0])
if err != nil {
return sanitized, fmt.Errorf("invalid chain ID: %s", split[0])
}
addr := common.HexToAddress(strings.ToLower(split[1]))
sanitized = fmt.Sprintf("%d%s%s", chainID, tokenIDDelimiter, addr.Hex())
return sanitized, nil
}
Use SanitizeTokenID
in quoter.go
:
// quoter.go
originIDPair, err := relconfig.SanitizeTokenID(quote.GetOriginIDPair())
if err != nil {
return false, fmt.Errorf("error sanitizing origin ID pair: %w", err)
}
destPairs := m.quotableTokens[originIDPair]
Config Overhaul: Use getters in more places to deduplicate and ensure consistency. Replace direct config map accesses with getter functions in relconfig/getters.go
.
// quoter.go
originIDPair, err := m.config.GetTokenID(quote.Transaction.OriginChainId, quote.Transaction.OriginToken.String())
if err != nil {
return false, fmt.Errorf("error getting origin token ID: %w", err)
}
destPairs, err := m.config.GetQuotableTokens(originIDPair)
if err != nil {
return false, fmt.Errorf("error getting quotable tokens: %w", err)
}
Ensure all token-related operations use these getters to maintain consistency and reduce duplication.
/services/rfq/relayer/quoter/quoter.go /services/rfq/relayer/relconfig/getters.go /services/rfq/relayer/relconfig/config.go
Couple of issues here we should be solving:
address is currently case sensitive. You can see this in
quoter.go
:vs
In order to get #1650 out, we're working around this by just lowercasing everything in in the config but we should make sure these are consistent. There's a chance this is a non-issue because of 2
See this comment Think config needs a complete overhaul basically. I'd use getter sin more places (this could also solve 1) and deduplicate a lot of the quotable token stuff.