forked from paraswap/paraswap-dex-lib
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request paraswap#488 from paraswap/aburkut/back-1263-equal…
…izer BACK-1263: Integrate Equalizer on Fantom
- Loading branch information
Showing
8 changed files
with
325 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Solidly } from '../solidly'; | ||
import { SolidlyPair } from '../types'; | ||
import { Network } from '../../../constants'; | ||
import { IDexHelper } from '../../../dex-helper'; | ||
import { Interface } from '@ethersproject/abi'; | ||
import { getDexKeysWithNetwork } from '../../../utils'; | ||
import { SolidlyConfig } from '../config'; | ||
import _ from 'lodash'; | ||
|
||
const EqualizerFactoryABI = [ | ||
{ | ||
inputs: [{ internalType: 'address', name: '_pair', type: 'address' }], | ||
name: 'getRealFee', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
]; | ||
|
||
const equalizerFactoryIface = new Interface(EqualizerFactoryABI); | ||
|
||
export class Equalizer extends Solidly { | ||
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] = | ||
getDexKeysWithNetwork(_.pick(SolidlyConfig, ['Equalizer'])); | ||
|
||
constructor( | ||
protected network: Network, | ||
dexKey: string, | ||
protected dexHelper: IDexHelper, | ||
) { | ||
super( | ||
network, | ||
dexKey, | ||
dexHelper, | ||
true, // dynamic fees | ||
); | ||
} | ||
|
||
protected getFeesMultiCallData(pair: SolidlyPair) { | ||
const callEntry = { | ||
target: this.factoryAddress, | ||
callData: equalizerFactoryIface.encodeFunctionData('getRealFee', [ | ||
pair.exchange, | ||
]), | ||
}; | ||
const callDecoder = (values: any[]) => | ||
parseInt( | ||
equalizerFactoryIface | ||
.decodeFunctionResult('getRealFee', values)[0] | ||
.toString(), | ||
); | ||
|
||
return { | ||
callEntry, | ||
callDecoder, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.