@oddmaki-protocol/sdk 1.4.0 → 1.5.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 +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +122 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,14 @@ var CONTRACT_ADDRESSES = {
|
|
|
17
17
|
subgraph: "https://api.studio.thegraph.com/query/1716020/oddmaki-base/version/latest"
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
var SUBGRAPH_IDS = {
|
|
21
|
+
[base.id]: "CxoYVjELrNCMLopAmVshnfVAie7yH6QZyCSKD3r41XSQ",
|
|
22
|
+
[baseSepolia.id]: "DCnd3ozSyvYxRg7kmZYiDWGBiJCe6QHwu8M93jMN1Q3b"
|
|
23
|
+
};
|
|
24
|
+
function buildSubgraphGatewayUrl(chainId, apiKey) {
|
|
25
|
+
const id = SUBGRAPH_IDS[chainId];
|
|
26
|
+
return id ? `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/${id}` : void 0;
|
|
27
|
+
}
|
|
20
28
|
var DEFAULT_CHAIN = base;
|
|
21
29
|
var SubgraphClient = class {
|
|
22
30
|
constructor(endpoint) {
|
|
@@ -7111,6 +7119,24 @@ var UmaOracle_default = [
|
|
|
7111
7119
|
],
|
|
7112
7120
|
outputs: [],
|
|
7113
7121
|
stateMutability: "nonpayable"
|
|
7122
|
+
},
|
|
7123
|
+
{
|
|
7124
|
+
type: "function",
|
|
7125
|
+
name: "disputeAssertion",
|
|
7126
|
+
inputs: [
|
|
7127
|
+
{
|
|
7128
|
+
name: "assertionId",
|
|
7129
|
+
type: "bytes32",
|
|
7130
|
+
internalType: "bytes32"
|
|
7131
|
+
},
|
|
7132
|
+
{
|
|
7133
|
+
name: "disputer",
|
|
7134
|
+
type: "address",
|
|
7135
|
+
internalType: "address"
|
|
7136
|
+
}
|
|
7137
|
+
],
|
|
7138
|
+
outputs: [],
|
|
7139
|
+
stateMutability: "nonpayable"
|
|
7114
7140
|
}
|
|
7115
7141
|
];
|
|
7116
7142
|
|
|
@@ -10489,6 +10515,97 @@ var UmaModule = class extends BaseModule {
|
|
|
10489
10515
|
});
|
|
10490
10516
|
return wallet.writeContract(request);
|
|
10491
10517
|
}
|
|
10518
|
+
/**
|
|
10519
|
+
* Get the UMA Optimistic Oracle V3 address for the active Diamond.
|
|
10520
|
+
*/
|
|
10521
|
+
async getUmaOracleAddress() {
|
|
10522
|
+
return await this.publicClient.readContract({
|
|
10523
|
+
address: this.config.diamondAddress,
|
|
10524
|
+
abi: ProtocolFacet_default,
|
|
10525
|
+
functionName: "getUmaOracle"
|
|
10526
|
+
});
|
|
10527
|
+
}
|
|
10528
|
+
/**
|
|
10529
|
+
* Dispute an active assertion directly on the UMA Optimistic Oracle V3.
|
|
10530
|
+
*
|
|
10531
|
+
* The dispute escalates the assertion to UMA's DVM, which arbitrates the
|
|
10532
|
+
* outcome via tokenholder vote. The disputer must post a bond equal to the
|
|
10533
|
+
* asserter's bond — the winner is reimbursed and receives a share of the
|
|
10534
|
+
* loser's bond.
|
|
10535
|
+
*
|
|
10536
|
+
* @param params.assertionId - The active assertionId to dispute
|
|
10537
|
+
* @param params.autoApprove - Approve the bond currency to the oracle if needed (default: true)
|
|
10538
|
+
*
|
|
10539
|
+
* @returns Transaction hash
|
|
10540
|
+
*/
|
|
10541
|
+
async disputeAssertion(params) {
|
|
10542
|
+
const wallet = this.walletClient;
|
|
10543
|
+
const account = await this.getSignerAccount();
|
|
10544
|
+
const accountAddress = await this.getSignerAddress();
|
|
10545
|
+
const autoApprove = params.autoApprove ?? true;
|
|
10546
|
+
const oracleAddress = await this.getUmaOracleAddress();
|
|
10547
|
+
const assertion = await this.publicClient.readContract({
|
|
10548
|
+
address: oracleAddress,
|
|
10549
|
+
abi: UmaOracle_default,
|
|
10550
|
+
functionName: "getAssertion",
|
|
10551
|
+
args: [params.assertionId]
|
|
10552
|
+
});
|
|
10553
|
+
const currency = assertion.currency;
|
|
10554
|
+
const bondAmount = BigInt(assertion.bond);
|
|
10555
|
+
if (assertion.disputer !== "0x0000000000000000000000000000000000000000") {
|
|
10556
|
+
throw new Error("Assertion has already been disputed");
|
|
10557
|
+
}
|
|
10558
|
+
if (assertion.settled) {
|
|
10559
|
+
throw new Error("Assertion is already settled");
|
|
10560
|
+
}
|
|
10561
|
+
const currentTime = Math.floor(Date.now() / 1e3);
|
|
10562
|
+
if (currentTime >= Number(assertion.expirationTime)) {
|
|
10563
|
+
throw new Error("Liveness period has expired \u2014 assertion can no longer be disputed");
|
|
10564
|
+
}
|
|
10565
|
+
const currentAllowance = await this.publicClient.readContract({
|
|
10566
|
+
address: currency,
|
|
10567
|
+
abi: erc20Abi,
|
|
10568
|
+
functionName: "allowance",
|
|
10569
|
+
args: [accountAddress, oracleAddress]
|
|
10570
|
+
});
|
|
10571
|
+
if (currentAllowance < bondAmount && autoApprove) {
|
|
10572
|
+
const approveHash = await wallet.writeContract({
|
|
10573
|
+
address: currency,
|
|
10574
|
+
abi: erc20Abi,
|
|
10575
|
+
functionName: "approve",
|
|
10576
|
+
args: [oracleAddress, bondAmount],
|
|
10577
|
+
account,
|
|
10578
|
+
chain: this.config.chain
|
|
10579
|
+
});
|
|
10580
|
+
await this.publicClient.waitForTransactionReceipt({
|
|
10581
|
+
hash: approveHash,
|
|
10582
|
+
confirmations: 2
|
|
10583
|
+
});
|
|
10584
|
+
} else if (currentAllowance < bondAmount) {
|
|
10585
|
+
throw new Error(
|
|
10586
|
+
`Insufficient bond currency allowance for oracle. Required: ${bondAmount.toString()}, Current: ${currentAllowance.toString()}.`
|
|
10587
|
+
);
|
|
10588
|
+
}
|
|
10589
|
+
const balance = await this.publicClient.readContract({
|
|
10590
|
+
address: currency,
|
|
10591
|
+
abi: erc20Abi,
|
|
10592
|
+
functionName: "balanceOf",
|
|
10593
|
+
args: [accountAddress]
|
|
10594
|
+
});
|
|
10595
|
+
if (balance < bondAmount) {
|
|
10596
|
+
throw new Error(
|
|
10597
|
+
`Insufficient bond currency balance. Required: ${bondAmount.toString()}, Have: ${balance.toString()}`
|
|
10598
|
+
);
|
|
10599
|
+
}
|
|
10600
|
+
const { request } = await this.publicClient.simulateContract({
|
|
10601
|
+
address: oracleAddress,
|
|
10602
|
+
abi: UmaOracle_default,
|
|
10603
|
+
functionName: "disputeAssertion",
|
|
10604
|
+
args: [params.assertionId, accountAddress],
|
|
10605
|
+
account
|
|
10606
|
+
});
|
|
10607
|
+
return wallet.writeContract(request);
|
|
10608
|
+
}
|
|
10492
10609
|
/**
|
|
10493
10610
|
* Report resolution after UMA settlement
|
|
10494
10611
|
*/
|
|
@@ -10704,7 +10821,9 @@ var UmaModule = class extends BaseModule {
|
|
|
10704
10821
|
expirationTime,
|
|
10705
10822
|
canSettle: currentTime >= expirationTime,
|
|
10706
10823
|
disputer: assertion.disputer,
|
|
10707
|
-
isDisputed: assertion.disputer !== "0x0000000000000000000000000000000000000000"
|
|
10824
|
+
isDisputed: assertion.disputer !== "0x0000000000000000000000000000000000000000",
|
|
10825
|
+
currency: assertion.currency,
|
|
10826
|
+
bond: BigInt(assertion.bond)
|
|
10708
10827
|
};
|
|
10709
10828
|
}
|
|
10710
10829
|
/**
|
|
@@ -11402,6 +11521,6 @@ function parseMetadata(json) {
|
|
|
11402
11521
|
// src/index.ts
|
|
11403
11522
|
var version = "0.1.0";
|
|
11404
11523
|
|
|
11405
|
-
export { AccessControlFacet_default as AccessControlFacetABI, AccessControlModule, BatchOrdersFacet_default as BatchOrdersFacetABI, CONTRACT_ADDRESSES, ConditionalTokens_default as ConditionalTokensABI, DEFAULT_CHAIN, ERC20_default as ERC20ABI, FeedProvider, GET_ALL_MARKETS_FEED, GET_ALL_MARKETS_FEED_BY_VOLUME, GET_CHART_TRADES, GET_CHART_TRADES_ALL, GET_GROUP_MARKETS, GET_LEADERBOARD, GET_MARKET, GET_MARKETS, GET_MARKETS_WITH_PRICING, GET_MARKET_GROUP, GET_MARKET_GROUPS, GET_MARKET_GROUP_ITEM, GET_MARKET_TOP_HOLDERS, GET_ORDERS, GET_PROTOCOL_STATS, GET_QUESTION, GET_QUESTIONS, GET_RECENT_MARKETS, GET_RECENT_TRADES, GET_TOP_OF_BOOK, GET_TRADER_CLOSED_POSITIONS, GET_TRADER_FILLS, GET_TRADER_POSITIONS, GET_TRADER_PROFILE, GET_TRADES, GET_UNIFIED_MARKET_FEED, GET_UNIFIED_MARKET_FEED_BY_VOLUME, GET_USER, GET_VENUES, LimitOrdersFacet_default as LimitOrdersFacetABI, MarketGroupFacet_default as MarketGroupFacetABI, MarketModule, MarketOrdersFacet_default as MarketOrdersFacetABI, MarketsFacet_default as MarketsFacetABI, MatchingFacet_default as MatchingFacetABI, MetadataFacet_default as MetadataFacetABI, NegRiskFacet_default as NegRiskFacetABI, OddMakiClient, OrderBookFacet_default as OrderBookFacetABI, PROTOCOL_FEES, PriceMarketFacet_default as PriceMarketFacetABI, PriceMarketModule, ProtocolFacet_default as ProtocolFacetABI, PublicModule, PythResolutionFacet_default as PythResolutionFacetABI, ResolutionFacet_default as ResolutionFacetABI, SubgraphClient, TICK_SIZE_FINE, TICK_SIZE_STANDARD, TagsFacet_default as TagsFacetABI, TokenModule, TradeModule, UMA_DEFAULTS, UmaModule, UmaOracle_default as UmaOracleABI, VALID_TICK_SIZES, VaultFacet_default as VaultFacetABI, VenueFacet_default as VenueFacetABI, VenueModule, WhitelistAccessControl_default as WhitelistAccessControlABI, calculateChancePercent, clearDecimalsCache, createExpiry, createOddMakiClient, formatAmount, formatAncillaryData, formatTimestamp, getCachedTokenDecimals, getOutcomePrice, getTokenDecimals, isValidTickSize, parseAmount, parseAncillaryData, parseMetadata, parseTokenAmount, priceToTick, resolveIPFSUri, tickToPercentage, tickToPrice, version };
|
|
11524
|
+
export { AccessControlFacet_default as AccessControlFacetABI, AccessControlModule, BatchOrdersFacet_default as BatchOrdersFacetABI, CONTRACT_ADDRESSES, ConditionalTokens_default as ConditionalTokensABI, DEFAULT_CHAIN, ERC20_default as ERC20ABI, FeedProvider, GET_ALL_MARKETS_FEED, GET_ALL_MARKETS_FEED_BY_VOLUME, GET_CHART_TRADES, GET_CHART_TRADES_ALL, GET_GROUP_MARKETS, GET_LEADERBOARD, GET_MARKET, GET_MARKETS, GET_MARKETS_WITH_PRICING, GET_MARKET_GROUP, GET_MARKET_GROUPS, GET_MARKET_GROUP_ITEM, GET_MARKET_TOP_HOLDERS, GET_ORDERS, GET_PROTOCOL_STATS, GET_QUESTION, GET_QUESTIONS, GET_RECENT_MARKETS, GET_RECENT_TRADES, GET_TOP_OF_BOOK, GET_TRADER_CLOSED_POSITIONS, GET_TRADER_FILLS, GET_TRADER_POSITIONS, GET_TRADER_PROFILE, GET_TRADES, GET_UNIFIED_MARKET_FEED, GET_UNIFIED_MARKET_FEED_BY_VOLUME, GET_USER, GET_VENUES, LimitOrdersFacet_default as LimitOrdersFacetABI, MarketGroupFacet_default as MarketGroupFacetABI, MarketModule, MarketOrdersFacet_default as MarketOrdersFacetABI, MarketsFacet_default as MarketsFacetABI, MatchingFacet_default as MatchingFacetABI, MetadataFacet_default as MetadataFacetABI, NegRiskFacet_default as NegRiskFacetABI, OddMakiClient, OrderBookFacet_default as OrderBookFacetABI, PROTOCOL_FEES, PriceMarketFacet_default as PriceMarketFacetABI, PriceMarketModule, ProtocolFacet_default as ProtocolFacetABI, PublicModule, PythResolutionFacet_default as PythResolutionFacetABI, ResolutionFacet_default as ResolutionFacetABI, SUBGRAPH_IDS, SubgraphClient, TICK_SIZE_FINE, TICK_SIZE_STANDARD, TagsFacet_default as TagsFacetABI, TokenModule, TradeModule, UMA_DEFAULTS, UmaModule, UmaOracle_default as UmaOracleABI, VALID_TICK_SIZES, VaultFacet_default as VaultFacetABI, VenueFacet_default as VenueFacetABI, VenueModule, WhitelistAccessControl_default as WhitelistAccessControlABI, buildSubgraphGatewayUrl, calculateChancePercent, clearDecimalsCache, createExpiry, createOddMakiClient, formatAmount, formatAncillaryData, formatTimestamp, getCachedTokenDecimals, getOutcomePrice, getTokenDecimals, isValidTickSize, parseAmount, parseAncillaryData, parseMetadata, parseTokenAmount, priceToTick, resolveIPFSUri, tickToPercentage, tickToPrice, version };
|
|
11406
11525
|
//# sourceMappingURL=index.mjs.map
|
|
11407
11526
|
//# sourceMappingURL=index.mjs.map
|