@@ -11,8 +11,9 @@ use crate::{
1111 AmmPool , AmmPoolRaw , CoinValue , PerpetualPosition , PoolExtraInfo , StakedPositionRaw ,
1212 } ,
1313 types:: {
14- BalanceAvailable , Mtp , OracleAssetInfo , PageResponse , PoolAsset , Price , StakedPosition ,
15- SwapAmountInRoute , SwapAmountOutRoute , UnstakedPosition , ValidatorDetail , VestingDetail ,
14+ BalanceAvailable , Mtp , MtpAndPrice , OracleAssetInfo , PageResponse , PoolAsset , Price ,
15+ StakedPosition , SwapAmountInRoute , SwapAmountOutRoute , UnstakedPosition , ValidatorDetail ,
16+ VestingDetail ,
1617 } ,
1718 ElysQuerier ,
1819} ;
@@ -67,13 +68,13 @@ pub struct OracleAssetInfoResponse {
6768
6869#[ cw_serde]
6970pub struct PerpetualQueryPositionsResponse {
70- pub mtps : Option < Vec < Mtp > > ,
71+ pub mtps : Option < Vec < MtpAndPrice > > ,
7172 pub pagination : PageResponse ,
7273}
7374
7475#[ cw_serde]
7576pub struct PerpetualMtpResponse {
76- pub mtp : Option < Mtp > ,
77+ pub mtp : Option < MtpAndPrice > ,
7778}
7879
7980#[ cw_serde]
@@ -100,6 +101,22 @@ pub struct AmmSwapEstimationByDenomResponse {
100101 pub price_impact : SignedDecimal ,
101102 pub slippage : Decimal ,
102103}
104+
105+ #[ cw_serde]
106+ pub struct CoinNeg {
107+ pub denom : String ,
108+ pub amount : Int128 ,
109+ }
110+
111+ impl Default for CoinNeg {
112+ fn default ( ) -> Self {
113+ Self {
114+ denom : "" . to_string ( ) ,
115+ amount : Int128 :: zero ( ) ,
116+ }
117+ }
118+ }
119+
103120#[ cw_serde]
104121pub struct PerpetualOpenEstimationRawResponse {
105122 pub position : Option < i32 > ,
@@ -122,7 +139,7 @@ pub struct PerpetualOpenEstimationRawResponse {
122139 pub funding_rate : Option < String > ,
123140 pub price_impact : Option < String > ,
124141 pub borrow_fee : Option < Coin > ,
125- pub funding_fee : Option < Coin > ,
142+ pub funding_fee : Option < CoinNeg > ,
126143}
127144
128145#[ cw_serde]
@@ -147,7 +164,7 @@ pub struct PerpetualOpenEstimationResponse {
147164 pub funding_rate : SignedDecimal ,
148165 pub price_impact : SignedDecimal ,
149166 pub borrow_fee : Coin ,
150- pub funding_fee : Coin ,
167+ pub funding_fee : CoinNeg ,
151168}
152169
153170impl Into < StdResult < PerpetualOpenEstimationResponse > > for PerpetualOpenEstimationRawResponse {
@@ -192,23 +209,35 @@ impl Into<StdResult<PerpetualOpenEstimationResponse>> for PerpetualOpenEstimatio
192209 price_impact : SignedDecimal :: from_str ( self . price_impact . unwrap_or_default ( ) . as_str ( ) )
193210 . unwrap_or_default ( ) ,
194211 borrow_fee : self . borrow_fee . unwrap_or_default ( ) ,
195- funding_fee : self . funding_fee . unwrap_or_default ( ) ,
212+ funding_fee : self . funding_fee . unwrap_or ( CoinNeg {
213+ denom : "" . to_string ( ) ,
214+ amount : Int128 :: zero ( ) ,
215+ } ) ,
196216 } )
197217 }
198218}
199219
200220#[ cw_serde]
201221pub struct PerpetualGetPositionsForAddressResponseRaw {
202- pub mtps : Option < Vec < Mtp > > ,
222+ pub mtps : Option < Vec < MtpAndPrice > > ,
203223 pub pagination : PageResponse ,
204224}
205225
206226#[ cw_serde]
207227pub struct PerpetualGetPositionsForAddressResponse {
208- pub mtps : Vec < Mtp > ,
228+ pub mtps : Vec < MtpAndPrice > ,
209229 pub pagination : PageResponse ,
210230}
211231
232+ impl PerpetualGetPositionsForAddressResponse {
233+ pub fn get_mtp_vec ( & self ) -> Vec < Mtp > {
234+ self . mtps
235+ . iter ( )
236+ . map ( |mtp_and_price| mtp_and_price. get_mtp ( ) )
237+ . collect ( )
238+ }
239+ }
240+
212241#[ cw_serde]
213242pub struct TierCalculateDiscountResponse {
214243 pub discount : String ,
0 commit comments