-
Notifications
You must be signed in to change notification settings - Fork 1.8k
hikari reapplication for defi Llama #5789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8126d16
96f7d61
e721857
8b99953
0f120c8
fadb92f
c738554
c0d6b3f
074420b
d66e363
4ea28d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { FetchOptions, SimpleAdapter } from "../adapters/types"; | ||
| import { CHAIN } from "../helpers/chains"; | ||
|
|
||
| const KATANA_TOKEN = "0x7F1f4b4b29f5058fA32CC7a97141b8D7e5ABDC2d"; | ||
| const hikariPool = "0x2ac7673C3a0370dE512A20464a800fa7C53235C3"; | ||
| const hikariStaking = "0xeCA16687491B0D748C6246645f56AAE787474f3b"; | ||
| const AUSD_TOKEN = "0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a"; | ||
|
|
||
| const FEE_EVENT = | ||
| "event Collect(address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1)"; | ||
|
|
||
| const SWAP_EVENT = | ||
| "event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)"; | ||
|
|
||
| const STAKED_EVENT = | ||
| "event Staked(address user, uint256 amount, address pool, uint256 time)"; | ||
|
|
||
| const UNSTAKED_EVENT = | ||
| "event Unstaked(address user, uint256 amount, address pool, uint256 time, uint256 matureTime)"; | ||
|
|
||
| const REWARD_CLAIMED_EVENT = | ||
| "event RewardClaimed(address user, uint256 ausd, address pool, uint256 time, address ausd_)"; // ausd_ is the reward token for the user | ||
|
|
||
| const KATANA_CLAIMED_EVENT = | ||
| "event KatanaClaimed(address sender, address vault, uint256 tokens, uint256 acc)"; | ||
|
|
||
| const fetch = async (options: FetchOptions) => { | ||
| const dailyUserFees = options.createBalances(); | ||
| const dailyFees = options.createBalances(); | ||
| const dailySupplySideRevenue = options.createBalances(); | ||
| const dailyRevenue = options.createBalances(); | ||
|
|
||
| const stakedLogs = await options.getLogs({ | ||
| target: hikariStaking, | ||
| eventAbi: STAKED_EVENT, | ||
| }); | ||
|
|
||
| const katanaLogs = await options.getLogs({ | ||
| target: hikariStaking, | ||
| eventAbi: KATANA_CLAIMED_EVENT, | ||
| }); | ||
|
|
||
| const feesLogs = await options.getLogs({ | ||
| target: hikariPool, | ||
| eventAbi: FEE_EVENT, | ||
| }); | ||
|
|
||
| const rewardClaimedLogs = await options.getLogs({ | ||
| target: hikariStaking, | ||
| eventAbi: REWARD_CLAIMED_EVENT, | ||
| }); | ||
|
|
||
| feesLogs.forEach((feeLog) => { | ||
| dailyRevenue.addUSDValue(feeLog.amount0); | ||
| }); | ||
|
|
||
| rewardClaimedLogs.forEach((rewardClaimedLog) => { | ||
| const rewardClaimed = Number(rewardClaimedLog.ausd) / 1e6; | ||
| const totalFees = rewardClaimed / 0.03; | ||
| const userFees = totalFees * 0.7; | ||
| dailyUserFees.addUSDValue(userFees); | ||
| dailyRevenue.addUSDValue(userFees); | ||
| dailySupplySideRevenue.add(AUSD_TOKEN, rewardClaimedLog.ausd); | ||
| }); | ||
|
|
||
| katanaLogs.forEach((katanaLog) => { | ||
| const katana = Number(katanaLog.tokens); | ||
| dailySupplySideRevenue.add(KATANA_TOKEN, katana); | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return { | ||
| dailyUserFees, | ||
| dailyFees, | ||
| dailyProtocolRevenue: dailyUserFees, | ||
| dailyRevenue, | ||
| dailySupplySideRevenue, | ||
| }; | ||
|
Comment on lines
+71
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Was this intentional, or should 🐛 Possible fix if dailyFees should mirror dailyRevenue from Collect events feesLogs.forEach((feeLog) => {
+ dailyFees.addUSDValue(feeLog.amount0);
dailyRevenue.addUSDValue(feeLog.amount0);
});🤖 Prompt for AI Agents |
||
| }; | ||
|
|
||
| const adapter: SimpleAdapter = { | ||
| methodology: { | ||
| Fees: "Fees collected from the Hikari pool's Concentrated Liquidity.", | ||
| Revenue: "Revenue collected from fees and yield from the staking contract.", | ||
| UserFees: "User fees collected from the staking contract.", | ||
| SupplySideRevenue: | ||
| "Supply side revenue collected from the staking contract in Katana tokens and AUSD tokens.", | ||
| }, | ||
| version: 2, | ||
| adapter: { | ||
| [CHAIN.KATANA]: { | ||
| fetch: fetch as any, | ||
| start: "2025-07-08", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default adapter; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify
amount0is actually a USD value.addUSDValue()expects a value denominated in USD, butamount0from theCollectevent is the raw token amount collected (likely in token decimals). If the collected token is not a USD-pegged stablecoin with 1:1 value, this will produce incorrect revenue figures.Consider whether you need to convert
amount0to USD using token pricing, or if AUSD is indeed 1:1 pegged with appropriate decimal handling.🤖 Prompt for AI Agents