Skip to main content

BasedAppManager

The BasedAppManager contract is the main contract for operations and management.

Based Applications Contracts Repository

Delegate Validator Balance

delegateBalance(account, percentage)

Description: Delegates a percentage of the caller's validator balance to another account.

ParameterTypeDescription
accountaddressThe address of the account to delegate to
percentageuint32The percentage of balance to delegate (scaled by 1e4, so 100% = 10000)

Events:

  • DelegationCreated(address indexed delegator, address indexed account, uint32 percentage)

updateDelegatedBalance(account, percentage)

Description: Updates an existing delegation percentage for an account.

ParameterTypeDescription
accountaddressThe address of the account whose delegation is being updated
percentageuint32The new percentage to delegate (scaled by 1e4)

Events:

  • DelegationUpdated(address indexed delegator, address indexed account, uint32 percentage)

removeDelegatedBalance(account)

Description: Removes delegation from an account.

ParameterTypeDescription
accountaddressThe address of the account whose delegation is being removed

Events:

  • DelegationRemoved(address indexed delegator, address indexed account)

bApps

registerBApp(bApp, tokens, sharedRiskLevels, metadataURI)

Description: Registers a new Based Application (bApp) with specified tokens and risk levels.

ParameterTypeDescription
bAppaddressThe address of the bApp to register
tokensaddress[]List of token addresses the bApp accepts
sharedRiskLevelsuint32[]Risk levels for each token (max 100000)
metadataURIstringmetadata URI of the bApp, which is a link (e.g., http://example.com) to a JSON file containing metadata such as the name, description, logo, etc.

Events:

  • BAppRegistered(address indexed bApp, address indexed owner, address[] tokens, uint32[] sharedRiskLevels, string metadataURI)

updateBAppMetadataURI(bApp, metadataURI)

Description: Updates the metadata URI of a Based Application (bApp). Can only be called by the bApp owner.

ParameterTypeDescription
bAppaddressThe address of the bApp
metadataURIstringThe new metadata URI pointing to the bApp's metadata JSON

Events:

  • BAppMetadataURIUpdated(address indexed bApp, string metadataURI)

addTokensToBApp(bApp, tokens, sharedRiskLevels)

Description: Adds new tokens to an existing bApp.

ParameterTypeDescription
bAppaddressThe address of the bApp
tokensaddress[]List of new token addresses to add
sharedRiskLevelsuint32[]Risk levels for each new token

Events:

  • TokensAddedToBApp(address indexed bApp, address[] tokens, uint32[] sharedRiskLevels)

updateBAppTokens(bApp, tokens, sharedRiskLevels)

Description: Updates the shared risk levels for existing tokens in a bApp. Can only be called by the bApp owner. Fails if any token is not already supported by the bApp or if the new risk level is the same as the current one.

ParameterTypeDescription
bAppaddressThe address of the bApp
tokensaddress[]List of token addresses to update
sharedRiskLevelsuint32[]New risk levels for each token (max 100000)

Events:

  • BAppTokensUpdated(address indexed bApp, address[] tokens, uint32[] sharedRiskLevels)

Strategy

createStrategy(fee, metadataURI)

Description: Creates a new strategy for the caller with specified fee and metadata.

ParameterTypeDescription
feeuint32The fee percentage for the strategy (scaled by 1e4)
metadataURIstringThe metadata URI for the strategy

Events:

  • StrategyCreated(uint32 indexed strategyId, address indexed owner, uint32 fee, string metadataURI)

updateStrategyMetadataURI(strategyId, metadataURI)

Description: Updates the metadata URI of a strategy. Can only be called by the strategy owner.

ParameterTypeDescription
strategyIduint32The ID of the strategy
metadataURIstringThe new metadata URI

Events:

  • StrategyMetadataURIUpdated(uint32 indexed strategyId, string metadataURI)

optInToBApp(strategyId, bApp, tokens, obligationPercentages, data)

Description: Opts a strategy into a bApp with specified tokens and obligation percentages. Each token must be supported by the bApp, and a strategy owner cannot opt into the same bApp twice. The obligation percentages don't need to be greater than 0.

ParameterTypeDescription
strategyIduint32The ID of the strategy
bAppaddressThe address of the bApp to opt into
tokensaddress[]List of token addresses to create obligations for
obligationPercentagesuint32[]List of obligation percentages for each token (scaled by 1e4)
databytesOptional parameter that could be required by the service

Events:

  • BAppOptedInByStrategy(uint32 indexed strategyId, address indexed bApp, bytes data, address[] tokens, uint32[] obligationPercentages)

depositERC20(strategyId, token, amount)

Description: Deposits ERC20 tokens into a strategy.

ParameterTypeDescription
strategyIduint32The ID of the strategy to deposit into
tokenaddressThe address of the ERC20 token
amountuint256The amount of tokens to deposit

Events:

  • StrategyDeposit(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)

depositETH(strategyId)

Description: Deposits ETH into a strategy.

ParameterTypeDescription
strategyIduint32The ID of the strategy to deposit into

Events:

  • StrategyDeposit(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)

fastWithdrawERC20(strategyId, token)

Description: Performs a fast withdrawal of ERC20 tokens from a strategy if the token is not used in any obligations.

ParameterTypeDescription
strategyIduint32The ID of the strategy to withdraw from
tokenaddressThe address of the ERC20 token to withdraw

Events:

  • StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)

fastWithdrawETH(strategyId)

Description: Performs a fast withdrawal of ETH from a strategy if the token is not used in any obligations.

ParameterTypeDescription
strategyIduint32The ID of the strategy to withdraw from

Events:

  • StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)

proposeWithdrawal(strategyId, token, amount)

Description: Proposes a withdrawal of ERC20 tokens from a strategy, initiating the timelock period. Cannot be used for ETH withdrawals (use proposeWithdrawalETH instead). The amount must be greater than 0 and not exceed the user's balance in the strategy.

ParameterTypeDescription
strategyIduint32The ID of the strategy
tokenaddressThe address of the ERC20 token to withdraw
amountuint256The amount of tokens to withdraw

Events:

  • StrategyWithdrawalProposed(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)

finalizeWithdrawal(strategyId, token)

Description: Finalizes an ERC20 token withdrawal after the timelock period has elapsed. The withdrawal must be completed within the expiry window (WITHDRAWAL_EXPIRE_TIME) after the timelock period ends.

ParameterTypeDescription
strategyIduint32The ID of the strategy
tokenIERC20The ERC20 token contract to withdraw

Events:

  • StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)

proposeWithdrawalETH(strategyId, amount)

Description: Proposes a withdrawal of ETH from a strategy, initiating the timelock period. The amount must be greater than 0 and not exceed the user's ETH balance in the strategy.

ParameterTypeDescription
strategyIduint32The ID of the strategy
amountuint256The amount of ETH to withdraw (in wei)

Events:

  • StrategyWithdrawalProposed(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount)

finalizeWithdrawalETH(strategyId)

Description: Finalizes an ETH withdrawal after the timelock period has elapsed.

ParameterTypeDescription
strategyIduint32The ID of the strategy

Events:

  • StrategyWithdrawal(uint32 indexed strategyId, address indexed account, address indexed token, uint256 amount, bool isFast)

createObligation(strategyId, bApp, token, obligationPercentage)

Description: Creates a single obligation for a bApp.

ParameterTypeDescription
strategyIduint32The ID of the strategy
bAppaddressThe address of the bApp
tokenaddressThe token address
obligationPercentageuint32Percentage to obligate (scaled by 1e4)

Events:

  • ObligationCreated(uint32 indexed strategyId, address indexed bApp, address indexed token, uint32 percentage)

fastUpdateObligation(strategyId, bApp, token, obligationPercentage)

Description: Quickly updates an obligation percentage higher for a bApp (can only increase).

ParameterTypeDescription
strategyIduint32The ID of the strategy
bAppaddressThe address of the bApp
tokenaddressThe token address
obligationPercentageuint32New percentage to obligate (must be higher than current)

Events:

  • ObligationUpdated(uint32 indexed strategyId, address indexed bApp, address indexed token, uint32 percentage, bool isFast)

proposeUpdateObligation(strategyId, bApp, token, obligationPercentage)

Description: Proposes an update to an obligation percentage, initiating the timelock period.

ParameterTypeDescription
strategyIduint32The ID of the strategy
bAppaddressThe address of the bApp
tokenaddressThe token address
obligationPercentageuint32New percentage to obligate

Events:

  • ObligationUpdateProposed(uint32 indexed strategyId, address indexed sender, address indexed token, uint32 percentage, uint32 unlockTime)

finalizeUpdateObligation(strategyId, bApp, token)

Description: Finalizes an obligation update after the timelock period has elapsed.

ParameterTypeDescription
strategyIduint32The ID of the strategy
bAppaddressThe address of the bApp
tokenaddressThe token address

Events:

  • ObligationUpdated(uint32 indexed strategyId, address indexed sender, address indexed token, uint32 percentage, bool isFast)

proposeFeeUpdate(strategyId, proposedFee)

Description: Proposes a new fee for a strategy, initiating the timelock period. The proposed fee cannot exceed the current fee plus maxFeeIncrement.

ParameterTypeDescription
strategyIduint32The ID of the strategy
proposedFeeuint32The proposed new fee (scaled by 1e4)

Events:

  • StrategyFeeUpdateProposed(uint32 indexed strategyId, address indexed sender, uint32 proposedFee, uint32 currentFee)

finalizeFeeUpdate(strategyId)

Description: Finalizes a fee update after the timelock period has elapsed. Must be called within the expiry window (FEE_EXPIRE_TIME).

ParameterTypeDescription
strategyIduint32The ID of the strategy

Events:

  • StrategyFeeUpdated(uint32 indexed strategyId, address indexed sender, uint32 newFee, uint32 oldFee)

Account

updateAccountMetadataURI(metadataURI)

Description: Updates the metadata URI of the caller's account.

ParameterTypeDescription
metadataURIstringThe new metadata URI for the account

Events:

  • AccountMetadataURIUpdated(address indexed account, string metadataURI)

Constants

ConstantValueDescription
FEE_TIMELOCK_PERIOD7 daysTime period that must elapse before a fee update can be finalized
FEE_EXPIRE_TIME1 dayWindow of time after timelock period during which fee update must be finalized
WITHDRAWAL_TIMELOCK_PERIOD5 daysTime period that must elapse before a withdrawal can be finalized
WITHDRAWAL_EXPIRE_TIME1 dayWindow of time after timelock period during which withdrawal must be finalized
OBLIGATION_TIMELOCK_PERIOD7 daysTime period that must elapse before an obligation update can be finalized
OBLIGATION_EXPIRE_TIME1 dayWindow of time after timelock period during which obligation update must be finalized
MAX_PERCENTAGE10000Maximum value for percentage calculations (100% = 10000)