Skip to content

Conversation

@k-yang
Copy link
Contributor

@k-yang k-yang commented Dec 25, 2023

(Highly opinionated change)

The check API and withdraw_creation_fee variables are confusing and causes an accounting error with campaign pools.

The flow of a campaign goes like this

  1. deposit
  2. reward_all
  3. check if necessary

In deposit, an amount for the campaign is specified, and in reward_all, the amount is deducted from the campaign and added to the user pool. Contradictorily, check puts the amount back to the campaign and causes accounting errors.

For example, imagine I create a campaign nibiru-itn-rewards with 1000unibi and reward 1000unibi to address nibi1gc6vpl9j0ty8tkt53787zps9ezc70kj88hluw4. The reward_all function subtracts 1000unibi from the campaign nibiru-itn-rewards and allocates it to nibi1gc6vpl9j0ty8tkt53787zps9ezc70kj88hluw4. Note that the campaign's amount is zero now.

If I call check with campaign id nibiru-itn-rewards and with amount 1000unibi, it resets the campaign amount to 1000unibi, which breaks accounting because now I can reward another 1000unibi to another user even though the total amount of unibi in the contract hasn't changed.

In reality, if I wanted to withdraw any surplus from the campaign, I could just cancel the campaign and use the withdraw function. The existence of this alternate route means that check and withdraw_creation_fee are unnecessary and cause additional headaches. Removing them simplifies the contract and reduces the size of the state, which gives us some gas improvements.

BREAKING CHANGE: Removes check and withdraw_creation_fee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant