Socket
Socket
Sign inDemoInstall

@balancer-labs/v2-pool-linear

Package Overview
Dependencies
3
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @balancer-labs/v2-pool-linear

Balancer V2 Linear Pools


Version published
Weekly downloads
3
increased by50%
Maintainers
4
Install size
599 kB
Created
Weekly downloads
 

Readme

Source

Balancer

Balancer V2 Linear Pools

NPM Package Docs

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.

Overview

Installation

$ npm install @balancer-labs/v2-pool-linear

Usage

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.

Licensing

GNU General Public License Version 3 (GPL v3).

FAQs

Last updated on 08 Feb 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc