-
Notifications
You must be signed in to change notification settings - Fork 5
/
osmodels.go
533 lines (479 loc) Β· 24.6 KB
/
osmodels.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
package osmodels
import (
"time"
"github.com/benleb/gloomberg/internal/nemo/totra"
"github.com/ethereum/go-ethereum/common"
)
type EventType string
const (
ItemListed EventType = "item_listed"
ItemSold EventType = "item_sold"
ItemReceivedOffer EventType = "item_received_offer"
// ItemMetadataUpdated EventType = "item_metadata_updated"
// ItemCancelled EventType = "item_cancelled"
// ItemReceivedBid EventType = "item_received_bid"
// ItemTransferred EventType = "item_transferred".
StreamAPIEndpoint string = "wss://stream.openseabeta.com/socket"
)
var TxType = map[EventType]totra.TxType{
ItemListed: totra.Listing,
ItemSold: totra.Sale,
}
type BaseStreamMessage struct {
StreamEvent EventType `json:"event_type" mapstructure:"event_type"`
SentAt string `json:"sent_at" mapstructure:"sent_at"`
}
type BaseItemMetadataType struct {
Name string `json:"name" mapstructure:"name"`
ImageURL string `json:"image_url" mapstructure:"image_url"`
AnimationURL string `json:"animation_url" mapstructure:"animation_url"`
MetadataURL string `json:"metadata_url" mapstructure:"metadata_url"`
}
type BaseItemType struct {
NftID string `json:"nft_id" mapstructure:"nft_id"`
Permalink string `json:"permalink" mapstructure:"permalink"`
Metadata BaseItemMetadataType `json:"metadata" mapstructure:"metadata"`
Chain Chain `json:"chain" mapstructure:"chain"`
}
type PayloadItemAndColl struct {
Item BaseItemType `json:"item" mapstructure:"item"`
Collection CollectionSlug `json:"collection" mapstructure:"collection"`
}
type CollectionSlug struct {
CollectionName string `json:"collection_name" mapstructure:"collection_name"`
CollectionSlug string `json:"collection_slug" mapstructure:"collection_slug"`
}
type Chain struct {
Name string `json:"name" mapstructure:"name"`
}
type ItemListedEvent struct {
BaseStreamMessage `json:"base_stream_message" mapstructure:",squash"`
Payload ItemListedEventPayload `json:"payload" mapstructure:"payload"`
}
type ItemListedEventPayload struct {
PayloadItemAndColl `json:"payload_item_and_coll" mapstructure:",squash"`
Quantity int `json:"quantity" mapstructure:"quantity"`
ListingType string `json:"listing_type" mapstructure:"listing_type"`
ListingDate string `json:"listing_date" mapstructure:"listing_date"`
ExpirationDate string `json:"expiration_date" mapstructure:"expiration_date"`
Maker Account `json:"maker" mapstructure:"maker"`
Taker Account `json:"taker" mapstructure:"taker"`
BasePrice string `json:"base_price" mapstructure:"base_price"`
PaymentToken PaymentToken `json:"payment_token" mapstructure:"payment_token"`
IsPrivate bool `json:"is_private" mapstructure:"is_private"`
EventTimestamp string `json:"event_timestamp" mapstructure:"event_timestamp"`
}
type ItemReceivedOfferEvent struct {
BaseStreamMessage `json:"base_stream_message" mapstructure:",squash"`
Payload ItemReceivedOfferEventPayload `json:"payload" mapstructure:"payload"`
}
type ItemReceivedOfferEventPayload struct {
PayloadItemAndColl `json:"payload_item_and_coll" mapstructure:",squash"`
Quantity int `json:"quantity" mapstructure:"quantity"`
CreatedDate string `json:"created_date" mapstructure:"created_date"`
ExpirationDate string `json:"expiration_date" mapstructure:"expiration_date"`
Maker Account `json:"maker" mapstructure:"maker"`
Taker Account `json:"taker" mapstructure:"taker"`
BasePrice string `json:"base_price" mapstructure:"base_price"`
PaymentToken PaymentToken `json:"payment_token" mapstructure:"payment_token"`
EventTimestamp string `json:"event_timestamp" mapstructure:"event_timestamp"`
}
type Account struct {
Address string `json:"address" mapstructure:"address"`
User string `json:"user" mapstructure:"user"`
}
type PaymentToken struct {
ID int `json:"id" mapstructure:"id"`
Symbol string `json:"symbol" mapstructure:"symbol"`
Address string `json:"address" mapstructure:"address"`
ImageURL string `json:"image_url" mapstructure:"image_url"`
Name string `json:"name" mapstructure:"name"`
Decimals int `json:"decimals" mapstructure:"decimals"`
EthPrice string `json:"eth_price" mapstructure:"eth_price"`
UsdPrice string `json:"usd_price" mapstructure:"usd_price"`
}
// bid
type ItemReceivedBidEvent struct {
BaseStreamMessage `mapstructure:",squash"`
Payload ItemReceivedBidEventPayload `mapstructure:"payload"`
}
type ItemReceivedBidEventPayload struct {
PayloadItemAndColl `mapstructure:",squash"`
Quantity int `mapstructure:"quantity"`
CreatedDate string `mapstructure:"created_date"`
ExpirationDate string `mapstructure:"expiration_date"`
Maker Account `mapstructure:"maker"`
Taker Account `mapstructure:"taker"`
BasePrice string `mapstructure:"base_price"`
PaymentToken PaymentToken `mapstructure:"payment_token"`
EventTimestamp string `mapstructure:"event_timestamp"`
}
// sale
type ItemSoldEvent struct {
BaseStreamMessage `mapstructure:",squash"`
Payload ItemSoldEventPayload `mapstructure:"payload"`
}
type ItemSoldEventPayload struct {
PayloadItemAndColl `mapstructure:",squash"`
ListingType string `mapstructure:"listing_type"`
ClosingDate string `mapstructure:"closing_date"`
Transaction Transaction `mapstructure:"transaction"`
Maker Account `mapstructure:"maker"`
Taker Account `mapstructure:"taker"`
SalePrice string `mapstructure:"sale_price"`
PaymentToken PaymentToken `mapstructure:"payment_token"`
IsPrivate bool `mapstructure:"is_private"`
EventTimestamp string `mapstructure:"event_timestamp"`
}
// transfer
type ItemTransferredEvent struct {
BaseStreamMessage `mapstructure:",squash"`
Payload ItemTransferredEventPayload `mapstructure:"payload"`
}
type ItemTransferredEventPayload struct {
PayloadItemAndColl `mapstructure:",squash"`
FromAccount Account `mapstructure:"from_account"`
Quantity int `mapstructure:"quantity"`
ToAccount Account `mapstructure:"to_account"`
Transaction Transaction `mapstructure:"transaction"`
EventTimestamp string `mapstructure:"event_timestamp"`
}
// cancel
type ItemCancelledEvent struct {
BaseStreamMessage `mapstructure:",squash"`
Payload ItemCancelledEventPayload `mapstructure:"payload"`
}
type ItemCancelledEventPayload struct {
PayloadItemAndColl `mapstructure:",squash"`
Quantity int `mapstructure:"quantity"`
ListingType string `mapstructure:"listing_type"`
Transaction Transaction `mapstructure:"transaction"`
PaymentToken PaymentToken `mapstructure:"payment_token"`
EventTimestamp string `mapstructure:"event_timestamp"`
}
// metadata update
type ItemMetadataUpdateEvent struct {
BaseStreamMessage `mapstructure:",squash"`
Payload ItemMetadataUpdatePayload `mapstructure:"payload"`
}
type ItemMetadataUpdatePayload struct {
PayloadItemAndColl `mapstructure:",squash"`
BaseItemMetadataType `mapstructure:",squash"`
Description string `mapstructure:"description"`
BackgroundColor string `mapstructure:"background_color"`
Traits []Trait `mapstructure:"traits"`
}
type Transaction struct {
Hash string `mapstructure:"hash"`
Timestamp string `mapstructure:"timestamp"`
}
type Trait struct {
TraitType interface{} `json:"trait_type"`
Value interface{} `json:"value"`
DisplayType interface{} `json:"display_type"`
MaxValue interface{} `json:"max_value"`
TraitCount interface{} `json:"trait_count"`
Order interface{} `json:"order"`
}
type AssetContract struct {
Collection OSCollection `json:"collection"`
Address string `json:"address"`
AssetContractType string `json:"asset_contract_type"`
CreatedDate string `json:"created_date"`
Name string `json:"name"`
NftVersion string `json:"nft_version"`
OpenseaVersion any `json:"opensea_version"`
Owner int `json:"owner"`
SchemaName string `json:"schema_name"`
Symbol string `json:"symbol"`
TotalSupply any `json:"total_supply"`
Description string `json:"description"`
ExternalLink string `json:"external_link"`
ImageURL string `json:"image_url"`
DefaultToFiat bool `json:"default_to_fiat"`
DevBuyerFeeBasisPoints int `json:"dev_buyer_fee_basis_points"`
DevSellerFeeBasisPoints int `json:"dev_seller_fee_basis_points"`
OnlyProxiedTransfers bool `json:"only_proxied_transfers"`
OpenseaBuyerFeeBasisPoints interface{} `json:"opensea_buyer_fee_basis_points"`
OpenseaSellerFeeBasisPoints interface{} `json:"opensea_seller_fee_basis_points"`
BuyerFeeBasisPoints int `json:"buyer_fee_basis_points"`
SellerFeeBasisPoints int `json:"seller_fee_basis_points"`
PayoutAddress string `json:"payout_address"`
}
type OSCollection struct {
BannerImageURL string `json:"banner_image_url"`
ChatURL any `json:"chat_url"`
CreatedDate string `json:"created_date"`
DefaultToFiat bool `json:"default_to_fiat"`
Description string `json:"description"`
DevBuyerFeeBasisPoints string `json:"dev_buyer_fee_basis_points"`
DevSellerFeeBasisPoints string `json:"dev_seller_fee_basis_points"`
DiscordURL string `json:"discord_url"`
DisplayData struct {
CardDisplayStyle string `json:"card_display_style"`
} `json:"display_data"`
ExternalURL string `json:"external_url"`
Featured bool `json:"featured"`
FeaturedImageURL any `json:"featured_image_url"`
Hidden bool `json:"hidden"`
SafelistRequestStatus string `json:"safelist_request_status"`
ImageURL string `json:"image_url"`
IsSubjectToWhitelist bool `json:"is_subject_to_whitelist"`
LargeImageURL any `json:"large_image_url"`
MediumUsername any `json:"medium_username"`
Name string `json:"name"`
OnlyProxiedTransfers bool `json:"only_proxied_transfers"`
OpenseaBuyerFeeBasisPoints string `json:"opensea_buyer_fee_basis_points"`
OpenseaSellerFeeBasisPoints string `json:"opensea_seller_fee_basis_points"`
PayoutAddress string `json:"payout_address"`
RequireEmail bool `json:"require_email"`
ShortDescription any `json:"short_description"`
Slug string `json:"slug"`
TelegramURL any `json:"telegram_url"`
TwitterUsername any `json:"twitter_username"`
InstagramUsername any `json:"instagram_username"`
WikiURL any `json:"wiki_url"`
}
type OpenSeaListingsResponse struct {
Next interface{} `json:"next"`
Previous interface{} `json:"previous"`
Orders []SeaportOrder `json:"orders"`
}
type SeaportUser struct {
Username string `json:"username"`
}
type SeaportAccount struct {
User int `json:"user"`
ProfileImgURL string `json:"profile_img_url"`
Address string `json:"address"`
Config string `json:"config"`
}
type SeaportOwner struct {
User SeaportUser `json:"user"`
ProfileImgURL string `json:"profile_img_url"`
Address string `json:"address"`
Config string `json:"config"`
}
type SeaportMakerFees struct {
Account SeaportAccount `json:"account"`
BasisPoints string `json:"basis_points"`
}
type SeaportConsiderationItem struct {
ItemType int `json:"itemType"`
Token string `json:"token"`
IdentifierOrCriteria string `json:"identifierOrCriteria"`
StartAmount string `json:"startAmount"`
EndAmount string `json:"endAmount"`
Recipient common.Address `json:"recipient"`
}
type SeaportOffer struct {
ItemType int `json:"itemType"`
Token common.Address `json:"token"`
IdentifierOrCriteria string `json:"identifierOrCriteria"`
StartAmount string `json:"startAmount"`
EndAmount string `json:"endAmount"`
}
type SeaportParameters struct {
Offerer common.Address `json:"offerer"`
Offer []SeaportOffer `json:"offer"`
Consideration []SeaportConsiderationItem `json:"consideration"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
OrderType int `json:"orderType"`
Zone common.Address `json:"zone"`
ZoneHash common.Hash `json:"zoneHash"`
Salt string `json:"salt"`
ConduitKey common.Hash `json:"conduitKey"`
TotalOriginalConsiderationItems int `json:"totalOriginalConsiderationItems"`
Counter int `json:"counter"`
}
type SeaportDisplayData struct {
CardDisplayStyle string `json:"card_display_style"`
}
type SeaportProtocolData struct {
Parameters SeaportParameters `json:"parameters"`
Signature string `json:"signature"`
}
type SeaportFees struct {
SellerFees map[string]int `json:"seller_fees"`
OpenseaFees map[string]int `json:"opensea_fees"`
}
type SeaportAssetContract struct {
Address string `json:"address"`
AssetContractType string `json:"asset_contract_type"`
CreatedDate string `json:"created_date"`
Name string `json:"name"`
NftVersion interface{} `json:"nft_version"`
OpenseaVersion interface{} `json:"opensea_version"`
Owner interface{} `json:"owner"`
SchemaName string `json:"schema_name"`
Symbol string `json:"symbol"`
TotalSupply interface{} `json:"total_supply"`
Description string `json:"description"`
ExternalLink interface{} `json:"external_link"`
ImageURL interface{} `json:"image_url"`
DefaultToFiat bool `json:"default_to_fiat"`
DevBuyerFeeBasisPoints int `json:"dev_buyer_fee_basis_points"`
DevSellerFeeBasisPoints int `json:"dev_seller_fee_basis_points"`
OnlyProxiedTransfers bool `json:"only_proxied_transfers"`
OpenseaBuyerFeeBasisPoints int `json:"opensea_buyer_fee_basis_points"`
OpenseaSellerFeeBasisPoints int `json:"opensea_seller_fee_basis_points"`
BuyerFeeBasisPoints int `json:"buyer_fee_basis_points"`
SellerFeeBasisPoints int `json:"seller_fee_basis_points"`
PayoutAddress interface{} `json:"payout_address"`
}
type SeaportCollection struct {
BannerImageURL string `json:"banner_image_url"`
ChatURL interface{} `json:"chat_url"`
CreatedDate time.Time `json:"created_date"`
DefaultToFiat bool `json:"default_to_fiat"`
Description string `json:"description"`
DevBuyerFeeBasisPoints string `json:"dev_buyer_fee_basis_points"`
DevSellerFeeBasisPoints string `json:"dev_seller_fee_basis_points"`
DiscordURL string `json:"discord_url"`
DisplayData SeaportDisplayData `json:"display_data"`
ExternalURL string `json:"external_url"`
Featured bool `json:"featured"`
FeaturedImageURL string `json:"featured_image_url"`
Hidden bool `json:"hidden"`
SafelistRequestStatus string `json:"safelist_request_status"`
ImageURL string `json:"image_url"`
IsSubjectToWhitelist bool `json:"is_subject_to_whitelist"`
LargeImageURL string `json:"large_image_url"`
MediumUsername interface{} `json:"medium_username"`
Name string `json:"name"`
OnlyProxiedTransfers bool `json:"only_proxied_transfers"`
OpenseaBuyerFeeBasisPoints string `json:"opensea_buyer_fee_basis_points"`
OpenseaSellerFeeBasisPoints string `json:"opensea_seller_fee_basis_points"`
PayoutAddress string `json:"payout_address"`
RequireEmail bool `json:"require_email"`
ShortDescription interface{} `json:"short_description"`
Slug string `json:"slug"`
TelegramURL interface{} `json:"telegram_url"`
TwitterUsername interface{} `json:"twitter_username"`
InstagramUsername interface{} `json:"instagram_username"`
WikiURL interface{} `json:"wiki_url"`
IsNsfw bool `json:"is_nsfw"`
Fees SeaportFees `json:"fees"`
IsRarityEnabled bool `json:"is_rarity_enabled"`
}
type SeaportAssetBundle struct {
Assets []SeaportAsset `json:"assets"`
Maker interface{} `json:"maker"`
Slug interface{} `json:"slug"`
Name string `json:"name"`
Description interface{} `json:"description"`
ExternalLink interface{} `json:"external_link"`
AssetContract SeaportAssetContract `json:"asset_contract"`
Permalink string `json:"permalink"`
SeaportSellOrders interface{} `json:"seaport_sell_orders"`
}
type SeaportAsset struct {
ID int `json:"id"`
NumSales int `json:"num_sales"`
BackgroundColor interface{} `json:"background_color"`
ImageURL string `json:"image_url"`
ImagePreviewURL string `json:"image_preview_url"`
ImageThumbnailURL string `json:"image_thumbnail_url"`
ImageOriginalURL string `json:"image_original_url"`
AnimationURL interface{} `json:"animation_url"`
AnimationOriginalURL interface{} `json:"animation_original_url"`
Name string `json:"name"`
Description string `json:"description"`
ExternalLink interface{} `json:"external_link"`
AssetContract SeaportAssetContract `json:"asset_contract"`
Permalink string `json:"permalink"`
Collection SeaportCollection `json:"collection"`
Decimals interface{} `json:"decimals"`
TokenMetadata string `json:"token_metadata"`
IsNsfw bool `json:"is_nsfw"`
Owner SeaportOwner `json:"owner"`
TokenID string `json:"token_id"`
}
type SeaportOrder struct {
CreatedDate string `json:"created_date"`
ClosingDate string `json:"closing_date"`
ListingTime int `json:"listing_time"`
ExpirationTime int `json:"expiration_time"`
OrderHash string `json:"order_hash"`
ProtocolData SeaportProtocolData `json:"protocol_data"`
ProtocolAddress string `json:"protocol_address"`
Maker SeaportAccount `json:"maker"`
Taker interface{} `json:"taker"`
CurrentPrice string `json:"current_price"`
MakerFees []SeaportMakerFees `json:"maker_fees"`
TakerFees []interface{} `json:"taker_fees"`
Side string `json:"side"`
OrderType string `json:"order_type"`
Cancelled bool `json:"cancelled"`
Finalized bool `json:"finalized"`
MarkedInvalid bool `json:"marked_invalid"`
ClientSignature string `json:"client_signature"`
RelayID string `json:"relay_id"`
CriteriaProof interface{} `json:"criteria_proof"`
MakerAssetBundle SeaportAssetBundle `json:"maker_asset_bundle"`
TakerAssetBundle SeaportAssetBundle `json:"taker_asset_bundle"`
}
type AssetCollection struct {
Editors []string `json:"editors"`
PaymentTokens []PaymentToken `json:"payment_tokens"`
PrimaryAssetContracts []AssetContract `json:"primary_asset_contracts"`
Traits struct{} `json:"traits"`
Stats CollectionStats `json:"stats"`
BannerImageURL string `json:"banner_image_url"`
ChatURL any `json:"chat_url"`
CreatedDate string `json:"created_date"`
DefaultToFiat bool `json:"default_to_fiat"`
Description string `json:"description"`
DevBuyerFeeBasisPoints string `json:"dev_buyer_fee_basis_points"`
DevSellerFeeBasisPoints string `json:"dev_seller_fee_basis_points"`
DiscordURL string `json:"discord_url"`
DisplayData struct {
CardDisplayStyle string `json:"card_display_style"`
} `json:"display_data"`
ExternalURL string `json:"external_url"`
Featured bool `json:"featured"`
FeaturedImageURL any `json:"featured_image_url"`
Hidden bool `json:"hidden"`
SafelistRequestStatus string `json:"safelist_request_status"`
ImageURL string `json:"image_url"`
IsSubjectToWhitelist bool `json:"is_subject_to_whitelist"`
LargeImageURL any `json:"large_image_url"`
MediumUsername any `json:"medium_username"`
Name string `json:"name"`
OnlyProxiedTransfers bool `json:"only_proxied_transfers"`
OpenseaBuyerFeeBasisPoints interface{} `json:"opensea_buyer_fee_basis_points"`
OpenseaSellerFeeBasisPoints interface{} `json:"opensea_seller_fee_basis_points"`
PayoutAddress any `json:"payout_address"`
RequireEmail bool `json:"require_email"`
ShortDescription any `json:"short_description"`
Slug string `json:"slug"`
TelegramURL any `json:"telegram_url"`
TwitterUsername any `json:"twitter_username"`
InstagramUsername any `json:"instagram_username"`
WikiURL any `json:"wiki_url"`
OwnedAssetCount int `json:"owned_asset_count"`
}
type CollectionStats struct {
OneDayVolume float64 `json:"one_day_volume"`
OneDayChange float64 `json:"one_day_change"`
OneDaySales float64 `json:"one_day_sales"`
OneDayAveragePrice float64 `json:"one_day_average_price"`
SevenDayVolume float64 `json:"seven_day_volume"`
SevenDayChange float64 `json:"seven_day_change"`
SevenDaySales float64 `json:"seven_day_sales"`
SevenDayAveragePrice float64 `json:"seven_day_average_price"`
ThirtyDayVolume float64 `json:"thirty_day_volume"`
ThirtyDayChange float64 `json:"thirty_day_change"`
ThirtyDaySales float64 `json:"thirty_day_sales"`
ThirtyDayAveragePrice float64 `json:"thirty_day_average_price"`
TotalVolume float64 `json:"total_volume"`
TotalSales float64 `json:"total_sales"`
TotalSupply float64 `json:"total_supply"`
Count float64 `json:"count"`
NumOwners float64 `json:"num_owners"`
AveragePrice float64 `json:"average_price"`
NumReports float64 `json:"num_reports"`
MarketCap float64 `json:"market_cap"`
FloorPrice float64 `json:"floor_price"`
}