pendulum-chain / pendulum

GNU General Public License v3.0
43 stars 14 forks source link

Add Treasury Buyout Extension pallet to Pendulum runtime #422

Closed prayagd closed 3 months ago

prayagd commented 4 months ago

Context

Follow-up ticket on Implement pallet that extends our current treasury pallet with buyout feature #396.

Requirement

Add this pallet to the Pendulum Runtime and use the following parameters.

Parameters

sudipghimire533 commented 4 months ago

Hello @prayagd Can I Take this?

ebma commented 4 months ago

This ticket is lacking a bit of the details. @pendulum-chain/product can you please change the description to something that looks similar to https://github.com/pendulum-chain/pendulum/issues/423.

annatekl commented 3 months ago

@pendulum-chain/devs can you provide same calculation for the sell fee as here

ebma commented 3 months ago

We charge the same raw gas fee values on Amplitude and Pendulum so we can assume that the gas cost for the buyout() extrinsic on Pendulum is the same as the value as on Amplitude. Thus, we will assume that the cost in the native token is the same as the extrapolated value derived here, ie. calling the buyout() extrinsic on Pendulum has a theoretic cost of 0.004216736845 PEN.

With the current PEN price of $0.080, we arrive at a cost of 0.004216736845 * 0.080 = $0.0003373389476 for the extrinsic. Assuming a DOT price of $9.8, the resulting sell fee has to be at least 0.0003373389476 / 9.8 = 0.0000344223415918 DOT. So we know that we need to choose a combination of MinAmountToBuyout and SellFee so that the user pays at least 0.0000344223415918 DOT as fee.

For a buyout of 0.1 PEN with a resulting absolute fee of at least 0.0000344223415918 DOT, we need to have a SellFee of >=4% because with the current exchange rate of 1 PEN = 0.00852107 DOT, we can see that 0.1 PEN 0.04 = 0.004 PEN and 0.004 PEN 0.00852107 DOT/PEN = 0.00003408428 DOT.

@pendulum-chain/product I think we should go ahead with the same values as we use on Amplitude, ie. minimum buyout amount of 0.1 PEN and a SellFee of 5%.

gianfra-t commented 3 months ago

I see that in in the Amplitude issue we ended up using 0.1 AMPE as the minimum buy amount. We should use 0.1 PEN here right @ebma?.

Also, I see in the code that right now the minimum is defined as 0.01 AMPE instead.

ebma commented 3 months ago

We should use 0.1 PEN here right @ebma?.

Yes, exactly 👍 I made a typo but changed my comment.

Also, I see in the code that right now the minimum is defined as 0.01 AMPE instead.

Oh you are right, we must have forgotten about changing that after we decided to go with a different value. I think it's okay if we just change it to the correct value, ie. 0.1 AMPE in the same PR (https://github.com/pendulum-chain/pendulum/pull/441) and roll it out in the next Amplitude release.