Claim Router

Technical documentation

The claim router serves as the connection between Concrete's Borrow flow and Earn flow. It's responsible for managing and routing claim requests, rewards, and repayments to protection strategies.

The core contract is ClaimRouter.sol

The only address capable of calling the Claim Router for purposes other than configuration is the Blueprint's address.

Requesting a Claim

function requestToken(VaultFlags, address tokenAddress, uint256 amount_, address payable userBlueprint)
    external
    onlyBlueprint
{
  • tokenAddress: The address of the token.

  • amount_: The amount of assets to request.

  • userBlueprint: The address of the user's blueprint contract.

The Claim router will receive claims from Concrete's borrow flow and route them based on the requested token, the amount, and other criteria:

The claim router first selects the vaults calling the Vault Registry to get all the vaults which share the requested asset as an underlying asset. Then it selects the protection strategy with the least accumulated yield that has enough balance to fulfill the request. If it can't find a strategy with enough balance, it will select the protection strategy with the least accumulated yield that has enough balance in its corresponding vault. If the router can't find a protection strategy with enough balance itself or in its related vault, it will trigger the token cascade mechanism. Once a protect strategy is found the function executeBorrowClaim will be call on the strategy

Token Cascade

The token cascade is a list of preferred tokens to borrow from in case any of the vaults of the requested tokens don't have enough balance to fulfill a request. It will replicate the previously described behavior but start from the first token in the list, usually a stablecoin. First, it checks that it's not the requested token to avoid checking a token already checked. If it's the requested token, it moves to the next; if it's not, it converts the amount using the oracle and then looks for a protection strategy that complies with the requirements. If not, the process is repeated until a protection strategy is found or the token list is exhausted. This should always be fulfilled, and the protocol should have enough liquidity to comply with the claims. If not, an error will be thrown.

Basic representation of a request

The Claim Router will select the protection strategy that has generated less yield, but it will prioritize one with enough balance over one that needs to borrow from other strategies to fulfill the request.


Adding tokens to protection strategies

Adding rewards

function addRewards(address tokenAddress, uint256 amount_, address userBlueprint) external onlyBlueprint
  • tokenAddress: The address of the token.

  • amount_: The amount of rewards to add.

  • userBlueprint: The address of the user's blueprint contract.

The claim router first selects the vaults calling the Vault Registry to retrieve all vaults that share the requested asset as an underlying asset. It calculates the total borrow amount from these vaults. Then, it distributes the added amount based on the proportion of the debt of each vault with a protection strategy. Vaults without protection receive a proportion of zero since the debt originates from the protection strategy. Any remainder after the calculation is considered dust and transferred to the last processed strategy.

Repayment

function repay(address tokenAddress, uint256 amount_, address userBlueprint) external onlyBlueprint {
  • tokenAddress: The address of the token.

  • amount_: The amount of rewards to add.

  • userBlueprint: The address of the user's blueprint contract.

This function works in the same way as the addRewards function, with a few considerations: it calls the function updateBorrowDebt from the protection strategy to subtract the amount repaid from the debt. If the amount distributed to a protection strategy is higher than the debt, the debt will be set to zero and the remainder will be added as rewards.


Config Function

These functions are only callable by the owner of the contract.

setBlueprint

function setBlueprint(address blueprint_) external onlyOwner
  • blueprint_: The new address of the blueprint contract.

Function to set the address of the blueprint contract. Only callable by the owner of the contract.


setVaultRegistry

function setVaultRegistry(address vaultRegistry_) external onlyOwner
  • vaultRegistry_: The new address of the vault registry contract.

This function allows the owner of the contract to set the address of the vault registry contract.


setTokenCascade

function setTokenCascade(address[] memory tokenCascade_) external onlyOwner
  • tokenCascade_: The new token cascade to be set, represented as an array of addresses.

This function allows the owner of the contract to set the address of the token cascade.

Last updated