-
Notifications
You must be signed in to change notification settings - Fork 15
Add Tokemak #22
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: main
Are you sure you want to change the base?
Add Tokemak #22
Conversation
fix: Fixed idle asset not being included
full_time = profit_unlock_settings.get('fullProfitUnlockTime', 0) | ||
profit_unlock_rate = profit_unlock_settings.get('profitUnlockRate', 0) | ||
last_profit_unlock_time = profit_unlock_settings.get('lastProfitUnlockTime', 0) | ||
self_balance = pool_state.get('selfBalance', 0) # this.balanceOf(address(this)) |
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.
Since this refers to the AutopoolFees contract itself, we’ll need the on-chain address of the AutopoolFees contract to correctly fetch this balance. Could you clarify where we should be sourcing that address from.
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.
break | ||
|
||
# currentShares is destVault.balanceOf(address(this)) where `this` is the autopool contract | ||
current_shares = destination_info[dest_vault].get('currentShares', 0) |
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.
Since this refers to the AutopoolDebtcontract itself, we’ll need the on-chain address of the AutopoolDebt contract to correctly fetch this balance. Could you clarify where we should be sourcing that address from.
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.
AutopoolDebt is a library which is used on the Autopool contract.
Thus, any state that is in autopooldebt.py
is in Autopool contract.
Regarding the destination_info
Dict, it is a mapping of address => DestVaultInfo
. The address
keys can be obtained from calling Autopool.getDestinations()
which returns an array of addresses. The struct of a DestVaultInfo
has been described here:

|
||
destination_info[destl]["currentShares"] = currentShares | ||
destination_info[destl]["underlyerCeilingPrice"] = underlyerCeilingPrice | ||
destination_info[destl]["underlyerFloorPrice"] = underlyerFloorPrice |
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.
For fetching each state we have a max computation units set to 1000000. While fetching underlyerCeilingPrice its taking more than the max computation units.
Here is the tenderly simulation you can have a look.
https://www.tdly.co/shared/simulation/73ccb525-6a4f-43cf-9f0a-ce0ec44dac98
Because of this limitation, we won’t be able to integrate this.
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 will devise a solution that fits this constraint
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.
@Ishita-GlueX is it possible that the computation unit be increased by 100k? That specific pool is directed towards institutional usage and is a new addition to the Tokemak catalogue.

You can see here after the 100k CU limit addition, the function call actually requires less than 1M CU:
https://www.tdly.co/shared/simulation/01424017-c55a-45df-8ccb-1c5078d60f17
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.
0x4b1ea6f0e97cb0e859b1521a4548fbd0a94e6a63 is a destination vault address, not a pool address.
Fetching getUnderlyerCeilingPrice() from this is consuming too much gas (over 100k).
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 understand, fetching each state such as DestinationVault.underlyerCeilingPrice()
has a limit of 1M CU. However, DestinationVault.underlyerCeilingPrice()
actually did not use more than that (1M CU). Instead, tenderly fails for some reason with gaslimit=1M. So, I increased the limit by 100k, essentially using gaslimit=1.1M. This, works and the result shows that underlyerCeillingPrice
actually did not use more than 1M CU, but somehow blocked by a factor unknown.
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.
The behavior is not always consistent — sometimes the call goes through under 1M, and other times it fails unless given some extra buffer. So it’s not a fixed threshold.
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.
@Ishita-GlueX This Silo institutional pool was new and is not under my watch when I implement this integration. The only pools that does this is Silo Institutional's, there are 2 of them. Other pools only need about 200k CU to fetch DestinationVault.underlyerCeilingPrice()
.
Protocol Information
Summary of Integration
Provide a brief overview of your integration:
Implementation Details
Execution Functions Required
Functions Implemented
get_amount_out()
get_amount_in()
get_apy()
get_tvl()
Dynamic States Required for AMM Calculations
oldestDebtReporting
- Obtained fromAutoPool.oldestDebtReporting()
totalSupply
-AutoPool.totalSupply()
assetBreakdown
- A dict, explained below. Obtained fromAutoPool.getAssetBreakdown()
totalIdle
- The amount of baseAsset deposited into the contract pending deploymenttotalDebt
- The current (though cached) value of assets we've deployedtotalDebtMax
- The current (though cached) value of assets we use for valuing during depositstotalDebtMin
- The current (though cached) value of assets we use for valuing during withdrawalspreviousAssetBreakdown
- The same dict asassetBreakdown
but N days agopreviousTotalSupply
- The same astotalSupply
but N days agodays
- N of days betweenprevious*
and current statespaused
-AutoPool.paused()
shutdown
-AutoPool.isShutdown()
profitUnlockSettings
- A dict explained below. Obtained fromAutoPool.getProfitUnlockSettings()
fullProfitUnlockTime
- Time at which all profit will have been unlockedprofitUnlockRate
- Per second rate at which profit shares unlocks. Rate when calculated is denominated in MAX_BPS_PROFITlastProfitUnlockTime
- Last time profits were unlockeddebtReportQueue
- Array of Addresses of destination vaults (obtained fromAutoPool.getDebtReportingQueue()
)destinationInfo
- Custom map ofdestVaultAddr => destInfo
, withdestInfo
explained below:lastReport
- Derived from thelastReport
key of the value ofAutoPool.getDestinationInfo()
ownedShares
- Derived from theownedShares
key of the value ofAutoPool.getDestinationInfo()
cachedMaxDebtValue
- Derived from thecachedMaxDebtValue
key of the value ofAutoPool.getDestinationInfo()
cachedMinDebtValue
- Derived from thecachedMinDebtValue
key of the value ofAutoPool.getDestinationInfo()
currentShares
-destVaultAddr.balanceOf(currentPoolAddr)
inuint256
underlyerCeilingPrice
-destVaultAddr.getUnderlyerCeilingPrice()
inuint256
underlyerFloorPrice
-destVaultAddr.getUnderlyerFloorPrice()
inuint256
ONE
-destVaultAddr.ONE()
inuint256
Static States Required for AMM Calculations
vaultTokenAddress
- Current in-operation ERC4626 vault addressasset
- Current in-operation vault's underlying token addressDependencies
N/A
Other Requirements
Test Results
Click to view test results