@oddmaki-protocol/sdk 1.4.1 → 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 CHANGED
@@ -9264,6 +9264,27 @@ declare class UmaModule extends BaseModule {
9264
9264
  * Settle an assertion after the liveness period
9265
9265
  */
9266
9266
  settleAssertion(assertionId: `0x${string}`): Promise<`0x${string}`>;
9267
+ /**
9268
+ * Get the UMA Optimistic Oracle V3 address for the active Diamond.
9269
+ */
9270
+ getUmaOracleAddress(): Promise<Address>;
9271
+ /**
9272
+ * Dispute an active assertion directly on the UMA Optimistic Oracle V3.
9273
+ *
9274
+ * The dispute escalates the assertion to UMA's DVM, which arbitrates the
9275
+ * outcome via tokenholder vote. The disputer must post a bond equal to the
9276
+ * asserter's bond — the winner is reimbursed and receives a share of the
9277
+ * loser's bond.
9278
+ *
9279
+ * @param params.assertionId - The active assertionId to dispute
9280
+ * @param params.autoApprove - Approve the bond currency to the oracle if needed (default: true)
9281
+ *
9282
+ * @returns Transaction hash
9283
+ */
9284
+ disputeAssertion(params: {
9285
+ assertionId: `0x${string}`;
9286
+ autoApprove?: boolean;
9287
+ }): Promise<`0x${string}`>;
9267
9288
  /**
9268
9289
  * Report resolution after UMA settlement
9269
9290
  */
@@ -9328,6 +9349,8 @@ declare class UmaModule extends BaseModule {
9328
9349
  canSettle: boolean;
9329
9350
  disputer: `0x${string}`;
9330
9351
  isDisputed: boolean;
9352
+ currency: Address;
9353
+ bond: bigint;
9331
9354
  }>;
9332
9355
  /**
9333
9356
  * Get comprehensive market status for UMA resolution
@@ -17250,6 +17273,25 @@ var UmaOracle = [
17250
17273
  outputs: [
17251
17274
  ],
17252
17275
  stateMutability: "nonpayable"
17276
+ },
17277
+ {
17278
+ type: "function",
17279
+ name: "disputeAssertion",
17280
+ inputs: [
17281
+ {
17282
+ name: "assertionId",
17283
+ type: "bytes32",
17284
+ internalType: "bytes32"
17285
+ },
17286
+ {
17287
+ name: "disputer",
17288
+ type: "address",
17289
+ internalType: "address"
17290
+ }
17291
+ ],
17292
+ outputs: [
17293
+ ],
17294
+ stateMutability: "nonpayable"
17253
17295
  }
17254
17296
  ];
17255
17297
 
package/dist/index.d.ts CHANGED
@@ -9264,6 +9264,27 @@ declare class UmaModule extends BaseModule {
9264
9264
  * Settle an assertion after the liveness period
9265
9265
  */
9266
9266
  settleAssertion(assertionId: `0x${string}`): Promise<`0x${string}`>;
9267
+ /**
9268
+ * Get the UMA Optimistic Oracle V3 address for the active Diamond.
9269
+ */
9270
+ getUmaOracleAddress(): Promise<Address>;
9271
+ /**
9272
+ * Dispute an active assertion directly on the UMA Optimistic Oracle V3.
9273
+ *
9274
+ * The dispute escalates the assertion to UMA's DVM, which arbitrates the
9275
+ * outcome via tokenholder vote. The disputer must post a bond equal to the
9276
+ * asserter's bond — the winner is reimbursed and receives a share of the
9277
+ * loser's bond.
9278
+ *
9279
+ * @param params.assertionId - The active assertionId to dispute
9280
+ * @param params.autoApprove - Approve the bond currency to the oracle if needed (default: true)
9281
+ *
9282
+ * @returns Transaction hash
9283
+ */
9284
+ disputeAssertion(params: {
9285
+ assertionId: `0x${string}`;
9286
+ autoApprove?: boolean;
9287
+ }): Promise<`0x${string}`>;
9267
9288
  /**
9268
9289
  * Report resolution after UMA settlement
9269
9290
  */
@@ -9328,6 +9349,8 @@ declare class UmaModule extends BaseModule {
9328
9349
  canSettle: boolean;
9329
9350
  disputer: `0x${string}`;
9330
9351
  isDisputed: boolean;
9352
+ currency: Address;
9353
+ bond: bigint;
9331
9354
  }>;
9332
9355
  /**
9333
9356
  * Get comprehensive market status for UMA resolution
@@ -17250,6 +17273,25 @@ var UmaOracle = [
17250
17273
  outputs: [
17251
17274
  ],
17252
17275
  stateMutability: "nonpayable"
17276
+ },
17277
+ {
17278
+ type: "function",
17279
+ name: "disputeAssertion",
17280
+ inputs: [
17281
+ {
17282
+ name: "assertionId",
17283
+ type: "bytes32",
17284
+ internalType: "bytes32"
17285
+ },
17286
+ {
17287
+ name: "disputer",
17288
+ type: "address",
17289
+ internalType: "address"
17290
+ }
17291
+ ],
17292
+ outputs: [
17293
+ ],
17294
+ stateMutability: "nonpayable"
17253
17295
  }
17254
17296
  ];
17255
17297
 
package/dist/index.js CHANGED
@@ -7121,6 +7121,24 @@ var UmaOracle_default = [
7121
7121
  ],
7122
7122
  outputs: [],
7123
7123
  stateMutability: "nonpayable"
7124
+ },
7125
+ {
7126
+ type: "function",
7127
+ name: "disputeAssertion",
7128
+ inputs: [
7129
+ {
7130
+ name: "assertionId",
7131
+ type: "bytes32",
7132
+ internalType: "bytes32"
7133
+ },
7134
+ {
7135
+ name: "disputer",
7136
+ type: "address",
7137
+ internalType: "address"
7138
+ }
7139
+ ],
7140
+ outputs: [],
7141
+ stateMutability: "nonpayable"
7124
7142
  }
7125
7143
  ];
7126
7144
 
@@ -10499,6 +10517,97 @@ var UmaModule = class extends BaseModule {
10499
10517
  });
10500
10518
  return wallet.writeContract(request);
10501
10519
  }
10520
+ /**
10521
+ * Get the UMA Optimistic Oracle V3 address for the active Diamond.
10522
+ */
10523
+ async getUmaOracleAddress() {
10524
+ return await this.publicClient.readContract({
10525
+ address: this.config.diamondAddress,
10526
+ abi: ProtocolFacet_default,
10527
+ functionName: "getUmaOracle"
10528
+ });
10529
+ }
10530
+ /**
10531
+ * Dispute an active assertion directly on the UMA Optimistic Oracle V3.
10532
+ *
10533
+ * The dispute escalates the assertion to UMA's DVM, which arbitrates the
10534
+ * outcome via tokenholder vote. The disputer must post a bond equal to the
10535
+ * asserter's bond — the winner is reimbursed and receives a share of the
10536
+ * loser's bond.
10537
+ *
10538
+ * @param params.assertionId - The active assertionId to dispute
10539
+ * @param params.autoApprove - Approve the bond currency to the oracle if needed (default: true)
10540
+ *
10541
+ * @returns Transaction hash
10542
+ */
10543
+ async disputeAssertion(params) {
10544
+ const wallet = this.walletClient;
10545
+ const account = await this.getSignerAccount();
10546
+ const accountAddress = await this.getSignerAddress();
10547
+ const autoApprove = params.autoApprove ?? true;
10548
+ const oracleAddress = await this.getUmaOracleAddress();
10549
+ const assertion = await this.publicClient.readContract({
10550
+ address: oracleAddress,
10551
+ abi: UmaOracle_default,
10552
+ functionName: "getAssertion",
10553
+ args: [params.assertionId]
10554
+ });
10555
+ const currency = assertion.currency;
10556
+ const bondAmount = BigInt(assertion.bond);
10557
+ if (assertion.disputer !== "0x0000000000000000000000000000000000000000") {
10558
+ throw new Error("Assertion has already been disputed");
10559
+ }
10560
+ if (assertion.settled) {
10561
+ throw new Error("Assertion is already settled");
10562
+ }
10563
+ const currentTime = Math.floor(Date.now() / 1e3);
10564
+ if (currentTime >= Number(assertion.expirationTime)) {
10565
+ throw new Error("Liveness period has expired \u2014 assertion can no longer be disputed");
10566
+ }
10567
+ const currentAllowance = await this.publicClient.readContract({
10568
+ address: currency,
10569
+ abi: viem.erc20Abi,
10570
+ functionName: "allowance",
10571
+ args: [accountAddress, oracleAddress]
10572
+ });
10573
+ if (currentAllowance < bondAmount && autoApprove) {
10574
+ const approveHash = await wallet.writeContract({
10575
+ address: currency,
10576
+ abi: viem.erc20Abi,
10577
+ functionName: "approve",
10578
+ args: [oracleAddress, bondAmount],
10579
+ account,
10580
+ chain: this.config.chain
10581
+ });
10582
+ await this.publicClient.waitForTransactionReceipt({
10583
+ hash: approveHash,
10584
+ confirmations: 2
10585
+ });
10586
+ } else if (currentAllowance < bondAmount) {
10587
+ throw new Error(
10588
+ `Insufficient bond currency allowance for oracle. Required: ${bondAmount.toString()}, Current: ${currentAllowance.toString()}.`
10589
+ );
10590
+ }
10591
+ const balance = await this.publicClient.readContract({
10592
+ address: currency,
10593
+ abi: viem.erc20Abi,
10594
+ functionName: "balanceOf",
10595
+ args: [accountAddress]
10596
+ });
10597
+ if (balance < bondAmount) {
10598
+ throw new Error(
10599
+ `Insufficient bond currency balance. Required: ${bondAmount.toString()}, Have: ${balance.toString()}`
10600
+ );
10601
+ }
10602
+ const { request } = await this.publicClient.simulateContract({
10603
+ address: oracleAddress,
10604
+ abi: UmaOracle_default,
10605
+ functionName: "disputeAssertion",
10606
+ args: [params.assertionId, accountAddress],
10607
+ account
10608
+ });
10609
+ return wallet.writeContract(request);
10610
+ }
10502
10611
  /**
10503
10612
  * Report resolution after UMA settlement
10504
10613
  */
@@ -10714,7 +10823,9 @@ var UmaModule = class extends BaseModule {
10714
10823
  expirationTime,
10715
10824
  canSettle: currentTime >= expirationTime,
10716
10825
  disputer: assertion.disputer,
10717
- isDisputed: assertion.disputer !== "0x0000000000000000000000000000000000000000"
10826
+ isDisputed: assertion.disputer !== "0x0000000000000000000000000000000000000000",
10827
+ currency: assertion.currency,
10828
+ bond: BigInt(assertion.bond)
10718
10829
  };
10719
10830
  }
10720
10831
  /**