Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно.
Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой.
import uuid
from datetime import datetime
from decimal import Decimal
from uuid import UUID
from pydantic import BaseModel
class MyModel(BaseModel):
id: UUID
date: datetime
value: Decimal
obj = MyModel(
id=uuid.uuid4(),
date=datetime.now(),
value='1.23'
)
print(obj.model_dump())
# не подходит для json.dump
# {
# 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'),
# 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111),
# 'value': Decimal('1.23')
# }
# добавляем свой кастомный сериализатор
json.dumps(obj.model_dump(), cls=MySerializer)
# {
# 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1',
# 'date': '2025-12-12T12:12:12.111111',
# 'value': '1.23'
# }
В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так:
class MySerializer(json.JSONEncoder):
def default(self, o):
if isinstance(o, Decimal):
return str(o)
elif isinstance(o, datetime):
return o.isoformat()
elif isinstance(o, UUID):
return str(o)
return super().default(o)
Специально для тех, кто всё еще так делает - в этом нет необходимости!
Pydantic может это сделать сам, просто нужно добавить параметр mode="json".
json.dumps(obj.model_dump(mode="json"))
# {
# 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1',
# 'date': '2012-12-12T12:12:12.111111',
# 'value': '1.23'
# }
#pydantic#libs
#Alameda Reaserch wallet 0xf02 further deposited 4,000 $ETH ($14.75M) to #Coinbase at $3,688 6 hours ago.
Notably, this is the largest single $ETH deposit by FTX and Alameda since the market rally in Feb. Since Feb 1, 2024, FTX and Alameda have deposited 21,650 $ETH ($72.4M) to #Coinbase at ~$3,343, mostly before the price dropped.
Follow @spotonchain and turn on your 🔔 for the FTX and Alameda Research entities at:
1. FTX: https://platform.spotonchain.ai/en/entity/354
2. Alameda Research: https://platform.spotonchain.ai/en/entity/79
🚨🚨#FTX and #Alameda transferred out $38.5M worth of 7 assets to exchanges ~6hrs ago:
• 750,000 $SOL ($31.2M)
• 325,501 $ENS ($2.76M)
• 10.1M $GMT ($2.22M)
• 642,702 $LDO ($1.26M)
• 288,211 $APE ($410K)
• 127,407 $BADGER ($365K)
• 555,342 $BNT ($323K)
Overall, as of Nov 8, #FTX and #Alameda have transferred out $350M worth of 36 assets to exchanges.
👉 More details: https://platform.spotonchain.ai/signal-details/ftx-and-alameda-research-further-moved-altcoins-to-exchanges-4711
Yesterday, #Alameda’s bankruptcy wallet swapped 129.04M $STG (~$26M) into 11.14M $ZRO (~$25.96M).
12 hours ago, they sent $ZRO to #WinterMute.
https://intel.arkm.com/explorer/entity/alameda-research
https://x.com/OnchainLens/status/2022268604151103646
Follow @OnchainLens for more Onchain Updates.
🚨#FTX and #Alameda Research just deposited 44.19M $CRO ($4.17M) to #Coinbase ~20 mins ago.
Overall, FTX and Alameda have deposited 13.99M worth of $ETH, $CRO, $MATH, $MPL, and $BLZ to Coinbase in the past 2 weeks.
👉 More details: https://platform.spotonchain.ai/en/signal-details/ftx-and-alameda-moved-cro-to-coinbase-prime-16235
⚠️FTX/Alameda unstaked and distributed 185,345 $SOL ($22.9M) to 38 wallets ~9 hours ago as part of their monthly SOL unloading.
Currently, 5.5M $SOL ($693.8M) remains in FTX/Alameda’s staking account.
Since November 2023, #FTX and #Alameda have unstaked and offloaded 8.019M $SOL (~$1B), mostly to #Coinbase and #Binance, at an average price of $125.8.
Follow @spotonchain for more details at https://x.com/spotonchain/status/1899992964296040930
🚨 FTX/Alameda unstaked and distributed 3.03M SOL$SOL ($432.5M) to 37 wallets, likely for deposits to #Coinbase and #Binance ~3 hours ago!
This is #FTX/#Alameda’s largest unstake since November 2023 and likely part of the 11.2M SOL$SOL (~$1.5B) set to be unlocked in early March.
Since November 2023, FTX/Alameda has unstaked and offloaded 7.83M SOL$SOL ($986M) to Coinbase and Binance at an average price of $125.8.
Follow @spotonchain and check out the details at https://x.com/spotonchain/status/1896749492738941142
#FTX and #Alameda Research deposited another 4,500 $ETH ($14.4M) to #Coinbase and #Binance at ~$3,207 in the past 8 hours.
Note that since Mar 1, FTX and Alameda have deposited 20,350 $ETH ($72.5M) into CEX at ~$3,562, often before significant price drops.
How will the price react this time? Follow @spotonchain and set alerts for FTX and Alameda via our platforms now:
1. FTX: https://platform.spotonchain.ai/en/entity/354
2. Alameda Research: https://platform.spotonchain.ai/en/entity/79
As the market rallied, #FTX and #Alameda returned to deposit 2,000 $ETH ($6.36M) to #Coinbase and 163,727 $PROM ($2.04M) to #Binance ~5hrs ago.
Notably, FTX and Alameda Research have deposited 10,447 $ETH to CEX at $2,641 ($27.6M) in the past month as the $ETH price surged 42%.
For more updates on FTX and Alameda Research’s activities, follow @spotonchain and turn your 🔔 at:
1. FTX entity: https://platform.spotonchain.ai/en/platform/entity/354
2. Alameda Research entity: https://platform.spotonchain.ai/en/platform/entity/79
🚨🚨#FTX and #Alameda related-addresses are depositing tokens to exchanges!
Via address 0xde9, #FTX 0x97f and #Alameda 0xf02 have transferred a total of $10.51M worth of 4 assets to #Binance and #Coinbase in the past 5 hours:
- 2,904 $ETH ($5.21M)
- 1,341 $MKR ($2.01M)
- 11,975 $AAVE ($1.02M)
- 198,807 $LINK ($2.27M)
👉 Address: https://platform.spotonchain.ai/profile?address=0xde9A61c2b776e2F4C6ddB0C9Ad5cCfCfC15B0a9B
🚨🚨#FTX further transferred out 1.25M $SOL ($50.1M) and 1,583 $ETH ($3M) to #Binance and #Kraken in the past 20 hours.
In total, #FTX and #Alameda have transferred a total of $312M worth of 31 tokens to exchanges since Oct 24 (13 days ago).
👉 More details: https://platform.spotonchain.ai/platform/entity/354
🎉🎉 FTX debtors may have 391M$ more thanks to $FTT recent pump!
➡️ $FTT surged by 117% due to a potential reboot of FTX crypto exchange
➡️ FTX and Alameda addresses hold ~267M $FTT (76% of the total supply)
➡️ Their $FTT value has jumped from $334M to $726M.
As of now, the addresses have yet to move any $FTT out in the recent sell-off.
🔔 Want to be informed of an $FTT activity from FTX and Alameda ASAP? Set alerts for the below entities on SpotOnChain platform now:
• FTX entity: https://platform.spotonchain.ai/platform/entity/354
• Alameda entity: https://platform.spotonchain.ai/platform/entity/79
#spotonchain#ftx#alameda
🚨🚨 Note that #FTX and #Alameda further deposited $36.01M worth of $MATIC and $AVAX to exchanges in the past 24 hours:
• 22.6M $MATIC ($17.2M) to #Coinbase and #FalconX
• 975,859 $AVAX ($18.83M) to #FalconX
Overall, FTX and Alameda have transferred out $488M worth of 48 tokens since October 24.
✅ Follow the FTX and Alameda Research entities on our platform now:
• https://platform.spotonchain.ai/entity/354
• https://platform.spotonchain.ai/entity/79
👉 More details: https://platform.spotonchain.ai/signal-details/ftx-and-alameda-continued-transferring-out-matic-and-avax-7075