Skip to content

Commit

Permalink
support all 3 new indices
Browse files Browse the repository at this point in the history
  • Loading branch information
jankjr committed Feb 14, 2025
1 parent cebb579 commit b360dc5
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 181 deletions.
80 changes: 80 additions & 0 deletions src.ts/configuration/data/8453/univ3.json
Original file line number Diff line number Diff line change
Expand Up @@ -4339,6 +4339,16 @@
"id": "0x4200000000000000000000000000000000000006"
}
},
{
"id": "0x5624a729b13af57cfd7155639dc312d4f0c308b1",
"feeTier": 3000,
"token0": {
"id": "0x4200000000000000000000000000000000000006"
},
"token1": {
"id": "0xcb9eec5748aaafa41fbcbe0b58465efed11ce176"
}
},
{
"id": "0x564b22ebed5b7ec8a04987a5e8bdd2e6578d5261",
"feeTier": 10000,
Expand Down Expand Up @@ -4669,6 +4679,16 @@
"id": "0x9124577428c5bd73ad7636cbc5014081384f29d6"
}
},
{
"id": "0x5c48cb68a4d5a344b85595ae44b0bd6a98a3b74b",
"feeTier": 3000,
"token0": {
"id": "0x4200000000000000000000000000000000000006"
},
"token1": {
"id": "0xfa1df3f6108db461fd89437f320fe50c125af5f0"
}
},
{
"id": "0x5c5dcffd04c10babd812da93ca6cf96468bd7b35",
"feeTier": 10000,
Expand Down Expand Up @@ -7589,6 +7609,16 @@
"id": "0xccc7e9b7a1e2fa193683f23e23c495ecde3c4db8"
}
},
{
"id": "0x9140d1bc4f976dbcea88575f42d73716054c38bd",
"feeTier": 3000,
"token0": {
"id": "0x378c326a472915d38b2d8d41e1345987835fab64"
},
"token1": {
"id": "0x4200000000000000000000000000000000000006"
}
},
{
"id": "0x91522e53e34505ecac2a4d6d5f734a55f9799c58",
"feeTier": 100,
Expand Down Expand Up @@ -8469,6 +8499,16 @@
"id": "0x4200000000000000000000000000000000000006"
}
},
{
"id": "0x9ed7eb51a8e6af23d77180acc32a3312a06bdc79",
"feeTier": 500,
"token0": {
"id": "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf"
},
"token1": {
"id": "0xf1143f3a8d76f1ca740d29d5671d365f66c44ed1"
}
},
{
"id": "0x9ef316e7915fa3910851098cb76a8401e652db49",
"feeTier": 100,
Expand Down Expand Up @@ -9259,6 +9299,16 @@
"id": "0x4a4200947ad71ba4eb5ffeff10cc603a17af2f95"
}
},
{
"id": "0xae50c3b3e9be6a836f2fe3c5c8daea5eafaf28b2",
"feeTier": 3000,
"token0": {
"id": "0x4200000000000000000000000000000000000006"
},
"token1": {
"id": "0xd01cb4171a985571deff48c9dc2f6e153a244d64"
}
},
{
"id": "0xae8d5b91fca627410a3bef77f55fcfe208409a40",
"feeTier": 10000,
Expand Down Expand Up @@ -10119,6 +10169,16 @@
"id": "0x919e43a2cce006710090e64bde9e01b38fd7f32f"
}
},
{
"id": "0xc06926b1ae55a2aeb99a45f27aad24d1eecc1501",
"feeTier": 3000,
"token0": {
"id": "0x40318ee213227894b5316e5ec84f6a5caf3bbedd"
},
"token1": {
"id": "0x4200000000000000000000000000000000000006"
}
},
{
"id": "0xc0dff99bf5afc985396d275c84a1c94dec5b9614",
"feeTier": 10000,
Expand Down Expand Up @@ -10839,6 +10899,16 @@
"id": "0xe3d43486d482757e4a7ac1a0b715be455684192f"
}
},
{
"id": "0xcf77b6cec4e7d7d8c46b6bd098e1eeaa98a648ac",
"feeTier": 3000,
"token0": {
"id": "0x4200000000000000000000000000000000000006"
},
"token1": {
"id": "0xdf5913632251585a55970134fad8a774628e9388"
}
},
{
"id": "0xcfa7c4bb565915f1c4f9475e2a0536d31efad776",
"feeTier": 10000,
Expand Down Expand Up @@ -12919,6 +12989,16 @@
"id": "0xe446374e71acc3b4800e8a7eaae913d74600dd00"
}
},
{
"id": "0xf511e60cbcc042cb6fe3efdfdf045b784dc0b43c",
"feeTier": 3000,
"token0": {
"id": "0x4200000000000000000000000000000000000006"
},
"token1": {
"id": "0x90131d95a9a5b48b6a3ee0400807248becf4b7a4"
}
},
{
"id": "0xf5677b22454dee978b2eb908d6a17923f5658a79",
"feeTier": 10000,
Expand Down
42 changes: 42 additions & 0 deletions src.ts/configuration/data/base/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -12119,6 +12119,12 @@
"name": "Pnut",
"decimals": 9
},
{
"address": "0x378c326a472915d38b2d8d41e1345987835fab64",
"symbol": "uXLM",
"name": "uXLM",
"decimals": 18
},
{
"address": "0x3792dbdd07e87413247df995e692806aa13d3299",
"symbol": "OMI",
Expand Down Expand Up @@ -14033,6 +14039,12 @@
"name": "sAMM-EXTRA/AERO",
"decimals": 18
},
{
"address": "0x40318ee213227894b5316e5ec84f6a5caf3bbedd",
"symbol": "uICP",
"name": "uICP",
"decimals": 18
},
{
"address": "0x40329296d658cc5b782e30714d07666465fdc535",
"symbol": "KWAII",
Expand Down Expand Up @@ -30095,6 +30107,12 @@
"name": "BEPIS",
"decimals": 18
},
{
"address": "0x90131d95a9a5b48b6a3ee0400807248becf4b7a4",
"symbol": "uONDO",
"name": "uONDO",
"decimals": 18
},
{
"address": "0x902af348410ffd27664ab2023f062596dd5d1325",
"symbol": "TURD",
Expand Down Expand Up @@ -41129,6 +41147,12 @@
"name": "Base Pump",
"decimals": 18
},
{
"address": "0xcb9eec5748aaafa41fbcbe0b58465efed11ce176",
"symbol": "BGB",
"name": "BGB",
"decimals": 18
},
{
"address": "0xcb9f9348f0eb3dd62e924b85fbe555f9d981899d",
"symbol": "DREAMBOY",
Expand Down Expand Up @@ -41939,6 +41963,12 @@
"name": "SAM",
"decimals": 18
},
{
"address": "0xd01cb4171a985571deff48c9dc2f6e153a244d64",
"symbol": "uARB",
"name": "uARB",
"decimals": 18
},
{
"address": "0xd01fc491b5f4242cc181ae9652facee9148c9c86",
"symbol": "Pochita",
Expand Down Expand Up @@ -44753,6 +44783,12 @@
"name": "LICKER",
"decimals": 9
},
{
"address": "0xdf5913632251585a55970134fad8a774628e9388",
"symbol": "uFIL",
"name": "uFIL",
"decimals": 18
},
{
"address": "0xdf66508f76f97608da6ae1b14c86eb3cb7b00ab4",
"symbol": "BOPCAT",
Expand Down Expand Up @@ -49307,6 +49343,12 @@
"name": "LORA",
"decimals": 18
},
{
"address": "0xfa1df3f6108db461fd89437f320fe50c125af5f0",
"symbol": "TRX",
"name": "TRX",
"decimals": 6
},
{
"address": "0xfa1f6e048e66ac240a4bb7eab7ee888e76081a6c",
"symbol": "DRONE",
Expand Down
7 changes: 7 additions & 0 deletions src.ts/configuration/setupUniswapV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ const configs: Record<ChainId, IUniswapV3Config> = {
pools: [
'0x5ffb17d686f6c7fb5105633734e76e632c4a5979',
'0x9ed7eb51a8e6af23d77180acc32a3312a06bdc79',
'0x5C48Cb68A4d5A344B85595AE44b0Bd6A98a3B74b',
'0xAe50c3B3E9bE6a836F2Fe3C5c8daea5EAfaF28b2',
'0x9140D1bc4F976dBCea88575f42d73716054c38BD',
'0xcf77b6cec4e7d7d8c46b6bd098e1eeaa98a648ac',
'0xf511E60cbCc042Cb6fe3eFDFDf045b784dC0b43c',
'0xc06926b1AE55A2aEB99a45F27AaD24d1eecC1501',
'0x5624a729b13AF57cFd7155639DC312d4f0c308b1',
],
staticPools: baseUniV3.map((i) => ({
...i,
Expand Down
57 changes: 27 additions & 30 deletions src.ts/exchange-graph/BFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,26 +301,24 @@ export const bestPath = async (
ctx: Universe,
start: TokenQuantity,
end: Token,
maxSteps: number,
preferedTokens?: Set<Token>
idealNumberOfSteps: number,
maxSteps: number
) => {
const graph = ctx.graph
const result = new Map<
Token,
{ path: Token[]; actions: Action[]; legAmount: TokenQuantity[] }
>()

if (preferedTokens == null) {
preferedTokens = computePreferredTokenSet(
ctx,
start.token,
end,
(maxSteps + 1) * 2
)
const preferedTokens = computePreferredTokenSet(
ctx,
start.token,
end,
maxSteps
)

if (preferedTokens.size === 0) {
return new Map()
}
if (preferedTokens.size === 0) {
return new Map()
}

const toVisit = new Queue<Node>()
Expand Down Expand Up @@ -356,12 +354,12 @@ export const bestPath = async (
if (lastToken === end) {
continue
}
if (node.steps >= maxSteps) {
if (node.steps >= idealNumberOfSteps) {
if (result.has(end)) {
continue
}
}
if (node.steps >= (maxSteps + 1) * 2) {
if (node.steps >= maxSteps) {
continue
}
const vertex = graph.vertices.get(node.token)
Expand All @@ -379,27 +377,26 @@ export const bestPath = async (
return
}
}
const minAmount = node.legAmount[0].amount * 4n
await Promise.all(
actions
.filter((action) => action.is1to1)
.map(async (action) => {
try {
if (action.isTrade) {
const bals = await action.balances(
ctx,
node.legAmount[0].token
)
const bal = bals.find(
(b) => b.token === node.legAmount[0].token
)
if (bal == null) {
return
}
if (bal.amount < minAmount) {
return
}
}
// if (action.isTrade) {
// const bals = await action.balances(
// ctx,
// node.legAmount[0].token
// )
// const bal = bals.find(
// (b) => b.token === node.legAmount[0].token
// )
// if (bal == null) {
// return
// }
// if (bal.amount < minAmount) {
// return
// }
// }
let newLegAmount
if (action instanceof UniswapV2Swap) {
newLegAmount = await action.quoteWithoutFeeCheck(
Expand Down
12 changes: 2 additions & 10 deletions src.ts/searcher/DexLiquidtyPriceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ export class DexLiquidtyPriceStore {
}
}
private async computeTradesPath(input: TokenQuantity, target: Token) {
let interestingTokens = new Set<Token>([
...Object.values(this.universe.commonTokens),
...Object.values(this.universe.rTokens),
])
if (!interestingTokens.has(target) || !interestingTokens.has(input.token)) {
console.log(`Disabling interesting paths for ${input.token} -> ${target}`)
interestingTokens.clear()
}
let path = this.bestPathCache.get(input.token).get(target)
if (path != null) {
return path
Expand All @@ -64,8 +56,8 @@ export class DexLiquidtyPriceStore {
this.universe,
input,
target,
1,
interestingTokens.size > 0 ? interestingTokens : undefined
2,
5
).then((m) => {
this.recordAllSingleStepBestPaths(input.token, m)
return m.get(target)?.path ?? []
Expand Down
14 changes: 11 additions & 3 deletions src.ts/searcher/TokenFlowGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,15 @@ const createResult = async (
const txFee = universe.nativeToken.from(gasUnits * universe.gasPrice)

const [inputPrices, outputPrices, gasPrice] = await Promise.all([
Promise.all(inputs.map((i) => i.price())),
Promise.all(outputs.map((o) => o.price().then((i) => i.asNumber()))),
Promise.all(inputs.map((i) => i.price().catch(() => i.token.zero))),
Promise.all(
outputs.map((o) =>
o
.price()
.then((i) => i.asNumber())
.catch(() => 0)
)
),
txFee.price(),
])
let outputTokenValue = 0
Expand All @@ -876,7 +883,8 @@ const createResult = async (
}
inputQuantity = inputs[0].asNumber()

const price = outputTokenValue / (inputSum + gasPrice.asNumber())
const price =
inputSum === 0 ? 0 : outputTokenValue / (inputSum + gasPrice.asNumber())

const dustValue = outputSum - outputTokenValue
return {
Expand Down
Loading

0 comments on commit b360dc5

Please sign in to comment.