xync-client 0.0.164__py3-none-any.whl → 0.0.179.dev4__py3-none-any.whl
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/Abc/Agent.py +154 -30
- xync_client/Abc/Ex.py +113 -136
- xync_client/Abc/Order.py +20 -17
- xync_client/Abc/xtype.py +139 -65
- xync_client/Binance/ex.py +2 -2
- xync_client/BingX/agent.py +1 -1
- xync_client/BingX/ex.py +2 -2
- xync_client/BitGet/agent.py +1 -3
- xync_client/BitGet/ex.py +10 -9
- xync_client/BitPapa/ex.py +12 -9
- xync_client/Bybit/agent.py +106 -349
- xync_client/Bybit/etype/ad.py +79 -58
- xync_client/Bybit/etype/cred.py +25 -3
- xync_client/Bybit/etype/order.py +148 -92
- xync_client/Bybit/ex.py +27 -15
- xync_client/Bybit/{InAgent.py → inAgent.py} +5 -10
- xync_client/Bybit/order.py +42 -16
- xync_client/Gate/ex.py +2 -2
- xync_client/Htx/agent.py +13 -16
- xync_client/Htx/etype/ad.py +2 -4
- xync_client/Htx/etype/test.py +4 -4
- xync_client/Htx/ex.py +37 -5
- xync_client/KuCoin/ex.py +2 -2
- xync_client/Mexc/agent.py +11 -13
- xync_client/Mexc/ex.py +5 -5
- xync_client/Okx/agent.py +3 -9
- xync_client/Okx/ex.py +11 -10
- xync_client/TgWallet/agent.py +21 -21
- xync_client/TgWallet/ex.py +15 -15
- xync_client/TgWallet/pyd.py +5 -5
- xync_client/pm_unifier.py +3 -2
- {xync_client-0.0.164.dist-info → xync_client-0.0.179.dev4.dist-info}/METADATA +1 -1
- {xync_client-0.0.164.dist-info → xync_client-0.0.179.dev4.dist-info}/RECORD +35 -35
- {xync_client-0.0.164.dist-info → xync_client-0.0.179.dev4.dist-info}/WHEEL +0 -0
- {xync_client-0.0.164.dist-info → xync_client-0.0.179.dev4.dist-info}/top_level.txt +0 -0
xync_client/Bybit/etype/ad.py
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
from enum import StrEnum
|
|
2
|
-
from typing import
|
|
3
|
-
from pydantic import BaseModel, Field
|
|
4
|
-
from xync_client.
|
|
5
|
-
from xync_schema.
|
|
1
|
+
from enum import StrEnum, IntEnum
|
|
2
|
+
from typing import Optional, Any, Literal
|
|
3
|
+
from pydantic import BaseModel, Field, model_validator
|
|
4
|
+
from xync_client.Abc.xtype import BaseAd, AdStatus as xAdStatus, RemapBase, BaseCredexsExidsTrait
|
|
5
|
+
from xync_schema.enums import Side, PriceType
|
|
6
6
|
|
|
7
|
-
from xync_client.Abc.xtype import BaseAdUpdate
|
|
8
7
|
|
|
8
|
+
class AdStatus(IntEnum):
|
|
9
|
+
active = 10
|
|
10
|
+
hidden = 20
|
|
11
|
+
complete = 30
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
|
|
14
|
+
class AdStatusReq(StrEnum):
|
|
11
15
|
sold_out = "1"
|
|
12
16
|
active = "2"
|
|
13
17
|
|
|
@@ -108,63 +112,80 @@ class AdPostRequest(BaseModel):
|
|
|
108
112
|
itemType: Literal["ORIGIN", "BULK"] = "ORIGIN"
|
|
109
113
|
|
|
110
114
|
|
|
111
|
-
class
|
|
115
|
+
class AdRequest(AdPostRequest, BaseAd):
|
|
112
116
|
actionType: Literal["MODIFY", "ACTIVE"] = "MODIFY"
|
|
113
117
|
|
|
114
118
|
|
|
115
|
-
class Ad(BaseAd):
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
119
|
+
class Ad(BaseAd, RemapBase):
|
|
120
|
+
_remap = {
|
|
121
|
+
"status": {
|
|
122
|
+
AdStatus.active: xAdStatus.active,
|
|
123
|
+
AdStatus.hidden: xAdStatus.defActive,
|
|
124
|
+
AdStatus.complete: xAdStatus.soldOut,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
auto_msg: None = None
|
|
129
|
+
cond_txt: str = Field(alias="remark")
|
|
130
|
+
created_at: int = Field(alias="createDate")
|
|
131
|
+
coinex_exid: str = Field(alias="tokenId") # ticker
|
|
132
|
+
curex_exid: str = Field(alias="currencyId") # ticker
|
|
133
|
+
maker_exid: int = Field(alias="userId")
|
|
134
|
+
maker_name: str = Field(alias="nickName")
|
|
135
|
+
max_fiat: float = Field(alias="maxAmount")
|
|
136
|
+
min_fiat: float = Field(alias="minAmount")
|
|
137
|
+
# paymentPeriod: int
|
|
138
|
+
pmex_exids: list[int] = Field(alias="payments")
|
|
139
|
+
# recentOrderNum: int
|
|
140
|
+
side: Literal[Side.BUY, Side.SALE]
|
|
141
|
+
priceType: Literal[PriceType.FIX, PriceType.FLOAT]
|
|
142
|
+
# tradingPreferenceSet: TradingPreferenceSet | None = None # for initial actualize
|
|
143
|
+
|
|
144
|
+
# accountId: str = None # for initial actualize
|
|
145
|
+
# authStatus: int = None # for initial actualize
|
|
146
|
+
# authTag: List[str] = None # for initial actualize
|
|
147
|
+
# ban: bool = None # for initial actualize
|
|
148
|
+
# baned: bool = None # for initial actualize
|
|
149
|
+
# blocked: str = None # for initial actualize
|
|
150
|
+
# createDate: str = None # for initial actualize
|
|
151
|
+
# executedQuantity: str = None # for initial actualize
|
|
152
|
+
# fee: str = None # for initial actualize
|
|
153
|
+
# finishNum: int = None # for initial actualize
|
|
154
|
+
# frozenQuantity: str = None # for initial actualize
|
|
155
|
+
# isOnline: bool = None # for initial actualize
|
|
156
|
+
# itemType: str = None # for initial actualize
|
|
157
|
+
# lastLogoutTime: str = None # for initial actualize
|
|
158
|
+
# lastQuantity: str = Field(serialization_alias="quantity")
|
|
159
|
+
# makerContact: bool = None # for initial actualize
|
|
160
|
+
# nickName: str = None # for initial actualize
|
|
161
|
+
# orderNum: int = None # for initial actualize
|
|
162
|
+
# paymentPeriod: int = None # for initial actualize
|
|
163
|
+
# payments: List[str] = None # for initial actualize
|
|
164
|
+
# quantity: str = Field(serialization_alias="allQuantity") # for initial actualize
|
|
165
|
+
# recentExecuteRate: int = None # for initial actualize
|
|
166
|
+
# recentOrderNum: int = None # for initial actualize
|
|
167
|
+
# recommend: bool = None # for initial actualize
|
|
168
|
+
# recommendTag: str = None # for initial actualize
|
|
169
|
+
# status: Literal[10, 20, 30] # 10: online; 20: offline; 30: completed
|
|
170
|
+
# symbolInfo: SymbolInfo = None # for initial actualize
|
|
171
|
+
# tokenName: str = None # for initial actualize
|
|
172
|
+
# userMaskId: str = None # for initial actualize
|
|
173
|
+
# userType: str = None # for initial actualize
|
|
174
|
+
# verificationOrderAmount: str = None # for initial actualize
|
|
175
|
+
# verificationOrderLabels: List[Any] = None # for initial actualize
|
|
176
|
+
# verificationOrderSwitch: bool = None # for initial actualize
|
|
177
|
+
# version: int = None # for initial actualize
|
|
163
178
|
|
|
164
179
|
# @field_serializer("status")
|
|
165
180
|
# def status(self, status, _info) -> xtype.AdStatus:
|
|
166
181
|
# return {10: xtype.AdStatus.active, 20: xtype.AdStatus.defActive, 30: xtype.AdStatus.soldOut}[status]
|
|
167
182
|
|
|
168
183
|
|
|
169
|
-
class MyAd(Ad):
|
|
170
|
-
|
|
184
|
+
class MyAd(Ad, BaseCredexsExidsTrait):
|
|
185
|
+
credex_exids: list[int] = Field(alias="paymentTerms")
|
|
186
|
+
# paymentTerms: list[MyPaymentTerm]
|
|
187
|
+
|
|
188
|
+
@model_validator(mode="before")
|
|
189
|
+
def cred_exids(cls, data: "MyAd"):
|
|
190
|
+
data["paymentTerms"] = [pt["id"] for pt in data["paymentTerms"]]
|
|
191
|
+
return data
|
xync_client/Bybit/etype/cred.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from pydantic import BaseModel
|
|
1
|
+
from pydantic import BaseModel, Field, model_validator
|
|
2
2
|
|
|
3
|
-
from xync_client.Abc.xtype import
|
|
3
|
+
from xync_client.Abc.xtype import BaseCredEx
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class PaymentItem(BaseModel):
|
|
@@ -37,7 +37,7 @@ class PaymentConfigVo(BasePaymentConf):
|
|
|
37
37
|
items: list[dict[str, str | bool]]
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
class PaymentTerm(
|
|
40
|
+
class PaymentTerm(BaseModel):
|
|
41
41
|
id: str # int
|
|
42
42
|
realName: str
|
|
43
43
|
paymentType: int # int
|
|
@@ -81,3 +81,25 @@ class MyCredEpyd(CredEpyd): # todo: заменить везде где надо
|
|
|
81
81
|
realNameVerified: bool
|
|
82
82
|
channel: str
|
|
83
83
|
currencyBalance: list[str]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class CredEx(BaseCredEx):
|
|
87
|
+
detail: str = Field(alias="accountNo")
|
|
88
|
+
extra: str | None = Field(alias="bankName")
|
|
89
|
+
name: str = Field(alias="realName")
|
|
90
|
+
pmex_exid: int = Field(alias="paymentType")
|
|
91
|
+
|
|
92
|
+
@model_validator(mode="before")
|
|
93
|
+
def xtr_fill(cls, data: PaymentTerm):
|
|
94
|
+
data = dict(data)
|
|
95
|
+
xtr = data["bankName"]
|
|
96
|
+
if data["branchName"]:
|
|
97
|
+
xtr += (" | " if xtr else "") + data["branchName"]
|
|
98
|
+
if data["payMessage"]:
|
|
99
|
+
xtr += (" | " if xtr else "") + data["payMessage"]
|
|
100
|
+
if data["qrcode"]:
|
|
101
|
+
xtr += (" | " if xtr else "") + data["qrcode"]
|
|
102
|
+
if data["paymentExt1"]:
|
|
103
|
+
xtr += (" | " if xtr else "") + data["paymentExt1"]
|
|
104
|
+
data["bankName"] = xtr
|
|
105
|
+
return data
|
xync_client/Bybit/etype/order.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from enum import IntEnum
|
|
2
2
|
from typing import Literal, ClassVar
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel
|
|
4
|
+
from pydantic import BaseModel, Field, model_validator
|
|
5
|
+
from xync_schema.enums import OrderStatus
|
|
5
6
|
|
|
6
|
-
from xync_client.Abc.xtype import RemapBase
|
|
7
|
-
from xync_client.Bybit.etype.cred import CredEpyd, PaymentTerm as CredPaymentTerm, PaymentConfigVo
|
|
7
|
+
from xync_client.Abc.xtype import RemapBase, BaseOrderItem, BaseOrderFull, BaseCounteragent
|
|
8
|
+
from xync_client.Bybit.etype.cred import CredEpyd, PaymentTerm as CredPaymentTerm, PaymentConfigVo, CredEx
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class Topic(IntEnum):
|
|
@@ -19,7 +20,7 @@ class Status(IntEnum):
|
|
|
19
20
|
# chain = 5 # waiting for chain (only web3)
|
|
20
21
|
created = 10 # waiting for buyer to pay
|
|
21
22
|
paid = 20 # waiting for seller to release
|
|
22
|
-
|
|
23
|
+
appealed = 30 # appealing
|
|
23
24
|
# appealed_by_buyer = 30 # the same appealing
|
|
24
25
|
canceled = 40 # order cancelled
|
|
25
26
|
completed = 50 # order finished
|
|
@@ -43,10 +44,6 @@ class TakeAdReq(BaseModel):
|
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
class OrderRequest(BaseModel):
|
|
46
|
-
class Side(IntEnum):
|
|
47
|
-
BUY = 0
|
|
48
|
-
SALE = 1
|
|
49
|
-
|
|
50
47
|
itemId: str
|
|
51
48
|
tokenId: str
|
|
52
49
|
currencyId: str
|
|
@@ -137,59 +134,74 @@ class PaymentTerm(CredPaymentTerm):
|
|
|
137
134
|
|
|
138
135
|
|
|
139
136
|
class _BaseOrder(RemapBase):
|
|
140
|
-
_remap: ClassVar[dict[str, dict]] = {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
_remap: ClassVar[dict[str, dict]] = {
|
|
138
|
+
"status": {
|
|
139
|
+
Status.ws_new: OrderStatus.created,
|
|
140
|
+
Status.created: OrderStatus.created,
|
|
141
|
+
Status.paid: OrderStatus.paid,
|
|
142
|
+
Status.appealed: OrderStatus.appealed_by_seller, # all appeals from bybit marks as appealed_by_seller
|
|
143
|
+
Status.canceled: OrderStatus.canceled,
|
|
144
|
+
Status.completed: OrderStatus.completed,
|
|
145
|
+
Status.appeal_disputed: OrderStatus.appeal_disputed, # appeal_disputed and appeal_dispute_disputed from bybit
|
|
146
|
+
Status.appeal_dispute_disputed: OrderStatus.appeal_disputed, # marks as just appeal_disputed
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
ad__pair_side__is_sell: bool = Field(
|
|
150
|
+
alias="side"
|
|
151
|
+
) # int: 0 покупка, 1 продажа (именно для меня - апи агента, и пох мейкер я или тейкер)
|
|
152
|
+
created_at: int = Field(alias="createDate")
|
|
147
153
|
|
|
148
154
|
|
|
149
155
|
class _BaseChange(_BaseOrder):
|
|
150
|
-
|
|
156
|
+
exid: int = Field(alias="id")
|
|
157
|
+
my_exid: int | None = None # апи агент юзер
|
|
158
|
+
|
|
159
|
+
ad__maker_exid: int = Field(alias="makerUserId")
|
|
151
160
|
appealedTimes: int
|
|
161
|
+
user_exid: int = Field(alias="userId") # todo: define: is it initiator or counteragent?
|
|
152
162
|
totalAppealedTimes: int
|
|
153
163
|
|
|
154
164
|
|
|
155
|
-
class OrderItem(_BaseOrder):
|
|
156
|
-
|
|
165
|
+
class OrderItem(_BaseOrder, BaseOrderItem):
|
|
166
|
+
my_exid: int = Field(alias="userId")
|
|
167
|
+
coinex_exid: str = Field(alias="tokenId")
|
|
157
168
|
orderType: Literal[
|
|
158
169
|
"ORIGIN", "SMALL_COIN", "WEB3"
|
|
159
170
|
] # str: ORIGIN: normal p2p order, SMALL_COIN: HotSwap p2p order, WEB3: web3 p2p order
|
|
160
|
-
amount:
|
|
161
|
-
|
|
162
|
-
price:
|
|
163
|
-
notifyTokenQuantity: str
|
|
164
|
-
notifyTokenId: str
|
|
165
|
-
fee:
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
amount: float
|
|
172
|
+
curex_exid: str = Field(alias="currencyId")
|
|
173
|
+
price: float
|
|
174
|
+
# notifyTokenQuantity: str
|
|
175
|
+
# notifyTokenId: str
|
|
176
|
+
fee: float
|
|
177
|
+
ctr_nick: str = Field(alias="targetNickName")
|
|
178
|
+
ctr_exid: int = Field(alias="targetUserId")
|
|
168
179
|
selfUnreadMsgCount: str
|
|
169
|
-
transferLastSeconds: str
|
|
170
|
-
appealLastSeconds: str
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
judgeInfo: JudgeInfo
|
|
180
|
+
# transferLastSeconds: str
|
|
181
|
+
# appealLastSeconds: str
|
|
182
|
+
seller_name: str = Field(alias="sellerRealName")
|
|
183
|
+
buyer_name: str = Field(alias="buyerRealName")
|
|
184
|
+
# judgeInfo: JudgeInfo
|
|
174
185
|
unreadMsgCount: str
|
|
175
|
-
extension: Extension
|
|
176
|
-
bulkOrderFlag: bool
|
|
186
|
+
# extension: Extension
|
|
187
|
+
# bulkOrderFlag: bool
|
|
177
188
|
|
|
178
189
|
|
|
179
|
-
class OrderFull(OrderItem):
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
class OrderFull(OrderItem, BaseOrderFull):
|
|
191
|
+
ad_id: int = Field(alias="itemId")
|
|
192
|
+
ad__maker_exid: int = Field(alias="makerUserId")
|
|
193
|
+
my_nick: str = Field(alias="nickName")
|
|
194
|
+
# targetAccountId: str
|
|
195
|
+
# targetFirstName: str
|
|
196
|
+
# targetSecondName: str
|
|
185
197
|
targetUserAuthStatus: int
|
|
186
198
|
targetConnectInformation: str
|
|
187
|
-
payerRealName: str
|
|
199
|
+
# payerRealName: str # todo: why? we have sellerRealName already
|
|
188
200
|
tokenName: str
|
|
189
|
-
quantity:
|
|
201
|
+
quantity: float
|
|
190
202
|
payCode: str
|
|
191
203
|
paymentType: int
|
|
192
|
-
|
|
204
|
+
payed_at: int = Field(alias="transferDate")
|
|
193
205
|
paymentTermList: list[CredEpyd]
|
|
194
206
|
remark: str
|
|
195
207
|
recentOrderNum: int
|
|
@@ -200,79 +212,109 @@ class OrderFull(OrderItem):
|
|
|
200
212
|
canAppeal: str
|
|
201
213
|
totalAppealTimes: str
|
|
202
214
|
paymentTermResult: CredEpyd
|
|
203
|
-
|
|
215
|
+
credex: CredEx = Field(alias="confirmedPayTerm")
|
|
204
216
|
appealedTimes: str
|
|
205
217
|
orderFinishMinute: int
|
|
206
218
|
makerFee: str
|
|
207
219
|
takerFee: str
|
|
208
220
|
showContact: bool
|
|
209
221
|
contactInfo: list[str]
|
|
210
|
-
tokenBalance:
|
|
211
|
-
fiatBalance:
|
|
212
|
-
updateDate:
|
|
213
|
-
judgeType: str
|
|
214
|
-
canReport: bool
|
|
215
|
-
canReportDisagree: bool
|
|
216
|
-
canReportType: list[str]
|
|
217
|
-
canReportDisagreeType: list[str]
|
|
222
|
+
tokenBalance: float
|
|
223
|
+
fiatBalance: float
|
|
224
|
+
updateDate: int
|
|
225
|
+
# judgeType: str
|
|
226
|
+
# canReport: bool
|
|
227
|
+
# canReportDisagree: bool
|
|
228
|
+
# canReportType: list[str]
|
|
229
|
+
# canReportDisagreeType: list[str]
|
|
218
230
|
appraiseStatus: str
|
|
219
231
|
appraiseInfo: AppraiseInfo
|
|
220
|
-
canReportDisagreeTypes: list[str]
|
|
221
|
-
canReportTypes: list[str]
|
|
222
|
-
middleToken: str
|
|
223
|
-
beforePrice: str
|
|
224
|
-
beforeQuantity: str
|
|
225
|
-
beforeToken: str
|
|
226
|
-
alternative: str
|
|
232
|
+
# canReportDisagreeTypes: list[str]
|
|
233
|
+
# canReportTypes: list[str]
|
|
234
|
+
# middleToken: str
|
|
235
|
+
# beforePrice: str
|
|
236
|
+
# beforeQuantity: str
|
|
237
|
+
# beforeToken: str
|
|
238
|
+
# alternative: str
|
|
227
239
|
appealUserId: str
|
|
228
240
|
cancelResponsible: str
|
|
229
|
-
chainType: str
|
|
230
|
-
chainAddress: str
|
|
241
|
+
# chainType: str
|
|
242
|
+
# chainAddress: str
|
|
231
243
|
tradeHashCode: str
|
|
232
|
-
estimatedGasFee: str
|
|
233
|
-
gasFeeTokenId: str
|
|
234
|
-
tradingFeeTokenId: str
|
|
235
|
-
onChainInfo: str
|
|
244
|
+
# estimatedGasFee: str
|
|
245
|
+
# gasFeeTokenId: str
|
|
246
|
+
# tradingFeeTokenId: str
|
|
247
|
+
# onChainInfo: str
|
|
236
248
|
transactionId: str
|
|
237
249
|
displayRefund: str
|
|
238
|
-
chainWithdrawLastSeconds: str
|
|
239
|
-
chainTransferLastSeconds: str
|
|
250
|
+
# chainWithdrawLastSeconds: str
|
|
251
|
+
# chainTransferLastSeconds: str
|
|
240
252
|
orderSource: str
|
|
241
253
|
cancelReason: str
|
|
242
|
-
sellerCancelExamineRemainTime: str
|
|
243
|
-
needSellerExamineCancel: bool
|
|
244
|
-
couponCurrencyAmount: str
|
|
245
|
-
totalCurrencyAmount: str
|
|
246
|
-
usedCoupon: bool # bool: 1: used, 2: no used
|
|
247
|
-
couponTokenId: str
|
|
248
|
-
couponQuantity: str
|
|
249
|
-
completedOrderAppealCount: int
|
|
250
|
-
totalCompletedOrderAppealCount: int
|
|
251
|
-
realOrderStatus: int
|
|
252
|
-
appealVersion: int
|
|
253
|
-
helpType: str
|
|
254
|
-
appealFlowStatus: str
|
|
255
|
-
appealSubStatus: str
|
|
256
|
-
targetUserType: str
|
|
257
|
-
targetUserDisplays: list[str]
|
|
258
|
-
appealProcessChangeFlag: bool
|
|
259
|
-
appealNegotiationNode: int
|
|
254
|
+
# sellerCancelExamineRemainTime: str
|
|
255
|
+
# needSellerExamineCancel: bool
|
|
256
|
+
# couponCurrencyAmount: str
|
|
257
|
+
# totalCurrencyAmount: str
|
|
258
|
+
# usedCoupon: bool # bool: 1: used, 2: no used
|
|
259
|
+
# couponTokenId: str
|
|
260
|
+
# couponQuantity: str
|
|
261
|
+
# completedOrderAppealCount: int
|
|
262
|
+
# totalCompletedOrderAppealCount: int
|
|
263
|
+
# realOrderStatus: int
|
|
264
|
+
# appealVersion: int
|
|
265
|
+
# helpType: str
|
|
266
|
+
# appealFlowStatus: str
|
|
267
|
+
# appealSubStatus: str
|
|
268
|
+
# targetUserType: str
|
|
269
|
+
# targetUserDisplays: list[str]
|
|
270
|
+
# appealProcessChangeFlag: bool
|
|
271
|
+
# appealNegotiationNode: int
|
|
272
|
+
|
|
273
|
+
@model_validator(mode="after") # todo: separate to common part, and special bybit only part
|
|
274
|
+
def users_cred_cur(self):
|
|
275
|
+
mc_exids = self.my_exid, self.ctr_exid
|
|
276
|
+
mc_nicks = self.my_nick, self.ctr_nick
|
|
277
|
+
sb_names = self.seller_name, self.buyer_name
|
|
278
|
+
im_maker = self.ad__maker_exid == self.my_exid
|
|
279
|
+
im_seller = self.ad__pair_side__is_sell == im_maker
|
|
280
|
+
taker_exid = mc_exids[int(im_maker)] # if im maker, then ctr(mc_exids[1]) - taker;
|
|
281
|
+
taker_nick = mc_nicks[int(im_maker)]
|
|
282
|
+
taker_name = sb_names[int(im_seller)] # if im seller(im_maker==ad__is_sell), then taker(sb_names[1]) - buyer;
|
|
283
|
+
seller_exid = mc_exids[int(not im_seller)] # if im buyer, then ctr(mc_exids[1]) - seller;
|
|
284
|
+
seller_nick = mc_nicks[int(not im_seller)]
|
|
285
|
+
self.taker = BaseCounteragent(
|
|
286
|
+
exid=taker_exid,
|
|
287
|
+
nick=taker_nick,
|
|
288
|
+
name=taker_name,
|
|
289
|
+
)
|
|
290
|
+
if self.credex: # по дефолту в credex confirmedPayTerm
|
|
291
|
+
if not self.credex.pmex_exid: # но если там пусто, берем из paymentTermResult
|
|
292
|
+
self.credex = CredEx.model_validate(self.paymentTermResult)
|
|
293
|
+
if not self.credex.pmex_exid: # а если и там пусто, то берем первый из paymentTermList
|
|
294
|
+
self.credex = CredEx.model_validate(self.paymentTermList[0])
|
|
295
|
+
self.credex.seller = BaseCounteragent(
|
|
296
|
+
exid=seller_exid,
|
|
297
|
+
nick=seller_nick,
|
|
298
|
+
name=self.seller_name,
|
|
299
|
+
)
|
|
300
|
+
self.credex.curex_exid = self.curex_exid
|
|
301
|
+
return self
|
|
260
302
|
|
|
261
303
|
|
|
262
304
|
class Message(BaseModel):
|
|
263
|
-
|
|
264
|
-
accountId: str
|
|
305
|
+
exid: int = Field(alias="id")
|
|
306
|
+
# accountId: str
|
|
265
307
|
message: str
|
|
266
308
|
msgType: Literal[
|
|
267
309
|
0, 1, 2, 5, 6, 7, 8
|
|
268
310
|
] # int: 0: system message, 1: text (user), 2: image (user), 5: text (admin), 6: image (admin), 7: pdf (user), 8: video (user)
|
|
269
311
|
msgCode: int
|
|
270
|
-
|
|
312
|
+
created_at: int = Field(alias="createDate")
|
|
271
313
|
isRead: Literal[0, 1] # int: 1: read, 0: unread
|
|
272
314
|
contentType: Literal["str", "pic", "pdf", "video"]
|
|
273
315
|
roleType: str
|
|
274
|
-
|
|
275
|
-
|
|
316
|
+
my_exid: int = Field(alias="userId")
|
|
317
|
+
order_exid: str = Field(alias="orderId")
|
|
276
318
|
msgUuid: str
|
|
277
319
|
nickName: str
|
|
278
320
|
read: Literal[0, 1]
|
|
@@ -281,7 +323,21 @@ class Message(BaseModel):
|
|
|
281
323
|
|
|
282
324
|
|
|
283
325
|
class StatusChange(_BaseChange):
|
|
284
|
-
|
|
326
|
+
status: OrderStatus | None = None
|
|
327
|
+
appealType: int = None # 3 - I (seller) uploaded additional proofs # todo: выяснить другие значения
|
|
328
|
+
appealVersion: int = None # 3 - my (seller) appeal is accepted by support # todo: выяснить другие значения
|
|
329
|
+
|
|
330
|
+
@model_validator(mode="after")
|
|
331
|
+
def amount_or_quantity_required(self):
|
|
332
|
+
if not self.status and not self.appealType and not self.appealVersion:
|
|
333
|
+
raise ValueError("either status or appealVersion or appealType is required")
|
|
334
|
+
if not self.status:
|
|
335
|
+
if self.appealVersion == 3:
|
|
336
|
+
self.status = OrderStatus.canceled
|
|
337
|
+
elif self.appealType == 3:
|
|
338
|
+
self.status = OrderStatus.appeal_disputed
|
|
339
|
+
|
|
340
|
+
return self
|
|
285
341
|
|
|
286
342
|
|
|
287
343
|
class CountDown(_BaseChange):
|
|
@@ -307,12 +363,12 @@ class Receive(_BaseMsg):
|
|
|
307
363
|
|
|
308
364
|
class Read(_BaseMsg):
|
|
309
365
|
readAmount: int
|
|
310
|
-
read: Literal["101", "110", "11", "111"]
|
|
366
|
+
read: Literal["1", "101", "110", "11", "111"]
|
|
311
367
|
orderStatus: Status
|
|
312
368
|
|
|
313
369
|
|
|
314
370
|
class SellerCancelChange(BaseModel):
|
|
315
371
|
userId: int
|
|
316
372
|
makerUserId: int
|
|
317
|
-
id:
|
|
373
|
+
id: int
|
|
318
374
|
createDate: int
|
xync_client/Bybit/ex.py
CHANGED
|
@@ -11,12 +11,11 @@ from xync_schema.models import Ex, Agent
|
|
|
11
11
|
from xync_client.Abc.Ex import BaseExClient
|
|
12
12
|
from xync_client.loader import NET_TOKEN
|
|
13
13
|
from xync_client.Bybit.etype import ad
|
|
14
|
-
from xync_client.Abc.xtype import PmEx, MapOfIdsList,
|
|
14
|
+
from xync_client.Abc.xtype import PmEx, MapOfIdsList, GetAdsReq
|
|
15
15
|
from xync_client.loader import TORM
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class ExClient(BaseExClient): # Bybit client
|
|
19
|
-
host = "api2.bybit.com"
|
|
20
19
|
headers = df_hdrs # rewrite token for public methods
|
|
21
20
|
agent: Agent = None
|
|
22
21
|
|
|
@@ -36,21 +35,33 @@ class ExClient(BaseExClient): # Bybit client
|
|
|
36
35
|
}[status]
|
|
37
36
|
|
|
38
37
|
async def _get_config(self):
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
hdrs = {
|
|
39
|
+
"accept-language": "en",
|
|
40
|
+
"lang": "en",
|
|
41
|
+
"platform": "PC",
|
|
42
|
+
"risktoken": "dmVyMQ|==||==",
|
|
43
|
+
"traceparent": "00-4b51509490cb5b62e83d6e4f502a48be-24cdc3508360d087-01",
|
|
44
|
+
}
|
|
45
|
+
resp = await self._get("/x-api/fiat/p2p/config/initial", hdrs=hdrs)
|
|
46
|
+
return resp["result"]["symbols"] # todo: tokens, pairs, ...
|
|
41
47
|
|
|
42
48
|
# 19: Список поддерживаемых валют тейкера
|
|
43
49
|
async def curs(self) -> dict[int, xtype.CurEx]:
|
|
44
50
|
config = await self._get_config()
|
|
45
51
|
return {
|
|
46
|
-
c["currencyId"]: xtype.CurEx(
|
|
47
|
-
|
|
52
|
+
c["currencyId"]: xtype.CurEx(
|
|
53
|
+
exid=c["currencyId"],
|
|
54
|
+
ticker=c["currencyId"],
|
|
55
|
+
scale=c["currency"]["scale"],
|
|
56
|
+
minimum=c["currencyMinQuote"],
|
|
57
|
+
)
|
|
58
|
+
for c in config
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
# 20: Список платежных методов
|
|
51
62
|
async def pms(self, cur: models.Cur = None) -> dict[int | str, PmEx]:
|
|
52
63
|
self.session.cookie_jar.update_cookies(await self._get_auth_cks())
|
|
53
|
-
pms = await self._post("/fiat/otc/configuration/queryAllPaymentList/")
|
|
64
|
+
pms = await self._post("/x-api/fiat/otc/configuration/queryAllPaymentList/")
|
|
54
65
|
self.session.cookie_jar.clear()
|
|
55
66
|
|
|
56
67
|
pms = pms["result"]["paymentConfigVo"]
|
|
@@ -59,14 +70,14 @@ class ExClient(BaseExClient): # Bybit client
|
|
|
59
70
|
# 21: Список платежных методов по каждой валюте
|
|
60
71
|
async def cur_pms_map(self) -> MapOfIdsList:
|
|
61
72
|
self.session.cookie_jar.update_cookies(await self._get_auth_cks())
|
|
62
|
-
pms = await self._post("/fiat/otc/configuration/queryAllPaymentList/")
|
|
73
|
+
pms = await self._post("/x-api/fiat/otc/configuration/queryAllPaymentList/")
|
|
63
74
|
return json.loads(pms["result"]["currencyPaymentIdMap"])
|
|
64
75
|
|
|
65
76
|
# 22: Список торгуемых монет (с ограничениям по валютам, если есть)
|
|
66
77
|
async def coins(self) -> dict[str, xtype.CoinEx]:
|
|
67
78
|
config = await self._get_config()
|
|
68
79
|
coinexs = {}
|
|
69
|
-
for c in config
|
|
80
|
+
for c in config:
|
|
70
81
|
coinexs[c["tokenId"]] = xtype.CoinEx(
|
|
71
82
|
exid=c["tokenId"], ticker=c["tokenId"], minimum=c["tokenMinQuote"], scale=c["token"]["scale"]
|
|
72
83
|
)
|
|
@@ -76,7 +87,7 @@ class ExClient(BaseExClient): # Bybit client
|
|
|
76
87
|
async def pairs(self) -> tuple[MapOfIdsList, MapOfIdsList]:
|
|
77
88
|
config = await self._get_config()
|
|
78
89
|
cc: dict[str, set[str]] = {}
|
|
79
|
-
for c in config
|
|
90
|
+
for c in config:
|
|
80
91
|
cc[c["currencyId"]] = cc.get(c["currencyId"], set()) | {c["tokenId"]}
|
|
81
92
|
return cc, cc
|
|
82
93
|
|
|
@@ -85,7 +96,7 @@ class ExClient(BaseExClient): # Bybit client
|
|
|
85
96
|
if post_pmexs:
|
|
86
97
|
req.payment = []
|
|
87
98
|
req.size = str(min(1000, int(req.size) * 25))
|
|
88
|
-
res = await self._post("/fiat/otc/item/online/", req.model_dump())
|
|
99
|
+
res = await self._post("/x-api/fiat/otc/item/online/", req.model_dump())
|
|
89
100
|
ads = [ad.Ad(**_ad) for _ad in res["result"]["items"]]
|
|
90
101
|
if post_pmexs:
|
|
91
102
|
post_pmexids = {p.exid for p in post_pmexs}
|
|
@@ -100,13 +111,14 @@ class ExClient(BaseExClient): # Bybit client
|
|
|
100
111
|
async def main():
|
|
101
112
|
_ = await init_db(TORM, True)
|
|
102
113
|
ex = await Ex.get(name="Bybit")
|
|
103
|
-
|
|
114
|
+
FileClient(NET_TOKEN)
|
|
104
115
|
# await bot.start()
|
|
105
|
-
cl = ExClient(ex
|
|
106
|
-
|
|
116
|
+
cl = ExClient(ex)
|
|
117
|
+
await cl.set_curs()
|
|
118
|
+
# await cl.set_pms(bot)
|
|
107
119
|
# await cl.set_coins()
|
|
108
120
|
# await cl.set_pairs()
|
|
109
|
-
x_ads_req =
|
|
121
|
+
x_ads_req = GetAdsReq(coin_id=1, cur_id=1, is_sell=True, pm_ids=[330, 366, 1853], amount=1000)
|
|
110
122
|
_ads = await cl.ads(x_ads_req)
|
|
111
123
|
# await bot.stop()
|
|
112
124
|
await cl.close()
|