# MarginAccount Interface for interacting with a margin account smart contract. ## Quick Reference ```rust // Initialize let margin_account = MarginAccount::new("main", "0x1234...", provider)?; // Deposit let tx = margin_account.deposit(&user_address, &token, &amount).await?; // Withdraw let tx = margin_account.withdraw(&token, &amount).await?; // Check Balance let balance = margin_account.get_balance(&user_address, &token).await?; ``` ## Methods ### `new(name: &str, address: &str, provider: P) -> Result` Creates a new margin account instance. ### `deposit(&self, user: &Address, token: &Token, amount: &U256) -> Result, MarginAccountError>` Deposits tokens into margin account. Checks balance and allowance before deposit. ### `withdraw(&self, token: &Token, amount: &U256) -> Result, MarginAccountError>` Withdraws tokens from margin account. ### `get_balance(&self, user: &Address, token: &Token) -> Result` Returns user's token balance in margin account. ## Error Types - `DepositError` - `WithdrawError` - `InsufficiantBalance` - `TransactionError` - `TxBuildError`