@@ -3,7 +3,7 @@ use std::{collections::BTreeMap, future, str::FromStr};
3
3
use anyhow:: Context ;
4
4
use binance:: model:: BookTickerEvent ;
5
5
use futures:: { StreamExt , TryStreamExt } ;
6
- use penumbra_asset:: asset:: DenomMetadata ;
6
+ use penumbra_asset:: asset:: Metadata ;
7
7
use penumbra_custody:: { AuthorizeRequest , CustodyClient } ;
8
8
use penumbra_dex:: {
9
9
lp:: {
@@ -12,11 +12,10 @@ use penumbra_dex::{
12
12
} ,
13
13
DirectedUnitPair ,
14
14
} ;
15
- use penumbra_fee:: Fee ;
16
15
use penumbra_keys:: keys:: { AddressIndex , FullViewingKey } ;
17
16
use penumbra_num:: Amount ;
18
- use penumbra_proto:: core:: component:: dex:: v1alpha1 :: query_service_client:: QueryServiceClient as DexQueryServiceClient ;
19
- use penumbra_proto:: core:: component:: dex:: v1alpha1 :: {
17
+ use penumbra_proto:: core:: component:: dex:: v1 :: query_service_client:: QueryServiceClient as DexQueryServiceClient ;
18
+ use penumbra_proto:: core:: component:: dex:: v1 :: {
20
19
LiquidityPositionsByPriceRequest , LiquidityPositionsRequest ,
21
20
} ;
22
21
use penumbra_view:: { Planner , ViewClient } ;
@@ -147,11 +146,7 @@ where
147
146
tracing:: debug!( "trader received event: {:?}" , book_ticker_event) ;
148
147
149
148
// Only update positions for a given symbol at most once per block
150
- let current_height = self
151
- . view
152
- . status ( self . fvk . wallet_id ( ) )
153
- . await ?
154
- . partial_sync_height ;
149
+ let current_height = self . view . status ( ) . await ?. partial_sync_height ;
155
150
if let Some ( last_updated_height) = self . last_updated_height . get ( symbol) {
156
151
if current_height <= * last_updated_height {
157
152
tracing:: debug!( ?symbol, "skipping symbol, already updated this block" ) ;
@@ -258,18 +253,15 @@ where
258
253
}
259
254
260
255
async fn finalize_and_submit ( & mut self , planner : & mut Planner < OsRng > ) -> anyhow:: Result < ( ) > {
261
- // Pay no fee for the transaction.
262
- let fee = Fee :: from_staking_token_amount ( 0u32 . into ( ) ) ;
263
-
264
256
// Sometimes building the plan can fail with an error, because there were no actions
265
257
// present. There's not an easy way to check this in the planner API right now.
258
+
259
+ // Fetch latest gas prices.
260
+ let gas_prices = self . view . gas_prices ( ) . await ?;
261
+
262
+ planner. set_gas_prices ( gas_prices) ;
266
263
let plan = planner
267
- . fee ( fee)
268
- . plan (
269
- & mut self . view ,
270
- self . fvk . wallet_id ( ) ,
271
- AddressIndex :: from ( self . account ) ,
272
- )
264
+ . plan ( & mut self . view , AddressIndex :: from ( self . account ) )
273
265
. await ?;
274
266
275
267
// 2. Authorize and build the transaction.
@@ -283,7 +275,7 @@ where
283
275
. data
284
276
. ok_or_else ( || anyhow:: anyhow!( "no auth data" ) ) ?
285
277
. try_into ( ) ?;
286
- let witness_data = self . view . witness ( self . fvk . wallet_id ( ) , & plan) . await ?;
278
+ let witness_data = self . view . witness ( & plan) . await ?;
287
279
let tx = plan
288
280
. build_concurrent ( & self . fvk , & witness_data, & auth_data)
289
281
. await ?;
@@ -410,12 +402,9 @@ where
410
402
market : & DirectedUnitPair ,
411
403
) -> anyhow:: Result < Vec < Position > > {
412
404
// We need to use the list of our notes to determine which positions we own.
413
- let notes = self
414
- . view
415
- . unspent_notes_by_address_and_asset ( self . fvk . wallet_id ( ) )
416
- . await ?;
405
+ let notes = self . view . unspent_notes_by_address_and_asset ( ) . await ?;
417
406
418
- fn is_closed_position_nft ( denom : & DenomMetadata ) -> bool {
407
+ fn is_closed_position_nft ( denom : & Metadata ) -> bool {
419
408
let prefix = "lpnft_closed_" . to_string ( ) ;
420
409
421
410
denom. starts_with ( & prefix)
@@ -476,12 +465,9 @@ where
476
465
market : & DirectedUnitPair ,
477
466
) -> anyhow:: Result < Vec < Position > > {
478
467
// We need to use the list of our notes to determine which positions we own.
479
- let notes = self
480
- . view
481
- . unspent_notes_by_address_and_asset ( self . fvk . wallet_id ( ) )
482
- . await ?;
468
+ let notes = self . view . unspent_notes_by_address_and_asset ( ) . await ?;
483
469
484
- fn is_opened_position_nft ( denom : & DenomMetadata ) -> bool {
470
+ fn is_opened_position_nft ( denom : & Metadata ) -> bool {
485
471
let prefix = "lpnft_opened_" . to_string ( ) ;
486
472
487
473
denom. starts_with ( & prefix)
@@ -659,10 +645,7 @@ where
659
645
// We could do this outside of the loop, but checking here
660
646
// assures we have the latest data, and the in-memory gRPC interface
661
647
// should be fast.
662
- let notes = self
663
- . view
664
- . unspent_notes_by_address_and_asset ( self . fvk . wallet_id ( ) )
665
- . await ?;
648
+ let notes = self . view . unspent_notes_by_address_and_asset ( ) . await ?;
666
649
667
650
let ( mut reserves_1, mut reserves_2) = ( Amount :: from ( 0u32 ) , Amount :: from ( 0u32 ) ) ;
668
651
0 commit comments