pub fn unstake(
        &mut self,
        pool_account_id: AccountId,
        amount: Balance,
    ) {
        assert_eq!(self.owner_id, env::predecessor_account_id(), "Must be owner");
        let pool_balance = self.stake_pools.get(&pool_account_id);
        assert!(pool_balance.is_some(), "Stake pool doesnt exist");

        // Stop if somehow we made it this far and have nothing to stake... RUDE
        assert_ne!(amount, 0, "Nothing to stake");

        // Update our local balance values, so we know whats in process of long-form unstaking
        // TODO: Consider storing a timestamp here, so we know WHEN to revisit and withdraw
        self.stake_pending_pools.insert(&pool_account_id, &amount);

        // Lastly, make the cross-contract call to DO the unstaking :D
        let p = env::promise_create(
            pool_account_id,
            b"unstake",
            json!({
                "amount": amount,
            }).to_string().as_bytes(),
            NO_DEPOSIT,
            GAS_STAKE_UNSTAKE
        );

        env::promise_return(p);
    }
/// Unstake from a pool, works in metapool and traditional validator pools
/// TODO: Consider amount optional, and setup a way to get current balance to signal unstake of ALL
/// 
/// ```bash
/// near call treasury.testnet unstake '{"pool_account_id": "steak.factory.testnet", "amount": "100000000000000000000000000"}' --accountId treasury.testnet
/// ```
Unstake from a pool, works in metapool and traditional validator pools
TODO: Consider amount optional, and setup a way to get current balance to signal unstake of ALL


Unstake from a pool works in metapool and traditional validator pools TODO : Consider amount optional and setup a way to get current balance to signal unstake of ALL
pub fn unstake(
        &mut self,
        pool_account_id: AccountId,
        amount: Balance,
    ) {
        assert_eq!(self.owner_id, env::predecessor_account_id(), "Must be owner");
        let pool_balance = self.stake_pools.get(&pool_account_id);
        assert!(pool_balance.is_some(), "Stake pool doesnt exist");
        // Stop if somehow we made it this far and have nothing to stake... RUDE
        assert_ne!(amount, 0, "Nothing to stake");
        // Update our local balance values, so we know whats in process of long-form unstaking
        // TODO: Consider storing a timestamp here, so we know WHEN to revisit and withdraw
        self.stake_pending_pools.insert(&pool_account_id, &amount);
        // Lastly, make the cross-contract call to DO the unstaking :D
        let p = env::promise_create(
            pool_account_id,
            b"unstake",
            json!({
                "amount": amount,
            }).to_string().as_bytes(),
            NO_DEPOSIT,
            GAS_STAKE_UNSTAKE
        );
        env::promise_return(p);
    }
pub fn unstake ( & mut self , pool_account_id : AccountId , amount : Balance , ) { assert_eq ! ( self owner_id env predecessor_account_id ( ) " " ) ; let pool_balance = self . stake_pools . get ( & pool_account_id ) ; assert ! ( pool_balance is_some ( ) " " ) ; // Stop if somehow we made it this far and have nothing to stake... RUDE assert_ne ! ( amount 0 " " ) ; // Update our local balance values, so we know whats in process of long-form unstaking // TODO: Consider storing a timestamp here, so we know WHEN to revisit and withdraw self . stake_pending_pools . insert ( & pool_account_id , & amount ) ; // Lastly, make the cross-contract call to DO the unstaking :D let p = env :: promise_create ( pool_account_id , b" " , json ! ( { " " amount } ) . to_string ( ) . as_bytes ( ) , NO_DEPOSIT , GAS_STAKE_UNSTAKE ) ; env :: promise_return ( p ) ; }
Unstake from a pool, works in metapool and traditional validator pools
TODO: Consider amount optional, and setup a way to get current balance to signal unstake of ALL
Unstake from a pool works in metapool and traditional validator pools TODO : Consider amount optional and setup a way to get current balance to signal unstake of ALL
&mut self
pool_account_id
AccountId
amount
Balance
&mut self
pool_account_id
AccountId
amount
Balance