Skip to content

Commit 7b8f92a

Browse files
committed
consider alloyed in route with more priority
1 parent 75e0ccc commit 7b8f92a

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

router/usecase/candidate_routes.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ func (c candidateRouteFinder) FindCandidateRoutesOutGivenIn(ctx context.Context,
125125
continue
126126
}
127127

128-
if pool.GetPoolLiquidityCap() < options.MinPoolLiquidityCap {
128+
// Skip pools with insufficient liquidity, except for transmuter pools
129+
// Transmuter pools should always be considered regardless of liquidity cap
130+
// because they provide no-slippage swaps and we want them prioritized
131+
if pool.GetPoolLiquidityCap() < options.MinPoolLiquidityCap && !pool.IsAlloyTransmuter {
129132
visited[pool.ID] = true
130133
// Skip pools that have less liquidity than the minimum required.
131134
continue

router/usecase/router.go

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,29 @@ func sortPools(pools []ingesttypes.PoolI, transmuterCodeIDs map[uint64]struct{},
122122

123123
ratedPools := make([]ratedPool, 0, len(pools))
124124
for _, pool := range pools {
125+
// Check if this is a transmuter pool first
126+
isTransmuterPool := false
127+
isOrderbookPool := false
128+
129+
if pool.GetType() == poolmanagertypes.CosmWasm {
130+
cosmWasmPoolModel := pool.GetSQSPoolModel().CosmWasmPoolModel
131+
if cosmWasmPoolModel != nil {
132+
if cosmWasmPoolModel.IsAlloyTransmuter() {
133+
isTransmuterPool = true
134+
} else if cosmWasmPoolModel.IsOrderbook() {
135+
isOrderbookPool = true
136+
}
137+
} else {
138+
cosmWasmPool, ok := pool.GetUnderlyingPool().(cosmwasmpooltypes.CosmWasmExtension)
139+
if ok {
140+
_, isTransmuter := transmuterCodeIDs[cosmWasmPool.GetCodeId()]
141+
if isTransmuter {
142+
isTransmuterPool = true
143+
}
144+
}
145+
}
146+
}
147+
125148
// Initialize rating to TVL.
126149
rating, _ := pool.GetPoolLiquidityCap().BigIntMut().Float64()
127150

@@ -143,31 +166,18 @@ func sortPools(pools []ingesttypes.PoolI, transmuterCodeIDs map[uint64]struct{},
143166
rating += totalTVLFloat / 2
144167
}
145168

146-
// Transmuter pools get a boost equal to 3/2 of total value locked across all pools
147-
if pool.GetType() == poolmanagertypes.CosmWasm {
148-
// Grant additional rating to alloyed transmuter.
149-
cosmWasmPoolModel := pool.GetSQSPoolModel().CosmWasmPoolModel
150-
if cosmWasmPoolModel != nil {
151-
if cosmWasmPoolModel.IsAlloyTransmuter() {
152-
// Grant additional rating if alloyed transmuter.
153-
rating += totalTVLFloat * 1.5
154-
} else if cosmWasmPoolModel.IsOrderbook() {
155-
// Orderbook is ranked the highest so that its limits are considered
156-
// frequently.
157-
rating += totalTVLFloat * 2
158-
}
159-
} else {
160-
// Grant additional rating if transmuter.
161-
cosmWasmPool, ok := pool.GetUnderlyingPool().(cosmwasmpooltypes.CosmWasmExtension)
162-
if !ok {
163-
logger.Debug("failed to cast a cosm wasm pool, skip silently", zap.Uint64("pool_id", pool.GetId()))
164-
continue
165-
}
166-
_, isTransmuter := transmuterCodeIDs[cosmWasmPool.GetCodeId()]
167-
if isTransmuter {
168-
rating += totalTVLFloat * 1.5
169-
}
170-
}
169+
// Orderbook pools get a boost equal to 2x of total value locked across all pools
170+
if isOrderbookPool {
171+
rating += totalTVLFloat * 2
172+
}
173+
174+
// For transmuter pools, ensure they're always prioritized by adding a massive boost
175+
// that guarantees higher rating than any non-transmuter pool
176+
if isTransmuterPool {
177+
// Add 10x totalTVL to ensure transmuters always rank highest
178+
// This is added on top of existing rating, so even if pool has zero liquidity cap,
179+
// it will have rating of 10x totalTVL, which beats any non-transmuter
180+
rating += totalTVLFloat * 10.0
171181
}
172182

173183
ratedPools = append(ratedPools, ratedPool{

0 commit comments

Comments
 (0)