@oddmaki-protocol/sdk 0.2.0 → 0.3.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.js CHANGED
@@ -594,6 +594,11 @@ var VenueFacet_default = [
594
594
  name: "InvalidTickSize",
595
595
  inputs: []
596
596
  },
597
+ {
598
+ type: "error",
599
+ name: "InvalidUmaMinBond",
600
+ inputs: []
601
+ },
597
602
  {
598
603
  type: "error",
599
604
  name: "InvalidVenueFee",
@@ -909,6 +914,11 @@ var MarketsFacet_default = [
909
914
  name: "creatorFeeBps",
910
915
  type: "uint256",
911
916
  internalType: "uint256"
917
+ },
918
+ {
919
+ name: "protocolFeeBps",
920
+ type: "uint256",
921
+ internalType: "uint256"
912
922
  }
913
923
  ]
914
924
  }
@@ -1999,6 +2009,25 @@ var MatchingFacet_default = [
1999
2009
  ],
2000
2010
  anonymous: false
2001
2011
  },
2012
+ {
2013
+ type: "event",
2014
+ name: "OrderAutoCancelled",
2015
+ inputs: [
2016
+ {
2017
+ name: "orderId",
2018
+ type: "uint256",
2019
+ indexed: true,
2020
+ internalType: "uint256"
2021
+ },
2022
+ {
2023
+ name: "refundedCollateral",
2024
+ type: "uint256",
2025
+ indexed: false,
2026
+ internalType: "uint256"
2027
+ }
2028
+ ],
2029
+ anonymous: false
2030
+ },
2002
2031
  {
2003
2032
  type: "event",
2004
2033
  name: "OrderDeleted",
@@ -2752,6 +2781,11 @@ var MarketGroupFacet_default = [
2752
2781
  name: "liveness",
2753
2782
  type: "uint64",
2754
2783
  internalType: "uint64"
2784
+ },
2785
+ {
2786
+ name: "reward",
2787
+ type: "uint256",
2788
+ internalType: "uint256"
2755
2789
  }
2756
2790
  ]
2757
2791
  }
@@ -2897,6 +2931,12 @@ var MarketGroupFacet_default = [
2897
2931
  type: "bytes32[]",
2898
2932
  indexed: false,
2899
2933
  internalType: "bytes32[]"
2934
+ },
2935
+ {
2936
+ name: "reward",
2937
+ type: "uint256",
2938
+ indexed: false,
2939
+ internalType: "uint256"
2900
2940
  }
2901
2941
  ],
2902
2942
  anonymous: false
@@ -3487,6 +3527,11 @@ var ResolutionFacet_default = [
3487
3527
  name: "settled",
3488
3528
  type: "bool",
3489
3529
  internalType: "bool"
3530
+ },
3531
+ {
3532
+ name: "asserter",
3533
+ type: "address",
3534
+ internalType: "address"
3490
3535
  }
3491
3536
  ]
3492
3537
  }
@@ -3675,6 +3720,31 @@ var ResolutionFacet_default = [
3675
3720
  ],
3676
3721
  anonymous: false
3677
3722
  },
3723
+ {
3724
+ type: "event",
3725
+ name: "RewardPaid",
3726
+ inputs: [
3727
+ {
3728
+ name: "assertionId",
3729
+ type: "bytes32",
3730
+ indexed: true,
3731
+ internalType: "bytes32"
3732
+ },
3733
+ {
3734
+ name: "asserter",
3735
+ type: "address",
3736
+ indexed: true,
3737
+ internalType: "address"
3738
+ },
3739
+ {
3740
+ name: "reward",
3741
+ type: "uint256",
3742
+ indexed: false,
3743
+ internalType: "uint256"
3744
+ }
3745
+ ],
3746
+ anonymous: false
3747
+ },
3678
3748
  {
3679
3749
  type: "error",
3680
3750
  name: "ApproveFailed",
@@ -3725,6 +3795,11 @@ var ResolutionFacet_default = [
3725
3795
  name: "OutcomeMismatch",
3726
3796
  inputs: []
3727
3797
  },
3798
+ {
3799
+ type: "error",
3800
+ name: "TransferFailed",
3801
+ inputs: []
3802
+ },
3728
3803
  {
3729
3804
  type: "error",
3730
3805
  name: "TransferFromFailed",
@@ -4023,6 +4098,19 @@ var NegRiskFacet_default = [
4023
4098
 
4024
4099
  // src/contracts/abis/ProtocolFacet.json
4025
4100
  var ProtocolFacet_default = [
4101
+ {
4102
+ type: "function",
4103
+ name: "getProtocolFeeBps",
4104
+ inputs: [],
4105
+ outputs: [
4106
+ {
4107
+ name: "",
4108
+ type: "uint256",
4109
+ internalType: "uint256"
4110
+ }
4111
+ ],
4112
+ stateMutability: "view"
4113
+ },
4026
4114
  {
4027
4115
  type: "function",
4028
4116
  name: "getProtocolPaused",
@@ -4138,6 +4226,19 @@ var ProtocolFacet_default = [
4138
4226
  outputs: [],
4139
4227
  stateMutability: "nonpayable"
4140
4228
  },
4229
+ {
4230
+ type: "function",
4231
+ name: "setProtocolFeeBps",
4232
+ inputs: [
4233
+ {
4234
+ name: "bps",
4235
+ type: "uint256",
4236
+ internalType: "uint256"
4237
+ }
4238
+ ],
4239
+ outputs: [],
4240
+ stateMutability: "nonpayable"
4241
+ },
4141
4242
  {
4142
4243
  type: "function",
4143
4244
  name: "setProtocolTreasury",
@@ -4309,6 +4410,19 @@ var ProtocolFacet_default = [
4309
4410
  ],
4310
4411
  anonymous: false
4311
4412
  },
4413
+ {
4414
+ type: "event",
4415
+ name: "ProtocolFeeBpsUpdated",
4416
+ inputs: [
4417
+ {
4418
+ name: "bps",
4419
+ type: "uint256",
4420
+ indexed: false,
4421
+ internalType: "uint256"
4422
+ }
4423
+ ],
4424
+ anonymous: false
4425
+ },
4312
4426
  {
4313
4427
  type: "event",
4314
4428
  name: "ProtocolPausedEvent",
@@ -6720,6 +6834,33 @@ var VenueModule = class extends BaseModule {
6720
6834
  args: [user, venueId]
6721
6835
  });
6722
6836
  }
6837
+ // ---- Protocol Fee (owner-only) ----
6838
+ /**
6839
+ * Get the current protocol fee in basis points. Snapshotted per market at creation.
6840
+ */
6841
+ async getProtocolFeeBps() {
6842
+ return this.publicClient.readContract({
6843
+ address: this.config.diamondAddress,
6844
+ abi: ProtocolFacet_default,
6845
+ functionName: "getProtocolFeeBps"
6846
+ });
6847
+ }
6848
+ /**
6849
+ * Set the protocol fee in basis points. Owner-only. Max 200 bps (2%).
6850
+ * Only affects markets created after this call (existing markets retain their snapshot).
6851
+ */
6852
+ async setProtocolFeeBps(bps) {
6853
+ const wallet = this.walletClient;
6854
+ const [account] = await wallet.getAddresses();
6855
+ const { request } = await this.publicClient.simulateContract({
6856
+ address: this.config.diamondAddress,
6857
+ abi: ProtocolFacet_default,
6858
+ functionName: "setProtocolFeeBps",
6859
+ args: [bps],
6860
+ account
6861
+ });
6862
+ return wallet.writeContract(request);
6863
+ }
6723
6864
  };
6724
6865
  var TICK_SIZE_STANDARD = 10000000000000000n;
6725
6866
  var TICK_SIZE_FINE = 1000000000000000n;
@@ -6836,6 +6977,72 @@ function getOutcomePrice(market, outcomeIndex) {
6836
6977
  const yesPercent = tickToPercentage(yesTick, tickSize);
6837
6978
  return outcomeIndex === 0 ? yesPercent : 100 - yesPercent;
6838
6979
  }
6980
+ var MARK_PRICE_SPREAD_THRESHOLD = 0.1;
6981
+ function calculateChancePercent(market) {
6982
+ const tickSizeNum = parseFloat(market.tickSize || "0");
6983
+ if (tickSizeNum === 0) return 50;
6984
+ if (market.status === "Resolved" && market.resolvedOutcome != null) {
6985
+ return parseInt(String(market.resolvedOutcome)) === 0 ? 100 : 0;
6986
+ }
6987
+ const maxTicks = 1e18 / tickSizeNum;
6988
+ if (market.topOfBook && market.topOfBook.length > 0) {
6989
+ const tob = parseTopOfBook(market.topOfBook);
6990
+ const result = computeImpliedMidpoint(tob, maxTicks, tickSizeNum);
6991
+ if (result !== null) return result;
6992
+ }
6993
+ return lastTradeFallback(market, tickSizeNum);
6994
+ }
6995
+ function parseTopOfBook(entries) {
6996
+ const result = { yesBid: 0, yesAsk: 0, noBid: 0, noAsk: 0 };
6997
+ for (const entry of entries) {
6998
+ const tick = parseFloat(entry.topTick || "0");
6999
+ const outcome = entry.outcome?.toString();
7000
+ const side = entry.side;
7001
+ if (outcome === "0" && side === "BUY") result.yesBid = tick;
7002
+ else if (outcome === "0" && side === "SELL") result.yesAsk = tick;
7003
+ else if (outcome === "1" && side === "BUY") result.noBid = tick;
7004
+ else if (outcome === "1" && side === "SELL") result.noAsk = tick;
7005
+ }
7006
+ return result;
7007
+ }
7008
+ function computeImpliedMidpoint(tob, maxTicks, tickSize) {
7009
+ const bidCandidates = [];
7010
+ if (tob.yesBid > 0) bidCandidates.push(tob.yesBid);
7011
+ if (tob.noAsk > 0) bidCandidates.push(maxTicks - tob.noAsk);
7012
+ const askCandidates = [];
7013
+ if (tob.yesAsk > 0) askCandidates.push(tob.yesAsk);
7014
+ if (tob.noBid > 0) askCandidates.push(maxTicks - tob.noBid);
7015
+ if (bidCandidates.length === 0 || askCandidates.length === 0) return null;
7016
+ const impliedBid = Math.max(...bidCandidates);
7017
+ const impliedAsk = Math.min(...askCandidates);
7018
+ const spreadDollars = (impliedAsk - impliedBid) * tickSize / 1e18;
7019
+ if (spreadDollars > MARK_PRICE_SPREAD_THRESHOLD) return null;
7020
+ const midTick = (impliedBid + impliedAsk) / 2;
7021
+ const percent = midTick * tickSize / 1e18 * 100;
7022
+ return parseFloat(Math.max(0, Math.min(100, percent)).toFixed(2));
7023
+ }
7024
+ function lastTradeFallback(market, tickSize) {
7025
+ const tick0 = parseFloat(market.lastPriceTick_0 || "0");
7026
+ const tick1 = parseFloat(market.lastPriceTick_1 || "0");
7027
+ const ts0 = parseFloat(market.lastTradeTimestamp_0 || "0");
7028
+ const ts1 = parseFloat(market.lastTradeTimestamp_1 || "0");
7029
+ if (tick0 > 0 && tick1 > 0) {
7030
+ if (ts0 > 0 || ts1 > 0) {
7031
+ if (ts0 >= ts1) {
7032
+ return parseFloat((tick0 * tickSize / 1e18 * 100).toFixed(2));
7033
+ }
7034
+ return parseFloat(((1 - tick1 * tickSize / 1e18) * 100).toFixed(2));
7035
+ }
7036
+ return parseFloat((tick0 * tickSize / 1e18 * 100).toFixed(2));
7037
+ }
7038
+ if (tick0 > 0) {
7039
+ return parseFloat((tick0 * tickSize / 1e18 * 100).toFixed(2));
7040
+ }
7041
+ if (tick1 > 0) {
7042
+ return parseFloat(((1 - tick1 * tickSize / 1e18) * 100).toFixed(2));
7043
+ }
7044
+ return 50;
7045
+ }
6839
7046
 
6840
7047
  // src/utils/decimals.ts
6841
7048
  async function getTokenDecimals(publicClient, token) {
@@ -6912,17 +7119,19 @@ var MarketModule = class extends BaseModule {
6912
7119
  functionName: "getVenue",
6913
7120
  args: [params.venueId]
6914
7121
  });
6915
- const feeRequired = venue.marketCreationFee;
6916
- if (feeRequired > 0n) {
7122
+ const feeRequired = BigInt(venue.marketCreationFee);
7123
+ const reward = BigInt(venue.umaRewardAmount) + (params.additionalReward ?? 0n);
7124
+ const totalRequired = feeRequired + reward;
7125
+ if (totalRequired > 0n) {
6917
7126
  const allowance = await this.publicClient.readContract({
6918
7127
  address: params.collateralToken,
6919
7128
  abi: viem.erc20Abi,
6920
7129
  functionName: "allowance",
6921
7130
  args: [account, this.config.diamondAddress]
6922
7131
  });
6923
- if (allowance < feeRequired) {
7132
+ if (allowance < totalRequired) {
6924
7133
  throw new Error(
6925
- `Insufficient allowance for Market Creation Fee. Approved: ${allowance.toString()}, Required: ${feeRequired.toString()}. Please approve the Diamond (${this.config.diamondAddress}).`
7134
+ `Insufficient allowance. Approved: ${allowance.toString()}, Required: ${totalRequired.toString()} (fee: ${feeRequired.toString()}, reward: ${reward.toString()}). Please approve the Diamond (${this.config.diamondAddress}).`
6926
7135
  );
6927
7136
  }
6928
7137
  const balance = await this.publicClient.readContract({
@@ -6931,9 +7140,9 @@ var MarketModule = class extends BaseModule {
6931
7140
  functionName: "balanceOf",
6932
7141
  args: [account]
6933
7142
  });
6934
- if (balance < feeRequired) {
7143
+ if (balance < totalRequired) {
6935
7144
  throw new Error(
6936
- `Insufficient collateral balance for Market Creation Fee. Have: ${balance.toString()}, Required: ${feeRequired.toString()}. Please acquire more tokens.`
7145
+ `Insufficient collateral balance. Have: ${balance.toString()}, Required: ${totalRequired.toString()} (fee: ${feeRequired.toString()}, reward: ${reward.toString()}).`
6937
7146
  );
6938
7147
  }
6939
7148
  }
@@ -7179,17 +7388,19 @@ var MarketModule = class extends BaseModule {
7179
7388
  functionName: "getVenue",
7180
7389
  args: [params.venueId]
7181
7390
  });
7182
- const feeRequired = venue.marketCreationFee;
7183
- if (feeRequired > 0n) {
7391
+ const feeRequired = BigInt(venue.marketCreationFee);
7392
+ const reward = BigInt(venue.umaRewardAmount) + (params.additionalReward ?? 0n);
7393
+ const totalRequired = feeRequired + reward;
7394
+ if (totalRequired > 0n) {
7184
7395
  const allowance = await this.publicClient.readContract({
7185
7396
  address: params.collateralToken,
7186
7397
  abi: viem.erc20Abi,
7187
7398
  functionName: "allowance",
7188
7399
  args: [account, this.config.diamondAddress]
7189
7400
  });
7190
- if (allowance < feeRequired) {
7401
+ if (allowance < totalRequired) {
7191
7402
  throw new Error(
7192
- `Insufficient allowance for Market Group Creation Fee. Approved: ${allowance.toString()}, Required: ${feeRequired.toString()}. Please approve the Diamond (${this.config.diamondAddress}).`
7403
+ `Insufficient allowance. Approved: ${allowance.toString()}, Required: ${totalRequired.toString()} (fee: ${feeRequired.toString()}, reward: ${reward.toString()}). Please approve the Diamond (${this.config.diamondAddress}).`
7193
7404
  );
7194
7405
  }
7195
7406
  const balance = await this.publicClient.readContract({
@@ -7198,9 +7409,9 @@ var MarketModule = class extends BaseModule {
7198
7409
  functionName: "balanceOf",
7199
7410
  args: [account]
7200
7411
  });
7201
- if (balance < feeRequired) {
7412
+ if (balance < totalRequired) {
7202
7413
  throw new Error(
7203
- `Insufficient collateral balance for Market Group Creation Fee. Have: ${balance.toString()}, Required: ${feeRequired.toString()}.`
7414
+ `Insufficient collateral balance. Have: ${balance.toString()}, Required: ${totalRequired.toString()} (fee: ${feeRequired.toString()}, reward: ${reward.toString()}).`
7204
7415
  );
7205
7416
  }
7206
7417
  }
@@ -8141,6 +8352,13 @@ var GET_MARKETS = graphqlRequest.gql`
8141
8352
  lastPriceTick_0
8142
8353
  lastPriceTick_1
8143
8354
  lastTradeTimestamp
8355
+ lastTradeTimestamp_0
8356
+ lastTradeTimestamp_1
8357
+ topOfBook {
8358
+ outcome
8359
+ side
8360
+ topTick
8361
+ }
8144
8362
  tags
8145
8363
  metadataURI
8146
8364
  }
@@ -8171,6 +8389,14 @@ var GET_MARKETS_WITH_PRICING = graphqlRequest.gql`
8171
8389
  lastPriceTick_0
8172
8390
  lastPriceTick_1
8173
8391
  lastTradeTimestamp
8392
+ lastTradeTimestamp_0
8393
+ lastTradeTimestamp_1
8394
+ # Top of book for mark price calculation
8395
+ topOfBook {
8396
+ outcome
8397
+ side
8398
+ topTick
8399
+ }
8174
8400
  # Statistics
8175
8401
  totalVolume
8176
8402
  totalOrders
@@ -8195,6 +8421,13 @@ var GET_MARKET = graphqlRequest.gql`
8195
8421
  lastPriceTick_0
8196
8422
  lastPriceTick_1
8197
8423
  lastTradeTimestamp
8424
+ lastTradeTimestamp_0
8425
+ lastTradeTimestamp_1
8426
+ topOfBook {
8427
+ outcome
8428
+ side
8429
+ topTick
8430
+ }
8198
8431
  totalVolume
8199
8432
  totalOrders
8200
8433
  totalFees
@@ -8434,6 +8667,7 @@ var GET_MARKET_GROUPS = graphqlRequest.gql`
8434
8667
  totalMarkets
8435
8668
  activeMarketCount
8436
8669
  resolvedMarketId
8670
+ reward
8437
8671
  tags
8438
8672
  metadataURI
8439
8673
  venue {
@@ -8507,6 +8741,13 @@ var GET_GROUP_MARKETS = graphqlRequest.gql`
8507
8741
  lastPriceTick_0
8508
8742
  lastPriceTick_1
8509
8743
  lastTradeTimestamp
8744
+ lastTradeTimestamp_0
8745
+ lastTradeTimestamp_1
8746
+ topOfBook {
8747
+ outcome
8748
+ side
8749
+ topTick
8750
+ }
8510
8751
  totalVolume
8511
8752
  totalOrders
8512
8753
  createdAt
@@ -8562,6 +8803,13 @@ var GET_UNIFIED_MARKET_FEED = graphqlRequest.gql`
8562
8803
  lastPriceTick_0
8563
8804
  lastPriceTick_1
8564
8805
  lastTradeTimestamp
8806
+ lastTradeTimestamp_0
8807
+ lastTradeTimestamp_1
8808
+ topOfBook {
8809
+ outcome
8810
+ side
8811
+ topTick
8812
+ }
8565
8813
  # Statistics
8566
8814
  totalVolume
8567
8815
  totalOrders
@@ -8654,8 +8902,17 @@ var GET_UNIFIED_MARKET_FEED_BY_VOLUME = graphqlRequest.gql`
8654
8902
  status
8655
8903
  collateralToken
8656
8904
  groupId
8905
+ tickSize
8657
8906
  lastPriceTick_0
8658
8907
  lastPriceTick_1
8908
+ lastTradeTimestamp
8909
+ lastTradeTimestamp_0
8910
+ lastTradeTimestamp_1
8911
+ topOfBook {
8912
+ outcome
8913
+ side
8914
+ topTick
8915
+ }
8659
8916
  totalVolume
8660
8917
  totalOrders
8661
8918
  uniqueTraders
@@ -8682,17 +8939,28 @@ var GET_UNIFIED_MARKET_FEED_BY_VOLUME = graphqlRequest.gql`
8682
8939
  marketQuestion
8683
8940
  status
8684
8941
  totalMarkets
8942
+ activeMarketCount
8943
+ resolvedMarketId
8685
8944
  tags
8686
8945
  metadataURI
8687
- resolvedMarketId
8688
8946
  createdAt
8947
+ activatedAt
8948
+ resolvedAt
8689
8949
  venue {
8690
8950
  id
8691
8951
  venueId
8692
8952
  name
8693
8953
  }
8954
+ creator {
8955
+ id
8956
+ address
8957
+ }
8694
8958
  markets {
8959
+ id
8695
8960
  marketId
8961
+ question
8962
+ status
8963
+ groupId
8696
8964
  tickSize
8697
8965
  lastPriceTick_0
8698
8966
  lastPriceTick_1
@@ -8727,6 +8995,13 @@ var GET_ALL_MARKETS_FEED = graphqlRequest.gql`
8727
8995
  lastPriceTick_0
8728
8996
  lastPriceTick_1
8729
8997
  lastTradeTimestamp
8998
+ lastTradeTimestamp_0
8999
+ lastTradeTimestamp_1
9000
+ topOfBook {
9001
+ outcome
9002
+ side
9003
+ topTick
9004
+ }
8730
9005
  totalVolume
8731
9006
  totalOrders
8732
9007
  uniqueTraders
@@ -8808,9 +9083,19 @@ var GET_ALL_MARKETS_FEED_BY_VOLUME = graphqlRequest.gql`
8808
9083
  outcomes
8809
9084
  status
8810
9085
  collateralToken
9086
+ conditionId
9087
+ tickSize
8811
9088
  groupId
8812
9089
  lastPriceTick_0
8813
9090
  lastPriceTick_1
9091
+ lastTradeTimestamp
9092
+ lastTradeTimestamp_0
9093
+ lastTradeTimestamp_1
9094
+ topOfBook {
9095
+ outcome
9096
+ side
9097
+ topTick
9098
+ }
8814
9099
  totalVolume
8815
9100
  totalOrders
8816
9101
  uniqueTraders
@@ -8821,6 +9106,10 @@ var GET_ALL_MARKETS_FEED_BY_VOLUME = graphqlRequest.gql`
8821
9106
  venueId
8822
9107
  name
8823
9108
  }
9109
+ creator {
9110
+ id
9111
+ address
9112
+ }
8824
9113
  }
8825
9114
 
8826
9115
  marketGroups(
@@ -8835,16 +9124,28 @@ var GET_ALL_MARKETS_FEED_BY_VOLUME = graphqlRequest.gql`
8835
9124
  marketQuestion
8836
9125
  status
8837
9126
  totalMarkets
8838
- metadataURI
9127
+ activeMarketCount
8839
9128
  resolvedMarketId
9129
+ metadataURI
8840
9130
  createdAt
9131
+ activatedAt
9132
+ resolvedAt
8841
9133
  venue {
8842
9134
  id
8843
9135
  venueId
8844
9136
  name
8845
9137
  }
9138
+ creator {
9139
+ id
9140
+ address
9141
+ }
8846
9142
  markets {
9143
+ id
8847
9144
  marketId
9145
+ question
9146
+ status
9147
+ groupId
9148
+ tickSize
8848
9149
  lastPriceTick_0
8849
9150
  lastPriceTick_1
8850
9151
  totalVolume
@@ -8868,6 +9169,7 @@ var GET_RECENT_TRADES = graphqlRequest.gql`
8868
9169
  market {
8869
9170
  marketId
8870
9171
  question
9172
+ outcomes
8871
9173
  venue {
8872
9174
  venueId
8873
9175
  name
@@ -9314,20 +9616,21 @@ var PublicModule = class extends BaseModule {
9314
9616
  return limit ? merged.slice(0, limit) : merged;
9315
9617
  }
9316
9618
  /**
9317
- * Calculate probability for a market using last trade price
9619
+ * Calculate probability for a market using mark price waterfall.
9318
9620
  * Returns probability as a decimal string (e.g., "0.65" for 65%)
9319
9621
  *
9320
- * @param market - Market object from subgraph
9622
+ * Uses Polymarket-style pricing: implied midpoint → last trade → default 50%.
9623
+ *
9624
+ * @param market - Market object from subgraph (with topOfBook and timestamp fields)
9321
9625
  * @returns Probability string or null if no data available
9322
9626
  */
9323
9627
  calculateMarketProbability(market) {
9324
- if (market.lastPriceTick_0 && market.tickSize) {
9325
- const tick = BigInt(market.lastPriceTick_0);
9326
- const tickSize = BigInt(market.tickSize);
9327
- const price = Number(tick * tickSize) / 1e18;
9328
- return price.toFixed(2);
9628
+ if (!market.tickSize) return null;
9629
+ const chance = calculateChancePercent(market);
9630
+ if (chance === 50 && !market.lastPriceTick_0 && !market.lastPriceTick_1) {
9631
+ return null;
9329
9632
  }
9330
- return null;
9633
+ return (chance / 100).toFixed(2);
9331
9634
  }
9332
9635
  /**
9333
9636
  * Format market group for display (Polymarket-style)
@@ -9556,6 +9859,15 @@ var TokenModule = class extends BaseModule {
9556
9859
  });
9557
9860
  }
9558
9861
  };
9862
+ var optimisticOracleV3Abi = [
9863
+ {
9864
+ inputs: [{ name: "currency", type: "address" }],
9865
+ name: "getMinimumBond",
9866
+ outputs: [{ name: "", type: "uint256" }],
9867
+ stateMutability: "view",
9868
+ type: "function"
9869
+ }
9870
+ ];
9559
9871
  var UmaModule = class extends BaseModule {
9560
9872
  /**
9561
9873
  * Assert an outcome for a market question
@@ -9577,14 +9889,8 @@ var UmaModule = class extends BaseModule {
9577
9889
  args: [params.marketId]
9578
9890
  });
9579
9891
  const questionId = registryData.questionId;
9580
- const oracleData = await this.publicClient.readContract({
9581
- address: this.config.diamondAddress,
9582
- abi: MarketsFacet_default,
9583
- functionName: "getMarketOracleData",
9584
- args: [params.marketId]
9585
- });
9586
- const bondAmount = BigInt(oracleData.requiredBond);
9587
- const currency = oracleData.currency;
9892
+ const { effectiveBond, currency } = await this.getEffectiveBond(params.marketId);
9893
+ const bondAmount = effectiveBond;
9588
9894
  const currentAllowance = await this.publicClient.readContract({
9589
9895
  address: currency,
9590
9896
  abi: viem.erc20Abi,
@@ -9641,6 +9947,33 @@ var UmaModule = class extends BaseModule {
9641
9947
  });
9642
9948
  return wallet.writeContract(request);
9643
9949
  }
9950
+ /**
9951
+ * Get the effective bond for a market, accounting for UMA's minimum bond.
9952
+ * The contract uses max(requiredBond, oo.getMinimumBond(currency)).
9953
+ */
9954
+ async getEffectiveBond(marketId) {
9955
+ const oracleData = await this.publicClient.readContract({
9956
+ address: this.config.diamondAddress,
9957
+ abi: MarketsFacet_default,
9958
+ functionName: "getMarketOracleData",
9959
+ args: [marketId]
9960
+ });
9961
+ const requiredBond = BigInt(oracleData.requiredBond);
9962
+ const currency = oracleData.currency;
9963
+ const umaOracle = await this.publicClient.readContract({
9964
+ address: this.config.diamondAddress,
9965
+ abi: ProtocolFacet_default,
9966
+ functionName: "getUmaOracle"
9967
+ });
9968
+ const minimumBond = await this.publicClient.readContract({
9969
+ address: umaOracle,
9970
+ abi: optimisticOracleV3Abi,
9971
+ functionName: "getMinimumBond",
9972
+ args: [currency]
9973
+ });
9974
+ const effectiveBond = requiredBond > minimumBond ? requiredBond : minimumBond;
9975
+ return { requiredBond, minimumBond, effectiveBond, currency };
9976
+ }
9644
9977
  /**
9645
9978
  * Settle an assertion after the liveness period
9646
9979
  */
@@ -10428,11 +10761,19 @@ function createOddMakiClient(params) {
10428
10761
 
10429
10762
  // src/constants.ts
10430
10763
  var PROTOCOL_FEES = {
10431
- /** Protocol fee: 20 bps (0.20%) */
10432
- PROTOCOL_FEE_BPS: 20n,
10764
+ /** Protocol fee: 50 bps (0.50%) — configurable via ProtocolFacet.setProtocolFeeBps() */
10765
+ PROTOCOL_FEE_BPS: 50n,
10433
10766
  /** Operator fee: 10 bps (0.10%) for match operators */
10434
10767
  OPERATOR_FEE_BPS: 10n
10435
10768
  };
10769
+ var UMA_DEFAULTS = {
10770
+ /** Recommended reward: 5 USDC. Incentivizes third-party resolution. */
10771
+ REWARD_USDC: 5000000n,
10772
+ /** Recommended minimum bond: 750 USDC. Matches Polymarket's production bond. */
10773
+ MIN_BOND_USDC: 750000000n,
10774
+ /** Default liveness period: 2 hours (7200 seconds). */
10775
+ LIVENESS: 7200n
10776
+ };
10436
10777
 
10437
10778
  // src/utils/metadata.ts
10438
10779
  var DEFAULT_IPFS_GATEWAY = "https://gateway.pinata.cloud/ipfs/";
@@ -10520,12 +10861,14 @@ exports.TICK_SIZE_STANDARD = TICK_SIZE_STANDARD;
10520
10861
  exports.TagsFacetABI = TagsFacet_default;
10521
10862
  exports.TokenModule = TokenModule;
10522
10863
  exports.TradeModule = TradeModule;
10864
+ exports.UMA_DEFAULTS = UMA_DEFAULTS;
10523
10865
  exports.UmaModule = UmaModule;
10524
10866
  exports.VALID_TICK_SIZES = VALID_TICK_SIZES;
10525
10867
  exports.VaultFacetABI = VaultFacet_default;
10526
10868
  exports.VenueFacetABI = VenueFacet_default;
10527
10869
  exports.VenueModule = VenueModule;
10528
10870
  exports.WhitelistAccessControlABI = WhitelistAccessControl_default;
10871
+ exports.calculateChancePercent = calculateChancePercent;
10529
10872
  exports.clearDecimalsCache = clearDecimalsCache;
10530
10873
  exports.createExpiry = createExpiry;
10531
10874
  exports.createOddMakiClient = createOddMakiClient;