Arche Protocol Positions
Fetch position updates for versions 1095000
to 1100000
.
Code
Rust
use futures::StreamExt;
use std::{collections::HashSet, sync::Arc};
use pangea_client::{
core::types::ChainId, query::Bound,
ClientBuilder, Format, WsProvider,
provider::MoveProvider, requests::arche::GetPositionsRequest,
};
#[tokio::main]
async fn main() {
dotenvy::dotenv_override().ok();
let client = match ClientBuilder::default()
.endpoint("movement.app.pangea.foundation")
.build::<WsProvider>()
.await
{
Ok(client) => Arc::new(client),
Err(e) => {
eprintln!("Client failed to initialize:\n{e}");
return;
}
};
{
let request = GetPositionsRequest {
chains: HashSet::from([ChainId::MOVEMENT]),
from_block: Bound::Exact(1095000),
to_block: Bound::Exact(1100000),
..Default::default()
};
let stream = match client
.get_move_arche_positions_by_format(request, Format::JsonStream, false)
.await
{
Ok(stream) => stream,
Err(e) => {
eprintln!("Request failed\n{e}");
return;
}
};
futures::pin_mut!(stream);
while let Some(chunk) = stream.next().await {
let chunk = String::from_utf8(chunk.unwrap()).unwrap();
println!("{chunk}");
}
}
}
Response
{
...
{
"block_number": 1099734,
"timestamp": 1743610319482916,
"borrower": "0xa912e0f93ffbae24663c73cf55c8045a41112732a87295e68b8da0c3822f870b",
"collateral": "0x000000000000000000000000000000000000000000000000000000000000000a",
"collateral_amount": 300000000,
"borrow_amount": 18200,
"debt_share_rate": {
"numerator": 18200,
"denominator": 18225
},
"last_debt_share_updated": 1741375806,
"info": {
"principal_debt": 815114417,
"interest_debt": 3335691,
"total_interest_spread": 3313491,
"last_interest_timestamp": 1743610120,
"loan_to_value": {
"numerator": 33,
"denominator": 50
},
"annual_percentage_yield": {
"numerator": 13,
"denominator": 200
},
"interest_spread": {
"numerator": 1,
"denominator": 1
},
"liquidator_fee": {
"numerator": 1,
"denominator": 10
},
"max_borrowable_amount": 50000000000,
"max_borrowable_amount_whitelist": [],
"dust_threshold": 10000
},
"price": {
"magnitude": 41017764,
"exponent": -8,
"timestamp": 1743610313
},
"health_factor": {
"numerator": 81215172,
"denominator": 1828300
},
"liquidation": null,
"borrow_fee": {
"amount": {
"numerator": 0,
"denominator": 1
}
},
"liquidation_fee": {
"amount": {
"numerator": 1,
"denominator": 40
}
}
}
Query parameters
chains
: Filters the data bychain
.from_block
: Filters the data by a startingversion
. As Move chains use a per-transaction versioned database, we useversion
interchangably withblock_number
and omit blocks altogether.to_block
: Filters the data by an endingversion
. As Move chains use a per-transaction versioned database, we useversion
interchangably withblock_number
and omit blocks altogether.