@structbuild/sdk 0.3.1 → 0.3.3
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.
- package/README.md +33 -7
- package/dist/generated/polymarket.d.ts +170 -24
- package/dist/generated/webhooks.d.ts +694 -46
- package/dist/generated/ws-alerts.d.ts +668 -42
- package/dist/generated/ws.d.ts +308 -8
- package/dist/index.cjs +15 -4
- package/dist/index.cjs.map +6 -6
- package/dist/index.js +15 -4
- package/dist/index.js.map +6 -6
- package/dist/namespaces/markets.d.ts +3 -3
- package/dist/namespaces/series.d.ts +2 -1
- package/dist/namespaces/trader.d.ts +4 -4
- package/dist/types/index.d.ts +4 -1
- package/dist/types/ws.d.ts +9 -0
- package/dist/ws.d.ts +1 -0
- package/package.json +2 -1
package/dist/generated/ws.d.ts
CHANGED
|
@@ -602,24 +602,28 @@ export interface components {
|
|
|
602
602
|
probability_high: number;
|
|
603
603
|
/** @description Lowest implied probability in window (0–1) */
|
|
604
604
|
probability_low: number;
|
|
605
|
-
/** Format: int64 */
|
|
606
|
-
historical_confirmed_at: number;
|
|
607
|
-
/** Format: int64 */
|
|
608
|
-
latest_confirmed_at: number;
|
|
609
|
-
/** Format: int64 */
|
|
610
|
-
latest_block: number;
|
|
611
605
|
};
|
|
612
|
-
/** @description Subscribe to the trader PnL stream. traders is required and must be non-empty. */
|
|
606
|
+
/** @description Subscribe to the trader PnL stream. `traders` is required and must be non-empty. `update_types` and `timeframes` are optional narrowing filters — omit or leave empty to receive all update types / timeframes. */
|
|
613
607
|
TraderPnlSubscribeMessage: {
|
|
614
608
|
/** @enum {string} */
|
|
615
609
|
action: "subscribe" | "unsubscribe_all";
|
|
616
610
|
/** @description EVM wallet addresses */
|
|
617
611
|
traders: string[];
|
|
612
|
+
/** @description Restrict pushed updates to this subset of PnL granularities. Empty/omitted = all three. Unknown values reject the subscription. */
|
|
613
|
+
update_types?: ("global" | "market" | "event")[];
|
|
614
|
+
/** @description Restrict pushed updates to these aggregation timeframes. Empty/omitted = all four. Unknown values reject the subscription. */
|
|
615
|
+
timeframes?: ("1d" | "7d" | "30d" | "lifetime")[];
|
|
618
616
|
};
|
|
619
|
-
/** @description Server acknowledgement for a trader PnL subscription */
|
|
617
|
+
/** @description Server acknowledgement for a trader PnL subscription. Echoes the accepted (normalized) filter sets so clients can confirm the active subscription. */
|
|
620
618
|
TraderPnlSubscribeResponse: {
|
|
621
619
|
traders?: string[];
|
|
620
|
+
/** @description Accepted update types. Empty = all. */
|
|
621
|
+
update_types?: ("global" | "market" | "event")[];
|
|
622
|
+
/** @description Accepted timeframes. Empty = all. */
|
|
623
|
+
timeframes?: ("1d" | "7d" | "30d" | "lifetime")[];
|
|
624
|
+
/** @description Trader addresses that were rejected (invalid EVM format). */
|
|
622
625
|
rejected?: string[];
|
|
626
|
+
/** @description Set if the entire subscription was rejected (e.g. empty traders, or an invalid update_type / timeframe value). */
|
|
623
627
|
error?: string | null;
|
|
624
628
|
};
|
|
625
629
|
/** @description Server-pushed event: global (portfolio-level) PnL update for a trader. Envelope type: "trader_global_pnl_update". */
|
|
@@ -910,6 +914,302 @@ export interface components {
|
|
|
910
914
|
/** @description Filter values that were rejected (invalid format or limit exceeded) */
|
|
911
915
|
rejected?: string[];
|
|
912
916
|
};
|
|
917
|
+
/**
|
|
918
|
+
* OrderFilled / OrdersMatched
|
|
919
|
+
* @description A buy/sell trade was matched on the exchange.
|
|
920
|
+
*/
|
|
921
|
+
TradeOrderFilledEvent: {
|
|
922
|
+
/** @enum {string} */
|
|
923
|
+
trade_type: "OrderFilled" | "OrdersMatched";
|
|
924
|
+
id: string;
|
|
925
|
+
hash: string;
|
|
926
|
+
/** @description Absent for pending trades */
|
|
927
|
+
block?: number;
|
|
928
|
+
/** @description Unix seconds. Absent for pending trades */
|
|
929
|
+
confirmed_at?: number;
|
|
930
|
+
/** @description Unix milliseconds. Present for pending trades only */
|
|
931
|
+
received_at?: number;
|
|
932
|
+
/** @description Absent for pending trades */
|
|
933
|
+
log_index?: number;
|
|
934
|
+
/** @description Absent for pending trades */
|
|
935
|
+
block_index?: number;
|
|
936
|
+
/** @description Absent for pending trades */
|
|
937
|
+
order_hash?: string;
|
|
938
|
+
trader: {
|
|
939
|
+
address?: string;
|
|
940
|
+
name?: string | null;
|
|
941
|
+
pseudonym?: string | null;
|
|
942
|
+
profile_image?: string | null;
|
|
943
|
+
x_username?: string | null;
|
|
944
|
+
verified_badge?: boolean;
|
|
945
|
+
};
|
|
946
|
+
/** @description Absent for pending trades */
|
|
947
|
+
taker?: string;
|
|
948
|
+
/** @enum {string} */
|
|
949
|
+
side?: "Buy" | "Sell";
|
|
950
|
+
condition_id?: string | null;
|
|
951
|
+
position_id?: string;
|
|
952
|
+
outcome?: string | null;
|
|
953
|
+
outcome_index?: number | null;
|
|
954
|
+
question?: string | null;
|
|
955
|
+
image_url?: string | null;
|
|
956
|
+
slug?: string | null;
|
|
957
|
+
event_slug?: string | null;
|
|
958
|
+
usd_amount?: number;
|
|
959
|
+
shares_amount?: number;
|
|
960
|
+
price?: number;
|
|
961
|
+
probability?: number | null;
|
|
962
|
+
/** @description Absent for pending trades */
|
|
963
|
+
fee?: number;
|
|
964
|
+
/** @description Absent for pending trades */
|
|
965
|
+
fee_shares?: number;
|
|
966
|
+
/** @description Absent for pending trades */
|
|
967
|
+
fee_pct?: number;
|
|
968
|
+
exchange: number;
|
|
969
|
+
};
|
|
970
|
+
/**
|
|
971
|
+
* Redemption
|
|
972
|
+
* @description Positions redeemed after market resolution.
|
|
973
|
+
*/
|
|
974
|
+
TradeRedemptionEvent: {
|
|
975
|
+
/** @enum {string} */
|
|
976
|
+
trade_type: "Redemption";
|
|
977
|
+
id: string;
|
|
978
|
+
hash: string;
|
|
979
|
+
block?: number;
|
|
980
|
+
confirmed_at?: number;
|
|
981
|
+
received_at?: number;
|
|
982
|
+
log_index?: number;
|
|
983
|
+
block_index?: number;
|
|
984
|
+
trader: {
|
|
985
|
+
address?: string;
|
|
986
|
+
name?: string | null;
|
|
987
|
+
pseudonym?: string | null;
|
|
988
|
+
profile_image?: string | null;
|
|
989
|
+
x_username?: string | null;
|
|
990
|
+
verified_badge?: boolean;
|
|
991
|
+
};
|
|
992
|
+
condition_id?: string | null;
|
|
993
|
+
outcome?: string | null;
|
|
994
|
+
outcome_index?: number | null;
|
|
995
|
+
question?: string | null;
|
|
996
|
+
image_url?: string | null;
|
|
997
|
+
slug?: string | null;
|
|
998
|
+
event_slug?: string | null;
|
|
999
|
+
usd_amount?: number;
|
|
1000
|
+
winning_outcome_index?: number | null;
|
|
1001
|
+
position_details?: {
|
|
1002
|
+
position_id?: string;
|
|
1003
|
+
outcome_index?: number;
|
|
1004
|
+
amount?: string;
|
|
1005
|
+
}[];
|
|
1006
|
+
exchange: number;
|
|
1007
|
+
};
|
|
1008
|
+
/**
|
|
1009
|
+
* Merge
|
|
1010
|
+
* @description Outcome tokens burned to receive collateral.
|
|
1011
|
+
*/
|
|
1012
|
+
TradeMergeEvent: {
|
|
1013
|
+
/** @enum {string} */
|
|
1014
|
+
trade_type: "Merge";
|
|
1015
|
+
id: string;
|
|
1016
|
+
hash: string;
|
|
1017
|
+
block?: number;
|
|
1018
|
+
confirmed_at?: number;
|
|
1019
|
+
received_at?: number;
|
|
1020
|
+
log_index?: number;
|
|
1021
|
+
block_index?: number;
|
|
1022
|
+
trader: {
|
|
1023
|
+
address?: string;
|
|
1024
|
+
name?: string | null;
|
|
1025
|
+
pseudonym?: string | null;
|
|
1026
|
+
profile_image?: string | null;
|
|
1027
|
+
x_username?: string | null;
|
|
1028
|
+
verified_badge?: boolean;
|
|
1029
|
+
};
|
|
1030
|
+
condition_id?: string | null;
|
|
1031
|
+
question?: string | null;
|
|
1032
|
+
image_url?: string | null;
|
|
1033
|
+
slug?: string | null;
|
|
1034
|
+
event_slug?: string | null;
|
|
1035
|
+
usd_amount?: number;
|
|
1036
|
+
position_details?: {
|
|
1037
|
+
position_id?: string;
|
|
1038
|
+
outcome_index?: number;
|
|
1039
|
+
amount?: string;
|
|
1040
|
+
}[];
|
|
1041
|
+
exchange: number;
|
|
1042
|
+
};
|
|
1043
|
+
/**
|
|
1044
|
+
* Split
|
|
1045
|
+
* @description Collateral deposited to receive outcome tokens.
|
|
1046
|
+
*/
|
|
1047
|
+
TradeSplitEvent: {
|
|
1048
|
+
/** @enum {string} */
|
|
1049
|
+
trade_type: "Split";
|
|
1050
|
+
id: string;
|
|
1051
|
+
hash: string;
|
|
1052
|
+
block?: number;
|
|
1053
|
+
confirmed_at?: number;
|
|
1054
|
+
received_at?: number;
|
|
1055
|
+
log_index?: number;
|
|
1056
|
+
block_index?: number;
|
|
1057
|
+
trader: {
|
|
1058
|
+
address?: string;
|
|
1059
|
+
name?: string | null;
|
|
1060
|
+
pseudonym?: string | null;
|
|
1061
|
+
profile_image?: string | null;
|
|
1062
|
+
x_username?: string | null;
|
|
1063
|
+
verified_badge?: boolean;
|
|
1064
|
+
};
|
|
1065
|
+
condition_id?: string | null;
|
|
1066
|
+
question?: string | null;
|
|
1067
|
+
image_url?: string | null;
|
|
1068
|
+
slug?: string | null;
|
|
1069
|
+
event_slug?: string | null;
|
|
1070
|
+
usd_amount?: number;
|
|
1071
|
+
position_details?: {
|
|
1072
|
+
position_id?: string;
|
|
1073
|
+
outcome_index?: number;
|
|
1074
|
+
amount?: string;
|
|
1075
|
+
}[];
|
|
1076
|
+
exchange: number;
|
|
1077
|
+
};
|
|
1078
|
+
/**
|
|
1079
|
+
* PositionsConverted
|
|
1080
|
+
* @description NegRisk NO tokens converted to YES tokens + collateral.
|
|
1081
|
+
*/
|
|
1082
|
+
TradePositionsConvertedEvent: {
|
|
1083
|
+
/** @enum {string} */
|
|
1084
|
+
trade_type: "PositionsConverted";
|
|
1085
|
+
id: string;
|
|
1086
|
+
hash: string;
|
|
1087
|
+
block?: number;
|
|
1088
|
+
confirmed_at?: number;
|
|
1089
|
+
received_at?: number;
|
|
1090
|
+
log_index?: number;
|
|
1091
|
+
block_index?: number;
|
|
1092
|
+
trader: {
|
|
1093
|
+
address?: string;
|
|
1094
|
+
name?: string | null;
|
|
1095
|
+
pseudonym?: string | null;
|
|
1096
|
+
profile_image?: string | null;
|
|
1097
|
+
x_username?: string | null;
|
|
1098
|
+
verified_badge?: boolean;
|
|
1099
|
+
};
|
|
1100
|
+
market_id?: string;
|
|
1101
|
+
index_set?: string;
|
|
1102
|
+
shares_amount?: number;
|
|
1103
|
+
exchange: number;
|
|
1104
|
+
};
|
|
1105
|
+
/**
|
|
1106
|
+
* Cancelled
|
|
1107
|
+
* @description Order cancelled on-chain.
|
|
1108
|
+
*/
|
|
1109
|
+
TradeCancelledEvent: {
|
|
1110
|
+
/** @enum {string} */
|
|
1111
|
+
trade_type: "Cancelled";
|
|
1112
|
+
id: string;
|
|
1113
|
+
hash: string;
|
|
1114
|
+
block?: number;
|
|
1115
|
+
confirmed_at?: number;
|
|
1116
|
+
received_at?: number;
|
|
1117
|
+
log_index?: number;
|
|
1118
|
+
block_index?: number;
|
|
1119
|
+
order_hash?: string;
|
|
1120
|
+
question?: string | null;
|
|
1121
|
+
image_url?: string | null;
|
|
1122
|
+
slug?: string | null;
|
|
1123
|
+
event_slug?: string | null;
|
|
1124
|
+
exchange: number;
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* Oracle Lifecycle Event
|
|
1128
|
+
* @description Market lifecycle events: Initialization, Proposal, Dispute, Settled, Resolution, ConditionResolution, Reset, Flag, Unflag, Pause, Unpause, ManualResolution, NegRiskOutcomeReported.
|
|
1129
|
+
*/
|
|
1130
|
+
TradeOracleLifecycleEvent: {
|
|
1131
|
+
/** @enum {string} */
|
|
1132
|
+
trade_type: "Initialization" | "Proposal" | "Dispute" | "Settled" | "Resolution" | "ConditionResolution" | "Reset" | "Flag" | "Unflag" | "Pause" | "Unpause" | "ManualResolution" | "NegRiskOutcomeReported";
|
|
1133
|
+
id: string;
|
|
1134
|
+
hash: string;
|
|
1135
|
+
block?: number;
|
|
1136
|
+
confirmed_at?: number;
|
|
1137
|
+
received_at?: number;
|
|
1138
|
+
log_index?: number;
|
|
1139
|
+
block_index?: number;
|
|
1140
|
+
oracle_contract: string;
|
|
1141
|
+
condition_id: string;
|
|
1142
|
+
question?: string | null;
|
|
1143
|
+
image_url?: string | null;
|
|
1144
|
+
slug?: string | null;
|
|
1145
|
+
event_slug?: string | null;
|
|
1146
|
+
assertion_id?: string | null;
|
|
1147
|
+
proposer?: string | null;
|
|
1148
|
+
disputer?: string | null;
|
|
1149
|
+
proposed_outcome?: string | null;
|
|
1150
|
+
settled_price?: number | null;
|
|
1151
|
+
disputed?: boolean | null;
|
|
1152
|
+
settlement_resolution?: boolean | null;
|
|
1153
|
+
bond?: string | null;
|
|
1154
|
+
expiration_time?: number | null;
|
|
1155
|
+
creator?: string | null;
|
|
1156
|
+
reward_token?: string | null;
|
|
1157
|
+
reward?: string | null;
|
|
1158
|
+
proposal_bond?: string | null;
|
|
1159
|
+
};
|
|
1160
|
+
/**
|
|
1161
|
+
* RegisterToken
|
|
1162
|
+
* @description YES/NO token pair registered for a condition.
|
|
1163
|
+
*/
|
|
1164
|
+
TradeRegisterTokenEvent: {
|
|
1165
|
+
/** @enum {string} */
|
|
1166
|
+
trade_type: "RegisterToken";
|
|
1167
|
+
id: string;
|
|
1168
|
+
hash: string;
|
|
1169
|
+
block?: number;
|
|
1170
|
+
confirmed_at?: number;
|
|
1171
|
+
received_at?: number;
|
|
1172
|
+
log_index?: number;
|
|
1173
|
+
block_index?: number;
|
|
1174
|
+
condition_id: string;
|
|
1175
|
+
token0?: string;
|
|
1176
|
+
token1?: string;
|
|
1177
|
+
question?: string | null;
|
|
1178
|
+
image_url?: string | null;
|
|
1179
|
+
slug?: string | null;
|
|
1180
|
+
event_slug?: string | null;
|
|
1181
|
+
exchange: number;
|
|
1182
|
+
};
|
|
1183
|
+
/**
|
|
1184
|
+
* Approval
|
|
1185
|
+
* @description ERC-1155 setApprovalForAll — operator approved/revoked.
|
|
1186
|
+
*/
|
|
1187
|
+
TradeApprovalEvent: {
|
|
1188
|
+
/** @enum {string} */
|
|
1189
|
+
trade_type: "Approval";
|
|
1190
|
+
id: string;
|
|
1191
|
+
hash: string;
|
|
1192
|
+
block?: number;
|
|
1193
|
+
confirmed_at?: number;
|
|
1194
|
+
received_at?: number;
|
|
1195
|
+
log_index?: number;
|
|
1196
|
+
block_index?: number;
|
|
1197
|
+
trader: {
|
|
1198
|
+
address?: string;
|
|
1199
|
+
name?: string | null;
|
|
1200
|
+
pseudonym?: string | null;
|
|
1201
|
+
profile_image?: string | null;
|
|
1202
|
+
x_username?: string | null;
|
|
1203
|
+
verified_badge?: boolean;
|
|
1204
|
+
};
|
|
1205
|
+
operator?: string;
|
|
1206
|
+
approved?: boolean;
|
|
1207
|
+
question?: string | null;
|
|
1208
|
+
image_url?: string | null;
|
|
1209
|
+
slug?: string | null;
|
|
1210
|
+
event_slug?: string | null;
|
|
1211
|
+
exchange: number;
|
|
1212
|
+
};
|
|
913
1213
|
};
|
|
914
1214
|
responses: never;
|
|
915
1215
|
parameters: never;
|
package/dist/index.cjs
CHANGED
|
@@ -390,11 +390,13 @@ class MarketsNamespace extends Namespace {
|
|
|
390
390
|
}
|
|
391
391
|
async getMarket(params, venue) {
|
|
392
392
|
const { conditionId, ...query } = params;
|
|
393
|
-
|
|
393
|
+
const res = await this.get(venue, `/market/${encodeURIComponent(conditionId)}`, { params: { ...query } });
|
|
394
|
+
return { ...res, data: res.data[0] };
|
|
394
395
|
}
|
|
395
396
|
async getMarketBySlug(params, venue) {
|
|
396
397
|
const { marketSlug, ...query } = params;
|
|
397
|
-
|
|
398
|
+
const res = await this.get(venue, `/market/slug/${encodeURIComponent(marketSlug)}`, { params: { ...query } });
|
|
399
|
+
return { ...res, data: res.data[0] };
|
|
398
400
|
}
|
|
399
401
|
async getMarketChart(params, venue) {
|
|
400
402
|
return this.get(venue, "/market/chart", { params: { ...params } });
|
|
@@ -432,6 +434,10 @@ class SeriesNamespace extends Namespace {
|
|
|
432
434
|
async getSeriesOutcomes(params, venue) {
|
|
433
435
|
return this.get(venue, "/series/outcomes", { params: { ...params } });
|
|
434
436
|
}
|
|
437
|
+
async getSeriesEvents(params, venue) {
|
|
438
|
+
const { identifier, ...query } = params;
|
|
439
|
+
return this.get(venue, `/series/${encodeURIComponent(identifier)}/events`, { params: { ...query } });
|
|
440
|
+
}
|
|
435
441
|
}
|
|
436
442
|
// src/namespaces/trader.ts
|
|
437
443
|
class TraderNamespace extends Namespace {
|
|
@@ -956,7 +962,7 @@ class StructWebSocket {
|
|
|
956
962
|
this.clearPongTimer();
|
|
957
963
|
return;
|
|
958
964
|
}
|
|
959
|
-
if (
|
|
965
|
+
if (this.isSubscribeResponseMessage(msg)) {
|
|
960
966
|
const pending = this.pendingSubscribes.get(msg.room_id);
|
|
961
967
|
if (pending) {
|
|
962
968
|
this.clearSubscribeTimer(pending);
|
|
@@ -974,6 +980,11 @@ class StructWebSocket {
|
|
|
974
980
|
}
|
|
975
981
|
this.emit(msg.type, msg.data);
|
|
976
982
|
}
|
|
983
|
+
isSubscribeResponseMessage(msg) {
|
|
984
|
+
if (!msg.type || !msg.room_id)
|
|
985
|
+
return false;
|
|
986
|
+
return msg.type === "subscribed" || msg.type.endsWith("_subscribe_response");
|
|
987
|
+
}
|
|
977
988
|
emit(event, payload) {
|
|
978
989
|
const set = this.listeners.get(event);
|
|
979
990
|
if (!set)
|
|
@@ -1345,5 +1356,5 @@ async function* paginate(fetcher, params, pageSize = DEFAULT_PAGE_SIZE) {
|
|
|
1345
1356
|
}
|
|
1346
1357
|
}
|
|
1347
1358
|
|
|
1348
|
-
//# debugId=
|
|
1359
|
+
//# debugId=C22008EEB4E58D0B64756E2164756E21
|
|
1349
1360
|
//# sourceMappingURL=index.js.map
|