@oddmaki-protocol/sdk 1.4.1 → 1.6.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.mjs CHANGED
@@ -7,7 +7,7 @@ var CONTRACT_ADDRESSES = {
7
7
  [baseSepolia.id]: {
8
8
  diamond: "0x31a4126aec35b36d46dd371eb0f0d5b71e1c2292",
9
9
  conditionalTokens: "0x7364747372Ac4a175B5326f5B2C9CB1C271d32e8",
10
- usdc: "0x1d3caa0156e8e573814b78766ba7958d7e11488b",
10
+ usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
11
11
  subgraph: "https://api.studio.thegraph.com/query/1716020/oddmaki-base-sepolia/version/latest"
12
12
  },
13
13
  [base.id]: {
@@ -6706,24 +6706,6 @@ var ERC20_default = [
6706
6706
  ],
6707
6707
  stateMutability: "view"
6708
6708
  },
6709
- {
6710
- type: "function",
6711
- name: "mint",
6712
- inputs: [
6713
- {
6714
- name: "to",
6715
- type: "address",
6716
- internalType: "address"
6717
- },
6718
- {
6719
- name: "amount",
6720
- type: "uint256",
6721
- internalType: "uint256"
6722
- }
6723
- ],
6724
- outputs: [],
6725
- stateMutability: "nonpayable"
6726
- },
6727
6709
  {
6728
6710
  type: "function",
6729
6711
  name: "name",
@@ -7119,6 +7101,24 @@ var UmaOracle_default = [
7119
7101
  ],
7120
7102
  outputs: [],
7121
7103
  stateMutability: "nonpayable"
7104
+ },
7105
+ {
7106
+ type: "function",
7107
+ name: "disputeAssertion",
7108
+ inputs: [
7109
+ {
7110
+ name: "assertionId",
7111
+ type: "bytes32",
7112
+ internalType: "bytes32"
7113
+ },
7114
+ {
7115
+ name: "disputer",
7116
+ type: "address",
7117
+ internalType: "address"
7118
+ }
7119
+ ],
7120
+ outputs: [],
7121
+ stateMutability: "nonpayable"
7122
7122
  }
7123
7123
  ];
7124
7124
 
@@ -10292,21 +10292,6 @@ var PublicModule = class extends BaseModule {
10292
10292
 
10293
10293
  // src/modules/token.ts
10294
10294
  var TokenModule = class extends BaseModule {
10295
- /**
10296
- * Mint tokens (for testnet/mock tokens only)
10297
- */
10298
- async mint(token, to, amount) {
10299
- const wallet = this.walletClient;
10300
- const account = await this.getSignerAccount();
10301
- const { request } = await this.publicClient.simulateContract({
10302
- address: token,
10303
- abi: ERC20_default,
10304
- functionName: "mint",
10305
- args: [to, amount],
10306
- account
10307
- });
10308
- return wallet.writeContract(request);
10309
- }
10310
10295
  /**
10311
10296
  * Approve a spender to spend tokens
10312
10297
  */
@@ -10497,6 +10482,97 @@ var UmaModule = class extends BaseModule {
10497
10482
  });
10498
10483
  return wallet.writeContract(request);
10499
10484
  }
10485
+ /**
10486
+ * Get the UMA Optimistic Oracle V3 address for the active Diamond.
10487
+ */
10488
+ async getUmaOracleAddress() {
10489
+ return await this.publicClient.readContract({
10490
+ address: this.config.diamondAddress,
10491
+ abi: ProtocolFacet_default,
10492
+ functionName: "getUmaOracle"
10493
+ });
10494
+ }
10495
+ /**
10496
+ * Dispute an active assertion directly on the UMA Optimistic Oracle V3.
10497
+ *
10498
+ * The dispute escalates the assertion to UMA's DVM, which arbitrates the
10499
+ * outcome via tokenholder vote. The disputer must post a bond equal to the
10500
+ * asserter's bond — the winner is reimbursed and receives a share of the
10501
+ * loser's bond.
10502
+ *
10503
+ * @param params.assertionId - The active assertionId to dispute
10504
+ * @param params.autoApprove - Approve the bond currency to the oracle if needed (default: true)
10505
+ *
10506
+ * @returns Transaction hash
10507
+ */
10508
+ async disputeAssertion(params) {
10509
+ const wallet = this.walletClient;
10510
+ const account = await this.getSignerAccount();
10511
+ const accountAddress = await this.getSignerAddress();
10512
+ const autoApprove = params.autoApprove ?? true;
10513
+ const oracleAddress = await this.getUmaOracleAddress();
10514
+ const assertion = await this.publicClient.readContract({
10515
+ address: oracleAddress,
10516
+ abi: UmaOracle_default,
10517
+ functionName: "getAssertion",
10518
+ args: [params.assertionId]
10519
+ });
10520
+ const currency = assertion.currency;
10521
+ const bondAmount = BigInt(assertion.bond);
10522
+ if (assertion.disputer !== "0x0000000000000000000000000000000000000000") {
10523
+ throw new Error("Assertion has already been disputed");
10524
+ }
10525
+ if (assertion.settled) {
10526
+ throw new Error("Assertion is already settled");
10527
+ }
10528
+ const currentTime = Math.floor(Date.now() / 1e3);
10529
+ if (currentTime >= Number(assertion.expirationTime)) {
10530
+ throw new Error("Liveness period has expired \u2014 assertion can no longer be disputed");
10531
+ }
10532
+ const currentAllowance = await this.publicClient.readContract({
10533
+ address: currency,
10534
+ abi: erc20Abi,
10535
+ functionName: "allowance",
10536
+ args: [accountAddress, oracleAddress]
10537
+ });
10538
+ if (currentAllowance < bondAmount && autoApprove) {
10539
+ const approveHash = await wallet.writeContract({
10540
+ address: currency,
10541
+ abi: erc20Abi,
10542
+ functionName: "approve",
10543
+ args: [oracleAddress, bondAmount],
10544
+ account,
10545
+ chain: this.config.chain
10546
+ });
10547
+ await this.publicClient.waitForTransactionReceipt({
10548
+ hash: approveHash,
10549
+ confirmations: 2
10550
+ });
10551
+ } else if (currentAllowance < bondAmount) {
10552
+ throw new Error(
10553
+ `Insufficient bond currency allowance for oracle. Required: ${bondAmount.toString()}, Current: ${currentAllowance.toString()}.`
10554
+ );
10555
+ }
10556
+ const balance = await this.publicClient.readContract({
10557
+ address: currency,
10558
+ abi: erc20Abi,
10559
+ functionName: "balanceOf",
10560
+ args: [accountAddress]
10561
+ });
10562
+ if (balance < bondAmount) {
10563
+ throw new Error(
10564
+ `Insufficient bond currency balance. Required: ${bondAmount.toString()}, Have: ${balance.toString()}`
10565
+ );
10566
+ }
10567
+ const { request } = await this.publicClient.simulateContract({
10568
+ address: oracleAddress,
10569
+ abi: UmaOracle_default,
10570
+ functionName: "disputeAssertion",
10571
+ args: [params.assertionId, accountAddress],
10572
+ account
10573
+ });
10574
+ return wallet.writeContract(request);
10575
+ }
10500
10576
  /**
10501
10577
  * Report resolution after UMA settlement
10502
10578
  */
@@ -10712,7 +10788,9 @@ var UmaModule = class extends BaseModule {
10712
10788
  expirationTime,
10713
10789
  canSettle: currentTime >= expirationTime,
10714
10790
  disputer: assertion.disputer,
10715
- isDisputed: assertion.disputer !== "0x0000000000000000000000000000000000000000"
10791
+ isDisputed: assertion.disputer !== "0x0000000000000000000000000000000000000000",
10792
+ currency: assertion.currency,
10793
+ bond: BigInt(assertion.bond)
10716
10794
  };
10717
10795
  }
10718
10796
  /**