Skip to content

Commit

Permalink
fix: improve restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieJoo committed Jan 7, 2025
1 parent 4e1d4d1 commit deab163
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/dex/fluid-dex/fluid-dex-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ describe('FluidDex E2E', () => {
describe('Mainnet', () => {
const network = Network.MAINNET;

// TODO: Uncomment when the issue is resolved. Currently no price as expected.
describe.only('FLUID -> ETH', () => {
const tokenASymbol: string = 'FLUID';
const tokenBSymbol: string = 'ETH';

const tokenAAmount: string = '160097047322810379';
const tokenBAmount: string = '79923068733005505624';

testForNetwork(
network,
dexKey,
tokenASymbol,
tokenBSymbol,
tokenAAmount,
tokenBAmount,
);
});

describe('ETH -> INST', () => {
const tokenASymbol: string = 'ETH';
const tokenBSymbol: string = 'INST';
Expand Down
20 changes: 14 additions & 6 deletions src/dex/fluid-dex/fluid-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {

pools: FluidDexPool[] = [];

// temporarily limit FLUID-ETH Dex Pool.
restrictedIds: string[] = [
'FluidDex_0xc800b0e15c40a1ff0539218100c86f4c1bac8d9c',
];

eventPools: FluidDexEventPool[] = [];

readonly factory: FluidDexFactory;
Expand Down Expand Up @@ -111,6 +116,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
async initializePricing(blockNumber: number) {
await this.factory.initialize(blockNumber);
this.pools = await this.fetchFluidDexPools(blockNumber);
this.pools = this.pools.filter(
pool => !this.restrictedIds.includes(pool.id),
);

this.eventPools = await Promise.all(
this.pools.map(async pool => {
Expand All @@ -135,6 +143,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {

protected onPoolCreatedUpdatePools(poolsFromFactory: readonly Pool[]) {
this.pools = this.generateFluidDexPoolsFromPoolsFactory(poolsFromFactory);
this.pools = this.pools.filter(
pool => !this.restrictedIds.includes(pool.id),
);
this.logger.info(`${this.dexKey}: pools list was updated ...`);
}

Expand Down Expand Up @@ -174,6 +185,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
// A pair must have 2 different tokens.
if (srcAddress === destAddress) return [];

this.pools = this.pools.filter(
pool => !this.restrictedIds.includes(pool.id),
);
const pools = this.pools.filter(
pool =>
(srcAddress === pool.token0 && destAddress === pool.token1) ||
Expand Down Expand Up @@ -206,12 +220,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
pools = pools.filter(pool => limitPools.includes(pool.id));
}

// temporarily limit FLUID-ETH Dex Pool.
pools = pools.filter(
pool =>
pool.id != 'FluidDex_0xc800b0e15c40a1ff0539218100c86f4c1bac8d9c',
);

if (!pools.length) return null;

const liquidityProxyState = await this.liquidityProxy.getStateOrGenerate(
Expand Down
5 changes: 5 additions & 0 deletions tests/constants-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ export const Tokens: {
decimals: 18,
symbol: 'EURA',
},
FLUID: {
address: '0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb',
decimals: 18,
},
EUROC: {
address: '0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c',
decimals: 6,
Expand Down Expand Up @@ -1703,6 +1707,7 @@ export const Holders: {
[network: number]: { [tokenAddress: string]: Address };
} = {
[Network.MAINNET]: {
FLUID: '0x2d675D4C52a8aE117b935fF98c6F9f29A15827F0',
USDS: '0xB1796E8f1eEcF23027c1E3C00fE303629A189d10',
sUSDS: '0xd564B3aE673CAa49D054Bf185bD72a6853763eE7',
SKY: '0x0ddda327A6614130CCb20bc0097313A282176A01',
Expand Down

0 comments on commit deab163

Please sign in to comment.