-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathupdate_balance_allowance.rs
More file actions
40 lines (33 loc) · 1.18 KB
/
update_balance_allowance.rs
File metadata and controls
40 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#![allow(
clippy::print_stdout,
reason = "Examples print their results to stdout"
)]
//! Refresh the server's cached on-chain allowance for the authenticated account.
use std::str::FromStr as _;
use alloy::signers::Signer as _;
use alloy::signers::local::LocalSigner;
use polymarket_client_sdk_v2::clob::types::AssetType;
use polymarket_client_sdk_v2::clob::types::request::UpdateBalanceAllowanceRequest;
use polymarket_client_sdk_v2::clob::{Client, Config};
use polymarket_client_sdk_v2::{POLYGON, PRIVATE_KEY_VAR};
use polymarket_client_sdk_v2::CLOB_HOST;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let host =
std::env::var("CLOB_API_URL").unwrap_or_else(|_| CLOB_HOST.into());
let signer =
LocalSigner::from_str(&std::env::var(PRIVATE_KEY_VAR)?)?.with_chain_id(Some(POLYGON));
let client = Client::new(&host, Config::default())?
.authentication_builder(&signer)
.authenticate()
.await?;
client
.update_balance_allowance(
UpdateBalanceAllowanceRequest::builder()
.asset_type(AssetType::Collateral)
.build(),
)
.await?;
println!("ok");
Ok(())
}