Delegate which will always take the most advantageous path for users between minting and swapping token project when triggering pay()
Provides a datasource and delegate which maximise the project token received by the contributor when they call pay
on the terminal. In order to do so, the delegate will either mint new tokens ("vanilla" path, bypassing the delegate) and/or swap existing token in an Uniswap V3 pool ("buyback" path), depending on the best quote available at the time of the call as well as the user preferences.
This BBD is used with ETH by JBDAO, this readme hence uses ETH
as terminal token, but the current implementation allows the use of any ERC20 token as terminal token.
pay(..)
(this amount might be the less than or equal to the total amount of ETH sent - ie "swap everything or just part of it"). These should be encoded using the delegate metadata library. If no quote is provided, a twap is then used.Pay(..)
will use the buyback delegate as datasource and, based on the minmum amount received, the amount to swap and the funding cycle weight, will mint (using the regular terminal flow) and/or swap.didPay
method, which will wrap and swap the eth, burn all the token received and mint them again (with extra-token if a portion of ETH was allocated to minting only). This allows to use the correct reserved rate as well as keep the caller's preference for preferClaimedTokens
.addToBalanceOf
).Anyone can deploy this delegate using the provided forge script.
To run this repo, you'll need Foundry and NodeJS installed.
Install the dependencies with npm install && git submodule update --init --force --recursive
, you should then be able to run the tests using forge test
or deploy a new delegate using forge script Deploy
(and the correct arguments, based on the chain and key you want to use - see the Foundry docs).
Maximizing the project token received by the contributor while leveling the funding cycle/secondary market price.