Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API endpoint from deprecated api.coindix to new api.nanoly #5849

Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b75346e
Update API endpoint from deprecated api.coindix to new api.nanoly
davidtran001 Dec 2, 2023
d4646c2
Renamed coindix_model and coindix_view to nanoly_model anmd nanoly_vi…
davidtran001 Dec 3, 2023
96180cc
Replaced instances of coindix with nanoly in defi tests
davidtran001 Dec 3, 2023
ef49f95
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 4, 2023
09e3f83
Changed data source from coindix to nanoly on screen
davidtran001 Dec 5, 2023
54d4257
Upated defi data source in defi_controller from coindix to nanoly
davidtran001 Dec 5, 2023
41f3e97
Merging with develop branch
davidtran001 Dec 5, 2023
a0085cd
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 5, 2023
dc3d56e
Renamed coindix models to nanoly model in sdk
davidtran001 Dec 5, 2023
6ccd76b
Deleted old coindix testing files
davidtran001 Dec 5, 2023
c852b02
Merge branch 'hotfix/update-api-endpoint' of github.com:davidtran001/…
davidtran001 Dec 5, 2023
2812e78
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 6, 2023
8b925e2
Fixed openbb_terminal.cryptocurrency.defi imports such that they're i…
davidtran001 Dec 6, 2023
cdaf25a
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 7, 2023
0a3ffaa
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 8, 2023
b60362c
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 11, 2023
db79720
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Dec 13, 2023
8b7bf30
Merge branch 'develop' into hotfix/update-api-endpoint
deeleeramone Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions openbb_terminal/core/sdk/models/crypto_sdk_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def __init__(self):
self.stvl_chart = lib.crypto_defi_llama_view.display_defi_tvl
self.validators = lib.crypto_defi_terramoney_fcd_model.get_validators
self.validators_chart = lib.crypto_defi_terramoney_fcd_view.display_validators
self.vaults = lib.crypto_defi_coindix_model.get_defi_vaults
self.vaults_chart = lib.crypto_defi_coindix_view.display_defi_vaults
self.vaults = lib.crypto_defi_nanoly_model.get_defi_vaults
self.vaults_chart = lib.crypto_defi_nanoly_view.display_defi_vaults


class CryptoDiscovery(Category):
Expand Down
4 changes: 2 additions & 2 deletions openbb_terminal/core/sdk/sdk_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@

# Cryptocurrency Defi
from openbb_terminal.cryptocurrency.defi import (
coindix_model as crypto_defi_coindix_model,
coindix_view as crypto_defi_coindix_view,
cryptosaurio_model as crypto_defi_cryptosaurio_model,
cryptosaurio_view as crypto_defi_cryptosaurio_view,
llama_model as crypto_defi_llama_model,
llama_view as crypto_defi_llama_view,
nanoly_model as crypto_defi_nanoly_model,
nanoly_view as crypto_defi_nanoly_view,
smartstake_model as crypto_defi_smartstake_model,
smartstake_view as crypto_defi_smartstake_view,
substack_model as crypto_defi_substack_model,
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/core/sdk/trail_map.csv
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ crypto.defi.sratio,crypto_defi_terramoney_fcd_model.get_staking_ratio_history,cr
crypto.defi.sreturn,crypto_defi_terramoney_fcd_model.get_staking_returns_history,crypto_defi_terramoney_fcd_view.display_staking_returns_history
crypto.defi.stvl,crypto_defi_llama_model.get_defi_tvl,crypto_defi_llama_view.display_defi_tvl
crypto.defi.validators,crypto_defi_terramoney_fcd_model.get_validators,crypto_defi_terramoney_fcd_view.display_validators
crypto.defi.vaults,crypto_defi_coindix_model.get_defi_vaults,crypto_defi_coindix_view.display_defi_vaults
crypto.defi.vaults,crypto_defi_nanoly_model.get_defi_vaults,crypto_defi_nanoly_view.display_defi_vaults
crypto.disc.categories_keys,crypto_disc_pycoingecko_model.get_categories_keys,
crypto.disc.coin_list,crypto_disc_pycoingecko_model.get_coin_list,
crypto.disc.coins,crypto_disc_pycoingecko_model.get_coins,crypto_disc_pycoingecko_view.display_coins
Expand Down
16 changes: 8 additions & 8 deletions openbb_terminal/cryptocurrency/defi/defi_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from openbb_terminal.core.session.current_user import get_current_user
from openbb_terminal.cryptocurrency.defi import (
coindix_model,
coindix_view,
nanoly_model,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is right here where Ruff is tripping. It wants to see these sorted alphabetically.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!
I have reordered the imports in defi_controller.py such that they're in alphabetical order in commit: 8b925e2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an error with the related tests. I think you may have to re-capture the tests for the model, view and controller.

Screenshot 2023-12-06 at 7 43 13 PM

pytest tests/openbb_terminal/path_to/test_file.py --record-mode once --rewrite-expected should get us there, allegedly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I have tried running the command you suggested but I can't get it to run on my machine locally.
The command:

pytest tests/openbb_terminal/cryptocurrency/test_defi_controller.py --record-mode once --rewrite-expected

and receive this error:

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --record-mode once
  inifile: /Users/davidtran/Code/OpenBBTerminal/pytest.ini
  rootdir: /Users/davidtran/Code/OpenBBTerminal

I have also ran

pytest tests/openbb_terminal/cryptocurrency/test_defi_controller.py --record-mode=once --rewrite-expected

But received the same error.

Do you have any suggestions where to go from here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo.. looks like I missed a sub-folder (defi), sorry about that.

tests/openbb_terminal/cryptocurrency/defi/test_defi_controller.py

nanoly_view,
cryptosaurio_view,
llama_model,
llama_view,
Expand Down Expand Up @@ -548,7 +548,7 @@ def call_vaults(self, other_args: List[str]):
prog="vaults",
description="""
Display Top DeFi Vaults.
[Source: https://coindix.com/]
[Source: https://nanoly.com/]
""",
)
parser.add_argument(
Expand All @@ -558,7 +558,7 @@ def call_vaults(self, other_args: List[str]):
type=str,
help="Blockchain name e.g. ethereum, terra",
default=None,
choices=coindix_model.CHAINS,
choices=nanoly_model.CHAINS,
required=False,
)
parser.add_argument(
Expand All @@ -568,7 +568,7 @@ def call_vaults(self, other_args: List[str]):
type=str,
help="DeFi protocol name e.g. aave, uniswap",
default=None,
choices=coindix_model.PROTOCOLS,
choices=nanoly_model.PROTOCOLS,
required=False,
)
parser.add_argument(
Expand All @@ -578,7 +578,7 @@ def call_vaults(self, other_args: List[str]):
type=str,
help="Kind/type of vault e.g. lp, single, noimploss, stable",
default=None,
choices=coindix_model.VAULT_KINDS,
choices=nanoly_model.VAULT_KINDS,
required=False,
)
parser.add_argument(
Expand All @@ -598,7 +598,7 @@ def call_vaults(self, other_args: List[str]):
type=str,
help="Sort by given column. Default: timestamp",
default="apy",
choices=coindix_model.VAULTS_FILTERS,
choices=nanoly_model.VAULTS_FILTERS,
)
parser.add_argument(
"-r",
Expand All @@ -625,7 +625,7 @@ def call_vaults(self, other_args: List[str]):
)

if ns_parser:
coindix_view.display_defi_vaults(
nanoly_view.display_defi_vaults(
chain=ns_parser.chain,
kind=ns_parser.kind,
protocol=ns_parser.protocol,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Coindix model"""
"""nanoly model"""
__docformat__ = "numpy"

import logging
Expand Down Expand Up @@ -86,7 +86,7 @@

@log_start_end(log=logger)
def _prepare_params(**kwargs) -> dict:
"""Helper method, which handles preparation of parameters for requests to coindix api.
"""Helper method, which handles preparation of parameters for requests to nanoly api.

Parameters
----------
Expand Down Expand Up @@ -116,7 +116,7 @@ def get_defi_vaults(
sortby: str = "apy",
) -> pd.DataFrame:
"""Get DeFi Vaults Information. DeFi Vaults are pools of funds with an assigned strategy which main goal is to
maximize returns of its crypto assets. [Source: https://coindix.com/]
maximize returns of its crypto assets. [Source: https://nanoly.com/]

Parameters
----------
Expand Down Expand Up @@ -145,10 +145,10 @@ def get_defi_vaults(
headers = {"User-Agent": get_user_agent()}
params = _prepare_params(chain=chain, protocol=protocol, kind=kind)
response = request(
"https://apiv2.coindix.com/search", headers=headers, params=params, verify=False
"https://api.nanoly.com/search", headers=headers, params=params, verify=False
)
if not 200 <= response.status_code < 300:
raise Exception(f"Coindix api exception: {response.text}")
raise Exception(f"nanoly api exception: {response.text}")

try:
data = response.json()["data"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Coindix view"""
"""nanoly view"""
__docformat__ = "numpy"

import logging
import os
from typing import Optional

from openbb_terminal.cryptocurrency.defi import coindix_model
from openbb_terminal.cryptocurrency.defi import nanoly_model
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import export_data, print_rich_table
from openbb_terminal.rich_config import console
Expand All @@ -28,7 +28,7 @@ def display_defi_vaults(
sheet_name: Optional[str] = None,
) -> None:
"""Prints table showing Top DeFi Vaults - pools of funds with an assigned strategy which main goal is to
maximize returns of its crypto assets. [Source: https://coindix.com/]
maximize returns of its crypto assets. [Source: https://nanoly.com/]

Parameters
----------
Expand Down Expand Up @@ -59,7 +59,7 @@ def display_defi_vaults(
Export dataframe data to csv,json,xlsx file
"""

df = coindix_model.get_defi_vaults(
df = nanoly_model.get_defi_vaults(
chain=chain, protocol=protocol, kind=kind, sortby=sortby, ascend=ascend
)
if df.empty:
Expand Down
24 changes: 12 additions & 12 deletions openbb_terminal/miscellaneous/gpt_index/data/crypto_defi_vaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ usage: vaults [-c {ethereum,polygon,avalanche,bsc,terra,fantom,moonriver,celo,he
[-p {aave,acryptos,alpaca,anchor,autofarm,balancer,bancor,beefy,belt,compound,convex,cream,curve,defichain,geist,lido,liquity,mirror,pancakeswap,raydium,sushi,tarot,traderjoe,tulip,ubeswap,uniswap,venus,yearn,osmosis,tulip}]
[-k {lp,single,noimploss,stable}] [-t TOP] [-s {name,chain,protocol,apy,tvl,link}] [-r] [-l]

Display Top DeFi Vaults. [Source: https://coindix.com/]
Display Top DeFi Vaults. [Source: https://nanoly.com/]

optional arguments:
-c {ethereum,polygon,avalanche,bsc,terra,fantom,moonriver,celo,heco,okex,cronos,arbitrum,eth,harmony,fuse,defichain,solana,optimism,kusama,metis,osmosis}, --chain {ethereum,polygon,avalanche,bsc,terra,fantom,moonriver,celo,heco,okex,cronos,arbitrum,eth,harmony,fuse,defichain,solana,optimism,kusama,metis,osmosis}
Expand All @@ -18,15 +18,15 @@ optional arguments:
-r, --reverse Data is sorted in descending order by default. Reverse flag will sort it in an ascending way. Only works when raw data is displayed. (default: False)
-l, --links Flag to show vault link (default: True)

Examples:
- Display top 10 DeFi vaults across all chains and protocols: crypto/defi/vaults
- Show top 5 DeFi vaults on the Ethereum blockchain: crypto/defi/vaults -c ethereum -t 5
- Display top DeFi vaults for the Aave protocol: crypto/defi/vaults -p aave
- Show top 10 single asset vaults: crypto/defi/vaults -k single
- Display top DeFi vaults on the Terra blockchain sorted by total value locked (TVL): crypto/defi/vaults -c terra -s tvl
- Show top 7 DeFi vaults for the Uniswap protocol, sorted by APY in ascending order: crypto/defi/vaults -p uniswap -t 7 -s apy -r
- Display top 5 DeFi vaults on the Binance Smart Chain with vault links: crypto/defi/vaults -c bsc -t 5 -l
- Show top DeFi vaults for the Sushi protocol on the Polygon network: crypto/defi/vaults -c polygon -p sushi
- Display top 3 no impermanent loss vaults sorted by name: crypto/defi/vaults -k noimploss -t 3 -s name

Examples:
- Display top 10 DeFi vaults across all chains and protocols: crypto/defi/vaults
- Show top 5 DeFi vaults on the Ethereum blockchain: crypto/defi/vaults -c ethereum -t 5
- Display top DeFi vaults for the Aave protocol: crypto/defi/vaults -p aave
- Show top 10 single asset vaults: crypto/defi/vaults -k single
- Display top DeFi vaults on the Terra blockchain sorted by total value locked (TVL): crypto/defi/vaults -c terra -s tvl
- Show top 7 DeFi vaults for the Uniswap protocol, sorted by APY in ascending order: crypto/defi/vaults -p uniswap -t 7 -s apy -r
- Display top 5 DeFi vaults on the Binance Smart Chain with vault links: crypto/defi/vaults -c bsc -t 5 -l
- Show top DeFi vaults for the Sushi protocol on the Polygon network: crypto/defi/vaults -c polygon -p sushi
- Display top 3 no impermanent loss vaults sorted by name: crypto/defi/vaults -k noimploss -t 3 -s name
- Show top 10 DeFi vaults on the Solana blockchain without vault links: crypto/defi/vaults -c solana -l
2 changes: 1 addition & 1 deletion openbb_terminal/miscellaneous/sources/openbb_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
},
"defi": {
"newsletter": ["Substack"],
"vaults": ["Coindix"],
"vaults": ["Nanoly"],
"tokens": ["TheGraph"],
"stats": ["TheGraph"],
"pairs": ["TheGraph"],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
User-Agent:
- Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.10; rv:83.0) Gecko/20100101 Firefox/83.0
method: GET
uri: https://apiv2.coindix.com/search?sort=-apy&tvl=1m&kind=all
uri: https://api.nanoly.com/search?sort=-apy&tvl=1m&kind=all
response:
body:
string: '{"hasPrevPage":false,"hasNextPage":true,"total":981,"totalPages":50,"data":[{"id":273200,"name":"MAGIC-WETH","chain":"Arbitrum","protocol":"Uniswap","base":23.7902436,"reward":0,"rewards":{},"apy":23.7902436,"tvl":1041078,"link":"https://api.nanoly.com/vaults/273200/redirect","is_new":false,"watched":false},{"id":272292,"name":"LCX-WETH","chain":"Ethereum","protocol":"Uniswap","base":3.3537874,"reward":0,"rewards":{},"apy":3.3537874,"tvl":1059213,"link":"https://api.nanoly.com/vaults/272292/redirect","is_new":false,"watched":false},{"id":272170,"name":"LDO-WETH","chain":"Ethereum","protocol":"Uniswap","base":3.2958058,"reward":0,"rewards":{},"apy":3.2958058,"tvl":4170799,"link":"https://api.nanoly.com/vaults/272170/redirect","is_new":false,"watched":false},{"id":272470,"name":"DYDX-WETH","chain":"Ethereum","protocol":"Uniswap","base":2.4461352,"reward":0,"rewards":{},"apy":2.4461352,"tvl":1486170,"link":"https://api.nanoly.com/vaults/272470/redirect","is_new":false,"watched":false},{"id":272216,"name":"FTM-WETH","chain":"Ethereum","protocol":"Uniswap","base":2.4265455,"reward":0,"rewards":{},"apy":2.4265455,"tvl":1710725,"link":"https://api.nanoly.com/vaults/272216/redirect","is_new":false,"watched":false},{"id":272424,"name":"OP-USDC","chain":"Optimism","protocol":"Uniswap","base":2.4134576,"reward":0,"rewards":{},"apy":2.4134576,"tvl":2478859,"link":"https://api.nanoly.com/vaults/272424/redirect","is_new":false,"watched":false},{"id":272140,"name":"APE-WETH","chain":"Ethereum","protocol":"Uniswap","base":2.3316127,"reward":0,"rewards":{},"apy":2.3316127,"tvl":8071844,"link":"https://api.nanoly.com/vaults/272140/redirect","is_new":false,"watched":false},{"id":273083,"name":"WMATIC-CRV","chain":"Polygon","protocol":"Uniswap","base":2.3040111,"reward":0,"rewards":{},"apy":2.3040111,"tvl":1229701,"link":"https://api.nanoly.com/vaults/273083/redirect","is_new":false,"watched":false},{"id":272850,"name":"USDC-CRV","chain":"Ethereum","protocol":"Uniswap","base":2.30376,"reward":0,"rewards":{},"apy":2.30376,"tvl":1106306,"link":"https://api.nanoly.com/vaults/272850/redirect","is_new":false,"watched":false},{"id":32055,"name":"AVAX-USDC","chain":"Avalanche","protocol":"Trader
Expand Down