πŸ–‡οΈ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);
circle-exclamation

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:

  • cbr as a number with 18 decimals.

  • fees struct with all the fees except partner fee (taken on top of other fees, transparent to the user)

  • tokens array of underlying assets (currently Arbera supports only 1 asset Dens).

  • pairedToken address 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 _token to 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 _index to unwrap.

Returns array of token addresses and array of amounts.

circle-info

Currently all Dens have single asset, so it's safe to assume you only receive 1 token, ie. length of the arrays equals 1.

Interactions

Wrap TOKEN into brTOKEN

  • token β€” underlying token address

  • amount β€” amount to wrap.

  • amountMintMin β€” minimum amount to receive (considdering fees and CBR).

circle-info

Calling this function needs approval of the amount of token to the Den token contract.

Unwrap brTOKEN into TOKEN

  • amount β€” amount to wrap.

  • amountMintMin β€” minimum amount to receive (considering fees and CBR).

circle-info

This function doesn't need approvals.

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.

circle-info

Calling this function needs approval of the daiTokens of pairedLPToken (DAI or WEBERA) to the Den token contract.

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.

circle-info

Calling this function needs approval of the lpTokens of LP receipt token to the Den token contract.

Flash loan underlying tokens

You need to implement IFlashLoanRecipient interface.

Last updated