Skip to content

Commit d9dcbcf

Browse files
lordshishonoateden
andauthored
create and configure liquidswap adapter (DefiLlama#3557)
* create and configure liquidswap adapter * use output volumes for consistency with other aggregators * refactor codes --------- Co-authored-by: Eden <noat.eth@gmail.com>
1 parent 4cfaf89 commit d9dcbcf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

aggregators/liquidswap/index.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {
2+
FetchOptions,
3+
FetchResultVolume,
4+
SimpleAdapter,
5+
} from "../../adapters/types";
6+
import { CHAIN } from "../../helpers/chains";
7+
8+
const SwapExecutedEvent =
9+
"event SwapExecuted(address indexed sender, address input_token_address, uint256 input_token_amount, address output_token_address, uint256 output_token_amount, uint256 timestamp)"
10+
11+
const LIQUIDSWAP_ADDRESS = "0x744489ee3d540777a66f2cf297479745e0852f7a"
12+
13+
const fetch: any = async (options: FetchOptions): Promise<FetchResultVolume> => {
14+
const dailyVolume = options.createBalances()
15+
16+
const logs = await options.getLogs({ target: LIQUIDSWAP_ADDRESS, eventAbi: SwapExecutedEvent })
17+
logs.forEach((log) => {
18+
dailyVolume.add(log.input_token_address, log.input_token_amount)
19+
})
20+
21+
return { dailyVolume }
22+
};
23+
24+
const adapter: SimpleAdapter = {
25+
version: 2,
26+
adapter: {
27+
[CHAIN.HYPERLIQUID]: {
28+
fetch: fetch,
29+
start: "2025-04-02",
30+
meta: {
31+
methodology: {
32+
Volume: "Volume is calculated from SwapExecuted events emitted by the LiquidSwap aggregator contract.",
33+
},
34+
},
35+
},
36+
},
37+
}
38+
39+
export default adapter

0 commit comments

Comments
 (0)