Skip to content

Commit

Permalink
enable vault rpc client
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Jun 14, 2024
1 parent 90b5058 commit 7f36a6d
Showing 1 changed file with 48 additions and 36 deletions.
84 changes: 48 additions & 36 deletions client/src/traits/vault.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,51 @@
use crate::{Result, RpcApi};
use defichain_rpc_json::{common::UTXO, vault::*};
use crate::{obj_into_json, Client, Result, RpcApi};
use async_trait::async_trait;
use defichain_rpc_json::vault::*;

#[async_trait]
pub trait VaultRPC: RpcApi {
fn close_vault(&self, close_vault: CloseVault, utxos: Option<UTXO>) -> Result<String>;
fn create_vault(&self, vault: CreateVault, utxos: Option<UTXO>) -> Result<String>;
fn deposit_to_vault(&self, deposit_vault: DepositVault, utxos: Option<UTXO>) -> Result<String>;
fn estimate_collateral(&self, target_ratio: u64) -> Result<()>;
fn estimate_loan(
&self,
vault_id: String,
token_split: TokenPercentageSplit,
target_ratio: Option<u64>,
) -> Result<()>;
fn estimate_vault(&self) -> Result<VaultEstimation>;
fn get_vault(&self, vault_id: String) -> Result<()>;
fn list_auction_history(
&self,
pagination: Option<ListAuctionHistoryPagination>,
) -> Result<Vec<ListAuctionHistoryDetail>>;
fn list_auctions(&self) -> Result<Vec<VaultLiquidation>>;
fn list_vaults(&self) -> Result<VaultActive>;
fn place_auction_bid(
&self,
place_auction_bid: PlaceAuctionBid,
utxos: Option<UTXO>,
) -> Result<String>;
fn update_vault(
&self,
vault_id: String,
vault: UpdateVault,
utxos: Option<UTXO>,
) -> Result<String>;
fn withdraw_from_vault(
&self,
withdraw_vault: WithdrawVault,
utxos: Option<UTXO>,
) -> Result<String>;
// fn close_vault(&self, close_vault: CloseVault, utxos: Option<UTXO>) -> Result<String>;
// fn create_vault(&self, vault: CreateVault, utxos: Option<UTXO>) -> Result<String>;
// fn deposit_to_vault(&self, deposit_vault: DepositVault, utxos: Option<UTXO>) -> Result<String>;
// fn estimate_collateral(&self, target_ratio: u64) -> Result<()>;
// fn estimate_loan(
// &self,
// vault_id: String,
// token_split: TokenPercentageSplit,
// target_ratio: Option<u64>,
// ) -> Result<()>;
// fn estimate_vault(&self) -> Result<VaultEstimation>;
// fn get_vault(&self, vault_id: String) -> Result<()>;
// fn list_auction_history(
// &self,
// pagination: Option<ListAuctionHistoryPagination>,
// ) -> Result<Vec<ListAuctionHistoryDetail>>;
async fn list_auctions(&self, pagination: Option<AuctionPagination>) -> Result<Vec<VaultLiquidation>>;
// fn list_vaults(&self) -> Result<VaultActive>;
// fn place_auction_bid(
// &self,
// place_auction_bid: PlaceAuctionBid,
// utxos: Option<UTXO>,
// ) -> Result<String>;
// fn update_vault(
// &self,
// vault_id: String,
// vault: UpdateVault,
// utxos: Option<UTXO>,
// ) -> Result<String>;
// fn withdraw_from_vault(
// &self,
// withdraw_vault: WithdrawVault,
// utxos: Option<UTXO>,
// ) -> Result<String>;
}

#[async_trait]
impl VaultRPC for Client {
async fn list_auctions(
&self,
pagination: Option<AuctionPagination>
) -> Result<Vec<VaultLiquidation>> {
self.call("listauctions", &[obj_into_json(pagination)?]).await
}
}

0 comments on commit 7f36a6d

Please sign in to comment.