1

I am trying to write AMM, here is my code:

pub struct Uniswap { uni_totalsupply: u128, uni_balance:LookupMap<AccountId, Balance>, } impl Uniswap { pub fn add_liquidity(&mut self, min_liquidity: u128, max_tokens: u128) { let deposit = env::attached_deposit(); assert!(max_tokens > 0, "Maximum tokens should be greater than zero"); assert!(deposit > 0, "Deposit must be greater than zero"); let total_liquidity = self.uni_totalsupply; if(total_liquidity > 0) { assert!(min_liquidity > 0, "Minimum liquidity must be greater than zero"); let near_reserve = near_balance_of_contract - deposit; let token_reserve = token_balance_of_contract; } } } 

How to get the near balance of the contract, and token balance of the contract?

1 Answer 1

1

It seems you are looking for env::account_balance

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.