-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Added chain generating for debank apps #251
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,12 @@ def test_fetch_chains(real_debank_api): | |
| def test_fetch_usage(): | ||
| assert False | ||
|
|
||
| @pytest.mark.integration | ||
| def test_fetch_debank_apps(real_debank_api): | ||
| response = real_debank_api.fetch_debank_apps('0x807A2E2e469df84b299Da5f90f15DdA4380dAcA1') | ||
| pass | ||
|
Comment on lines
+38
to
+41
|
||
|
|
||
|
|
||
|
|
||
| def _save(name: str, data: FetchResult): | ||
| if not OPTION_SAVE_DATA: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1197,12 +1197,18 @@ class DebankModelPredictionDetail(BaseModel): | |
| event_end_at: Optional[float] = None | ||
|
|
||
|
|
||
| class DebankModelDepositDetail(BaseModel): | ||
| """Detail for deposit/common type portfolio items.""" | ||
| class DebankDepositToken(BaseModel): | ||
| """Token within deposit/common type portfolio items.""" | ||
|
|
||
| id: str | ||
| symbol: str | ||
| name: str | ||
| amount: float | ||
| app_id: str | ||
| price: float | ||
| logo_url: Optional[str] = None | ||
|
|
||
|
|
||
| supply_token_list: Optional[list[dict]] = None | ||
| borrow_token_list: Optional[list[dict]] = None | ||
| reward_token_list: Optional[list[dict]] = None | ||
|
|
||
|
|
||
| class DebankModelAppPortfolioItem(BaseModel): | ||
|
|
@@ -1214,7 +1220,7 @@ class DebankModelAppPortfolioItem(BaseModel): | |
| detail: dict | ||
| position_index: str | ||
| asset_dict: Optional[dict] = None | ||
| asset_token_list: Optional[list[dict]] = None | ||
| asset_token_list: list[DebankDepositToken] = [] | ||
| update_at: Optional[float] = None | ||
|
Comment on lines
1221
to
1224
|
||
| proxy_detail: Optional[dict] = None | ||
|
|
||
|
|
@@ -1242,6 +1248,7 @@ class DebankPrediction: | |
| claimable: bool | ||
| event_end_at: Optional[datetime] | ||
| is_market_closed: bool | ||
| chain: Blockchain | ||
| position_index: Optional[str] | ||
| update_at: Optional[datetime] | ||
|
|
||
|
|
@@ -1256,6 +1263,7 @@ def from_api( | |
| usd_value: Union[str, float, int], | ||
| claimable: bool, | ||
| is_market_closed: bool, | ||
| chain: Blockchain, | ||
| event_end_at: Optional[Union[int, float]] = None, | ||
| position_index: Optional[str] = None, | ||
| update_at: Optional[Union[int, float]] = None, | ||
|
|
@@ -1269,6 +1277,7 @@ def from_api( | |
| claimable=claimable, | ||
| event_end_at=parse_dt(event_end_at) if event_end_at is not None else None, | ||
| is_market_closed=is_market_closed, | ||
| chain=chain, | ||
| position_index=position_index, | ||
| update_at=parse_dt(update_at) if update_at is not None else None, | ||
| ) | ||
|
|
@@ -1282,7 +1291,8 @@ class DebankAppDeposit: | |
| asset_usd_value: Decimal | ||
| debt_usd_value: Decimal | ||
| net_usd_value: Decimal | ||
| tokens: list[dict] # Raw token data for flexibility | ||
| tokens: list[DebankDepositToken] | ||
| chain: Blockchain | ||
| position_index: Optional[str] | ||
| update_at: Optional[datetime] | ||
|
|
||
|
|
@@ -1295,7 +1305,8 @@ def from_api( | |
| debt_usd_value: Union[str, float, int], | ||
| net_usd_value: Union[str, float, int], | ||
| position_index: str, | ||
| tokens: Optional[list[dict]] = None, | ||
| tokens: Optional[list[DebankDepositToken]] = None, | ||
| chain: Blockchain, | ||
| update_at: Optional[Union[int, float]] = None, | ||
| ) -> 'DebankAppDeposit': | ||
| return cls( | ||
|
|
@@ -1304,14 +1315,15 @@ def from_api( | |
| debt_usd_value=to_decimal(debt_usd_value), | ||
| net_usd_value=to_decimal(net_usd_value), | ||
| tokens=tokens or [], | ||
| chain=chain, | ||
| position_index=position_index, | ||
| update_at=parse_dt(update_at) if update_at else None, | ||
| ) | ||
|
|
||
| @property | ||
| def token_symbols(self) -> list[str]: | ||
| """Get list of token symbols in this deposit.""" | ||
| return [t.get('symbol', t.get('name', '')) for t in self.tokens] | ||
| return [t.symbol for t in self.tokens] | ||
|
|
||
|
|
||
| @attr.s(auto_attribs=True, slots=True, frozen=True) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_fetch_usagecontainsassert False, which will always fail when integration tests are enabled. Either implement the test (assert on the response / save fixture data) or mark it as skipped/xfail so it doesn’t break CI runs that include integration tests.