⬅️ Contracts
BalancerLBPSwapper
Author: Fei Protocol
an auction contract which cyclically sells one token for another using Balancer LBP
Mainnet implementations
Core, PCVEquityMinter
Events
BackupOracleUpdate
event BackupOracleUpdate(address,address)
Params
Param |
Type |
Notes |
oldBackupOracle |
address indexed |
|
newBackupOracle |
address indexed |
|
ContractAdminRoleUpdate
event ContractAdminRoleUpdate(bytes32,bytes32)
Params
Param |
Type |
Notes |
oldContractAdminRole |
bytes32 indexed |
|
newContractAdminRole |
bytes32 indexed |
|
CoreUpdate
event CoreUpdate(address,address)
Params
Param |
Type |
Notes |
oldCore |
address indexed |
|
newCore |
address indexed |
|
DecimalsNormalizerUpdate
event DecimalsNormalizerUpdate(int256,int256)
Params
Param |
Type |
Notes |
oldDecimalsNormalizer |
int256 |
|
newDecimalsNormalizer |
int256 |
|
DurationUpdate
event DurationUpdate(uint256,uint256)
Params
Param |
Type |
Notes |
oldDuration |
uint256 |
|
newDuration |
uint256 |
|
ExitPool
event ExitPool()
InvertUpdate
event InvertUpdate(bool,bool)
Params
Param |
Type |
Notes |
oldDoInvert |
bool |
|
newDoInvert |
bool |
|
MinTokenSpentUpdate
event MinTokenSpentUpdate(uint256,uint256)
Params
Param |
Type |
Notes |
oldMinTokenSpentBalance |
uint256 |
|
newMinTokenSpentBalance |
uint256 |
|
OracleUpdate
event OracleUpdate(address,address)
Params
Param |
Type |
Notes |
oldOracle |
address indexed |
|
newOracle |
address indexed |
|
Paused
event Paused(address)
Params
Param |
Type |
Notes |
account |
address |
|
Swap
event Swap(address,address,address,uint256,uint256)
Params
Param |
Type |
Notes |
_caller |
address indexed |
|
_tokenSpent |
address indexed |
|
_tokenReceived |
address indexed |
|
_amountSpent |
uint256 |
|
_amountReceived |
uint256 |
|
TimerReset
event TimerReset(uint256)
Params
Param |
Type |
Notes |
startTime |
uint256 |
|
Unpaused
event Unpaused(address)
Params
Param |
Type |
Notes |
account |
address |
|
UpdateReceivingAddress
event UpdateReceivingAddress(address,address)
Params
Param |
Type |
Notes |
oldTokenReceivingAddress |
address |
|
newTokenReceivingAddress |
address |
|
WithdrawERC20
event WithdrawERC20(address,address,address,uint256)
Params
Param |
Type |
Notes |
_caller |
address indexed |
|
_token |
address indexed |
|
_to |
address indexed |
|
_amount |
uint256 |
|
Methods
CONTRACT_ADMIN_ROLE
function CONTRACT_ADMIN_ROLE() view returns(bytes32)
a role used with a subset of governor permissions for this contract only
Returns
backupOracle
function backupOracle() view returns(address)
the backup oracle reference by the contract
Returns
core
function core() view returns(address)
address of the Core contract referenced
Returns
Param |
Type |
Notes |
|
address |
ICore implementation address |
decimalsNormalizer
function decimalsNormalizer() view returns(int256)
number of decimals to scale oracle price by, i.e. multiplying by 10^(decimalsNormalizer)
Returns
doInvert
function doInvert() view returns(bool)
Returns
duration
function duration() view returns(uint256)
the duration of the timed period
Returns
exitPool
function exitPool(address) nonpayable
redeeem all assets from LP pool
Params
Param |
Type |
Notes |
to |
address |
destination for withdrawn tokens |
fei
function fei() view returns(address)
address of the Fei contract referenced by Core
Returns
Param |
Type |
Notes |
|
address |
IFei implementation address |
feiBalance
function feiBalance() view returns(uint256)
fei balance of contract
Returns
Param |
Type |
Notes |
|
uint256 |
fei amount held |
forceSwap
function forceSwap() nonpayable
Force a swap() call, without waiting afterTime. This should only be callable after init() call, when no other swap is happening (call reverts if weight change is in progress).
getTokensIn
function getTokensIn(uint256) view returns(address[],uint256[])
return the amount of tokens needed to seed the next auction
Params
Param |
Type |
Notes |
spentTokenBalance |
uint256 |
|
Returns
Param |
Type |
Notes |
tokens |
address[] |
|
amountsIn |
uint256[] |
|
init
function init(address) nonpayable
initialize Balancer LBP Needs to be a separate method because this contract needs to be deployed and supplied as the owner of the pool on construction. Includes various checks to ensure the pool contract is correct and initialization can only be done once
Params
Param |
Type |
Notes |
_pool |
address |
the Balancer LBP used for swapping |
invert
function invert((uint256)) pure returns(tuple)
invert a peg price
the inverted peg would be X per FEI
Params
Param |
Type |
Notes |
price |
tuple |
the peg price to invert |
Returns
Param |
Type |
Notes |
|
tuple |
the inverted peg as a Decimal |
isContractAdmin
function isContractAdmin(address) view returns(bool)
returns whether a given address has the admin role for this contract
Params
Param |
Type |
Notes |
_admin |
address |
|
Returns
isTimeEnded
function isTimeEnded() view returns(bool)
return true if time period has ended
Returns
isTimeStarted
function isTimeStarted() view returns(bool)
Returns
minTokenSpentBalance
function minTokenSpentBalance() view returns(uint256)
the minimum amount of tokenSpent to kick off a new auction on swap()
Returns
oracle
function oracle() view returns(address)
the oracle reference by the contract
Returns
pause
function pause() nonpayable
set pausable methods to paused
paused
function paused() view returns(bool)
Returns true if the contract is paused, and false otherwise.
Returns
pid
function pid() view returns(bytes32)
the Balancer V2 Pool id of pool
Returns
pool
function pool() view returns(address)
the Balancer LBP used for swapping
Returns
readOracle
function readOracle() view returns(tuple)
the peg price of the referenced oracle
the peg is defined as FEI per X with X being ETH, dollars, etc
Returns
Param |
Type |
Notes |
|
tuple |
the peg as a Decimal |
remainingTime
function remainingTime() view returns(uint256)
number of seconds remaining until time is up
Returns
Param |
Type |
Notes |
|
uint256 |
remaining |
setAssetManagerPoolConfig
function setAssetManagerPoolConfig(address,address,(uint64,uint64,uint64)) nonpayable
Params
Param |
Type |
Notes |
pool |
address |
|
token |
address |
|
poolConfig |
tuple |
|
setBackupOracle
function setBackupOracle(address) nonpayable
sets the referenced backup oracle
Params
Param |
Type |
Notes |
newBackupOracle |
address |
the new backup oracle to reference |
setContractAdminRole
function setContractAdminRole(bytes32) nonpayable
sets a new admin role for this contract
Params
Param |
Type |
Notes |
newContractAdminRole |
bytes32 |
|
setCore
function setCore(address) nonpayable
set new Core reference address
Params
Param |
Type |
Notes |
newCore |
address |
the new core address |
setDecimalsNormalizer
function setDecimalsNormalizer(int256) nonpayable
sets the new decimalsNormalizer
Params
Param |
Type |
Notes |
newDecimalsNormalizer |
int256 |
the new decimalsNormalizer |
setDoInvert
function setDoInvert(bool) nonpayable
sets the flag for whether to invert or not
Params
Param |
Type |
Notes |
newDoInvert |
bool |
the new flag for whether to invert |
setMinTokenSpent
function setMinTokenSpent(uint256) nonpayable
sets the minimum token spent balance
Params
Param |
Type |
Notes |
newMinTokenSpentBalance |
uint256 |
minimum amount of FEI to trigger a new auction |
setOracle
function setOracle(address) nonpayable
sets the referenced oracle
Params
Param |
Type |
Notes |
newOracle |
address |
the new oracle to reference |
setPaused
function setPaused(address,bool) nonpayable
Params
Param |
Type |
Notes |
pool |
address |
|
paused |
bool |
|
setReceivingAddress
function setReceivingAddress(address) nonpayable
Sets the address receiving swap's inbound tokens
Params
Param |
Type |
Notes |
newTokenReceivingAddress |
address |
the address that will receive tokens |
setSwapEnabled
function setSwapEnabled(address,bool) nonpayable
Params
Param |
Type |
Notes |
pool |
address |
|
swapEnabled |
bool |
|
setSwapFee
function setSwapFee(address,uint256) nonpayable
Params
Param |
Type |
Notes |
pool |
address |
|
swapFee |
uint256 |
|
setSwapFrequency
function setSwapFrequency(uint256) nonpayable
sets the minimum time between swaps
Params
Param |
Type |
Notes |
_frequency |
uint256 |
minimum time between swaps in seconds |
startTime
function startTime() view returns(uint256)
the start timestamp of the timed period
Returns
swap
function swap() nonpayable
Swap algorithm 1. Withdraw existing LP tokens 2. Reset weights 3. Provide new liquidity 4. Trigger gradual weight change 5. Transfer remaining tokenReceived to tokenReceivingAddress
assumes tokenSpent balance of contract exceeds minTokenSpentBalance to kick off a new auction
swapEndTime
function swapEndTime() view returns(uint256)
returns when the next auction ends
Returns
Param |
Type |
Notes |
endTime |
uint256 |
|
timeSinceStart
function timeSinceStart() view returns(uint256)
number of seconds since contract was initialized
will be less than or equal to duration
Returns
Param |
Type |
Notes |
|
uint256 |
timestamp |
tokenReceived
function tokenReceived() view returns(address)
the token to buy
Returns
tokenReceivingAddress
function tokenReceivingAddress() view returns(address)
the address to send tokenReceived
Returns
tokenSpent
function tokenSpent() view returns(address)
the token to be auctioned
Returns
tribe
function tribe() view returns(address)
address of the Tribe contract referenced by Core
Returns
Param |
Type |
Notes |
|
address |
IERC20 implementation address |
tribeBalance
function tribeBalance() view returns(uint256)
tribe balance of contract
Returns
Param |
Type |
Notes |
|
uint256 |
tribe amount held |
unpause
function unpause() nonpayable
set pausable methods to unpaused
updateOracle
function updateOracle() nonpayable
updates the referenced oracle
updateWeightsGradually
function updateWeightsGradually(address,uint256,uint256,uint256[]) nonpayable
Params
Param |
Type |
Notes |
pool |
address |
|
startTime |
uint256 |
|
endTime |
uint256 |
|
endWeights |
uint256[] |
|
vault
function vault() view returns(address)
the Balancer V2 Vault contract
Returns
withdrawCollectedManagementFees
function withdrawCollectedManagementFees(address,address) nonpayable
Params
Param |
Type |
Notes |
pool |
address |
|
recipient |
address |
|
withdrawERC20
function withdrawERC20(address,address,uint256) nonpayable
withdraw ERC20 from the contract
Params
Param |
Type |
Notes |
token |
address |
address of the ERC20 to send |
to |
address |
address destination of the ERC20 |
amount |
uint256 |
quantity of ERC20 to send |
⬅️ Contracts