4
4
from datamaxi .lib .utils import check_required_parameter
5
5
from datamaxi .lib .utils import check_required_parameters
6
6
from datamaxi .lib .utils import check_required_parameter_list
7
+ from datamaxi .lib .utils import check_at_least_one_set_parameters
7
8
from datamaxi .lib .utils import encode_string_list
8
9
from datamaxi .lib .utils import make_list
9
10
from datamaxi .lib .utils import postprocess
@@ -360,21 +361,21 @@ def stablecoin_price(
360
361
@postprocess ()
361
362
def fee (
362
363
self ,
363
- protocols : Union [ str , List [ str ]] = None ,
364
- chains : Union [ str , List [ str ]] = None ,
364
+ protocol : str = None ,
365
+ chain : str = None ,
365
366
daily : bool = True ,
366
367
pandas : bool = True ,
367
368
) -> Union [List , pd .DataFrame ]:
368
- """Get fee for given protocols or chains
369
+ """Get fee for given protocol or chain
369
370
370
371
`GET /v1/defillama/fee`
371
372
372
373
<https://docs.datamaxiplus.com/defillama/fee>
373
374
374
375
Args:
375
- protocols (Union[ str, List[str]] ): single protocol or multiple protocol names
376
- chains (Union[ str, List[str]] ): single chain or multiple chain names
377
- daily (bool): daily fee or total fee
376
+ protocol ( str): Protocol name
377
+ chain ( str): Chain name
378
+ daily (bool): Daily fee or total fee
378
379
pandas (bool): Return data as pandas DataFrame
379
380
380
381
Returns:
@@ -385,38 +386,36 @@ def fee(
385
386
"daily" : str (daily ).lower (),
386
387
}
387
388
388
- if not ((protocols is None ) ^ (chains is None )):
389
+ if not ((protocol is None ) ^ (chain is None )):
389
390
raise ValueError ("Either protocols or chains should be provided" )
390
391
391
- if protocols is not None :
392
- protocols = make_list (protocols )
393
- check_required_parameter_list (protocols , "protocols" )
394
- params ["protocols" ] = encode_string_list (protocols )
395
- elif chains is not None :
396
- chains = make_list (chains )
397
- check_required_parameter_list (chains , "chains" )
398
- params ["chains" ] = encode_string_list (chains )
392
+ if protocol is not None :
393
+ check_required_parameter (protocol , "protocol" )
394
+ params ["protocol" ] = protocol
395
+ elif chain is not None :
396
+ check_required_parameter (chain , "chain" )
397
+ params ["chain" ] = chain
399
398
400
399
return self .query ("/v1/defillama/fee" , params )
401
400
402
401
@postprocess ()
403
402
def revenue (
404
403
self ,
405
- protocols : Union [ str , List [ str ]] = None ,
406
- chains : Union [ str , List [ str ]] = None ,
404
+ protocol : str = None ,
405
+ chain : str = None ,
407
406
daily : bool = True ,
408
407
pandas : bool = True ,
409
408
) -> Union [List , pd .DataFrame ]:
410
- """Get revenue for given protocols or chains
409
+ """Get revenue for given protocol or chain
411
410
412
411
`GET /v1/defillama/revenue`
413
412
414
413
<https://docs.datamaxiplus.com/defillama/revenue>
415
414
416
415
Args:
417
- protocols (Union[ str, List[str]] ): single protocol or multiple protocol names
418
- chains (Union[ str, List[str]] ): single chain or multiple chain names
419
- daily (bool): daily revenue or total revenue
416
+ protocol ( str): Protocol name
417
+ chain ( str): Chain name
418
+ daily (bool): Daily revenue or total revenue
420
419
pandas (bool): Return data as pandas DataFrame
421
420
422
421
Returns:
@@ -427,23 +426,25 @@ def revenue(
427
426
"daily" : str (daily ).lower (),
428
427
}
429
428
430
- if not ((protocols is None ) ^ (chains is None )):
429
+ if not ((protocol is None ) ^ (chain is None )):
431
430
raise ValueError ("Either protocols or chains should be provided" )
432
431
433
- if protocols is not None :
434
- protocols = make_list (protocols )
435
- check_required_parameter_list (protocols , "protocols" )
436
- params ["protocols" ] = encode_string_list (protocols )
437
- elif chains is not None :
438
- chains = make_list (chains )
439
- check_required_parameter_list (chains , "chains" )
440
- params ["chains" ] = encode_string_list (chains )
432
+ if protocol is not None :
433
+ check_required_parameter (protocol , "protocol" )
434
+ params ["protocol" ] = protocol
435
+ elif chain is not None :
436
+ check_required_parameter (chain , "chain" )
437
+ params ["chain" ] = chain
441
438
442
439
return self .query ("/v1/defillama/revenue" , params )
443
440
444
441
@postprocess (num_index = 3 )
445
442
def fee_detail (
446
- self , protocol : str , chain : str = None , daily : bool = True , pandas : bool = True
443
+ self ,
444
+ protocol : str = None ,
445
+ chain : str = None ,
446
+ daily : bool = True ,
447
+ pandas : bool = True ,
447
448
) -> Union [List , pd .DataFrame ]:
448
449
"""Get fee detail for given protocol and chain
449
450
@@ -452,27 +453,35 @@ def fee_detail(
452
453
<https://docs.datamaxiplus.com/defillama/fee-detail>
453
454
454
455
Args:
455
- protocol (str): protocol name
456
- chain (str): chain name (optional)
457
- daily (bool): daily fee or total fee
456
+ protocol (str): Protocol name
457
+ chain (str): Chain name
458
+ daily (bool): Daily fee or total fee
458
459
pandas (bool): Return data as pandas DataFrame
459
460
460
461
Returns:
461
462
Timeseries of fee detail for a given protocol and chain
462
463
"""
463
- check_required_parameters ([[ protocol , "protocol" ], [ daily , "daily" ]] )
464
+ check_required_parameter ( daily , "daily" )
464
465
params = {
465
- "protocol" : protocol ,
466
466
"daily" : str (daily ).lower (),
467
467
}
468
+
469
+ check_at_least_one_set_parameters ([[protocol , "protocol" ], [chain , "chain" ]])
470
+ if protocol is not None :
471
+ params ["protocol" ] = protocol
472
+
468
473
if chain is not None :
469
474
params ["chain" ] = chain
470
475
471
476
return self .query ("/v1/defillama/fee/detail" , params )
472
477
473
478
@postprocess (num_index = 3 )
474
479
def revenue_detail (
475
- self , protocol : str , chain : str = None , daily : bool = True , pandas : bool = True
480
+ self ,
481
+ protocol : str = None ,
482
+ chain : str = None ,
483
+ daily : bool = True ,
484
+ pandas : bool = True ,
476
485
) -> Union [List , pd .DataFrame ]:
477
486
"""Get revenue detail for given protocol and chain
478
487
@@ -481,19 +490,23 @@ def revenue_detail(
481
490
<https://docs.datamaxiplus.com/defillama/revenue-detail>
482
491
483
492
Args:
484
- protocol (str): protocol name
485
- chain (str): chain name (optional)
486
- daily (bool): daily revenue or total revenue
493
+ protocol (str): Protocol name
494
+ chain (str): Chain name
495
+ daily (bool): Daily revenue or total revenue
487
496
pandas (bool): Return data as pandas DataFrame
488
497
489
498
Returns:
490
499
Timeseries of revenue detail for a given protocol and chain
491
500
"""
492
- check_required_parameters ([[ protocol , "protocol" ], [ daily , "daily" ]] )
501
+ check_required_parameter ( daily , "daily" )
493
502
params = {
494
- "protocol" : protocol ,
495
503
"daily" : str (daily ).lower (),
496
504
}
505
+
506
+ check_at_least_one_set_parameters ([[protocol , "protocol" ], [chain , "chain" ]])
507
+ if protocol is not None :
508
+ params ["protocol" ] = protocol
509
+
497
510
if chain is not None :
498
511
params ["chain" ] = chain
499
512
0 commit comments