-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add HumanTap from World Chain #3211
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
Open
jwcheon
wants to merge
1
commit into
DefiLlama:master
Choose a base branch
from
jwcheon:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,106 @@ | ||
import type { SimpleAdapter } from "../../adapters/types"; | ||
import type { FetchOptions, FetchResultV2, FetchV2 } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const CONTRACTS = { | ||
V1: "0xC9f0Cc4e0cbb1143CcBE12Fc59cE5270112d7845", | ||
V2: "0xF92dEC11Eb85DE7a3E618c4E8e4F79Fc60651Ba8", | ||
V3: "0x3f117952Bb5FbB19a6aDf4fBDa28F86bC6eD9587", | ||
CLAIM: "0xa41C23Dd9525FD8620F3a49305eCecD3639Fbc5c", | ||
}; | ||
|
||
const WLD = "0x2cFc85d8E48F8EAB294be644d9E25C3030863003"; | ||
const HTAP = "0xab4EAAC9D4DF861C82A0637db86dE45dd562379a"; | ||
|
||
const abi = { | ||
HTAPBought: "event HTAPBought(address indexed user, uint256 wldSpent, uint256 htapReceived, uint256 timestamp)", | ||
WLDDistributed: "event WLDDistributed(uint256 lpAmount, uint256 buybackAmount, uint256 treasuryAmount)", | ||
Claimed: "event Claimed(address indexed user, uint256 claimed, uint256 burned)", | ||
}; | ||
|
||
async function fetchContractData(contract: string, options: FetchOptions) { | ||
const dailyVolume = options.createBalances(); | ||
|
||
// Get WLD distribution logs | ||
const wldLogs = await options.getLogs({ | ||
target: contract, | ||
eventAbi: abi.WLDDistributed, | ||
}); | ||
|
||
for (const log of wldLogs) { | ||
// Add total WLD volume (sum of all portions) | ||
const totalWLD = BigInt(log.lpAmount) + BigInt(log.buybackAmount) + BigInt(log.treasuryAmount); | ||
dailyVolume.add(WLD, totalWLD); | ||
} | ||
|
||
// Get HTAP volume from HTAPBought events | ||
const htapLogs = await options.getLogs({ | ||
target: contract, | ||
eventAbi: abi.HTAPBought, | ||
}); | ||
|
||
for (const log of htapLogs) { | ||
// Add HTAP volume (amount received) | ||
dailyVolume.add(HTAP, BigInt(log.htapReceived)); | ||
} | ||
|
||
return dailyVolume; | ||
} | ||
|
||
async function fetchAirdropData(options: FetchOptions) { | ||
const dailyVolume = options.createBalances(); | ||
|
||
// Track claimed tokens | ||
const claimLogs = await options.getLogs({ | ||
target: CONTRACTS.CLAIM, | ||
eventAbi: abi.Claimed, | ||
}); | ||
|
||
for (const log of claimLogs) { | ||
// Add claimed HTAP to volume | ||
dailyVolume.add(HTAP, BigInt(log.claimed)); | ||
// Add burned HTAP to volume | ||
dailyVolume.add(HTAP, BigInt(log.burned)); | ||
} | ||
|
||
return dailyVolume; | ||
} | ||
|
||
export const fetch: FetchV2 = async (options: FetchOptions): Promise<FetchResultV2> => { | ||
const dailyVolume = options.createBalances(); | ||
|
||
// Fetch data from all three versions of PayWLDWithPermit | ||
const v1Volume = await fetchContractData(CONTRACTS.V1, options); | ||
const v2Volume = await fetchContractData(CONTRACTS.V2, options); | ||
const v3Volume = await fetchContractData(CONTRACTS.V3, options); | ||
|
||
// Fetch airdrop data | ||
const airdropVolume = await fetchAirdropData(options); | ||
|
||
// Combine all volumes | ||
dailyVolume.addBalances(v1Volume); | ||
dailyVolume.addBalances(v2Volume); | ||
dailyVolume.addBalances(v3Volume); | ||
dailyVolume.addBalances(airdropVolume); | ||
|
||
return { | ||
dailyVolume, | ||
}; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.WC]: { | ||
fetch: fetch, | ||
start: "2025-04-19", | ||
meta: { | ||
methodology: { | ||
dailyVolume: "Volume is calculated as the sum of: 1) Total WLD distributed (LP + buyback + treasury) from WLDDistributed events and HTAP received from HTAPBought events across all three contract versions, 2) All HTAP claimed and penaltized for early claim in the airdrop contract", | ||
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. I am bit confused, we dont treat token distribution as volume. but if there are purchases done in your app, we can track those fees, and maybe show the revenue of the app, and percentage of the fees given back to holders via buyback. |
||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default adapter; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
so, this event is emitted when users purchase on your platform? what percentage of it is used for buyback?