Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I fixed my own dumbass issue sending 1.5sols to fanout instead hodlin… #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

staccDOTsol
Copy link
Collaborator

…g account, merge plz ser

gm

#23

@vercel
Copy link

vercel bot commented May 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
hydra-dox ✅ Ready (Inspect) Visit Preview May 4, 2022 at 7:48PM (UTC)

let hodling = ctx.accounts.holding_account.to_account_info();
let snapshot: u64 = fanout.lamports();

**fanout.lamports.borrow_mut() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to drop the fanout to below rent-exempt minimum?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik from my previous work with candy machine refunds it will empty the thing and solana conveniently kicks it out (can't afford rent).

It's ? a weird process?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh - good point - we don't want to destroy the fanout in this particular case.

There's a function somewhere for RENT_EXEMPT_MINIMUM or w/e?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/cardinal-labs/cardinal-token-manager/blob/3825e0eb70007a2b1e263dedeaf02b693c9614b7/programs/cardinal-token-manager/src/instructions/invalidate.rs#L199-L205

            let required_lamports = ctx.accounts.rent.minimum_balance(token_manager.to_account_info().data_len());
            let token_manager_lamports = token_manager.to_account_info().lamports();
            if token_manager_lamports > required_lamports {
                let diff = token_manager_lamports.checked_sub(required_lamports).expect("Sub error");
                **token_manager.to_account_info().try_borrow_mut_lamports()? = required_lamports;
                **ctx.accounts.collector.to_account_info().try_borrow_mut_lamports()? = ctx.accounts.collector.to_account_info().lamports().checked_add(diff).expect("Add error");
            };

this example gets rent minimum and removes any extra lamports above that

@@ -1,2 +1,4 @@
pub mod init_for_mint;
pub mod init_parent;
pub mod transfer_to_hodling;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strongly dislike this name for a instruction in publicly available smart contract 😬

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gm haha :) my PRs are always suggestions, some are lulzy && for the culture - this trend continues :) in a newer one I've used 'inverse_bruh' as a variable, much to @ChewingGlass dismay - and in one a long time ago @austbot had to rewrite most of my output to the CLI in favor of 'consider supporting free & open source developers'

I trust the maintainers to make calls about what's culture and what's better without the lulz

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.

2 participants