Arche Protocol Loans
Fetch loan events for versions 0
to 130000
.
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::GetLoansRequest,
};
#[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 = GetLoansRequest {
chains: HashSet::from([ChainId::MOVEMENT]),
from_block: Bound::Exact(0),
to_block: Bound::Exact(130000),
..Default::default()
};
let stream = match client
.get_move_arche_loans_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": 609644,
"transaction_hash": "0x510d2ac9c8057321722801915feb51a024e72d8d751d5f9849885ac310c6186d",
"log_index": 9,
"timestamp": 1742325304481110,
"arche_address": "0xbcc40f56a3538c9cc25254f485f48e6f150f9acac53a2e92c6d698a9c1751a0b",
"event_type": "Borrowed",
"asset_address": "0x000000000000000000000000000000000000000000000000000000000000000a",
"asset_name": "Move Coin",
"asset_symbol": "MOVE",
"asset_decimals": 8,
"address": "0x195ad9d86b49bc89eb3dad5a005f20809ebe2139837c5580514f4ff1996e0707",
"collateral_amount": null,
"borrowed_amount": 1089000,
"borrow_fee_amount": null,
"interest_spread_amount": null,
"debt_accrued_amount": null,
"repay_amount": null,
"unlocked_collateral_amount": null,
"liquidated_collateral_amount": null,
"liquidator_address": null
}
}
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.event_type__in
: Filters the data by a list ofevent_type
.address__in
: Filters the data by a list of borroweraddress
.asset_address__in
/collateral_asset__in
: Filters the data by a list of collateralasset_address
.liquidator_address__in
: Filters the data by a list ofliquidator_address
.