Skip to content

Commit 944c9eb

Browse files
committed
2 parents 201c8c7 + f85a46f commit 944c9eb

2 files changed

Lines changed: 79 additions & 1 deletion

File tree

dexs/smardex-usdn/index.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
2+
import { CHAIN } from "../../helpers/chains";
3+
import ADDRESSES from "../../helpers/coreAssets.json";
4+
import { ethers } from "ethers";
5+
6+
// Configuration
7+
const CONFIG = {
8+
TOKENS: {
9+
USDN: "0xde17a000ba631c5d7c2bd9fb692efea52d90dee2",
10+
WSTETH: ADDRESSES.ethereum.WSTETH,
11+
},
12+
CONTRACTS: {
13+
USDN: "0x656cb8c6d154aad29d8771384089be5b5141f01a",
14+
DIP_ACCUMULATOR: "0xaebcc85a5594e687f6b302405e6e92d616826e03",
15+
},
16+
};
17+
18+
// ABIs
19+
const usdnAbi = {
20+
vaultDepositEvent: "event ValidatedDeposit(address indexed to, address indexed validator, uint256 amountAfterFees, uint256 usdnMinted, uint256 timestamp)",
21+
vaultWithdrawalEvent: "event ValidatedWithdrawal(address indexed to, address indexed validator, uint256 amountWithdrawnAfterFees, uint256 usdnBurned, uint256 timestamp)",
22+
longOpenPositionEvent: "event InitiatedOpenPosition(address indexed owner, address indexed validator, uint40 timestamp, uint128 totalExpo, uint128 amount, uint128 startPrice, tuple(int24 tick, uint256 tickVersion, uint256 index) posId)",
23+
longClosePositionEvent: "event ValidatedClosePosition(address indexed validator, address indexed to, tuple(int24 tick, uint256 tickVersion, uint256 index) posId, uint256 amountReceived, int256 profit)",
24+
rebalancerDepositEvent: "event AssetsDeposited(address indexed user, uint256 amount, uint256 positionVersion)",
25+
rebalancerWithdrawalEvent: "event AssetsWithdrawn(address indexed user, address indexed to, uint256 amount)",
26+
liquidatedTickEvent: "event LiquidatedTick(int24 indexed tick, uint256 indexed oldTickVersion, uint256 liquidationPrice, uint256 effectiveTickPrice, int256 remainingCollateral)",
27+
liquidatorRewarded: "event LiquidatorRewarded (address indexed liquidator, uint256 rewards)",
28+
};
29+
30+
const eventConfigs = [
31+
{
32+
abi: usdnAbi.longOpenPositionEvent,
33+
token: CONFIG.TOKENS.WSTETH,
34+
valueIndex: 4,
35+
contract: CONFIG.CONTRACTS.USDN,
36+
},
37+
{
38+
abi: usdnAbi.longClosePositionEvent,
39+
token: CONFIG.TOKENS.WSTETH,
40+
valueIndex: 3,
41+
contract: CONFIG.CONTRACTS.USDN,
42+
},
43+
];
44+
45+
const fetch = async (options: FetchOptions) => {
46+
const dailyVolume = options.createBalances();
47+
48+
for (const config of eventConfigs) {
49+
const logs = await options.getLogs({
50+
eventAbi: config.abi,
51+
target: config.contract,
52+
entireLog: true,
53+
});
54+
55+
const iface = new ethers.Interface([config.abi]);
56+
for (const log of logs) {
57+
const parsedLog = iface.parseLog(log)
58+
const valueDecoded = parsedLog!.args[config.valueIndex] as bigint;
59+
dailyVolume.add(config.token, Number(valueDecoded));
60+
}
61+
}
62+
63+
return {
64+
dailyVolume
65+
};
66+
};
67+
68+
const adapter: SimpleAdapter = {
69+
version: 2,
70+
adapter: {
71+
[CHAIN.ETHEREUM]: {
72+
fetch,
73+
start: '2025-01-22',
74+
},
75+
},
76+
};
77+
78+
export default adapter;

fees/amped/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume
55

66
const endpoints: Record<string, string> = {
77
[CHAIN.LIGHTLINK_PHOENIX]: "https://graph.phoenix.lightlink.io/query/subgraphs/name/amped-finance/trades",
8-
[CHAIN.SONIC]: "https://api.goldsky.com/api/public/project_cm9j641qy0e0w01tzh6s6c8ek/subgraphs/sonic-trades/1.0.1/gn",
8+
[CHAIN.SONIC]: "https://api.goldsky.com/api/public/project_cm9j641qy0e0w01tzh6s6c8ek/subgraphs/sonic-trades/1.0.6/gn",
99
// [CHAIN.BSC]: "https://api.studio.thegraph.com/query/91379/amped-trades-bsc/version/latest"
1010
[CHAIN.BERACHAIN]: "https://api.studio.thegraph.com/query/91379/amped-trades-bera/version/latest",
1111
[CHAIN.BASE]: "https://api.studio.thegraph.com/query/91379/trades-base/version/latest",

0 commit comments

Comments
 (0)