How can I query the balance of a contract from the SDK?

You can get the balance of a contract using the provider as shown in the example below:

let provider = wallet.get_provider().unwrap();
let balance = provider
     .get_contract_asset_balance(
          &Bech32ContractId::from(MyContractID.clone()),
          AssetId::from(*MyTokenAssetContractID.clone())
     )
     .await
     .unwrap();

You can also use the get_balances method if you have the contract instance.

let contract_balances = contract_instance.get_balances().await?;