-
Notifications
You must be signed in to change notification settings - Fork 1.7k
shmonad fee adapter #4878
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?
shmonad fee adapter #4878
Conversation
|
The shmonad adapter exports: |
fees/shmonad/index.ts
Outdated
| * @return totalZeroYieldPayable The MON amount earmarked for zero-yield obligations (e.g., commission accruals). | ||
| * https://github.com/FastLane-Labs/fastlane-contracts/blob/485e9305b251089b94f62ef22b7ab9a74e0d32c3/src/shmonad/Storage.sol#L157 | ||
| */ | ||
| const globalLiabilitiesAbi = "function globalLiabilities() view returns (uint128 rewardsPayable, uint128 redemptionsPayable, uint128 totalZeroYieldPayable)"; |
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.
I would wrap all abi variables inside a single variable like ABIS = { getAtomicCapitalAbi, ... }, it makes codes easier to read
fees/shmonad/index.ts
Outdated
| const getAtomicCapitalAbi = "function getAtomicCapital() view returns (uint256 allocated, uint256 distributed)"; | ||
| const getCurrentAssetsAbi = "function getCurrentAssets() view returns (uint256)"; | ||
| const getWorkingCapitalAbi = "function getWorkingCapital() view returns (uint256 staked, uint256 reserved)"; | ||
| const totalSupplyAbi = "function totalSupply() view returns (uint256)"; |
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.
let you know we support simple form of abi for function like totalSupply
Instead of function totalSupply() view returns (uint256)
you can use uint256:totalSupply
fees/shmonad/index.ts
Outdated
| atomicCapital.allocated + | ||
| currentAssets; | ||
|
|
||
| const totalLiabilities = |
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.
Do we really need to calculate this? Because I can see we can get Liabilities from atomicCapital, something like this:
https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/shmonad/index.js#L27
fees/shmonad/index.ts
Outdated
| return totalAssets - totalLiabilities; | ||
| } | ||
|
|
||
| const getFetch = () => { |
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.
please don't do this, except when you need to pass parameters to getFetch function. I would use simple function
const fetch = async (options: FetchOptions) => {
// code logics
}
fees/shmonad/index.ts
Outdated
| const dailyProtocolRevenue = options.createBalances(); | ||
| const dailySupplySideRevenue = options.createBalances(); | ||
|
|
||
| try { |
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.
you don't need try catch here, you should throw Error when failed to read contract
fees/shmonad/index.ts
Outdated
| options.fromApi.call({ target: SHMONAD_CONTRACT, abi: getWorkingCapitalAbi }), | ||
| options.fromApi.call({ target: SHMONAD_CONTRACT, abi: getAtomicCapitalAbi }), | ||
| options.fromApi.call({ target: SHMONAD_CONTRACT, abi: getCurrentAssetsAbi }), | ||
| options.fromApi.call({ target: SHMONAD_CONTRACT, abi: globalLiabilitiesAbi }), |
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.
check this codes, you can reduce the globalLiabilitiesAbi contract call
https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/shmonad/index.js#L27
fees/shmonad/index.ts
Outdated
|
|
||
| // CONVERT TO BIGINT | ||
| // Helper function to safely convert contract return objects to BigInt structure. | ||
| const toBigInt = (obj: any) => ({ |
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.
you don't need to do this, because sdk return data in BigInt already
noateden
left a comment
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.
can you check the contract again? I believe it was an ERC 4626 vault, so you can get the exchange rate before/after by using 2 api calls only
fees/shmonad/index.ts
Outdated
| if (totalRewards > 0n) { | ||
| dailyFees.addGasToken(totalRewards); | ||
|
|
||
| // Protocol revenue = 5% |
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.
Does shmond distribute rewards to stakers pre or post protocol revenue cut?
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.
Does shmond distribute rewards to stakers pre or post protocol revenue cut?
shmond distribute rewards to stakers post protocol revenue cut
|
Thanks for the detailed review @noateden — noted on all points. |
231712c to
227c5e8
Compare
|
The shmonad adapter exports: |
The contract is indeed an ERC 4626 vault. Thanks for the clarification! |
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
package.json/package-lock.jsonfile as part of your changesName (to be shown on DefiLlama):
Twitter Link:
List of audit links if any:
Website Link:
Logo (High resolution, will be shown with rounded borders):
Current TVL:
Treasury Addresses (if the protocol has treasury)
Chain:
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one:
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project:
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
Github org/user (Optional, if your code is open source, we can track activity):