From 7d4360046b9c32274a64b6538a20214e7d244134 Mon Sep 17 00:00:00 2001 From: RequiemOfSouls Date: Mon, 13 Nov 2023 22:27:11 +0800 Subject: [PATCH] fmt --- bindings/sdk/src/ffi.udl | 5 +++-- provider/src/response.rs | 2 +- types/src/tx_type/contract/funding.rs | 9 ++++++--- types/src/tx_type/contract/update_global_var.rs | 2 +- types/src/tx_type/validator.rs | 4 +++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bindings/sdk/src/ffi.udl b/bindings/sdk/src/ffi.udl index 03e98b48..ccc3d7b3 100644 --- a/bindings/sdk/src/ffi.udl +++ b/bindings/sdk/src/ffi.udl @@ -218,8 +218,9 @@ dictionary UpdateGlobalVarBuilder { u64 serial_id; }; -dictionary FundingRate { +dictionary FundingInfo { PairId pair_id; + BigUint price; i16 funding_rate; }; @@ -380,7 +381,7 @@ interface Parameter { FeeAccount(AccountId account_id); InsuranceFundAccount(AccountId account_id); MarginInfo(MarginId margin_id, TokenId token_id, u8 ratio); - FundingRates( sequence funding_rates ); + FundingInfos( sequence infos ); InitialMarginRate(PairId pair_id, u16 rate); MaintenanceMarginRate(PairId pair_id, u16 rate); }; diff --git a/provider/src/response.rs b/provider/src/response.rs index faad5969..ca79a04a 100644 --- a/provider/src/response.rs +++ b/provider/src/response.rs @@ -1,6 +1,6 @@ +use bigdecimal::num_bigint::BigInt; use bigdecimal::BigDecimal; use std::collections::HashMap; -use bigdecimal::num_bigint::BigInt; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; diff --git a/types/src/tx_type/contract/funding.rs b/types/src/tx_type/contract/funding.rs index 1ee6c93b..ad18dcbd 100644 --- a/types/src/tx_type/contract/funding.rs +++ b/types/src/tx_type/contract/funding.rs @@ -1,17 +1,20 @@ use crate::basic_types::pack::pack_fee_amount; use crate::basic_types::{AccountId, GetBytes, Nonce, PairId, SubAccountId, TokenId}; -use crate::params::{FUNDING_RATE_BYTES, PAIR_BIT_WIDTH, PRICE_BIT_WIDTH, SIGNED_BATCH_FUNDING_BIT_WIDTH, SIGNED_FUNDING_BIT_WIDTH}; +use crate::params::{ + FUNDING_RATE_BYTES, PAIR_BIT_WIDTH, PRICE_BIT_WIDTH, SIGNED_BATCH_FUNDING_BIT_WIDTH, + SIGNED_FUNDING_BIT_WIDTH, +}; +use crate::prelude::pad_front; use crate::prelude::validator::*; #[cfg(feature = "ffi")] use crate::tx_builder::FundingBuilder; use crate::tx_type::{TxTrait, ZkSignatureTrait}; -use num::BigUint; use num::traits::ToBytes; +use num::BigUint; use serde::{Deserialize, Serialize}; use validator::Validate; use zklink_sdk_signers::zklink_signer::ZkLinkSignature; use zklink_sdk_utils::serde::BigUintSerdeAsRadix10Str; -use crate::prelude::pad_front; #[derive(Default, Debug, Clone, Serialize, Deserialize, Validate)] #[serde(rename_all = "camelCase")] diff --git a/types/src/tx_type/contract/update_global_var.rs b/types/src/tx_type/contract/update_global_var.rs index 8eb17aa2..8a9e3a8b 100644 --- a/types/src/tx_type/contract/update_global_var.rs +++ b/types/src/tx_type/contract/update_global_var.rs @@ -124,7 +124,7 @@ impl GetBytes for Parameter { .into_iter() .chain(rate.to_be_bytes()) .collect(), - Parameter::FundingInfos{ infos } => infos.get_bytes(), + Parameter::FundingInfos { infos } => infos.get_bytes(), }); bytes } diff --git a/types/src/tx_type/validator.rs b/types/src/tx_type/validator.rs index e077b9b4..11e203e9 100644 --- a/types/src/tx_type/validator.rs +++ b/types/src/tx_type/validator.rs @@ -257,7 +257,9 @@ pub fn order_nonce_validator(nonce: &Nonce) -> Result<(), ValidationError> { /// pub fn parameter_validator(param: &Parameter) -> Result<(), ValidationError> { match param { - Parameter::FundingInfos { infos: funding_rates } => { + Parameter::FundingInfos { + infos: funding_rates, + } => { if funding_rates.len() != USED_POSITION_NUMBER { return Err(ValidationError::new("update funding rates number mismatch")); }