35 releases (9 breaking)

0.11.1 Dec 28, 2021
0.10.3 Nov 16, 2021
0.8.0-rc1 Jul 29, 2021
0.6.0-alpha1 Mar 12, 2021
0.3.1 Oct 16, 2020

#7 in #cw20-token

Download history 33/week @ 2023-11-20 26/week @ 2024-01-01 145/week @ 2024-01-08 17/week @ 2024-01-15 42/week @ 2024-01-22 17/week @ 2024-01-29 31/week @ 2024-02-05 51/week @ 2024-02-12 19/week @ 2024-02-19 4/week @ 2024-02-26 12/week @ 2024-03-04

86 downloads per month

Apache-2.0

215KB
4.5K SLoC

Staking Derivatives

This is a sample contract that releases a minimal form of staking derivatives. This is to be used for integration tests and as a foundation for other to build more complex logic upon.

Functionality

On one side, this acts as a CW20 token, holding a list of balances for multiple addresses, and exposing queries and transfers (no allowances and "transfer from" to focus the logic on the staking stuff). However, it has no initial balance. Instead, it mints and burns them based on delegations.

For such a "bonding curve" we expose two additional message types. A "bond" message sends native staking tokens to the contract to be bonded to a validator and credits the user with the appropriate amount of derivative tokens. Likewise you can burn some of your derivative tokens, and the contract will unbond the proportional amount of stake to the user's account (after typical 21-day unbonding period).

To show an example of charging for such a service, we allow the contract owner to take a small exit tax, thus maybe 98% of the tokens will be unbonded and sent to the original account, and 2% of the tokens are not unbonded, but rather transferred to the owners account. (The ownership can also be transferred).

Dependencies

~3.5–5.5MB
~119K SLoC