Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@balancer-labs/v2-pool-linear
Advanced tools
Readme
This package contains the source code of Balancer V2 Linear Pools. These are three-token pools which contain "Main" and "Wrapped" tokens, where the wrapped token is typically yield-bearing: e.g., USDC and aUSDC. The third token is the BPT itself, enabling "joins" and "exits" to be performed as part of a batch swap.
Linear Pools are not designed to be accessed directly by end users. Rather, they are typically components of other pools, mainly as constituents of a ComposableStablePool
, which enables the "Boosted Pool" behavior.
$ npm install @balancer-labs/v2-pool-linear
This package includes AaveLinearPool
, a Linear Pool that integrates with the Aave Protocol and holds aTokens as their "Wrapped" token.
However, some users might want to develop their own kind of Linear Pool, potentially integrating with a different protocol. In order to do this, you must inherit the LinearPool
contract and implement the _getWrappedTokenRate()
function:
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import '@balancer-labs/v2-pool-linear/contracts/LinearPool.sol';
contract CustomLinearPool is LinearPool {
/**
* @dev Returns a 18-decimal fixed point value that represents the value of the wrapped token in terms of the main
* token. The final wrapped token scaling factor is this value multiplied by the wrapped token's decimal scaling
* factor.
*
* WARNING: care must be take if calling external contracts from here, even `view` or `pure` functions. If said
* calls revert, any revert data must not be bubbled-up directly but instead passed to `bubbleUpNonMaliciousRevert`
* from `ExternalCallLib` (located in the `v2-pool-utils` package). See the following example:
*
* try externalContract.someCall() returns (uint256 value) {
* return value;
* } catch (bytes memory revertData) {
* // Don't automatically bubble-up revert data.
* ExternalCallLib.bubbleUpNonMaliciousRevert(revertData);
* }
*/
function _getWrappedTokenRate() internal view override returns (uint256) {}
}
Note: this example is missing some details, like calling the constructor of LinearPool
.
Additionally, users might want to also take advantage of the LinearPoolRebalancer
contract to have a simple, permissionless and highly efficient way of rebalancing their Pools.
To do this, inherit from LinearPoolRebalancer
and implement the _wrapTokens
, _unwrapTokens
and _getRequiredTokensToWrap
functions. See AaveLinearPoolRebalancer
for an example.
FAQs
Balancer V2 Linear Pools
The npm package @balancer-labs/v2-pool-linear receives a total of 2 weekly downloads. As such, @balancer-labs/v2-pool-linear popularity was classified as not popular.
We found that @balancer-labs/v2-pool-linear demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.