- »
- Curve StableSwap Exchange: LP Tokens
- Edit on GitHub
In exchange for depositing coins into a Curve pool (see Curve Pools), liquidity providers receive pool LP tokens. A Curve pool LP token is an ERC20 contract specific to the Curve pool. Hence, LP tokens are transferrable. Holders of pool LP tokens may stake the token into a pool’s liquidity gauge in order to receive CRV
token rewards. Alternatively, if the LP token is supported by a metapool, the token may be deposited into the respective metapool in exchange for the metapool’s LP token (see here).
The following versions of Curve pool LP tokens exist:
CurveTokenV1: LP token targetting Vyper ^0.1.0-beta.16
CurveTokenV2: LP token targetting Vyper ^0.2.0
CurveTokenV3: LP token targetting Vyper ^0.2.0 with gas optimizations
The version of each pool’s LP token can be found in the Deployment Addresses.
Note
For older Curve pools the token
attribute is not always public
and a getter has not been explicitly implemented.
Curve Token V1
The implementation for a Curve Token V1 may be viewed on GitHub.
- CurveToken.name() → string[64]: view
Get the name of the token.
>>> lp_token.name()'Curve.fi yDAI/yUSDC/yUSDT/yBUSD'
- CurveToken.symbol() → string[32]: view
Get the token symbol.
>>> lp_token.symbol()'yDAI+yUSDC+yUSDT+yBUSD'
- CurveToken.decimals() → uint256: view
Get the number of decimals for the token.
>>> lp_token.decimals()18
- CurveToken.balanceOf(account: address) → uint256: view
Get the token balance for an account.
account
: Address to get the token balance for
>>> lp_token.balanceOf("0x69fb7c45726cfe2badee8317005d3f94be838840")72372801850459006740117197
- CurveToken.totalSupply() → uint256: view
Get the total token supply.
>>> lp_token.totalSupply()73112516629065063732935484
- CurveToken.allowance(_owner: address, _spender: address) → uint256: view
Get the allowance of an account to spend on behalf of some other account.
_owner
: Account that is paying when_spender
spends the allowance_spender
: Account that can spend up to the allowance
Returns the allowance of
_spender
for_owner
.
- CurveToken.transfer(_to: address, _value: uint256) → bool
Transfer tokens to a specified address.
_to
: Receiver of the tokens_value
: Amount of tokens to transfer
Returns
True
if the transfer succeeded.
- CurveToken.transferFrom(_from: address, _to: address, _value: uint256) → bool
Transfer tokens from one address to another. Note that while this function emits a Transfer event, this is not required as per the specification, and other compliant implementations may not emit the event.
_from
: Address which you want to send tokens from_to
: Address which you want to transfer to_value
: Amount of tokens to be transferred
Returns
True
if transfer succeeded.
- CurveToken.approve(_spender: address, _value: uint256) → bool
Approve the passed address to spend the specified amount of tokens on behalf of
msg.sender
.Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender’s allowance to 0 and set the desired value afterwards (see this GitHub issue).
_spender
: Address which will spend the funds._value
: Amount of tokens to be spent.
Returns
True
if approval succeeded.Warning
For Curve LP Tokens V1 and V2, non-zero to non-zero approvals are prohibited. Instead, after every non-zero approval, the allowance for the spender must be reset to
0
.
Minter Methods
The following methods are only callable by the minter
(private attribute).
Note
For Curve Token V1, the minter
attribute is not public
.
- CurveToken.mint(_to: address, _value: uint256)
Mint an amount of the token and assign it to an account. This encapsulates the modification of balances such that the proper events are emitted.
_to
: Address that will receive the created tokens_value
: Amount that will be created
- CurveToken.burn(_value: uint256)
Burn an amount of the token of
msg.sender
._value
: Token amount that will be burned
- CurveToken.burnFrom(_to: address, _value: uint256)
Burn an amount of the token from a given account.
_to
: Account whose tokens will be burned_value
: Amount that will be burned
- CurveToken.set_minter(_minter: address)
Set a new minter for the token.
_minter
: Address of the new minter
Curve Token V2
The implementation for a Curve Token V2 may be viewed on GitHub.
Note
Compared to Curve Token v1, the following changes have been made to the API:
minter
attribute ispublic
and therefore a minter getter has been generated
name
andsymbol
attributes can be set viaset_name
mint
method returnsbool
burnFrom
method returnsbool
burn
method has been removed
Warning
For Curve LP Tokens V1 and V2, non-zero to non-zero approvals are prohibited. Instead, after every non-zero approval, the allowance for the spender must be reset to 0
.
- CurveToken.minter() → address: view
Getter for the address of the
minter
of the token.
- CurveToken.set_name(_name: String[64], _symbol: String[32])
Set the name and symbol of the token.
_name
: New name of token_symbol
: New symbol of token
This method can only be called by
minter
.
- CurveToken.mint(_to: address, _value: uint256) → bool
Mint an amount of the token and assign it to an account. This encapsulates the modification of balances such that the proper events are emitted.
Returns
True
if not reverted.
- CurveToken.burnFrom(_to: address, _value: uint256) → bool
Burn an amount of the token from a given account.
_to
: Account whose tokens will be burned_value
: Amount that will be burned
Returns
True
if not reverted.
Curve Token V3
The Curve Token V3 is more gas efficient than versions 1 and 2.
Note
Compared to the Curve Token V2 API, there have been the following changes:
increaseAllowance
anddecreaseAllowance
methods added to mitigate race conditions
The implementation for a Curve Token V3 may be viewed on GitHub.
- CurveToken.increaseAllowance(_spender: address, _added_value: uint256) → bool
Increase the allowance granted to
_spender
by themsg.sender
.This is alternative to
approve
that can be used as a mitigation for the potential race condition._spender
: Address which will transfer the funds_added_value
: Amount of to increase the allowance
Returns
True
if success.
- CurveToken.decreaseAllowance(_spender: address, _subtracted_value: uint256) → bool
Decrease the allowance granted to
_spender
by themsg.sender
.This is alternative to {approve} that can be used as a mitigation for the potential race condition.
_spender
: Address which will transfer the funds_subtracted_value
: Amount of to decrease the allowance
Returns
True
if success.