ποΈIntegration 101
Common contract integration points.
You can find deployed contracts addresses and interfaces in Deployed Addresses.
View functions
Get list of all the Dens
// IndexManager.sol
struct IIndexAndStatus {
address index;
bool verified;
}
function allIndexes() external view returns (IIndexAndStatus[] memory);If the Den is not verified it's better not to interact with it, as it may have been unverified for security reasons.
Get Den Info (CBR, fees)
// IndexLens.sol
struct Fees {
uint16 burn;
uint16 bond;
uint16 debond;
uint16 buy;
uint16 sell;
}
struct DenInfoMutable {
uint cbr;
Fees fees;
address[] tokens;
address pairedToken;
[...]
}
function getIndexImmutableInfo(address _indexAddress) external view returns (DenInfoImmutable memory info_);Returns DenInfoImmutable struct with Den info which cannot change:
cbras a number with 18 decimals.feesstruct with all the fees except partner fee (taken on top of other fees, transparent to the user)tokensarray of underlying assets (currently Arbera supports only 1 asset Dens).pairedTokenaddress of the Paired LP Token (currently HONEY or WBERA).
And many more β check out IndexLens.sol verified contract code.
Calculate CBR (Manual)
To get CBR just divide underlying.balanceOf(index) by index.totalSupply() .
If totalSupply is 0 or there is no underlying token deposited it should default to 1e18.
Get amount of brTOKEN received by wrapping TOKEN
_indexβ address of the Den token._tokenβ underlying asset of the Den._amountβ amount of underlying_tokento wrap.
Returns amounts of brTOKEN received (after fees and accounting for CBR).
Get amount of TOKEN received by unwrapping brTOKEN
_indexβ address of the Den token._amountβ amount of underlying_indexto unwrap.
Returns array of token addresses and array of amounts.
Interactions
Wrap TOKEN into brTOKEN
tokenβ underlying token addressamountβ amount to wrap.amountMintMinβ minimum amount to receive (considdering fees and CBR).
Unwrap brTOKEN into TOKEN
amountβ amount to wrap.amountMintMinβ minimum amount to receive (considering fees and CBR).
Add liquidity without fees
idxTokensβ amount of Den tokens (brTOKEN).daiTokensβ amount of paired LP Token (currently DAI or WBERA).slippageβ slippage as number with 4 decimals, ie.100 = 1%deadlineβ deadline timestamp for providing liquidity.
Remove liquidity without fees
idxTokensβ amount of Den tokens (brTOKEN).daiTokensβ amount of paired LP Token (currently DAI or WBERA).slippageβ slippage as number with 4 decimals, ie.100 = 1%deadlineβ deadline timestamp for providing liquidity.
Flash loan underlying tokens
You need to implement IFlashLoanRecipient interface.
Last updated