@oddmaki-protocol/sdk 0.1.3 → 0.2.0
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/dist/index.d.mts +179 -40
- package/dist/index.d.ts +179 -40
- package/dist/index.js +224 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +224 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6006,6 +6006,30 @@ var WhitelistAccessControl_default = [
|
|
|
6006
6006
|
|
|
6007
6007
|
// src/contracts/abis/ConditionalTokens.json
|
|
6008
6008
|
var ConditionalTokens_default = [
|
|
6009
|
+
{
|
|
6010
|
+
type: "function",
|
|
6011
|
+
name: "balanceOf",
|
|
6012
|
+
inputs: [
|
|
6013
|
+
{
|
|
6014
|
+
name: "account",
|
|
6015
|
+
type: "address",
|
|
6016
|
+
internalType: "address"
|
|
6017
|
+
},
|
|
6018
|
+
{
|
|
6019
|
+
name: "id",
|
|
6020
|
+
type: "uint256",
|
|
6021
|
+
internalType: "uint256"
|
|
6022
|
+
}
|
|
6023
|
+
],
|
|
6024
|
+
outputs: [
|
|
6025
|
+
{
|
|
6026
|
+
name: "",
|
|
6027
|
+
type: "uint256",
|
|
6028
|
+
internalType: "uint256"
|
|
6029
|
+
}
|
|
6030
|
+
],
|
|
6031
|
+
stateMutability: "view"
|
|
6032
|
+
},
|
|
6009
6033
|
{
|
|
6010
6034
|
type: "function",
|
|
6011
6035
|
name: "getCollectionId",
|
|
@@ -6028,7 +6052,7 @@ var ConditionalTokens_default = [
|
|
|
6028
6052
|
],
|
|
6029
6053
|
outputs: [
|
|
6030
6054
|
{
|
|
6031
|
-
name: "",
|
|
6055
|
+
name: "collectionId",
|
|
6032
6056
|
type: "bytes32",
|
|
6033
6057
|
internalType: "bytes32"
|
|
6034
6058
|
}
|
|
@@ -6057,7 +6081,7 @@ var ConditionalTokens_default = [
|
|
|
6057
6081
|
],
|
|
6058
6082
|
outputs: [
|
|
6059
6083
|
{
|
|
6060
|
-
name: "",
|
|
6084
|
+
name: "conditionId",
|
|
6061
6085
|
type: "bytes32",
|
|
6062
6086
|
internalType: "bytes32"
|
|
6063
6087
|
}
|
|
@@ -6076,13 +6100,37 @@ var ConditionalTokens_default = [
|
|
|
6076
6100
|
],
|
|
6077
6101
|
outputs: [
|
|
6078
6102
|
{
|
|
6079
|
-
name: "",
|
|
6103
|
+
name: "outcomeSlotCount",
|
|
6080
6104
|
type: "uint256",
|
|
6081
6105
|
internalType: "uint256"
|
|
6082
6106
|
}
|
|
6083
6107
|
],
|
|
6084
6108
|
stateMutability: "view"
|
|
6085
6109
|
},
|
|
6110
|
+
{
|
|
6111
|
+
type: "function",
|
|
6112
|
+
name: "getPositionId",
|
|
6113
|
+
inputs: [
|
|
6114
|
+
{
|
|
6115
|
+
name: "collateralToken",
|
|
6116
|
+
type: "address",
|
|
6117
|
+
internalType: "contract IERC20"
|
|
6118
|
+
},
|
|
6119
|
+
{
|
|
6120
|
+
name: "collectionId",
|
|
6121
|
+
type: "bytes32",
|
|
6122
|
+
internalType: "bytes32"
|
|
6123
|
+
}
|
|
6124
|
+
],
|
|
6125
|
+
outputs: [
|
|
6126
|
+
{
|
|
6127
|
+
name: "positionId",
|
|
6128
|
+
type: "uint256",
|
|
6129
|
+
internalType: "uint256"
|
|
6130
|
+
}
|
|
6131
|
+
],
|
|
6132
|
+
stateMutability: "pure"
|
|
6133
|
+
},
|
|
6086
6134
|
{
|
|
6087
6135
|
type: "function",
|
|
6088
6136
|
name: "mergePositions",
|
|
@@ -6116,6 +6164,49 @@ var ConditionalTokens_default = [
|
|
|
6116
6164
|
outputs: [],
|
|
6117
6165
|
stateMutability: "nonpayable"
|
|
6118
6166
|
},
|
|
6167
|
+
{
|
|
6168
|
+
type: "function",
|
|
6169
|
+
name: "payoutDenominator",
|
|
6170
|
+
inputs: [
|
|
6171
|
+
{
|
|
6172
|
+
name: "conditionId",
|
|
6173
|
+
type: "bytes32",
|
|
6174
|
+
internalType: "bytes32"
|
|
6175
|
+
}
|
|
6176
|
+
],
|
|
6177
|
+
outputs: [
|
|
6178
|
+
{
|
|
6179
|
+
name: "",
|
|
6180
|
+
type: "uint256",
|
|
6181
|
+
internalType: "uint256"
|
|
6182
|
+
}
|
|
6183
|
+
],
|
|
6184
|
+
stateMutability: "view"
|
|
6185
|
+
},
|
|
6186
|
+
{
|
|
6187
|
+
type: "function",
|
|
6188
|
+
name: "payoutNumerators",
|
|
6189
|
+
inputs: [
|
|
6190
|
+
{
|
|
6191
|
+
name: "conditionId",
|
|
6192
|
+
type: "bytes32",
|
|
6193
|
+
internalType: "bytes32"
|
|
6194
|
+
},
|
|
6195
|
+
{
|
|
6196
|
+
name: "index",
|
|
6197
|
+
type: "uint256",
|
|
6198
|
+
internalType: "uint256"
|
|
6199
|
+
}
|
|
6200
|
+
],
|
|
6201
|
+
outputs: [
|
|
6202
|
+
{
|
|
6203
|
+
name: "",
|
|
6204
|
+
type: "uint256",
|
|
6205
|
+
internalType: "uint256"
|
|
6206
|
+
}
|
|
6207
|
+
],
|
|
6208
|
+
stateMutability: "view"
|
|
6209
|
+
},
|
|
6119
6210
|
{
|
|
6120
6211
|
type: "function",
|
|
6121
6212
|
name: "prepareCondition",
|
|
@@ -6139,6 +6230,34 @@ var ConditionalTokens_default = [
|
|
|
6139
6230
|
outputs: [],
|
|
6140
6231
|
stateMutability: "nonpayable"
|
|
6141
6232
|
},
|
|
6233
|
+
{
|
|
6234
|
+
type: "function",
|
|
6235
|
+
name: "redeemPositions",
|
|
6236
|
+
inputs: [
|
|
6237
|
+
{
|
|
6238
|
+
name: "collateralToken",
|
|
6239
|
+
type: "address",
|
|
6240
|
+
internalType: "contract IERC20"
|
|
6241
|
+
},
|
|
6242
|
+
{
|
|
6243
|
+
name: "parentCollectionId",
|
|
6244
|
+
type: "bytes32",
|
|
6245
|
+
internalType: "bytes32"
|
|
6246
|
+
},
|
|
6247
|
+
{
|
|
6248
|
+
name: "conditionId",
|
|
6249
|
+
type: "bytes32",
|
|
6250
|
+
internalType: "bytes32"
|
|
6251
|
+
},
|
|
6252
|
+
{
|
|
6253
|
+
name: "indexSets",
|
|
6254
|
+
type: "uint256[]",
|
|
6255
|
+
internalType: "uint256[]"
|
|
6256
|
+
}
|
|
6257
|
+
],
|
|
6258
|
+
outputs: [],
|
|
6259
|
+
stateMutability: "nonpayable"
|
|
6260
|
+
},
|
|
6142
6261
|
{
|
|
6143
6262
|
type: "function",
|
|
6144
6263
|
name: "reportPayouts",
|
|
@@ -6198,14 +6317,19 @@ var ERC20_default = [
|
|
|
6198
6317
|
type: "constructor",
|
|
6199
6318
|
inputs: [
|
|
6200
6319
|
{
|
|
6201
|
-
name: "
|
|
6320
|
+
name: "_name",
|
|
6202
6321
|
type: "string",
|
|
6203
6322
|
internalType: "string"
|
|
6204
6323
|
},
|
|
6205
6324
|
{
|
|
6206
|
-
name: "
|
|
6325
|
+
name: "_symbol",
|
|
6207
6326
|
type: "string",
|
|
6208
6327
|
internalType: "string"
|
|
6328
|
+
},
|
|
6329
|
+
{
|
|
6330
|
+
name: "_decimals",
|
|
6331
|
+
type: "uint8",
|
|
6332
|
+
internalType: "uint8"
|
|
6209
6333
|
}
|
|
6210
6334
|
],
|
|
6211
6335
|
stateMutability: "nonpayable"
|
|
@@ -6215,12 +6339,12 @@ var ERC20_default = [
|
|
|
6215
6339
|
name: "allowance",
|
|
6216
6340
|
inputs: [
|
|
6217
6341
|
{
|
|
6218
|
-
name: "
|
|
6342
|
+
name: "",
|
|
6219
6343
|
type: "address",
|
|
6220
6344
|
internalType: "address"
|
|
6221
6345
|
},
|
|
6222
6346
|
{
|
|
6223
|
-
name: "
|
|
6347
|
+
name: "",
|
|
6224
6348
|
type: "address",
|
|
6225
6349
|
internalType: "address"
|
|
6226
6350
|
}
|
|
@@ -6263,7 +6387,7 @@ var ERC20_default = [
|
|
|
6263
6387
|
name: "balanceOf",
|
|
6264
6388
|
inputs: [
|
|
6265
6389
|
{
|
|
6266
|
-
name: "
|
|
6390
|
+
name: "",
|
|
6267
6391
|
type: "address",
|
|
6268
6392
|
internalType: "address"
|
|
6269
6393
|
}
|
|
@@ -6292,50 +6416,20 @@ var ERC20_default = [
|
|
|
6292
6416
|
},
|
|
6293
6417
|
{
|
|
6294
6418
|
type: "function",
|
|
6295
|
-
name: "
|
|
6419
|
+
name: "mint",
|
|
6296
6420
|
inputs: [
|
|
6297
6421
|
{
|
|
6298
|
-
name: "
|
|
6299
|
-
type: "address",
|
|
6300
|
-
internalType: "address"
|
|
6301
|
-
},
|
|
6302
|
-
{
|
|
6303
|
-
name: "subtractedValue",
|
|
6304
|
-
type: "uint256",
|
|
6305
|
-
internalType: "uint256"
|
|
6306
|
-
}
|
|
6307
|
-
],
|
|
6308
|
-
outputs: [
|
|
6309
|
-
{
|
|
6310
|
-
name: "",
|
|
6311
|
-
type: "bool",
|
|
6312
|
-
internalType: "bool"
|
|
6313
|
-
}
|
|
6314
|
-
],
|
|
6315
|
-
stateMutability: "nonpayable"
|
|
6316
|
-
},
|
|
6317
|
-
{
|
|
6318
|
-
type: "function",
|
|
6319
|
-
name: "increaseAllowance",
|
|
6320
|
-
inputs: [
|
|
6321
|
-
{
|
|
6322
|
-
name: "spender",
|
|
6422
|
+
name: "to",
|
|
6323
6423
|
type: "address",
|
|
6324
6424
|
internalType: "address"
|
|
6325
6425
|
},
|
|
6326
6426
|
{
|
|
6327
|
-
name: "
|
|
6427
|
+
name: "amount",
|
|
6328
6428
|
type: "uint256",
|
|
6329
6429
|
internalType: "uint256"
|
|
6330
6430
|
}
|
|
6331
6431
|
],
|
|
6332
|
-
outputs: [
|
|
6333
|
-
{
|
|
6334
|
-
name: "",
|
|
6335
|
-
type: "bool",
|
|
6336
|
-
internalType: "bool"
|
|
6337
|
-
}
|
|
6338
|
-
],
|
|
6432
|
+
outputs: [],
|
|
6339
6433
|
stateMutability: "nonpayable"
|
|
6340
6434
|
},
|
|
6341
6435
|
{
|
|
@@ -7635,6 +7729,80 @@ var TradeModule = class extends BaseModule {
|
|
|
7635
7729
|
});
|
|
7636
7730
|
return result;
|
|
7637
7731
|
}
|
|
7732
|
+
/**
|
|
7733
|
+
* Execute a market sell order (FOK or FAK)
|
|
7734
|
+
*
|
|
7735
|
+
* @param params.marketId - The market to sell on
|
|
7736
|
+
* @param params.outcomeId - Which outcome to sell (0=YES, 1=NO)
|
|
7737
|
+
* @param params.tokenAmount - Amount of outcome tokens to sell
|
|
7738
|
+
* @param params.minPriceTick - Minimum price tick willing to accept (slippage protection)
|
|
7739
|
+
* @param params.orderType - 0=FOK (Fill-Or-Kill), 1=FAK (Fill-And-Kill)
|
|
7740
|
+
*/
|
|
7741
|
+
async placeMarketSell(params) {
|
|
7742
|
+
const wallet = this.walletClient;
|
|
7743
|
+
const [account] = await wallet.getAddresses();
|
|
7744
|
+
const { request } = await this.publicClient.simulateContract({
|
|
7745
|
+
address: this.config.diamondAddress,
|
|
7746
|
+
abi: MarketOrdersFacet_default,
|
|
7747
|
+
functionName: "placeMarketSell",
|
|
7748
|
+
args: [
|
|
7749
|
+
params.marketId,
|
|
7750
|
+
params.outcomeId,
|
|
7751
|
+
params.tokenAmount,
|
|
7752
|
+
params.minPriceTick,
|
|
7753
|
+
params.orderType
|
|
7754
|
+
],
|
|
7755
|
+
account
|
|
7756
|
+
});
|
|
7757
|
+
return wallet.writeContract(request);
|
|
7758
|
+
}
|
|
7759
|
+
/**
|
|
7760
|
+
* Execute a market sell order with simple string inputs (recommended for frontends)
|
|
7761
|
+
* @param params.amount - Token amount as decimal string (e.g., "100.5")
|
|
7762
|
+
* @param params.minPrice - Minimum price as decimal string (e.g., "0.70")
|
|
7763
|
+
* @param params.orderType - 'FOK' or 'FAK' (default: 'FAK')
|
|
7764
|
+
*/
|
|
7765
|
+
async placeMarketSellSimple(params) {
|
|
7766
|
+
const tradingData = await this.publicClient.readContract({
|
|
7767
|
+
address: this.config.diamondAddress,
|
|
7768
|
+
abi: MarketsFacet_default,
|
|
7769
|
+
functionName: "getMarketTradingData",
|
|
7770
|
+
args: [params.marketId]
|
|
7771
|
+
});
|
|
7772
|
+
const collateralToken = tradingData.collateralToken;
|
|
7773
|
+
const decimals = await getCachedTokenDecimals(this.publicClient, collateralToken);
|
|
7774
|
+
const tokenAmount = parseTokenAmount(params.amount, decimals);
|
|
7775
|
+
const minPriceTick = priceToTick(params.minPrice);
|
|
7776
|
+
const orderType = params.orderType === "FOK" ? 0 : 1;
|
|
7777
|
+
return this.placeMarketSell({
|
|
7778
|
+
marketId: params.marketId,
|
|
7779
|
+
outcomeId: params.outcomeId,
|
|
7780
|
+
tokenAmount,
|
|
7781
|
+
minPriceTick,
|
|
7782
|
+
orderType
|
|
7783
|
+
});
|
|
7784
|
+
}
|
|
7785
|
+
/**
|
|
7786
|
+
* Preview a market sell order (simulate transaction)
|
|
7787
|
+
*/
|
|
7788
|
+
async previewMarketSell(params) {
|
|
7789
|
+
const wallet = this.walletClient;
|
|
7790
|
+
const [account] = await wallet.getAddresses();
|
|
7791
|
+
const { result } = await this.publicClient.simulateContract({
|
|
7792
|
+
address: this.config.diamondAddress,
|
|
7793
|
+
abi: MarketOrdersFacet_default,
|
|
7794
|
+
functionName: "placeMarketSell",
|
|
7795
|
+
args: [
|
|
7796
|
+
params.marketId,
|
|
7797
|
+
params.outcomeId,
|
|
7798
|
+
params.tokenAmount,
|
|
7799
|
+
params.minPriceTick,
|
|
7800
|
+
params.orderType
|
|
7801
|
+
],
|
|
7802
|
+
account
|
|
7803
|
+
});
|
|
7804
|
+
return result;
|
|
7805
|
+
}
|
|
7638
7806
|
/**
|
|
7639
7807
|
* Watch for MarketOrderExecuted events
|
|
7640
7808
|
*/
|
|
@@ -7647,6 +7815,18 @@ var TradeModule = class extends BaseModule {
|
|
|
7647
7815
|
onLogs
|
|
7648
7816
|
});
|
|
7649
7817
|
}
|
|
7818
|
+
/**
|
|
7819
|
+
* Watch for MarketSellExecuted events
|
|
7820
|
+
*/
|
|
7821
|
+
watchMarketSell(marketId, onLogs) {
|
|
7822
|
+
return this.publicClient.watchContractEvent({
|
|
7823
|
+
address: this.config.diamondAddress,
|
|
7824
|
+
abi: MarketOrdersFacet_default,
|
|
7825
|
+
eventName: "MarketSellExecuted",
|
|
7826
|
+
args: { marketId },
|
|
7827
|
+
onLogs
|
|
7828
|
+
});
|
|
7829
|
+
}
|
|
7650
7830
|
/**
|
|
7651
7831
|
* Check whether any orders are matchable in the given market.
|
|
7652
7832
|
* Returns a preview of which fill paths have crossing conditions,
|
|
@@ -8008,6 +8188,7 @@ var GET_MARKET = graphqlRequest.gql`
|
|
|
8008
8188
|
question
|
|
8009
8189
|
outcomes
|
|
8010
8190
|
status
|
|
8191
|
+
resolvedOutcome
|
|
8011
8192
|
collateralToken
|
|
8012
8193
|
conditionId
|
|
8013
8194
|
tickSize
|
|
@@ -8312,6 +8493,7 @@ var GET_GROUP_MARKETS = graphqlRequest.gql`
|
|
|
8312
8493
|
question
|
|
8313
8494
|
outcomes
|
|
8314
8495
|
status
|
|
8496
|
+
resolvedOutcome
|
|
8315
8497
|
collateralToken
|
|
8316
8498
|
conditionId
|
|
8317
8499
|
tickSize
|