xync-client 0.0.25.dev38__tar.gz → 0.0.25.dev39__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xync_client-0.0.25.dev38/xync_client.egg-info → xync_client-0.0.25.dev39}/PKG-INFO +2 -2
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/pyproject.toml +1 -1
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/pyd.py +6 -2
- {xync_client-0.0.25.dev38/xync_client/Htx/pyd → xync_client-0.0.25.dev39/xync_client/Htx/etype}/cred.py +2 -7
- xync_client-0.0.25.dev39/xync_client/Htx/etype/pm.py +23 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Htx/ex.py +9 -8
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/agent.py +8 -7
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/auth.py +5 -1
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/ex.py +34 -29
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/pyd.py +1 -1
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/pyro.py +5 -4
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39/xync_client.egg-info}/PKG-INFO +2 -2
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client.egg-info/SOURCES.txt +4 -5
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client.egg-info/requires.txt +1 -1
- xync_client-0.0.25.dev38/xync_client/Htx/pyd/actor.py +0 -4
- xync_client-0.0.25.dev38/xync_client/Htx/pyd/pm.py +0 -12
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/.env.sample +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/.gitignore +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/.pre-commit-config.yaml +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/README.md +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/makefile +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/setup.cfg +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/TestAgent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/TestAsset.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/TestEx.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/TestOrder.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Binance/test_binance.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Bybit/test_bybit.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Bybit/test_bybit_p2p.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Gate/test_gate.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Htx/test_htx_p2p.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Wallet/test_agent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Wallet/test_ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/__init__.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/_test_ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/Agent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/Asset.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/AuthTrait.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/Base.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/BaseTest.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/Ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/InAgent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Abc/Order.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/__init__.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/binance_async.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/earn_api.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/exceptions.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/sapi.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Binance/web_c2c.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/__init__.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/agent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/base.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/req.mjs +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/sign.js +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BingX/test/main.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BitGet/__init__.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BitGet/agent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BitGet/ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/BitGet/req.mjs +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Bybit/agent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Bybit/ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Bybit/web_earn.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Bybit/web_p2p.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Gate/ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Gate/premarket.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Htx/agent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Htx/earn.py +0 -0
- /xync_client-0.0.25.dev38/xync_client/Htx/pyd/types.py → /xync_client-0.0.25.dev39/xync_client/Htx/etype/__init__.py +0 -0
- {xync_client-0.0.25.dev38/xync_client/Htx/pyd → xync_client-0.0.25.dev39/xync_client/Htx/etype}/ad.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/KuCoin/pub.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/KuCoin/web.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Okx/ex.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/Okx/pyd.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/asset.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/inAgent.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/order.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/TgWallet/web.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/__init__.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/loader.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client/pyro.py +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client.egg-info/dependency_links.txt +0 -0
- {xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client.egg-info/top_level.txt +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xync-client
|
|
3
|
-
Version: 0.0.25.
|
|
3
|
+
Version: 0.0.25.dev39
|
|
4
4
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/XyncNet/client
|
|
6
6
|
Project-URL: Repository, https://gitlab.com/XyncNet/client
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
8
|
Requires-Dist: asynchuobi
|
|
9
9
|
Requires-Dist: bs4
|
|
10
|
+
Requires-Dist: msgspec
|
|
10
11
|
Requires-Dist: python-binance
|
|
11
12
|
Requires-Dist: pybit
|
|
12
13
|
Requires-Dist: pyotp
|
|
@@ -14,7 +15,6 @@ Requires-Dist: pyrogram
|
|
|
14
15
|
Requires-Dist: python-dotenv
|
|
15
16
|
Requires-Dist: python-okx
|
|
16
17
|
Requires-Dist: xn-client>=0.0.3dev3
|
|
17
|
-
Requires-Dist: xn-auth
|
|
18
18
|
Requires-Dist: xync-schema
|
|
19
19
|
Provides-Extra: dev
|
|
20
20
|
Requires-Dist: build; extra == "dev"
|
|
@@ -9,6 +9,7 @@ dynamic = ["version"]
|
|
|
9
9
|
dependencies = [
|
|
10
10
|
"asynchuobi",
|
|
11
11
|
"bs4",
|
|
12
|
+
"msgspec",
|
|
12
13
|
"python-binance",
|
|
13
14
|
"pybit",
|
|
14
15
|
"pyotp",
|
|
@@ -17,7 +18,6 @@ dependencies = [
|
|
|
17
18
|
"python-okx",
|
|
18
19
|
# "tgcrypto",
|
|
19
20
|
"xn-client>=0.0.3dev3",
|
|
20
|
-
"xn-auth",
|
|
21
21
|
"xync-schema"
|
|
22
22
|
]
|
|
23
23
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from pydantic import BaseModel
|
|
2
2
|
from typing import List
|
|
3
|
-
from xync_schema.
|
|
3
|
+
from xync_schema.types import BaseAd
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
class User(BaseModel):
|
|
6
7
|
nickname: str
|
|
@@ -32,6 +33,7 @@ class PmEpyd(BaseModel):
|
|
|
32
33
|
icon: str
|
|
33
34
|
number: int
|
|
34
35
|
|
|
36
|
+
|
|
35
37
|
class UserPaymentMethod(BaseModel):
|
|
36
38
|
id: int
|
|
37
39
|
paymentMethodId: int
|
|
@@ -39,6 +41,7 @@ class UserPaymentMethod(BaseModel):
|
|
|
39
41
|
paymentMethodIcon: str
|
|
40
42
|
mainColor: str
|
|
41
43
|
|
|
44
|
+
|
|
42
45
|
class PaymentMethod(BaseModel):
|
|
43
46
|
id: int
|
|
44
47
|
name: str
|
|
@@ -46,6 +49,7 @@ class PaymentMethod(BaseModel):
|
|
|
46
49
|
mainColor: str
|
|
47
50
|
userPaymentMethodList: List[UserPaymentMethod]
|
|
48
51
|
|
|
52
|
+
|
|
49
53
|
class Ad(BaseAd):
|
|
50
54
|
orderNo: str
|
|
51
55
|
tradeRecent: int
|
|
@@ -87,4 +91,4 @@ class Ad(BaseAd):
|
|
|
87
91
|
merchantKycType: int
|
|
88
92
|
merchantVerificationType: int
|
|
89
93
|
isUserMatchCondition: bool
|
|
90
|
-
notMatchConditionReason: str
|
|
94
|
+
notMatchConditionReason: str
|
|
@@ -6,15 +6,10 @@ field_ids = {
|
|
|
6
6
|
926496571879587801: "payee",
|
|
7
7
|
926496571879587802: "bank",
|
|
8
8
|
926496571879587803: "sub_bank",
|
|
9
|
-
926496571879587804: "pay_account"
|
|
9
|
+
926496571879587804: "pay_account",
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
field_types = {
|
|
13
|
-
"payee": "cred__name",
|
|
14
|
-
"bank": "pm__name",
|
|
15
|
-
"sub_bank": None,
|
|
16
|
-
"pay_account": "cred__detail"
|
|
17
|
-
}
|
|
12
|
+
field_types = {"payee": "cred__name", "bank": "pm__name", "sub_bank": None, "pay_account": "cred__detail"}
|
|
18
13
|
|
|
19
14
|
|
|
20
15
|
class Cred(BaseModel):
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
from msgspec import Struct
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PmEType(IntEnum):
|
|
7
|
+
credit_card = 0
|
|
8
|
+
bank = 1
|
|
9
|
+
cash = 2
|
|
10
|
+
web_wallet = 3
|
|
11
|
+
web_wallet1 = 4
|
|
12
|
+
IFSC = 5
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Resp(Struct):
|
|
16
|
+
payMethodId: int
|
|
17
|
+
name: str
|
|
18
|
+
template: int
|
|
19
|
+
bankType: int
|
|
20
|
+
color: str
|
|
21
|
+
bankImage: str | None
|
|
22
|
+
bankImageWeb: str | None
|
|
23
|
+
defaultName: str | None = None
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
from asyncio import run
|
|
2
2
|
|
|
3
|
+
from msgspec import convert
|
|
3
4
|
from x_model import init_db
|
|
4
5
|
from xync_schema import models, types
|
|
5
6
|
from xync_schema.models import Ex, Cur
|
|
6
7
|
from xync_schema.enums import PmType
|
|
7
8
|
|
|
8
9
|
from xync_client.Abc.Ex import BaseExClient
|
|
9
|
-
from xync_client.Htx.
|
|
10
|
+
from xync_client.Htx.etype import pm, Country
|
|
10
11
|
from xync_client.loader import PG_DSN
|
|
11
12
|
|
|
12
13
|
|
|
@@ -22,16 +23,16 @@ class ExClient(BaseExClient):
|
|
|
22
23
|
5: PmType.IFSC,
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
pms = (await self._coin_curs_pms())["payMethod"]
|
|
26
|
+
pms: list[pm.Resp] = [convert(p, pm.Resp) for p in (await self._coin_curs_pms())["payMethod"]]
|
|
26
27
|
|
|
27
28
|
pmsd = {
|
|
28
|
-
|
|
29
|
-
id=
|
|
30
|
-
name=
|
|
31
|
-
type_=dist.get(
|
|
32
|
-
logo=
|
|
29
|
+
p.payMethodId: types.Pm(
|
|
30
|
+
id=p.payMethodId,
|
|
31
|
+
name=p.name,
|
|
32
|
+
type_=dist.get(p.template),
|
|
33
|
+
logo=p.bankImage or p.bankImageWeb,
|
|
33
34
|
)
|
|
34
|
-
for
|
|
35
|
+
for p in pms
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
return pmsd
|
|
@@ -192,10 +192,11 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
192
192
|
raise HTTPException(
|
|
193
193
|
FailReason.body, f"No Pmcur with cur#{fiat.currency} and pm#{fiat.paymentMethod.code}", 404
|
|
194
194
|
)
|
|
195
|
+
ch = self.agent.actor.ch_id
|
|
195
196
|
cred_pin = CredPydIn(
|
|
196
197
|
exid=fiat.id,
|
|
197
198
|
pmcur=pmcur,
|
|
198
|
-
|
|
199
|
+
ch=ch,
|
|
199
200
|
name=fiat.name,
|
|
200
201
|
)
|
|
201
202
|
for val in fiat.attributes.values:
|
|
@@ -311,7 +312,7 @@ class AgentClient(BaseAgentClient, AuthClient):
|
|
|
311
312
|
) -> AdMakerNewSale | AdMakerNewBuy:
|
|
312
313
|
coinex = await Coinex.get(coin=coin, ex=self.ex)
|
|
313
314
|
curex = await Curex.get(ex=self.ex, cur=cur)
|
|
314
|
-
creds = await Cred.filter(
|
|
315
|
+
creds = await Cred.filter(ch__actor__agent__user_id=self.agent.user_id, pmcur__cur=cur).limit(5)
|
|
315
316
|
# todo: ordering and filtering by fiat.amount-target
|
|
316
317
|
ad_ein = _AdNew(
|
|
317
318
|
type="SALE" if is_sell else "PURCHASE",
|
|
@@ -431,11 +432,11 @@ async def main():
|
|
|
431
432
|
)
|
|
432
433
|
mcl: AgentClient = maker.client()
|
|
433
434
|
tcl: AgentClient = taker.client()
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
435
|
+
await tcl.set_fiats()
|
|
436
|
+
await mcl.set_fiats()
|
|
437
|
+
my_ads = await mcl.my_ads()
|
|
438
|
+
my_ads_in = [await mcl.ad_epyd2pydin(ma) for ma in my_ads]
|
|
439
|
+
_my_ads_db = [await mcl.ad_pydin2db(ma) for ma in my_ads_in]
|
|
439
440
|
|
|
440
441
|
coin = await Coin.get(ticker="USDT")
|
|
441
442
|
cur = await Cur.get(ticker="RUB")
|
|
@@ -9,7 +9,11 @@ from xync_client.TgWallet.pyro import PyroClient
|
|
|
9
9
|
class AuthClient(BaseAuthTrait, BaseClient):
|
|
10
10
|
async def _get_auth_hdrs(self) -> dict[str, str]:
|
|
11
11
|
if not self.agent:
|
|
12
|
-
self.agent =
|
|
12
|
+
self.agent = (
|
|
13
|
+
await Agent.filter(actor__ex=self.ex, auth__isnull=False)
|
|
14
|
+
.prefetch_related("actor__person__user")
|
|
15
|
+
.first()
|
|
16
|
+
)
|
|
13
17
|
pyro = PyroClient(self.agent)
|
|
14
18
|
init_data = await pyro.get_init_data()
|
|
15
19
|
tokens = HttpClient("walletbot.me")._post("/api/v1/users/auth/", init_data)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
from asyncio import run
|
|
2
2
|
|
|
3
3
|
from x_model import init_db
|
|
4
|
-
from xync_schema
|
|
5
|
-
|
|
4
|
+
from xync_schema import types
|
|
6
5
|
from xync_schema import models
|
|
7
|
-
from xync_schema.models import Ex, Direction, Pair, Coin, Cur, Pm, Actor, PairEx
|
|
8
6
|
|
|
9
7
|
from xync_client.TgWallet.pyd import (
|
|
10
8
|
PmEpydRoot,
|
|
@@ -22,10 +20,10 @@ from xync_client.TgWallet.auth import AuthClient
|
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
class ExClient(BaseExClient, AuthClient):
|
|
25
|
-
def __init__(self, ex: Ex):
|
|
23
|
+
def __init__(self, ex: models.Ex):
|
|
26
24
|
super().__init__(ex) # BaseExClient
|
|
27
25
|
|
|
28
|
-
def pm_type_map(self, pm: Pm) -> str:
|
|
26
|
+
def pm_type_map(self, pm: models.Pm) -> str:
|
|
29
27
|
return "V2" if pm.name.startswith("SBP") else "V1"
|
|
30
28
|
|
|
31
29
|
# 00: todo: min-max for cur and coin ad amount, order, fee ..
|
|
@@ -34,13 +32,13 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
34
32
|
return settings["data"]
|
|
35
33
|
|
|
36
34
|
# 19: Список поддерживаемых валют тейкера
|
|
37
|
-
async def curs(self) -> list[
|
|
35
|
+
async def curs(self) -> list[types.CurE]:
|
|
38
36
|
coins_curs = await self._post("/p2p/public-api/v2/currency/all-supported")
|
|
39
37
|
stg = await self._settings()
|
|
40
38
|
roundings: dict[str, int] = stg["offerSettings"]["roundingScaleByFiatCurrency"]
|
|
41
39
|
minimums: dict[str, str] = stg["offerSettings"]["minOrderAmountByCurrencyCode"]
|
|
42
40
|
return [
|
|
43
|
-
|
|
41
|
+
types.CurE(
|
|
44
42
|
exid=c["code"], ticker=c["code"], rounding_scale=roundings.get(c["code"]), minimum=minimums[c["code"]]
|
|
45
43
|
)
|
|
46
44
|
for c in coins_curs["data"]["fiat"]
|
|
@@ -51,7 +49,7 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
51
49
|
return {pm["code"]: PmEpydRoot(**pm) for pm in pms["data"]}
|
|
52
50
|
|
|
53
51
|
# 20: Список платежных методов. todo: refact to pmexs?
|
|
54
|
-
async def pms(self, cur: str = None) -> dict[str,
|
|
52
|
+
async def pms(self, cur: str = None) -> dict[str, types.Pm]:
|
|
55
53
|
pms: dict[str:PmEpydRoot] = {}
|
|
56
54
|
if cur:
|
|
57
55
|
pms = await self._pms(cur)
|
|
@@ -59,7 +57,11 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
59
57
|
for cur in await self.curs():
|
|
60
58
|
pms |= await self._pms(cur.exid)
|
|
61
59
|
return {
|
|
62
|
-
k:
|
|
60
|
+
k: types.Pm(
|
|
61
|
+
identifier=pm.code,
|
|
62
|
+
name=pm.nameEng,
|
|
63
|
+
banks=[types.PmexBank(exid=b.code, name=b.name) for b in pm.banks or []],
|
|
64
|
+
)
|
|
63
65
|
for k, pm in pms.items()
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -68,13 +70,14 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
68
70
|
return {cur.exid: list(await self._pms(cur.exid)) for cur in await self.curs()}
|
|
69
71
|
|
|
70
72
|
# 22: Список торгуемых монет (с ограничениям по валютам, если есть)
|
|
71
|
-
async def coins(self) -> list[
|
|
73
|
+
async def coins(self) -> list[types.CoinE]:
|
|
72
74
|
coins_curs = await self._post("/p2p/public-api/v2/currency/all-supported")
|
|
73
75
|
stg = await self._settings()
|
|
74
76
|
lims = list(stg["offerSettings"]["offerVolumeLimitsPerMarket"].values())
|
|
75
77
|
coins = {k: max(float(v[k]["minInclusive"]) for v in lims) for k, v in lims[0].items()}
|
|
76
78
|
return [
|
|
77
|
-
|
|
79
|
+
types.CoinE(exid=c["code"], ticker=c["code"], minimum=coins[c["code"]])
|
|
80
|
+
for c in coins_curs["data"]["crypto"]
|
|
78
81
|
]
|
|
79
82
|
|
|
80
83
|
# 23: Список пар валюта/монет
|
|
@@ -106,13 +109,13 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
106
109
|
ads = await self._post("/p2p/public-api/v2/offer/depth-of-market/", params, "data")
|
|
107
110
|
return [AdTakerSaleBuy(**ad) for ad in ads]
|
|
108
111
|
|
|
109
|
-
async def ad_common_epyd2pydin(self, ad: _BaseAd) ->
|
|
110
|
-
coin = await Coin.get_or_create_by_name(ad.price.baseCurrencyCode)
|
|
111
|
-
cur = await Cur.get_or_create_by_name(ad.price.quoteCurrencyCode)
|
|
112
|
-
pair, _ = await Pair.get_or_create(coin=coin, cur=cur)
|
|
113
|
-
pairex, _ = await PairEx.get_or_create(pair=pair, ex=self.ex)
|
|
114
|
-
dr, _ = await Direction.get_or_create(pairex=pairex, sell=ad.is_sell)
|
|
115
|
-
return
|
|
112
|
+
async def ad_common_epyd2pydin(self, ad: _BaseAd) -> types.BaseAdIn:
|
|
113
|
+
coin = await models.Coin.get_or_create_by_name(ad.price.baseCurrencyCode)
|
|
114
|
+
cur = await models.Cur.get_or_create_by_name(ad.price.quoteCurrencyCode)
|
|
115
|
+
pair, _ = await models.Pair.get_or_create(coin=coin, cur=cur)
|
|
116
|
+
pairex, _ = await models.PairEx.get_or_create(pair=pair, ex=self.ex)
|
|
117
|
+
dr, _ = await models.Direction.get_or_create(pairex=pairex, sell=ad.is_sell)
|
|
118
|
+
return types.BaseAdIn(
|
|
116
119
|
exid=ad.id,
|
|
117
120
|
price=ad.price.value,
|
|
118
121
|
min_fiat=ad.orderAmountLimits.min,
|
|
@@ -121,28 +124,30 @@ class ExClient(BaseExClient, AuthClient):
|
|
|
121
124
|
detail=getattr(ad, "comment", None),
|
|
122
125
|
)
|
|
123
126
|
|
|
124
|
-
async def ad_taker_epyd2pydin(self, ad: _TakerOne) ->
|
|
125
|
-
adx:
|
|
126
|
-
adx.maker = (await Actor.update_or_create({"name": ad.user.nickname}, ex=self.ex, exid=ad.user.userId))[
|
|
127
|
+
async def ad_taker_epyd2pydin(self, ad: _TakerOne) -> types.AdBuyIn:
|
|
128
|
+
adx: types.BaseAdIn = await self.ad_common_epyd2pydin(ad)
|
|
129
|
+
adx.maker = (await models.Actor.update_or_create({"name": ad.user.nickname}, ex=self.ex, exid=ad.user.userId))[
|
|
130
|
+
0
|
|
131
|
+
]
|
|
127
132
|
pms = ad.paymentMethods if isinstance(ad, _PmsTrait) else [pd.paymentMethod for pd in ad.paymentDetails]
|
|
128
|
-
return
|
|
129
|
-
**adx.model_dump(), pms_=await Pm.filter(pmexs__ex=self.ex, pmexs__exid__in=[p.code for p in pms])
|
|
133
|
+
return types.AdBuyIn(
|
|
134
|
+
**adx.model_dump(), pms_=await models.Pm.filter(pmexs__ex=self.ex, pmexs__exid__in=[p.code for p in pms])
|
|
130
135
|
)
|
|
131
136
|
|
|
132
137
|
|
|
133
138
|
async def _test():
|
|
134
139
|
await init_db(PG_DSN, models, True)
|
|
135
|
-
tgex = await Ex.get(name="TgWallet")
|
|
140
|
+
tgex = await models.Ex.get(name="TgWallet")
|
|
136
141
|
cl: ExClient = tgex.client()
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
await cl.pairs()
|
|
143
|
+
await cl.set_pmcurexs()
|
|
144
|
+
await cl.set_coinexs()
|
|
140
145
|
|
|
141
146
|
# # # SALE # # #
|
|
142
147
|
# get ads list
|
|
143
148
|
ads: list[AdTakerSaleBuy] = await cl.ads("TON", "RUB", True)
|
|
144
149
|
# prepare ad list items for saving
|
|
145
|
-
ads_pydin: list[
|
|
150
|
+
ads_pydin: list[types.BaseAdIn] = [await cl.ad_taker_epyd2pydin(adp) for adp in ads]
|
|
146
151
|
# list items save
|
|
147
152
|
_ads_db = [await cl.ad_pydin2db(adi) for adi in ads_pydin]
|
|
148
153
|
|
|
@@ -157,7 +162,7 @@ async def _test():
|
|
|
157
162
|
# get ads list
|
|
158
163
|
ads: list[AdTakerSaleBuy] = await cl.ads("TON", "RUB", False)
|
|
159
164
|
# prepare ad list items for saving
|
|
160
|
-
ads_pydin: list[
|
|
165
|
+
ads_pydin: list[types.BaseAdIn] = [await cl.ad_taker_epyd2pydin(adp) for adp in ads]
|
|
161
166
|
# list items save
|
|
162
167
|
_ads_db = [await cl.ad_pydin2db(adi) for adi in ads_pydin]
|
|
163
168
|
|
|
@@ -2,16 +2,17 @@ from asyncio import run
|
|
|
2
2
|
from urllib.parse import parse_qs
|
|
3
3
|
from pyrogram import Client
|
|
4
4
|
from pyrogram.raw import functions
|
|
5
|
-
from src.loader import PG_DSN
|
|
6
5
|
from x_model import init_db
|
|
7
|
-
from xync_client.loader import TG_API_ID, TG_API_HASH
|
|
6
|
+
from xync_client.loader import TG_API_ID, TG_API_HASH, PG_DSN
|
|
8
7
|
from xync_schema import models
|
|
9
8
|
from xync_schema.models import Agent
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
class PyroClient:
|
|
13
12
|
def __init__(self, agent: Agent):
|
|
14
|
-
self.app: Client = Client(
|
|
13
|
+
self.app: Client = Client(
|
|
14
|
+
str(agent.actor.person.user.id), TG_API_ID, TG_API_HASH, session_string=agent.auth["sess"]
|
|
15
|
+
)
|
|
15
16
|
|
|
16
17
|
async def get_init_data(self) -> dict:
|
|
17
18
|
async with self.app as app:
|
|
@@ -44,7 +45,7 @@ async def main():
|
|
|
44
45
|
_ = await init_db(PG_DSN, models, True)
|
|
45
46
|
agent: Agent = await Agent.filter(auth__isnull=False, ex__name="TgWallet").prefetch_related("ex").first()
|
|
46
47
|
pcl = PyroClient(agent)
|
|
47
|
-
await pcl.create_orders_forum(agent.user_id)
|
|
48
|
+
await pcl.create_orders_forum(agent.actor.user_id)
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
if __name__ == "__main__":
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: xync-client
|
|
3
|
-
Version: 0.0.25.
|
|
3
|
+
Version: 0.0.25.dev39
|
|
4
4
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/XyncNet/client
|
|
6
6
|
Project-URL: Repository, https://gitlab.com/XyncNet/client
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
8
|
Requires-Dist: asynchuobi
|
|
9
9
|
Requires-Dist: bs4
|
|
10
|
+
Requires-Dist: msgspec
|
|
10
11
|
Requires-Dist: python-binance
|
|
11
12
|
Requires-Dist: pybit
|
|
12
13
|
Requires-Dist: pyotp
|
|
@@ -14,7 +15,6 @@ Requires-Dist: pyrogram
|
|
|
14
15
|
Requires-Dist: python-dotenv
|
|
15
16
|
Requires-Dist: python-okx
|
|
16
17
|
Requires-Dist: xn-client>=0.0.3dev3
|
|
17
|
-
Requires-Dist: xn-auth
|
|
18
18
|
Requires-Dist: xync-schema
|
|
19
19
|
Provides-Extra: dev
|
|
20
20
|
Requires-Dist: build; extra == "dev"
|
|
@@ -61,11 +61,10 @@ xync_client/Gate/premarket.py
|
|
|
61
61
|
xync_client/Htx/agent.py
|
|
62
62
|
xync_client/Htx/earn.py
|
|
63
63
|
xync_client/Htx/ex.py
|
|
64
|
-
xync_client/Htx/
|
|
65
|
-
xync_client/Htx/
|
|
66
|
-
xync_client/Htx/
|
|
67
|
-
xync_client/Htx/
|
|
68
|
-
xync_client/Htx/pyd/types.py
|
|
64
|
+
xync_client/Htx/etype/__init__.py
|
|
65
|
+
xync_client/Htx/etype/ad.py
|
|
66
|
+
xync_client/Htx/etype/cred.py
|
|
67
|
+
xync_client/Htx/etype/pm.py
|
|
69
68
|
xync_client/KuCoin/pub.py
|
|
70
69
|
xync_client/KuCoin/web.py
|
|
71
70
|
xync_client/Okx/ex.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Binance/test_binance.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Bybit/test_bybit.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Bybit/test_bybit_p2p.py
RENAMED
|
File without changes
|
|
File without changes
|
{xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Htx/test_htx_p2p.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/tests/_todo_refact/Wallet/test_agent.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.25.dev38 → xync_client-0.0.25.dev39}/xync_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|