Skip to content

Commit

Permalink
feat(path-finder): add StellaSwapV4 (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayden0323 authored Feb 12, 2025
1 parent 2a7cc0b commit e8273f6
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 287 deletions.
4 changes: 2 additions & 2 deletions examples/v2-aggregation-router-api-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"v2-aggregation-router-api"
],
"scripts": {
"start": "esno index.ts",
"start": "tsx index.ts",
"check": "tsc --pretty --noEmit",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"lint": "TIMING=1 eslint . --fix"
Expand All @@ -24,8 +24,8 @@
"@zenlink-interface/typescript-config": "workspace:*",
"dotenv": "^16.3.1",
"eslint": "^8.51.0",
"esno": "^0.17.0",
"ts-node": "^10.9.1",
"tsx": "^4.19.2",
"typescript": "5.2.2"
}
}
14 changes: 7 additions & 7 deletions packages/smart-router/src/__tests__/datafetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { afterAll, beforeAll, expect, describe, it } from "vitest"
import { DataFetcher } from "../fetchers"
import { LiquidityProviders, NativeWrapProvider } from "../liquidity-providers"
import { Chain, createPublicClient, http } from "viem"
import { scroll } from "@zenlink-interface/wagmi-config"
import { moonbeam, scroll } from "@zenlink-interface/wagmi-config"
import { Router } from "../routers"
import { BigNumber } from "@ethersproject/bignumber"

const DATA_FETCHER = new DataFetcher(
ParachainId.SCROLL,
ParachainId.MOONBEAM,
createPublicClient({
chain: scroll as Chain,
transport: http(scroll.rpcUrls.default.http[0]),
chain: moonbeam as Chain,
transport: http(moonbeam.rpcUrls.default.http[0]),
})
)
const DEFAULT_PROVIDERS = [
LiquidityProviders.KyperElastic,
LiquidityProviders.StellaSwapV4,
// LiquidityProviders.Sirius,
// LiquidityProviders.ZenlinkStableSwap,
// LiquidityProviders.Gmx,
Expand Down Expand Up @@ -46,8 +46,8 @@ describe('DataFetcher', () => {
expect(DATA_FETCHER.getCurrentPoolStateId(DEFAULT_PROVIDERS)).toBe(0)
})

const token0 = WNATIVE[ParachainId.SCROLL]
const token1 = USDC[ParachainId.SCROLL]
const token0 = WNATIVE[ParachainId.MOONBEAM]
const token1 = USDC[ParachainId.MOONBEAM]

it.skip(`should fetch pools for ${token0.symbol} and ${token1.symbol}`, async () => {
DATA_FETCHER.startDataFetching(DEFAULT_PROVIDERS)
Expand Down
2 changes: 1 addition & 1 deletion packages/smart-router/src/entities/Graph.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
import type {
BaseToken,
NetworkInfo,
RouteLeg,
SplitMultiRoute,
} from '@zenlink-interface/amm'
import type { BasePool } from './pools'
/* eslint-disable no-console */
import { BigNumber } from '@ethersproject/bignumber'
import { PoolType, RouteStatus } from '@zenlink-interface/amm'
import invariant from 'tiny-invariant'
Expand Down
3 changes: 3 additions & 0 deletions packages/smart-router/src/fetchers/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
StellaStableProvider,
StellaSwapV2Provider,
StellaSwapV3Provider,
StellaSwapV4Provider,
SushiProvider,
SushiV3Provider,
SyncswapProvider,
Expand Down Expand Up @@ -46,6 +47,7 @@ export const LIQUIDITY_PROVIDERS_MAP: Record<string, typeof MinimalImplLiquidity
[LiquidityProviders.StellaStable]: StellaStableProvider,
[LiquidityProviders.StellaSwapV2]: StellaSwapV2Provider,
[LiquidityProviders.StellaSwapV3]: StellaSwapV3Provider,
[LiquidityProviders.StellaSwapV4]: StellaSwapV4Provider,
[LiquidityProviders.BeamswapV2]: BeamSwapV2Provider,
[LiquidityProviders.BeamswapV3]: BeamSwapV3Provider,
[LiquidityProviders.BeamStable]: BeamStableProvider,
Expand Down Expand Up @@ -76,6 +78,7 @@ export const LIQUIDITY_PROVIDERS: LiquidityProviders[] = [
LiquidityProviders.StellaStable,
LiquidityProviders.StellaSwapV2,
LiquidityProviders.StellaSwapV3,
LiquidityProviders.StellaSwapV4,
LiquidityProviders.BeamswapV2,
LiquidityProviders.BeamswapV3,
LiquidityProviders.BeamStable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum LiquidityProviders {
ZenlinkStableSwap = 'ZenlinkStableSwap',
StellaSwapV2 = 'StellaSwapV2',
StellaSwapV3 = 'StellaSwapV3',
StellaSwapV4 = 'StellaSwapV4',
StellaStable = 'StellaStable',
Solarbeam = 'Solarbeam',
ArthSwapV2 = 'ArthSwapV2',
Expand Down
26 changes: 26 additions & 0 deletions packages/smart-router/src/liquidity-providers/StellaSwapV4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { PublicClient } from 'viem'
import { ParachainId } from '@zenlink-interface/chain'

import { AlgebraBaseProvider } from './AlgebraBase'
import { LiquidityProviders } from './LiquidityProvider'

export class StellaSwapV4Provider extends AlgebraBaseProvider {
public constructor(chainId: ParachainId, client: PublicClient) {
const factory = {
[ParachainId.MOONBEAM]: '0x90dD87C994959A36d725bB98F9008B0b3C3504A0',
} as const
const stateMultiCall = {
[ParachainId.MOONBEAM]: '0x5dA55ED94De76E82A4355921504A7eCFEFA2EF00',
} as const

super(chainId, client, factory, stateMultiCall)
}

public getType(): LiquidityProviders {
return LiquidityProviders.StellaSwapV4
}

public getPoolProviderName(): string {
return 'StellaSwapV4'
}
}
1 change: 1 addition & 0 deletions packages/smart-router/src/liquidity-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './Skydrome'
export * from './StellaStable'
export * from './StellaSwapV2'
export * from './StellaSwapV3'
export * from './StellaSwapV4'
export * from './Sushi'
export * from './SushiV3'
export * from './Syncswap'
Expand Down
Loading

0 comments on commit e8273f6

Please sign in to comment.