This tutorial covers the process of rebalancing a megapool on Puzzle Swap. For more details on Puzzle, please check our website puzzleswap.org.
To rebalance a pool, you need to be a pool owner and have an approval granted from liquidity providers (LPs) of the pool.
Generally, your steps would be:
discuss pool composition update with LPs and get agreement from the majority (skip this if you are a solo LP in your pool),
prepare a setRebalancingPlan transaction (as described below) and broadcast it,
wait for one of the rebalancing delegates to approve your rebalancing.
For the showcase, let’s use the Forbes pool as an example. Currently, it consists of 2 tokens, Puzzle and Waves, in equal shares (weights).

In case I want to update its composition to add USDT token, as a pool owner I have a feasibility to do so. For this, I shall go to the Waves Dapp interface of this pool to interact with the setRebalancingPlan function.

According to the fields filled above, the pool will be recomposed to include USDT with a 10% share by diluting the share of PUZZLE from 50% to 40%.
Let’s take a deeper look at each of the arguments and what you should fill in them.
assetIdsStr: stores a list of all asset ids, divided by comma “,” (do not add spaces in between!). Important: string in the example is just a showcase, in reality you would need to replace PUZZLEID and USDTID with the whole asset ids.
assetWeightsStr: a list of asset shares, according to the order in the previous argument. Important: to define a share of 40% you need to pass the integer 4000 with 2 extra digits.
baseTokenIdStr: defines a token which will be used as the main one in composition, particularly this token will be used to provide liquidity with one token. It’s recommended to pick the one with the biggest share to be a base token (WAVES in this example).
stepsAmount: defines an amount of doRebalancing steps needed to finalize the rebalancing. The more steps, the smoother rebalancing will be. It’s recommended to pick the value from 50 to 100, or 1 step per 50 usd in a pool.
stepsInterval: defines an interval in blocks (approximately in minutes) between steps. Usually it’s enough to set it to 1. Don’t set it higher than 3.
Payments: needs to be included in case you add a new token to composition (USDT in this example). Ideally you should attach the dollar equivalent of the first rebalancing step, however even if it’s 1 USD, the pool will balance itself. Important: you won’t get this amount back, as a pool owner you should consider this payment as a small donation to your liquidity providers.
That’s basically it. After the transaction goes through, your job is complete - everything else will be done by rebalancing daemon, IF rebalancing is confirmed by a delegate.
…
Important: carefully double check all the inserted values. If you miss-spell some of them, it will take much longer to restart the entire process. To verify yourself, follow these bullet points:
make sure you used the right asset ids (you can double check asset ids on wavescap.com),
check there are no spaces between items of assets and weights lists,
carefully go through assets one-by-one to check if weight corresponds to the right asset id.
In case something is unclear, please ask for community support in the Puzzle Telegram chat.
Rebalancing has already been used many times in different pools, however it’s still highly experimental, hence we recommend to proceed with it slowly. For example, if you want to replace as many as 5 tokens in your pool, it’s recommended to proceed with multiple rebalancings, changing tokens one-by-one, no more than 2 tokens at one time.
Some of the limitations are inherited from the megapool settings, particularly:
there cannot be more than 10 tokens in a megapool,
the minimum weight for a token is 1%.
Go to the pool page to find the smart contract address, which you need as input in Waves dApps.
For the first rebalancing you use the following info: Click the link to wscan, click tab ‘Set DApp’, mark the oldest date of ‘Set DApp’ transaction. Refresh the wscan page, click tab ‘Date’, input the oldest date, click the ‘preInit’ transaction. You can use the 2 data fields for all current asset ids and pool weights: static_tokenids, static_tokenWeights.
…
Good luck with your rebalancings!
This tutorial covers the process of rebalancing a megapool on Puzzle Swap. For more details on Puzzle, please check our website puzzleswap.org.
To rebalance a pool, you need to be a pool owner and have an approval granted from liquidity providers (LPs) of the pool.
Generally, your steps would be:
discuss pool composition update with LPs and get agreement from the majority (skip this if you are a solo LP in your pool),
prepare a setRebalancingPlan transaction (as described below) and broadcast it,
wait for one of the rebalancing delegates to approve your rebalancing.
For the showcase, let’s use the Forbes pool as an example. Currently, it consists of 2 tokens, Puzzle and Waves, in equal shares (weights).

In case I want to update its composition to add USDT token, as a pool owner I have a feasibility to do so. For this, I shall go to the Waves Dapp interface of this pool to interact with the setRebalancingPlan function.

According to the fields filled above, the pool will be recomposed to include USDT with a 10% share by diluting the share of PUZZLE from 50% to 40%.
Let’s take a deeper look at each of the arguments and what you should fill in them.
assetIdsStr: stores a list of all asset ids, divided by comma “,” (do not add spaces in between!). Important: string in the example is just a showcase, in reality you would need to replace PUZZLEID and USDTID with the whole asset ids.
assetWeightsStr: a list of asset shares, according to the order in the previous argument. Important: to define a share of 40% you need to pass the integer 4000 with 2 extra digits.
baseTokenIdStr: defines a token which will be used as the main one in composition, particularly this token will be used to provide liquidity with one token. It’s recommended to pick the one with the biggest share to be a base token (WAVES in this example).
stepsAmount: defines an amount of doRebalancing steps needed to finalize the rebalancing. The more steps, the smoother rebalancing will be. It’s recommended to pick the value from 50 to 100, or 1 step per 50 usd in a pool.
stepsInterval: defines an interval in blocks (approximately in minutes) between steps. Usually it’s enough to set it to 1. Don’t set it higher than 3.
Payments: needs to be included in case you add a new token to composition (USDT in this example). Ideally you should attach the dollar equivalent of the first rebalancing step, however even if it’s 1 USD, the pool will balance itself. Important: you won’t get this amount back, as a pool owner you should consider this payment as a small donation to your liquidity providers.
That’s basically it. After the transaction goes through, your job is complete - everything else will be done by rebalancing daemon, IF rebalancing is confirmed by a delegate.
…
Important: carefully double check all the inserted values. If you miss-spell some of them, it will take much longer to restart the entire process. To verify yourself, follow these bullet points:
make sure you used the right asset ids (you can double check asset ids on wavescap.com),
check there are no spaces between items of assets and weights lists,
carefully go through assets one-by-one to check if weight corresponds to the right asset id.
In case something is unclear, please ask for community support in the Puzzle Telegram chat.
Rebalancing has already been used many times in different pools, however it’s still highly experimental, hence we recommend to proceed with it slowly. For example, if you want to replace as many as 5 tokens in your pool, it’s recommended to proceed with multiple rebalancings, changing tokens one-by-one, no more than 2 tokens at one time.
Some of the limitations are inherited from the megapool settings, particularly:
there cannot be more than 10 tokens in a megapool,
the minimum weight for a token is 1%.
Go to the pool page to find the smart contract address, which you need as input in Waves dApps.
For the first rebalancing you use the following info: Click the link to wscan, click tab ‘Set DApp’, mark the oldest date of ‘Set DApp’ transaction. Refresh the wscan page, click tab ‘Date’, input the oldest date, click the ‘preInit’ transaction. You can use the 2 data fields for all current asset ids and pool weights: static_tokenids, static_tokenWeights.
…
Good luck with your rebalancings!
<100 subscribers
<100 subscribers
Share Dialog
Share Dialog
No comments yet