Crates.io | dao-voting-onft-staked |
lib.rs | dao-voting-onft-staked |
version | 2.6.0 |
source | src |
created_at | 2024-10-31 06:05:57.402587 |
updated_at | 2024-11-08 00:36:53.395157 |
description | A DAO DAO voting module based on staked x/onft tokens. |
homepage | |
repository | https://github.com/DA0-DA0/dao-contracts |
max_upload_size | |
id | 1429704 |
size | 171,792 |
dao-voting-onft-staked
This is a basic implementation of an NFT staking contract that supports OmniFlix's NFT standard: x/onft.
Staked tokens can be unbonded with a configurable unbonding period. Staked balances can be queried at any arbitrary height by external contracts. This contract implements the interface needed to be a DAO DAO voting module.
Unlike the base cw721 smart contract, the x/onft SDK module doesn't support executing a smart contract on NFT transfer, so the stake process is broken up into three steps:
PrepareStake
to inform this staking contract of the NFTs
that are about to be staked. This will succeed only if the sender currently
owns the NFT(s).ConfirmStake
on this staking contract which confirms the
NFTs were transferred to it and registers the stake.In case this process is interrupted, or executed incorrectly (e.g. the sender
accidentally transfers an NFT to the staking contract without first preparing
it), there is also a CancelStake
action to help recover NFTs. If called by:
The recipient field only applies when the sender is the DAO. In the other cases, the NFT(s) will always be sent back to the sender. Note: if the NFTs were sent to the staking contract, but no stake was prepared, only the DAO will be able to correct this and send them somewhere.
The PrepareStake
step overrides any previous PrepareStake
calls as long as
the new sender owns the NFT(s) and the first stake was never confirmed (which
should be impossible if someone else now owns the NFT(s)). Thus there is no
combination of messages or steps where someone can stake nor prevent stake when
it would otherwise be valid. A stake is only ever confirmed if it was prepared
and transferred by the same address confirming, and the DAO can always recover
an NFT that accidentally skipped the preparation step.