@gvnrdao/dh-sdk 0.0.248 → 0.0.251

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
@@ -18805,7 +18805,7 @@ var require_wrappers = __commonJS({
18805
18805
  }
18806
18806
  };
18807
18807
  exports.ContractTransactionReceipt = ContractTransactionReceipt2;
18808
- var ContractTransactionResponse2 = class extends provider_js_1.TransactionResponse {
18808
+ var ContractTransactionResponse3 = class extends provider_js_1.TransactionResponse {
18809
18809
  #iface;
18810
18810
  /**
18811
18811
  * @_ignore:
@@ -18831,7 +18831,7 @@ var require_wrappers = __commonJS({
18831
18831
  return new ContractTransactionReceipt2(this.#iface, this.provider, receipt);
18832
18832
  }
18833
18833
  };
18834
- exports.ContractTransactionResponse = ContractTransactionResponse2;
18834
+ exports.ContractTransactionResponse = ContractTransactionResponse3;
18835
18835
  var ContractUnknownEventPayload2 = class extends index_js_1.EventPayload {
18836
18836
  /**
18837
18837
  * The log with no matching events.
@@ -31904,7 +31904,7 @@ ${errorReport}`);
31904
31904
  }
31905
31905
  init_debug_logger();
31906
31906
  init_session_signature_cache();
31907
- var import_ethers12 = require_lib2();
31907
+ var import_ethers13 = require_lib2();
31908
31908
  var ACTIVE_LOAN_LIQUIDATION_THRESHOLD_BPS = 13e3;
31909
31909
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
31910
31910
  var GRACE_PERIOD_DAYS = 30;
@@ -34221,12 +34221,12 @@ ${errorReport}`);
34221
34221
  }
34222
34222
  async function executeVaultSnapshot(params) {
34223
34223
  global.ethers = {
34224
- ...import_ethers12.ethers,
34224
+ ...import_ethers13.ethers,
34225
34225
  providers: {
34226
- StaticJsonRpcProvider: import_ethers12.ethers.JsonRpcProvider
34226
+ StaticJsonRpcProvider: import_ethers13.ethers.JsonRpcProvider
34227
34227
  },
34228
- Contract: import_ethers12.ethers.Contract,
34229
- utils: import_ethers12.ethers
34228
+ Contract: import_ethers13.ethers.Contract,
34229
+ utils: import_ethers13.ethers
34230
34230
  // v6 moved utils to top level
34231
34231
  };
34232
34232
  global.Lit = {
@@ -34414,7 +34414,7 @@ var init_deployment_addresses = __esm({
34414
34414
  AdminModule: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
34415
34415
  PositionManagerViews: "0x3b970E41a0668508B4B2ACb83653b2A402F745AE",
34416
34416
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
34417
- OperationAuthorizationRegistry: "0xb295050EBCE12aD5f228bB2C4C31fCb24a79257C",
34417
+ OperationAuthorizationRegistry: "0x75f36E772df9616d40b02092642744D6fd702Df8",
34418
34418
  PKPValidation: "0xC8Ca02238fbCDAEbE6dbF804461D43F46F9406F4",
34419
34419
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
34420
34420
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
@@ -34428,18 +34428,18 @@ var init_deployment_addresses = __esm({
34428
34428
  },
34429
34429
  upgraded: {
34430
34430
  PositionManager: {
34431
- previousImplementation: "0xc7Bc4ead66D24C0a4dCe088176F0fC8DF54579d4",
34432
- newImplementation: "0x5492b2cE6138c1750BDD8DbB15Dc0ea00A5CF241",
34433
- upgradedAt: "2026-05-14T18:44:37.112Z",
34431
+ previousImplementation: "0x5492b2cE6138c1750BDD8DbB15Dc0ea00A5CF241",
34432
+ newImplementation: "0x623f3bDff8830d2161D3b5D42d38b39697c65eBE",
34433
+ upgradedAt: "2026-05-15T10:41:01.767Z",
34434
34434
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34435
34435
  reason: "Shared upgrade script: PositionManager implementation update"
34436
34436
  },
34437
34437
  LoanOperationsManagerModule: {
34438
- previousImplementation: "0x1db353Dad5818e00F073e4F73f66B6028Ee71DDC",
34439
- newImplementation: "0x3C1d7887858f106e43aa48bBF0D86C6EBA979980",
34440
- upgradedAt: "2026-05-14T16:24:49.712Z",
34438
+ previousImplementation: "0x3C1d7887858f106e43aa48bBF0D86C6EBA979980",
34439
+ newImplementation: "0xdEf0A042670834369d456c5fbE73ad2126008bD2",
34440
+ upgradedAt: "2026-05-15T10:37:26.881Z",
34441
34441
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34442
- reason: "Shared upgrade script: LoanOperationsManagerModule implementation update"
34442
+ reason: "Shared upgrade script: LoanOperationsManagerModule v1.4.0 (M-3 Chainlink cross-check)"
34443
34443
  },
34444
34444
  UCDController: {
34445
34445
  previousImplementation: "0x0F7c669c891C6534Bfef222B0A6bc9B71c256C58",
@@ -34505,9 +34505,9 @@ var init_deployment_addresses = __esm({
34505
34505
  reason: "Shared upgrade script: CollateralManagerModule implementation update"
34506
34506
  },
34507
34507
  LiquidationManagerModule: {
34508
- previousImplementation: "0x104a3bF95fC924f310a1e1C809fe2c8b71D08A1B",
34509
- newImplementation: "0x8E069E4A1deba9Ac021956F3cD771e9e65d756bb",
34510
- upgradedAt: "2026-05-14T16:12:24.858Z",
34508
+ previousImplementation: "0x8E069E4A1deba9Ac021956F3cD771e9e65d756bb",
34509
+ newImplementation: "0x15864ea3ECBe7E9FFa0a52b49c4dc7f258FA6300",
34510
+ upgradedAt: "2026-05-15T10:43:13.136Z",
34511
34511
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34512
34512
  reason: "Shared upgrade script: LiquidationManagerModule implementation update"
34513
34513
  },
@@ -34552,6 +34552,13 @@ var init_deployment_addresses = __esm({
34552
34552
  upgradedAt: "2026-05-14T16:30:13.519Z",
34553
34553
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34554
34554
  reason: "Shared upgrade script: PositionDelegateRegistry implementation update"
34555
+ },
34556
+ OperationAuthorizationRegistry: {
34557
+ previousImplementation: "0x982466844AfaBb4aCd8010e03330E8a38369F117",
34558
+ newImplementation: "0x9f8072d4672d643e39d8638478e900Fea1f2c81D",
34559
+ upgradedAt: "2026-05-15T08:49:01.387Z",
34560
+ upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34561
+ reason: "Shared upgrade script: OperationAuthorizationRegistry implementation update"
34555
34562
  }
34556
34563
  },
34557
34564
  history: {
@@ -34602,7 +34609,7 @@ var init_deployment_addresses = __esm({
34602
34609
  PKP_VALIDATION_REGISTRY: "0xC8Ca02238fbCDAEbE6dbF804461D43F46F9406F4",
34603
34610
  PKP_VALIDATION_CID_V1: "0x1220246b43f71828ed1cfdc455b6bd4fd9e7382251ea634589f8da9b12f61d40cd51",
34604
34611
  PKP_ETH_ADDRESS: "0x9624C46073E1d1F5AB975c67Fc899536d599bb57",
34605
- OPERATION_AUTHORIZATION_REGISTRY: "0xb295050EBCE12aD5f228bB2C4C31fCb24a79257C",
34612
+ OPERATION_AUTHORIZATION_REGISTRY: "0x75f36E772df9616d40b02092642744D6fd702Df8",
34606
34613
  UCD_MINT_VALIDATOR_ADDRESS: "0x4D9299055093938d0CD2F26C42A87260CB50adD8",
34607
34614
  UCD_MINT_VALIDATOR_VERSION: 1,
34608
34615
  BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0x7b9316cAA00B257F7CE30F7F6979bd6867BA9eE2",
@@ -34620,12 +34627,12 @@ var init_deployment_addresses = __esm({
34620
34627
  CIRCUIT_BREAKER_MODULE: "0x3D0B2cAE481821E57BA9CC3807bCC0d0D7F18bd8",
34621
34628
  ADMIN_MODULE: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
34622
34629
  UCD_CONTROLLER_IMPL: "0x9AFE20da679EA9877893c4A991c8087caE5F7e4C",
34623
- LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0x3C1d7887858f106e43aa48bBF0D86C6EBA979980",
34630
+ LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0xdEf0A042670834369d456c5fbE73ad2126008bD2",
34624
34631
  TERM_MANAGER_MODULE_IMPL: "0x309CE239A87ffFB31d4C720804e9908E482d4f10",
34625
34632
  CIRCUIT_BREAKER_MODULE_IMPL: "0x24C345841360EEe81C944c00e0E5c8f6CCc53C00",
34626
34633
  ADMIN_MODULE_IMPL: "0x70a500896A26E4e7CDb56886b9e6438e39DB5ae4",
34627
34634
  POSITION_MANAGER_VIEWS_IMPL: "0x92311E348730e30237cbF0a58FaD704F8f2B8101",
34628
- POSITION_MANAGER_IMPL: "0x5492b2cE6138c1750BDD8DbB15Dc0ea00A5CF241",
34635
+ POSITION_MANAGER_IMPL: "0x623f3bDff8830d2161D3b5D42d38b39697c65eBE",
34629
34636
  SIMPLE_PSM_V2: "0x19EcF7BA26e054fd4Ff06009A03070103dbBB058",
34630
34637
  SIMPLE_PSM_V2_IMPL: "0x0728434d86532FD67A4a7227958654C029b333F6",
34631
34638
  UCD_TOKEN_IMPL: "0x65c23B6fB5331ACeeC2d82328c6de7dB6b62bB65",
@@ -34651,7 +34658,8 @@ var init_deployment_addresses = __esm({
34651
34658
  POSITION_DELEGATE_REGISTRY_IMPL: "0xAE227De03D5aeDC870d6e096D9C6652E001a92aF",
34652
34659
  AGENT_MODULE: "0xefb8C29C1e7e92ed7d81a52dbedaed74e37fe380",
34653
34660
  FEE_RECIPIENT_REGISTRY: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
34654
- FEE_RECIPIENT_REGISTRY_IMPL: "0x974a0f64d572a4F4e1395aaeB22d1c2685D22459"
34661
+ FEE_RECIPIENT_REGISTRY_IMPL: "0x974a0f64d572a4F4e1395aaeB22d1c2685D22459",
34662
+ OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0x982466844AfaBb4aCd8010e03330E8a38369F117"
34655
34663
  }
34656
34664
  };
34657
34665
  SEPOLIA_CONTRACTS = {
@@ -34668,7 +34676,7 @@ var init_deployment_addresses = __esm({
34668
34676
  AdminModule: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
34669
34677
  PositionManagerViews: "0x3b970E41a0668508B4B2ACb83653b2A402F745AE",
34670
34678
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
34671
- OperationAuthorizationRegistry: "0xb295050EBCE12aD5f228bB2C4C31fCb24a79257C",
34679
+ OperationAuthorizationRegistry: "0x75f36E772df9616d40b02092642744D6fd702Df8",
34672
34680
  PKPValidation: "0xC8Ca02238fbCDAEbE6dbF804461D43F46F9406F4",
34673
34681
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
34674
34682
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
@@ -48467,6 +48475,109 @@ function _ContractBase() {
48467
48475
  var Contract = class extends _ContractBase() {
48468
48476
  };
48469
48477
 
48478
+ // node_modules/ethers/lib.esm/contract/factory.js
48479
+ var ContractFactory = class _ContractFactory {
48480
+ /**
48481
+ * The Contract Interface.
48482
+ */
48483
+ interface;
48484
+ /**
48485
+ * The Contract deployment bytecode. Often called the initcode.
48486
+ */
48487
+ bytecode;
48488
+ /**
48489
+ * The ContractRunner to deploy the Contract as.
48490
+ */
48491
+ runner;
48492
+ /**
48493
+ * Create a new **ContractFactory** with %%abi%% and %%bytecode%%,
48494
+ * optionally connected to %%runner%%.
48495
+ *
48496
+ * The %%bytecode%% may be the ``bytecode`` property within the
48497
+ * standard Solidity JSON output.
48498
+ */
48499
+ constructor(abi, bytecode, runner) {
48500
+ const iface = Interface.from(abi);
48501
+ if (bytecode instanceof Uint8Array) {
48502
+ bytecode = hexlify(getBytes(bytecode));
48503
+ } else {
48504
+ if (typeof bytecode === "object") {
48505
+ bytecode = bytecode.object;
48506
+ }
48507
+ if (!bytecode.startsWith("0x")) {
48508
+ bytecode = "0x" + bytecode;
48509
+ }
48510
+ bytecode = hexlify(getBytes(bytecode));
48511
+ }
48512
+ defineProperties(this, {
48513
+ bytecode,
48514
+ interface: iface,
48515
+ runner: runner || null
48516
+ });
48517
+ }
48518
+ attach(target) {
48519
+ return new BaseContract(target, this.interface, this.runner);
48520
+ }
48521
+ /**
48522
+ * Resolves to the transaction to deploy the contract, passing %%args%%
48523
+ * into the constructor.
48524
+ */
48525
+ async getDeployTransaction(...args) {
48526
+ let overrides = {};
48527
+ const fragment = this.interface.deploy;
48528
+ if (fragment.inputs.length + 1 === args.length) {
48529
+ overrides = await copyOverrides(args.pop());
48530
+ }
48531
+ if (fragment.inputs.length !== args.length) {
48532
+ throw new Error("incorrect number of arguments to constructor");
48533
+ }
48534
+ const resolvedArgs = await resolveArgs(this.runner, fragment.inputs, args);
48535
+ const data = concat([this.bytecode, this.interface.encodeDeploy(resolvedArgs)]);
48536
+ return Object.assign({}, overrides, { data });
48537
+ }
48538
+ /**
48539
+ * Resolves to the Contract deployed by passing %%args%% into the
48540
+ * constructor.
48541
+ *
48542
+ * This will resolve to the Contract before it has been deployed to the
48543
+ * network, so the [[BaseContract-waitForDeployment]] should be used before
48544
+ * sending any transactions to it.
48545
+ */
48546
+ async deploy(...args) {
48547
+ const tx = await this.getDeployTransaction(...args);
48548
+ assert(this.runner && typeof this.runner.sendTransaction === "function", "factory runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
48549
+ operation: "sendTransaction"
48550
+ });
48551
+ const sentTx = await this.runner.sendTransaction(tx);
48552
+ const address = getCreateAddress(sentTx);
48553
+ return new BaseContract(address, this.interface, this.runner, sentTx);
48554
+ }
48555
+ /**
48556
+ * Return a new **ContractFactory** with the same ABI and bytecode,
48557
+ * but connected to %%runner%%.
48558
+ */
48559
+ connect(runner) {
48560
+ return new _ContractFactory(this.interface, this.bytecode, runner);
48561
+ }
48562
+ /**
48563
+ * Create a new **ContractFactory** from the standard Solidity JSON output.
48564
+ */
48565
+ static fromSolidity(output, runner) {
48566
+ assertArgument(output != null, "bad compiler output", "output", output);
48567
+ if (typeof output === "string") {
48568
+ output = JSON.parse(output);
48569
+ }
48570
+ const abi = output.abi;
48571
+ let bytecode = "";
48572
+ if (output.bytecode) {
48573
+ bytecode = output.bytecode;
48574
+ } else if (output.evm && output.evm.bytecode) {
48575
+ bytecode = output.evm.bytecode;
48576
+ }
48577
+ return new this(abi, bytecode, runner);
48578
+ }
48579
+ };
48580
+
48470
48581
  // node_modules/ethers/lib.esm/providers/ens-resolver.js
48471
48582
  function getIpfsLink(link) {
48472
48583
  if (link.match(/^ipfs:\/\/ipfs\//i)) {
@@ -56065,7 +56176,8 @@ var LoanQuery = class {
56065
56176
  statusUpdates: events.statusUpdates.length,
56066
56177
  liquidated: !!events.liquidation,
56067
56178
  mints: events.mints.length,
56068
- feeDistributions: events.feeDistributions.length
56179
+ renewals: events.renewals.length,
56180
+ withdrawals: events.withdrawals.length
56069
56181
  });
56070
56182
  }
56071
56183
  return events;
@@ -58185,6 +58297,7 @@ var DiamondHandsGraph = class {
58185
58297
  orderDirection = "desc"
58186
58298
  } = filter || {};
58187
58299
  const shouldQuery = {
58300
+ positionCreated: !eventTypes || eventTypes.includes("positionCreated"),
58188
58301
  payment: !eventTypes || eventTypes.includes("payment"),
58189
58302
  status: !eventTypes || eventTypes.includes("status"),
58190
58303
  liquidation: !eventTypes || eventTypes.includes("liquidation"),
@@ -58194,13 +58307,7 @@ var DiamondHandsGraph = class {
58194
58307
  operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
58195
58308
  mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
58196
58309
  burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
58197
- collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
58198
- circuitBreaker: !eventTypes || eventTypes.includes("circuitBreaker"),
58199
- termFeeUpdate: !eventTypes || eventTypes.includes("termFeeUpdate"),
58200
- loanProtocolParamUpdate: !eventTypes || eventTypes.includes("loanProtocolParamUpdate"),
58201
- maxLoanValueUpdate: !eventTypes || eventTypes.includes("maxLoanValueUpdate"),
58202
- btcPriceBoundsUpdate: !eventTypes || eventTypes.includes("btcPriceBoundsUpdate"),
58203
- perUserMintLimitUpdate: !eventTypes || eventTypes.includes("perUserMintLimitUpdate")
58310
+ collateralEvent: !eventTypes || eventTypes.includes("collateralEvent")
58204
58311
  };
58205
58312
  const buildPositionWhereClause = () => {
58206
58313
  const conditions = [`position: "${positionId.toLowerCase()}"`];
@@ -58214,18 +58321,6 @@ var DiamondHandsGraph = class {
58214
58321
  conditions.push(`blockNumber_lte: "${toBlock}"`);
58215
58322
  return `where: { ${conditions.join(", ")} }`;
58216
58323
  };
58217
- const buildProtocolWhereClause = () => {
58218
- const conditions = [];
58219
- if (fromTimestamp)
58220
- conditions.push(`timestamp_gte: "${fromTimestamp}"`);
58221
- if (toTimestamp)
58222
- conditions.push(`timestamp_lte: "${toTimestamp}"`);
58223
- if (fromBlock)
58224
- conditions.push(`blockNumber_gte: "${fromBlock}"`);
58225
- if (toBlock)
58226
- conditions.push(`blockNumber_lte: "${toBlock}"`);
58227
- return conditions.length > 0 ? `where: { ${conditions.join(", ")} }` : "";
58228
- };
58229
58324
  const query = `
58230
58325
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
58231
58326
  position(id: $positionId) {
@@ -58235,7 +58330,6 @@ var DiamondHandsGraph = class {
58235
58330
  first: $limit,
58236
58331
  orderBy: timestamp,
58237
58332
  orderDirection: $orderDirection
58238
- ${buildProtocolWhereClause()}
58239
58333
  ) {
58240
58334
  id
58241
58335
  payer { id }
@@ -58247,15 +58341,13 @@ var DiamondHandsGraph = class {
58247
58341
  logIndex
58248
58342
  newDebt
58249
58343
  newCollateralRatio
58250
- }
58251
- ` : ""}
58344
+ }` : ""}
58252
58345
 
58253
58346
  ${shouldQuery.status ? `
58254
58347
  statusUpdates(
58255
58348
  first: $limit,
58256
58349
  orderBy: timestamp,
58257
58350
  orderDirection: $orderDirection
58258
- ${buildProtocolWhereClause()}
58259
58351
  ) {
58260
58352
  id
58261
58353
  oldStatus
@@ -58264,8 +58356,7 @@ var DiamondHandsGraph = class {
58264
58356
  timestamp
58265
58357
  blockNumber
58266
58358
  transactionHash
58267
- }
58268
- ` : ""}
58359
+ }` : ""}
58269
58360
 
58270
58361
  ${shouldQuery.liquidation ? `
58271
58362
  liquidation {
@@ -58279,8 +58370,7 @@ var DiamondHandsGraph = class {
58279
58370
  commitHash
58280
58371
  commitTimestamp
58281
58372
  revealDelay
58282
- }
58283
- ` : ""}
58373
+ }` : ""}
58284
58374
 
58285
58375
  ${shouldQuery.withdrawal ? `
58286
58376
  withdrawals(
@@ -58296,8 +58386,7 @@ var DiamondHandsGraph = class {
58296
58386
  blockNumber
58297
58387
  transactionHash
58298
58388
  logIndex
58299
- }
58300
- ` : ""}
58389
+ }` : ""}
58301
58390
 
58302
58391
  ${shouldQuery.renewal ? `
58303
58392
  renewals(
@@ -58313,8 +58402,7 @@ var DiamondHandsGraph = class {
58313
58402
  blockNumber
58314
58403
  transactionHash
58315
58404
  logIndex
58316
- }
58317
- ` : ""}
58405
+ }` : ""}
58318
58406
 
58319
58407
  ${shouldQuery.operationFailure ? `
58320
58408
  operationFailures(
@@ -58331,8 +58419,7 @@ var DiamondHandsGraph = class {
58331
58419
  blockNumber
58332
58420
  transactionHash
58333
58421
  logIndex
58334
- }
58335
- ` : ""}
58422
+ }` : ""}
58336
58423
 
58337
58424
  ${shouldQuery.mintRequest ? `
58338
58425
  mintRequests(
@@ -58354,8 +58441,7 @@ var DiamondHandsGraph = class {
58354
58441
  blockNumber
58355
58442
  transactionHash
58356
58443
  logIndex
58357
- }
58358
- ` : ""}
58444
+ }` : ""}
58359
58445
 
58360
58446
  ${shouldQuery.burnRequest ? `
58361
58447
  burnRequests(
@@ -58374,10 +58460,27 @@ var DiamondHandsGraph = class {
58374
58460
  blockNumber
58375
58461
  transactionHash
58376
58462
  logIndex
58377
- }
58378
- ` : ""}
58463
+ }` : ""}
58379
58464
  }
58380
58465
 
58466
+ ${shouldQuery.positionCreated ? `
58467
+ positionCreatedEvents(
58468
+ ${buildPositionWhereClause()}
58469
+ first: 1,
58470
+ orderBy: timestamp,
58471
+ orderDirection: asc
58472
+ ) {
58473
+ id
58474
+ pkpId
58475
+ borrower { id }
58476
+ requestedCollateralRatio
58477
+ selectedTerm
58478
+ expiryAt
58479
+ timestamp
58480
+ blockNumber
58481
+ transactionHash
58482
+ }` : ""}
58483
+
58381
58484
  ${shouldQuery.mint ? `
58382
58485
  ucdmintEvents(
58383
58486
  ${buildPositionWhereClause()}
@@ -58393,8 +58496,7 @@ var DiamondHandsGraph = class {
58393
58496
  timestamp
58394
58497
  blockNumber
58395
58498
  transactionHash
58396
- }
58397
- ` : ""}
58499
+ }` : ""}
58398
58500
 
58399
58501
  ${shouldQuery.collateralEvent ? `
58400
58502
  collateralEvents(
@@ -58412,116 +58514,7 @@ var DiamondHandsGraph = class {
58412
58514
  blockNumber
58413
58515
  transactionHash
58414
58516
  logIndex
58415
- }
58416
- ` : ""}
58417
-
58418
- ${shouldQuery.circuitBreaker ? `
58419
- circuitBreakerEvents(
58420
- ${buildProtocolWhereClause()}
58421
- first: $limit,
58422
- orderBy: timestamp,
58423
- orderDirection: $orderDirection
58424
- ) {
58425
- id
58426
- isActivated
58427
- admin
58428
- reason
58429
- timestamp
58430
- blockNumber
58431
- transactionHash
58432
- }
58433
- ` : ""}
58434
-
58435
- ${shouldQuery.termFeeUpdate ? `
58436
- termFeeUpdates(
58437
- ${buildProtocolWhereClause()}
58438
- first: $limit,
58439
- orderBy: timestamp,
58440
- orderDirection: $orderDirection
58441
- ) {
58442
- id
58443
- term { id }
58444
- oldOriginationFee
58445
- newOriginationFee
58446
- oldExtensionFee
58447
- newExtensionFee
58448
- timestamp
58449
- blockNumber
58450
- transactionHash
58451
- }
58452
- ` : ""}
58453
-
58454
- ${shouldQuery.loanProtocolParamUpdate ? `
58455
- loanProtocolParamUpdates(
58456
- ${buildProtocolWhereClause()}
58457
- first: $limit,
58458
- orderBy: timestamp,
58459
- orderDirection: $orderDirection
58460
- ) {
58461
- id
58462
- oldLiquidationThreshold
58463
- newLiquidationThreshold
58464
- oldMinimumLoanValueUcd
58465
- newMinimumLoanValueUcd
58466
- caller
58467
- timestamp
58468
- blockNumber
58469
- transactionHash
58470
- }
58471
- ` : ""}
58472
-
58473
- ${shouldQuery.maxLoanValueUpdate ? `
58474
- maxLoanValueUpdates(
58475
- ${buildProtocolWhereClause()}
58476
- first: $limit,
58477
- orderBy: timestamp,
58478
- orderDirection: $orderDirection
58479
- ) {
58480
- id
58481
- oldValueUcd
58482
- newValueUcd
58483
- caller
58484
- timestamp
58485
- blockNumber
58486
- transactionHash
58487
- }
58488
- ` : ""}
58489
-
58490
- ${shouldQuery.btcPriceBoundsUpdate ? `
58491
- btcPriceBoundsUpdates(
58492
- ${buildProtocolWhereClause()}
58493
- first: $limit,
58494
- orderBy: timestamp,
58495
- orderDirection: $orderDirection
58496
- ) {
58497
- id
58498
- oldMinBound
58499
- newMinBound
58500
- oldMaxBound
58501
- newMaxBound
58502
- caller
58503
- timestamp
58504
- blockNumber
58505
- transactionHash
58506
- }
58507
- ` : ""}
58508
-
58509
- ${shouldQuery.perUserMintLimitUpdate ? `
58510
- perUserDailyMintLimitUpdates(
58511
- ${buildProtocolWhereClause()}
58512
- first: $limit,
58513
- orderBy: timestamp,
58514
- orderDirection: $orderDirection
58515
- ) {
58516
- id
58517
- oldLimit
58518
- newLimit
58519
- updatedBy
58520
- timestamp
58521
- blockNumber
58522
- transactionHash
58523
- }
58524
- ` : ""}
58517
+ }` : ""}
58525
58518
  }
58526
58519
  `;
58527
58520
  const variables = {
@@ -58530,6 +58523,19 @@ var DiamondHandsGraph = class {
58530
58523
  orderDirection
58531
58524
  };
58532
58525
  const result = await this.client.execute(query, variables);
58526
+ const rawCreated = result.positionCreatedEvents?.[0];
58527
+ const positionCreated = rawCreated ? {
58528
+ id: rawCreated.id,
58529
+ positionId,
58530
+ pkpId: rawCreated.pkpId,
58531
+ borrower: rawCreated.borrower.id,
58532
+ requestedCollateralRatio: rawCreated.requestedCollateralRatio,
58533
+ selectedTerm: rawCreated.selectedTerm,
58534
+ expiryAt: rawCreated.expiryAt,
58535
+ timestamp: rawCreated.timestamp,
58536
+ blockNumber: rawCreated.blockNumber,
58537
+ transactionHash: rawCreated.transactionHash
58538
+ } : void 0;
58533
58539
  const payments = (result.position?.payments || []).map(
58534
58540
  (p) => ({
58535
58541
  id: p.id,
@@ -58590,17 +58596,19 @@ var DiamondHandsGraph = class {
58590
58596
  transactionHash: w.transactionHash,
58591
58597
  logIndex: w.logIndex
58592
58598
  }));
58593
- const renewals = (result.position?.renewals || []).map((r) => ({
58594
- id: r.id,
58595
- positionId,
58596
- extensionTerm: r.extensionTerm,
58597
- extensionFee: r.extensionFee,
58598
- newExpiryDate: r.newExpiryDate,
58599
- timestamp: r.timestamp,
58600
- blockNumber: r.blockNumber,
58601
- transactionHash: r.transactionHash,
58602
- logIndex: r.logIndex
58603
- }));
58599
+ const renewals = (result.position?.renewals || []).map(
58600
+ (r) => ({
58601
+ id: r.id,
58602
+ positionId,
58603
+ extensionTerm: r.extensionTerm,
58604
+ extensionFee: r.extensionFee,
58605
+ newExpiryDate: r.newExpiryDate,
58606
+ timestamp: r.timestamp,
58607
+ blockNumber: r.blockNumber,
58608
+ transactionHash: r.transactionHash,
58609
+ logIndex: r.logIndex
58610
+ })
58611
+ );
58604
58612
  const operationFailures = (result.position?.operationFailures || []).map((o) => ({
58605
58613
  id: o.id,
58606
58614
  positionId,
@@ -58656,69 +58664,10 @@ var DiamondHandsGraph = class {
58656
58664
  transactionHash: c.transactionHash,
58657
58665
  logIndex: c.logIndex
58658
58666
  }));
58659
- const circuitBreakerEvents = (result.circuitBreakerEvents || []).map((cb) => ({
58660
- id: cb.id,
58661
- isActivated: cb.isActivated,
58662
- admin: cb.admin,
58663
- reason: cb.reason,
58664
- timestamp: cb.timestamp,
58665
- blockNumber: cb.blockNumber,
58666
- transactionHash: cb.transactionHash
58667
- }));
58668
- const termFeeUpdates = (result.termFeeUpdates || []).map((t) => ({
58669
- id: t.id,
58670
- termMonths: t.term.id,
58671
- oldOriginationFee: t.oldOriginationFee,
58672
- newOriginationFee: t.newOriginationFee,
58673
- oldExtensionFee: t.oldExtensionFee,
58674
- newExtensionFee: t.newExtensionFee,
58675
- timestamp: t.timestamp,
58676
- blockNumber: t.blockNumber,
58677
- transactionHash: t.transactionHash
58678
- }));
58679
- const loanProtocolParamUpdates = (result.loanProtocolParamUpdates || []).map((p) => ({
58680
- id: p.id,
58681
- oldLiquidationThreshold: p.oldLiquidationThreshold,
58682
- newLiquidationThreshold: p.newLiquidationThreshold,
58683
- oldMinimumLoanValueUcd: p.oldMinimumLoanValueUcd,
58684
- newMinimumLoanValueUcd: p.newMinimumLoanValueUcd,
58685
- caller: p.caller,
58686
- timestamp: p.timestamp,
58687
- blockNumber: p.blockNumber,
58688
- transactionHash: p.transactionHash
58689
- }));
58690
- const maxLoanValueUpdates = (result.maxLoanValueUpdates || []).map((m) => ({
58691
- id: m.id,
58692
- oldValueUcd: m.oldValueUcd,
58693
- newValueUcd: m.newValueUcd,
58694
- caller: m.caller,
58695
- timestamp: m.timestamp,
58696
- blockNumber: m.blockNumber,
58697
- transactionHash: m.transactionHash
58698
- }));
58699
- const btcPriceBoundsUpdates = (result.btcPriceBoundsUpdates || []).map((b2) => ({
58700
- id: b2.id,
58701
- oldMinBound: b2.oldMinBound,
58702
- newMinBound: b2.newMinBound,
58703
- oldMaxBound: b2.oldMaxBound,
58704
- newMaxBound: b2.newMaxBound,
58705
- caller: b2.caller,
58706
- timestamp: b2.timestamp,
58707
- blockNumber: b2.blockNumber,
58708
- transactionHash: b2.transactionHash
58709
- }));
58710
- const perUserMintLimitUpdates = (result.perUserDailyMintLimitUpdates || []).map((p) => ({
58711
- id: p.id,
58712
- oldLimit: p.oldLimit,
58713
- newLimit: p.newLimit,
58714
- updatedBy: p.updatedBy,
58715
- timestamp: p.timestamp,
58716
- blockNumber: p.blockNumber,
58717
- transactionHash: p.transactionHash
58718
- }));
58719
- const totalEvents = payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + withdrawals.length + renewals.length + operationFailures.length + mintRequests.length + burnRequests.length + collateralEvents.length + circuitBreakerEvents.length + termFeeUpdates.length + loanProtocolParamUpdates.length + maxLoanValueUpdates.length + btcPriceBoundsUpdates.length + perUserMintLimitUpdates.length;
58667
+ const totalEvents = (positionCreated ? 1 : 0) + payments.length + statusUpdates.length + (liquidation ? 1 : 0) + mints.length + withdrawals.length + renewals.length + operationFailures.length + mintRequests.length + burnRequests.length + collateralEvents.length;
58720
58668
  return {
58721
58669
  positionId,
58670
+ positionCreated,
58722
58671
  payments,
58723
58672
  statusUpdates,
58724
58673
  liquidation,
@@ -58729,187 +58678,2378 @@ var DiamondHandsGraph = class {
58729
58678
  mintRequests,
58730
58679
  burnRequests,
58731
58680
  collateralEvents,
58732
- circuitBreakerEvents,
58733
- termFeeUpdates,
58734
- loanProtocolParamUpdates,
58735
- maxLoanValueUpdates,
58736
- btcPriceBoundsUpdates,
58737
- perUserMintLimitUpdates,
58738
- feeDistributions: [],
58739
58681
  totalEvents
58740
58682
  };
58741
58683
  }
58742
- };
58743
-
58744
- // src/modules/mock/mock-token-manager.module.ts
58745
- var MockTokenManager = class {
58746
- config;
58747
- constructor(config) {
58748
- this.config = config;
58749
- if (this.isProductionNetwork()) {
58750
- log.warn("\u26A0\uFE0F MockTokenManager initialized on production network", {
58751
- network: config.network
58752
- });
58753
- }
58754
- }
58684
+ // ============================================================================
58685
+ // Protocol-wide Events
58686
+ // ============================================================================
58755
58687
  /**
58756
- * Mint mock BTC tokens
58688
+ * Retrieve events across the full protocol, optionally narrowed to a position.
58689
+ * Returns a merged, sorted discriminated-union timeline suitable for explorers.
58757
58690
  *
58758
- * @param amount - Amount to mint in satoshis
58759
- * @param recipient - Recipient address
58760
- * @returns Transaction result
58691
+ * Protocol-global admin events (circuit breaker, term fees, etc.) are included
58692
+ * by default; pass `kinds` to restrict.
58761
58693
  */
58762
- async mintMockBTC(amount, recipient) {
58763
- if (this.config.debug) {
58764
- log.info("\u{1FA99} Minting mock BTC", {
58765
- amount: amount.toString(),
58766
- recipient
58767
- });
58694
+ async getAllEvents(filter) {
58695
+ const {
58696
+ positionId,
58697
+ kinds,
58698
+ fromTimestamp,
58699
+ toTimestamp,
58700
+ fromBlock,
58701
+ toBlock,
58702
+ limit = 1e3,
58703
+ orderDirection = "desc"
58704
+ } = filter || {};
58705
+ const includeKind = (k) => !kinds || kinds.includes(k);
58706
+ const buildTimeWhereClause = (extra = []) => {
58707
+ const conditions = [...extra];
58708
+ if (fromTimestamp)
58709
+ conditions.push(`timestamp_gte: "${fromTimestamp}"`);
58710
+ if (toTimestamp)
58711
+ conditions.push(`timestamp_lte: "${toTimestamp}"`);
58712
+ if (fromBlock)
58713
+ conditions.push(`blockNumber_gte: "${fromBlock}"`);
58714
+ if (toBlock)
58715
+ conditions.push(`blockNumber_lte: "${toBlock}"`);
58716
+ return conditions.length > 0 ? `where: { ${conditions.join(", ")} }` : "";
58717
+ };
58718
+ const positionFilter = positionId ? [`position: "${positionId.toLowerCase()}"`] : [];
58719
+ const query = `
58720
+ query GetAllEvents($limit: Int!, $orderDirection: OrderDirection!) {
58721
+
58722
+ ${includeKind("position") ? `
58723
+ positionCreatedEvents(
58724
+ ${buildTimeWhereClause(positionFilter)}
58725
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58726
+ ) {
58727
+ id
58728
+ position { id }
58729
+ pkpId
58730
+ borrower { id }
58731
+ requestedCollateralRatio
58732
+ selectedTerm
58733
+ expiryAt
58734
+ timestamp
58735
+ blockNumber
58736
+ transactionHash
58737
+ }
58738
+ positionStatusUpdates: positionStatusUpdates(
58739
+ ${buildTimeWhereClause(positionFilter)}
58740
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58741
+ ) {
58742
+ id
58743
+ position { id }
58744
+ oldStatus
58745
+ newStatus
58746
+ timestamp
58747
+ blockNumber
58748
+ transactionHash
58749
+ }
58750
+ renewalEvents: renewalEvents(
58751
+ ${buildTimeWhereClause(positionFilter)}
58752
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58753
+ ) {
58754
+ id
58755
+ position { id }
58756
+ extensionTerm
58757
+ extensionFee
58758
+ newExpiryDate
58759
+ timestamp
58760
+ blockNumber
58761
+ transactionHash
58762
+ }` : ""}
58763
+
58764
+ ${includeKind("payment") ? `
58765
+ payments(
58766
+ ${buildTimeWhereClause(positionFilter)}
58767
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58768
+ ) {
58769
+ id
58770
+ position { id }
58771
+ payer { id }
58772
+ amount
58773
+ type
58774
+ newDebt
58775
+ newCollateralRatio
58776
+ timestamp
58777
+ blockNumber
58778
+ transactionHash
58779
+ }` : ""}
58780
+
58781
+ ${includeKind("liquidation") ? `
58782
+ liquidations(
58783
+ ${buildTimeWhereClause(positionFilter)}
58784
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58785
+ ) {
58786
+ id
58787
+ position { id }
58788
+ liquidator
58789
+ liquidatedAmount
58790
+ collateralSeized
58791
+ timestamp
58792
+ blockNumber
58793
+ transactionHash
58794
+ }` : ""}
58795
+
58796
+ ${includeKind("collateral") ? `
58797
+ collateralEvents(
58798
+ ${buildTimeWhereClause(positionFilter)}
58799
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58800
+ ) {
58801
+ id
58802
+ position { id }
58803
+ eventType
58804
+ networkFee
58805
+ remainingCollateral
58806
+ timestamp
58807
+ blockNumber
58808
+ transactionHash
58809
+ }` : ""}
58810
+
58811
+ ${includeKind("mint") ? `
58812
+ ucdmintEvents(
58813
+ ${buildTimeWhereClause(positionFilter)}
58814
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58815
+ ) {
58816
+ id
58817
+ position { id }
58818
+ amount
58819
+ minter { id }
58820
+ isCommunityMint
58821
+ timestamp
58822
+ blockNumber
58823
+ transactionHash
58824
+ }` : ""}
58825
+
58826
+ ${includeKind("withdrawal") ? `
58827
+ withdrawalEvents: withdrawalEvents(
58828
+ ${buildTimeWhereClause(positionFilter)}
58829
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58830
+ ) {
58831
+ id
58832
+ position { id }
58833
+ withdrawalAmount
58834
+ withdrawalAddress
58835
+ timestamp
58836
+ blockNumber
58837
+ transactionHash
58838
+ }` : ""}
58839
+
58840
+ ${includeKind("psm") ? `
58841
+ psmTransactions(
58842
+ ${buildTimeWhereClause()}
58843
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58844
+ ) {
58845
+ id
58846
+ type
58847
+ user
58848
+ stablecoinAmount
58849
+ ucdAmount
58850
+ timestamp
58851
+ blockNumber
58852
+ transactionHash
58853
+ }` : ""}
58854
+
58855
+ ${includeKind("admin") ? `
58856
+ circuitBreakerEvents(
58857
+ ${buildTimeWhereClause()}
58858
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58859
+ ) {
58860
+ id
58861
+ isActivated
58862
+ admin
58863
+ timestamp
58864
+ blockNumber
58865
+ transactionHash
58866
+ }
58867
+ termFeeUpdates(
58868
+ ${buildTimeWhereClause()}
58869
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58870
+ ) {
58871
+ id
58872
+ term { id }
58873
+ oldOriginationFee
58874
+ newOriginationFee
58875
+ timestamp
58876
+ blockNumber
58877
+ transactionHash
58878
+ }
58879
+ loanProtocolParamUpdates(
58880
+ ${buildTimeWhereClause()}
58881
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58882
+ ) {
58883
+ id
58884
+ newLiquidationThreshold
58885
+ newMinimumLoanValueUcd
58886
+ caller
58887
+ timestamp
58888
+ blockNumber
58889
+ transactionHash
58890
+ }
58891
+ maxLoanValueUpdates(
58892
+ ${buildTimeWhereClause()}
58893
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58894
+ ) {
58895
+ id
58896
+ newValueUcd
58897
+ caller
58898
+ timestamp
58899
+ blockNumber
58900
+ transactionHash
58901
+ }
58902
+ btcPriceBoundsUpdates(
58903
+ ${buildTimeWhereClause()}
58904
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58905
+ ) {
58906
+ id
58907
+ newMinBound
58908
+ newMaxBound
58909
+ caller
58910
+ timestamp
58911
+ blockNumber
58912
+ transactionHash
58913
+ }
58914
+ perUserDailyMintLimitUpdates(
58915
+ ${buildTimeWhereClause()}
58916
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58917
+ ) {
58918
+ id
58919
+ newLimit
58920
+ updatedBy
58921
+ timestamp
58922
+ blockNumber
58923
+ transactionHash
58924
+ }` : ""}
58925
+ }
58926
+ `;
58927
+ const result = await this.client.execute(query, {
58928
+ limit,
58929
+ orderDirection
58930
+ });
58931
+ const events = [];
58932
+ for (const e of result.positionCreatedEvents || []) {
58933
+ events.push({ kind: "position", subkind: "created", positionId: e.position.id, ...e });
58768
58934
  }
58769
- if (this.isProductionNetwork()) {
58770
- return failure(
58771
- new SDKError({
58772
- message: "Cannot mint mock tokens on production network",
58773
- category: "CONFIGURATION" /* CONFIGURATION */,
58774
- severity: "HIGH" /* HIGH */,
58775
- originalError: new Error("Production network detected")
58776
- })
58777
- );
58935
+ for (const e of result.positionStatusUpdates || []) {
58936
+ events.push({ kind: "position", subkind: "status", positionId: e.position.id, ...e });
58778
58937
  }
58779
- return tryCatchAsync(
58780
- async () => {
58781
- const signerResult = this.config.contractManager.getSigner();
58782
- if (!signerResult.success) {
58783
- throw signerResult.error;
58784
- }
58785
- throw new Error("Mock BTC contract not yet integrated");
58786
- },
58787
- (error) => new SDKError({
58788
- message: "Failed to mint mock BTC",
58789
- category: "CONTRACT" /* CONTRACT */,
58790
- severity: "MEDIUM" /* MEDIUM */,
58791
- originalError: error instanceof Error ? error : new Error(String(error)),
58792
- context: { amount: amount.toString(), recipient }
58793
- })
58794
- );
58795
- }
58796
- /**
58797
- * Approve mock BTC spending
58798
- *
58799
- * @param spender - Spender address
58800
- * @param amount - Amount to approve in satoshis
58801
- * @returns Transaction result
58802
- */
58803
- async approveMockBTC(spender, amount) {
58804
- if (this.config.debug) {
58805
- log.info("\u2705 Approving mock BTC spending", {
58806
- spender,
58807
- amount: amount.toString()
58808
- });
58938
+ for (const e of result.renewalEvents || []) {
58939
+ events.push({ kind: "position", subkind: "renewed", positionId: e.position.id, ...e });
58809
58940
  }
58810
- if (this.isProductionNetwork()) {
58811
- return failure(
58812
- new SDKError({
58813
- message: "Cannot approve mock tokens on production network",
58814
- category: "CONFIGURATION" /* CONFIGURATION */,
58815
- severity: "HIGH" /* HIGH */,
58816
- originalError: new Error("Production network detected")
58817
- })
58818
- );
58941
+ for (const e of result.payments || []) {
58942
+ events.push({ kind: "payment", positionId: e.position.id, ...e });
58819
58943
  }
58820
- return tryCatchAsync(
58821
- async () => {
58822
- const signerResult = this.config.contractManager.getSigner();
58823
- if (!signerResult.success) {
58824
- throw signerResult.error;
58825
- }
58826
- throw new Error("Mock BTC contract not yet integrated");
58827
- },
58828
- (error) => new SDKError({
58829
- message: "Failed to approve mock BTC",
58830
- category: "CONTRACT" /* CONTRACT */,
58831
- severity: "MEDIUM" /* MEDIUM */,
58832
- originalError: error instanceof Error ? error : new Error(String(error)),
58833
- context: { spender, amount: amount.toString() }
58834
- })
58835
- );
58836
- }
58837
- /**
58838
- * Get mock BTC balance
58839
- *
58840
- * @param address - Address to query
58841
- * @returns Balance in satoshis
58842
- */
58843
- async getMockBTCBalance(address) {
58844
- if (this.config.debug) {
58845
- log.info("\u{1F50D} Querying mock BTC balance", { address });
58944
+ for (const e of result.liquidations || []) {
58945
+ events.push({ kind: "liquidation", positionId: e.position.id, ...e });
58846
58946
  }
58847
- return tryCatchAsync(
58848
- async () => {
58849
- throw new Error("Mock BTC contract not yet integrated");
58850
- },
58851
- (error) => new SDKError({
58852
- message: "Failed to get mock BTC balance",
58853
- category: "CONTRACT" /* CONTRACT */,
58854
- severity: "MEDIUM" /* MEDIUM */,
58855
- originalError: error instanceof Error ? error : new Error(String(error)),
58856
- context: { address }
58857
- })
58858
- );
58859
- }
58860
- /**
58861
- * Check if current network is production (mainnet)
58862
- */
58863
- isProductionNetwork() {
58864
- return this.config.network.toLowerCase().includes("mainnet");
58947
+ for (const e of result.collateralEvents || []) {
58948
+ events.push({ kind: "collateral", positionId: e.position.id, ...e });
58949
+ }
58950
+ for (const e of result.ucdmintEvents || []) {
58951
+ events.push({ kind: "mint", positionId: e.position.id, ...e });
58952
+ }
58953
+ for (const e of result.withdrawalEvents || []) {
58954
+ events.push({ kind: "withdrawal", positionId: e.position.id, ...e });
58955
+ }
58956
+ for (const e of result.psmTransactions || []) {
58957
+ const subkind = e.type === "SWAP" ? "swap" : "redeem";
58958
+ events.push({ kind: "psm", subkind, ...e });
58959
+ }
58960
+ for (const e of result.circuitBreakerEvents || []) {
58961
+ events.push({ kind: "admin", subkind: "circuitBreaker", ...e });
58962
+ }
58963
+ for (const e of result.termFeeUpdates || []) {
58964
+ events.push({ kind: "admin", subkind: "termFee", ...e });
58965
+ }
58966
+ for (const e of result.loanProtocolParamUpdates || []) {
58967
+ events.push({ kind: "admin", subkind: "loanParams", ...e });
58968
+ }
58969
+ for (const e of result.maxLoanValueUpdates || []) {
58970
+ events.push({ kind: "admin", subkind: "maxLoanValue", ...e });
58971
+ }
58972
+ for (const e of result.btcPriceBoundsUpdates || []) {
58973
+ events.push({ kind: "admin", subkind: "btcBounds", ...e });
58974
+ }
58975
+ for (const e of result.perUserDailyMintLimitUpdates || []) {
58976
+ events.push({ kind: "admin", subkind: "mintLimit", ...e });
58977
+ }
58978
+ events.sort((a, b2) => {
58979
+ const diff = BigInt(a.timestamp) - BigInt(b2.timestamp);
58980
+ return orderDirection === "asc" ? Number(diff) : -Number(diff);
58981
+ });
58982
+ const byKind = {};
58983
+ for (const e of events) {
58984
+ byKind[e.kind] = (byKind[e.kind] ?? 0) + 1;
58985
+ }
58986
+ return { events, totalEvents: events.length, byKind };
58865
58987
  }
58866
58988
  };
58867
- function createMockTokenManager(config) {
58868
- try {
58869
- const manager = new MockTokenManager(config);
58870
- return success(manager);
58871
- } catch (error) {
58872
- return failure(
58873
- new SDKError({
58874
- message: "Failed to create MockTokenManager",
58875
- category: "INITIALIZATION" /* INITIALIZATION */,
58876
- severity: "HIGH" /* HIGH */,
58877
- originalError: error instanceof Error ? error : new Error(String(error))
58878
- })
58879
- );
58880
- }
58881
- }
58882
-
58883
- // src/modules/diamond-hands-sdk.ts
58884
- var import_dh_lit_actions2 = __toESM(require_pkg_src());
58885
- import { LitOps } from "@gvnrdao/dh-lit-ops";
58886
58989
 
58887
- // src/utils/telegram-messaging.utils.ts
58888
- var TelegramBot = null;
58889
- try {
58890
- if (typeof window === "undefined" && typeof global !== "undefined") {
58891
- TelegramBot = __require("node-telegram-bot-api");
58892
- }
58893
- } catch (error) {
58894
- console.warn("Telegram bot API not available:", error instanceof Error ? error.message : String(error));
58895
- }
58896
- function formatMintMessage(mintAmount, loanId, txHash) {
58897
- return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
58898
- }
58899
- function formatPartialPaymentMessage(paymentAmount, loanId, txHash) {
58900
- return `\u2705 DH SDK: ${paymentAmount} UCD was repaid for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
58901
- }
58902
- function formatPartialPaymentFailureMessage(paymentAmount, loanId, txHash) {
58903
- const baseMessage = `\u274C DH SDK: FAILED to repay ${paymentAmount} UCD for loan id: ${loanId}`;
58904
- if (txHash) {
58905
- return `${baseMessage} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
58906
- }
58907
- return baseMessage;
58908
- }
58909
- function formatLoanCreationMessage(positionId, pkpId, vaultAddress) {
58910
- const vault = vaultAddress || "unknown";
58911
- return `\u2705 DH SDK: A new loan was created Id: ${positionId} Pkp: ${pkpId} Regtest BTC vault: ${vault}`;
58912
- }
58990
+ // src/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.ts
58991
+ var _abi = [
58992
+ {
58993
+ inputs: [],
58994
+ stateMutability: "nonpayable",
58995
+ type: "constructor"
58996
+ },
58997
+ {
58998
+ inputs: [
58999
+ {
59000
+ internalType: "uint256",
59001
+ name: "amount",
59002
+ type: "uint256"
59003
+ },
59004
+ {
59005
+ internalType: "uint256",
59006
+ name: "maximum",
59007
+ type: "uint256"
59008
+ }
59009
+ ],
59010
+ name: "AboveMaxRedeem",
59011
+ type: "error"
59012
+ },
59013
+ {
59014
+ inputs: [
59015
+ {
59016
+ internalType: "uint256",
59017
+ name: "amount",
59018
+ type: "uint256"
59019
+ },
59020
+ {
59021
+ internalType: "uint256",
59022
+ name: "maximum",
59023
+ type: "uint256"
59024
+ }
59025
+ ],
59026
+ name: "AboveMaxSwap",
59027
+ type: "error"
59028
+ },
59029
+ {
59030
+ inputs: [],
59031
+ name: "AccessControlBadConfirmation",
59032
+ type: "error"
59033
+ },
59034
+ {
59035
+ inputs: [
59036
+ {
59037
+ internalType: "address",
59038
+ name: "account",
59039
+ type: "address"
59040
+ },
59041
+ {
59042
+ internalType: "bytes32",
59043
+ name: "neededRole",
59044
+ type: "bytes32"
59045
+ }
59046
+ ],
59047
+ name: "AccessControlUnauthorizedAccount",
59048
+ type: "error"
59049
+ },
59050
+ {
59051
+ inputs: [
59052
+ {
59053
+ internalType: "address",
59054
+ name: "target",
59055
+ type: "address"
59056
+ }
59057
+ ],
59058
+ name: "AddressEmptyCode",
59059
+ type: "error"
59060
+ },
59061
+ {
59062
+ inputs: [],
59063
+ name: "ArrayLengthMismatch",
59064
+ type: "error"
59065
+ },
59066
+ {
59067
+ inputs: [
59068
+ {
59069
+ internalType: "uint256",
59070
+ name: "amount",
59071
+ type: "uint256"
59072
+ },
59073
+ {
59074
+ internalType: "uint256",
59075
+ name: "minimum",
59076
+ type: "uint256"
59077
+ }
59078
+ ],
59079
+ name: "BelowMinRedeem",
59080
+ type: "error"
59081
+ },
59082
+ {
59083
+ inputs: [
59084
+ {
59085
+ internalType: "uint256",
59086
+ name: "amount",
59087
+ type: "uint256"
59088
+ },
59089
+ {
59090
+ internalType: "uint256",
59091
+ name: "minimum",
59092
+ type: "uint256"
59093
+ }
59094
+ ],
59095
+ name: "BelowMinSwap",
59096
+ type: "error"
59097
+ },
59098
+ {
59099
+ inputs: [
59100
+ {
59101
+ internalType: "uint8",
59102
+ name: "provided",
59103
+ type: "uint8"
59104
+ },
59105
+ {
59106
+ internalType: "uint8",
59107
+ name: "actual",
59108
+ type: "uint8"
59109
+ }
59110
+ ],
59111
+ name: "DecimalsMismatch",
59112
+ type: "error"
59113
+ },
59114
+ {
59115
+ inputs: [],
59116
+ name: "DecimalsQueryFailed",
59117
+ type: "error"
59118
+ },
59119
+ {
59120
+ inputs: [
59121
+ {
59122
+ internalType: "address",
59123
+ name: "implementation",
59124
+ type: "address"
59125
+ }
59126
+ ],
59127
+ name: "ERC1967InvalidImplementation",
59128
+ type: "error"
59129
+ },
59130
+ {
59131
+ inputs: [],
59132
+ name: "ERC1967NonPayable",
59133
+ type: "error"
59134
+ },
59135
+ {
59136
+ inputs: [],
59137
+ name: "EnforcedPause",
59138
+ type: "error"
59139
+ },
59140
+ {
59141
+ inputs: [
59142
+ {
59143
+ internalType: "uint256",
59144
+ name: "fee",
59145
+ type: "uint256"
59146
+ },
59147
+ {
59148
+ internalType: "uint256",
59149
+ name: "max",
59150
+ type: "uint256"
59151
+ }
59152
+ ],
59153
+ name: "EntryFeeTooHigh",
59154
+ type: "error"
59155
+ },
59156
+ {
59157
+ inputs: [
59158
+ {
59159
+ internalType: "uint256",
59160
+ name: "fee",
59161
+ type: "uint256"
59162
+ },
59163
+ {
59164
+ internalType: "uint256",
59165
+ name: "max",
59166
+ type: "uint256"
59167
+ }
59168
+ ],
59169
+ name: "ExitFeeTooHigh",
59170
+ type: "error"
59171
+ },
59172
+ {
59173
+ inputs: [],
59174
+ name: "ExpectedPause",
59175
+ type: "error"
59176
+ },
59177
+ {
59178
+ inputs: [],
59179
+ name: "FailedCall",
59180
+ type: "error"
59181
+ },
59182
+ {
59183
+ inputs: [],
59184
+ name: "FailedToGetStablecoinDecimals",
59185
+ type: "error"
59186
+ },
59187
+ {
59188
+ inputs: [],
59189
+ name: "FailedToGetUCDDecimals",
59190
+ type: "error"
59191
+ },
59192
+ {
59193
+ inputs: [],
59194
+ name: "InitialBalanceTooLarge",
59195
+ type: "error"
59196
+ },
59197
+ {
59198
+ inputs: [
59199
+ {
59200
+ internalType: "uint256",
59201
+ name: "available",
59202
+ type: "uint256"
59203
+ },
59204
+ {
59205
+ internalType: "uint256",
59206
+ name: "required",
59207
+ type: "uint256"
59208
+ }
59209
+ ],
59210
+ name: "InsufficientReserves",
59211
+ type: "error"
59212
+ },
59213
+ {
59214
+ inputs: [],
59215
+ name: "InvalidAddress",
59216
+ type: "error"
59217
+ },
59218
+ {
59219
+ inputs: [],
59220
+ name: "InvalidAdmin",
59221
+ type: "error"
59222
+ },
59223
+ {
59224
+ inputs: [],
59225
+ name: "InvalidAmount",
59226
+ type: "error"
59227
+ },
59228
+ {
59229
+ inputs: [],
59230
+ name: "InvalidController",
59231
+ type: "error"
59232
+ },
59233
+ {
59234
+ inputs: [
59235
+ {
59236
+ internalType: "uint8",
59237
+ name: "decimals",
59238
+ type: "uint8"
59239
+ }
59240
+ ],
59241
+ name: "InvalidDecimals",
59242
+ type: "error"
59243
+ },
59244
+ {
59245
+ inputs: [],
59246
+ name: "InvalidExchangeRate",
59247
+ type: "error"
59248
+ },
59249
+ {
59250
+ inputs: [],
59251
+ name: "InvalidInitialization",
59252
+ type: "error"
59253
+ },
59254
+ {
59255
+ inputs: [],
59256
+ name: "InvalidStablecoinAddress",
59257
+ type: "error"
59258
+ },
59259
+ {
59260
+ inputs: [],
59261
+ name: "InvalidToken",
59262
+ type: "error"
59263
+ },
59264
+ {
59265
+ inputs: [
59266
+ {
59267
+ internalType: "uint8",
59268
+ name: "decimals",
59269
+ type: "uint8"
59270
+ }
59271
+ ],
59272
+ name: "InvalidUCDDecimals",
59273
+ type: "error"
59274
+ },
59275
+ {
59276
+ inputs: [
59277
+ {
59278
+ internalType: "uint256",
59279
+ name: "maximum",
59280
+ type: "uint256"
59281
+ },
59282
+ {
59283
+ internalType: "uint256",
59284
+ name: "minimum",
59285
+ type: "uint256"
59286
+ }
59287
+ ],
59288
+ name: "MaxRedeemBelowMin",
59289
+ type: "error"
59290
+ },
59291
+ {
59292
+ inputs: [],
59293
+ name: "MaxRedeemCapDisabled",
59294
+ type: "error"
59295
+ },
59296
+ {
59297
+ inputs: [
59298
+ {
59299
+ internalType: "uint256",
59300
+ name: "maximum",
59301
+ type: "uint256"
59302
+ },
59303
+ {
59304
+ internalType: "uint256",
59305
+ name: "minimum",
59306
+ type: "uint256"
59307
+ }
59308
+ ],
59309
+ name: "MaxSwapBelowMin",
59310
+ type: "error"
59311
+ },
59312
+ {
59313
+ inputs: [],
59314
+ name: "MaxSwapCapDisabled",
59315
+ type: "error"
59316
+ },
59317
+ {
59318
+ inputs: [],
59319
+ name: "NormalizationOverflow",
59320
+ type: "error"
59321
+ },
59322
+ {
59323
+ inputs: [],
59324
+ name: "NotContract",
59325
+ type: "error"
59326
+ },
59327
+ {
59328
+ inputs: [],
59329
+ name: "NotInitializing",
59330
+ type: "error"
59331
+ },
59332
+ {
59333
+ inputs: [],
59334
+ name: "RateLimitExceeded",
59335
+ type: "error"
59336
+ },
59337
+ {
59338
+ inputs: [],
59339
+ name: "RedemptionsPaused",
59340
+ type: "error"
59341
+ },
59342
+ {
59343
+ inputs: [],
59344
+ name: "ReentrancyGuardReentrantCall",
59345
+ type: "error"
59346
+ },
59347
+ {
59348
+ inputs: [],
59349
+ name: "ReserveOverflow",
59350
+ type: "error"
59351
+ },
59352
+ {
59353
+ inputs: [],
59354
+ name: "ReserveTooLarge",
59355
+ type: "error"
59356
+ },
59357
+ {
59358
+ inputs: [],
59359
+ name: "ReserveUnderflow",
59360
+ type: "error"
59361
+ },
59362
+ {
59363
+ inputs: [
59364
+ {
59365
+ internalType: "address",
59366
+ name: "token",
59367
+ type: "address"
59368
+ }
59369
+ ],
59370
+ name: "SafeERC20FailedOperation",
59371
+ type: "error"
59372
+ },
59373
+ {
59374
+ inputs: [
59375
+ {
59376
+ internalType: "uint256",
59377
+ name: "got",
59378
+ type: "uint256"
59379
+ },
59380
+ {
59381
+ internalType: "uint256",
59382
+ name: "minimum",
59383
+ type: "uint256"
59384
+ }
59385
+ ],
59386
+ name: "SlippageExceeded",
59387
+ type: "error"
59388
+ },
59389
+ {
59390
+ inputs: [],
59391
+ name: "SlippageProtectionRequired",
59392
+ type: "error"
59393
+ },
59394
+ {
59395
+ inputs: [
59396
+ {
59397
+ internalType: "address",
59398
+ name: "stablecoin",
59399
+ type: "address"
59400
+ }
59401
+ ],
59402
+ name: "StablecoinAlreadySupported",
59403
+ type: "error"
59404
+ },
59405
+ {
59406
+ inputs: [
59407
+ {
59408
+ internalType: "address",
59409
+ name: "stablecoin",
59410
+ type: "address"
59411
+ }
59412
+ ],
59413
+ name: "StablecoinNotContract",
59414
+ type: "error"
59415
+ },
59416
+ {
59417
+ inputs: [
59418
+ {
59419
+ internalType: "address",
59420
+ name: "stablecoin",
59421
+ type: "address"
59422
+ }
59423
+ ],
59424
+ name: "StablecoinNotSupported",
59425
+ type: "error"
59426
+ },
59427
+ {
59428
+ inputs: [
59429
+ {
59430
+ internalType: "address",
59431
+ name: "stablecoin",
59432
+ type: "address"
59433
+ }
59434
+ ],
59435
+ name: "StablecoinNotSupportedInV1",
59436
+ type: "error"
59437
+ },
59438
+ {
59439
+ inputs: [],
59440
+ name: "SyncDriftTooLarge",
59441
+ type: "error"
59442
+ },
59443
+ {
59444
+ inputs: [],
59445
+ name: "UUPSUnauthorizedCallContext",
59446
+ type: "error"
59447
+ },
59448
+ {
59449
+ inputs: [
59450
+ {
59451
+ internalType: "bytes32",
59452
+ name: "slot",
59453
+ type: "bytes32"
59454
+ }
59455
+ ],
59456
+ name: "UUPSUnsupportedProxiableUUID",
59457
+ type: "error"
59458
+ },
59459
+ {
59460
+ inputs: [],
59461
+ name: "UnexpectedRoleGrantFailure",
59462
+ type: "error"
59463
+ },
59464
+ {
59465
+ inputs: [],
59466
+ name: "V2AlreadyInitialized",
59467
+ type: "error"
59468
+ },
59469
+ {
59470
+ inputs: [
59471
+ {
59472
+ internalType: "uint256",
59473
+ name: "amount",
59474
+ type: "uint256"
59475
+ },
59476
+ {
59477
+ internalType: "uint256",
59478
+ name: "reserves",
59479
+ type: "uint256"
59480
+ }
59481
+ ],
59482
+ name: "WithdrawalExceedsReserves",
59483
+ type: "error"
59484
+ },
59485
+ {
59486
+ anonymous: false,
59487
+ inputs: [
59488
+ {
59489
+ indexed: true,
59490
+ internalType: "address",
59491
+ name: "stablecoin",
59492
+ type: "address"
59493
+ },
59494
+ {
59495
+ indexed: false,
59496
+ internalType: "uint256",
59497
+ name: "oldFee",
59498
+ type: "uint256"
59499
+ },
59500
+ {
59501
+ indexed: false,
59502
+ internalType: "uint256",
59503
+ name: "newFee",
59504
+ type: "uint256"
59505
+ }
59506
+ ],
59507
+ name: "EntryFeeUpdated",
59508
+ type: "event"
59509
+ },
59510
+ {
59511
+ anonymous: false,
59512
+ inputs: [
59513
+ {
59514
+ indexed: true,
59515
+ internalType: "address",
59516
+ name: "stablecoin",
59517
+ type: "address"
59518
+ },
59519
+ {
59520
+ indexed: false,
59521
+ internalType: "uint256",
59522
+ name: "oldRate",
59523
+ type: "uint256"
59524
+ },
59525
+ {
59526
+ indexed: false,
59527
+ internalType: "uint256",
59528
+ name: "newRate",
59529
+ type: "uint256"
59530
+ }
59531
+ ],
59532
+ name: "ExchangeRateUpdated",
59533
+ type: "event"
59534
+ },
59535
+ {
59536
+ anonymous: false,
59537
+ inputs: [
59538
+ {
59539
+ indexed: true,
59540
+ internalType: "address",
59541
+ name: "stablecoin",
59542
+ type: "address"
59543
+ },
59544
+ {
59545
+ indexed: false,
59546
+ internalType: "uint256",
59547
+ name: "oldFee",
59548
+ type: "uint256"
59549
+ },
59550
+ {
59551
+ indexed: false,
59552
+ internalType: "uint256",
59553
+ name: "newFee",
59554
+ type: "uint256"
59555
+ }
59556
+ ],
59557
+ name: "ExitFeeUpdated",
59558
+ type: "event"
59559
+ },
59560
+ {
59561
+ anonymous: false,
59562
+ inputs: [
59563
+ {
59564
+ indexed: false,
59565
+ internalType: "uint64",
59566
+ name: "version",
59567
+ type: "uint64"
59568
+ }
59569
+ ],
59570
+ name: "Initialized",
59571
+ type: "event"
59572
+ },
59573
+ {
59574
+ anonymous: false,
59575
+ inputs: [
59576
+ {
59577
+ indexed: false,
59578
+ internalType: "address",
59579
+ name: "account",
59580
+ type: "address"
59581
+ }
59582
+ ],
59583
+ name: "Paused",
59584
+ type: "event"
59585
+ },
59586
+ {
59587
+ anonymous: false,
59588
+ inputs: [
59589
+ {
59590
+ indexed: true,
59591
+ internalType: "address",
59592
+ name: "user",
59593
+ type: "address"
59594
+ },
59595
+ {
59596
+ indexed: true,
59597
+ internalType: "address",
59598
+ name: "stablecoin",
59599
+ type: "address"
59600
+ },
59601
+ {
59602
+ indexed: false,
59603
+ internalType: "uint256",
59604
+ name: "ucdAmount",
59605
+ type: "uint256"
59606
+ },
59607
+ {
59608
+ indexed: false,
59609
+ internalType: "uint256",
59610
+ name: "stablecoinAmount",
59611
+ type: "uint256"
59612
+ },
59613
+ {
59614
+ indexed: false,
59615
+ internalType: "uint256",
59616
+ name: "exitFee",
59617
+ type: "uint256"
59618
+ },
59619
+ {
59620
+ indexed: false,
59621
+ internalType: "uint256",
59622
+ name: "timestamp",
59623
+ type: "uint256"
59624
+ }
59625
+ ],
59626
+ name: "Redeem",
59627
+ type: "event"
59628
+ },
59629
+ {
59630
+ anonymous: false,
59631
+ inputs: [
59632
+ {
59633
+ indexed: false,
59634
+ internalType: "bool",
59635
+ name: "enabled",
59636
+ type: "bool"
59637
+ }
59638
+ ],
59639
+ name: "RedemptionStatusChanged",
59640
+ type: "event"
59641
+ },
59642
+ {
59643
+ anonymous: false,
59644
+ inputs: [
59645
+ {
59646
+ indexed: true,
59647
+ internalType: "address",
59648
+ name: "stablecoin",
59649
+ type: "address"
59650
+ },
59651
+ {
59652
+ indexed: false,
59653
+ internalType: "uint256",
59654
+ name: "oldReserve",
59655
+ type: "uint256"
59656
+ },
59657
+ {
59658
+ indexed: false,
59659
+ internalType: "uint256",
59660
+ name: "newReserve",
59661
+ type: "uint256"
59662
+ }
59663
+ ],
59664
+ name: "ReserveUpdated",
59665
+ type: "event"
59666
+ },
59667
+ {
59668
+ anonymous: false,
59669
+ inputs: [
59670
+ {
59671
+ indexed: true,
59672
+ internalType: "bytes32",
59673
+ name: "role",
59674
+ type: "bytes32"
59675
+ },
59676
+ {
59677
+ indexed: true,
59678
+ internalType: "bytes32",
59679
+ name: "previousAdminRole",
59680
+ type: "bytes32"
59681
+ },
59682
+ {
59683
+ indexed: true,
59684
+ internalType: "bytes32",
59685
+ name: "newAdminRole",
59686
+ type: "bytes32"
59687
+ }
59688
+ ],
59689
+ name: "RoleAdminChanged",
59690
+ type: "event"
59691
+ },
59692
+ {
59693
+ anonymous: false,
59694
+ inputs: [
59695
+ {
59696
+ indexed: true,
59697
+ internalType: "bytes32",
59698
+ name: "role",
59699
+ type: "bytes32"
59700
+ },
59701
+ {
59702
+ indexed: true,
59703
+ internalType: "address",
59704
+ name: "account",
59705
+ type: "address"
59706
+ },
59707
+ {
59708
+ indexed: true,
59709
+ internalType: "address",
59710
+ name: "sender",
59711
+ type: "address"
59712
+ }
59713
+ ],
59714
+ name: "RoleGranted",
59715
+ type: "event"
59716
+ },
59717
+ {
59718
+ anonymous: false,
59719
+ inputs: [
59720
+ {
59721
+ indexed: true,
59722
+ internalType: "bytes32",
59723
+ name: "role",
59724
+ type: "bytes32"
59725
+ },
59726
+ {
59727
+ indexed: true,
59728
+ internalType: "address",
59729
+ name: "account",
59730
+ type: "address"
59731
+ },
59732
+ {
59733
+ indexed: true,
59734
+ internalType: "address",
59735
+ name: "sender",
59736
+ type: "address"
59737
+ }
59738
+ ],
59739
+ name: "RoleRevoked",
59740
+ type: "event"
59741
+ },
59742
+ {
59743
+ anonymous: false,
59744
+ inputs: [
59745
+ {
59746
+ indexed: true,
59747
+ internalType: "address",
59748
+ name: "stablecoin",
59749
+ type: "address"
59750
+ },
59751
+ {
59752
+ indexed: false,
59753
+ internalType: "uint256",
59754
+ name: "exchangeRate",
59755
+ type: "uint256"
59756
+ },
59757
+ {
59758
+ indexed: false,
59759
+ internalType: "uint256",
59760
+ name: "fee",
59761
+ type: "uint256"
59762
+ }
59763
+ ],
59764
+ name: "StablecoinAdded",
59765
+ type: "event"
59766
+ },
59767
+ {
59768
+ anonymous: false,
59769
+ inputs: [
59770
+ {
59771
+ indexed: true,
59772
+ internalType: "address",
59773
+ name: "stablecoin",
59774
+ type: "address"
59775
+ }
59776
+ ],
59777
+ name: "StablecoinRemoved",
59778
+ type: "event"
59779
+ },
59780
+ {
59781
+ anonymous: false,
59782
+ inputs: [
59783
+ {
59784
+ indexed: true,
59785
+ internalType: "address",
59786
+ name: "stablecoin",
59787
+ type: "address"
59788
+ },
59789
+ {
59790
+ indexed: false,
59791
+ internalType: "uint256",
59792
+ name: "exchangeRate",
59793
+ type: "uint256"
59794
+ },
59795
+ {
59796
+ indexed: false,
59797
+ internalType: "uint256",
59798
+ name: "entryFeeBps",
59799
+ type: "uint256"
59800
+ },
59801
+ {
59802
+ indexed: false,
59803
+ internalType: "uint256",
59804
+ name: "exitFeeBps",
59805
+ type: "uint256"
59806
+ },
59807
+ {
59808
+ indexed: false,
59809
+ internalType: "uint8",
59810
+ name: "decimals",
59811
+ type: "uint8"
59812
+ },
59813
+ {
59814
+ indexed: false,
59815
+ internalType: "uint256",
59816
+ name: "minSwapAmount",
59817
+ type: "uint256"
59818
+ },
59819
+ {
59820
+ indexed: false,
59821
+ internalType: "uint256",
59822
+ name: "minRedeemAmount",
59823
+ type: "uint256"
59824
+ },
59825
+ {
59826
+ indexed: false,
59827
+ internalType: "uint256",
59828
+ name: "maxSwapAmount",
59829
+ type: "uint256"
59830
+ },
59831
+ {
59832
+ indexed: false,
59833
+ internalType: "uint256",
59834
+ name: "maxRedeemAmount",
59835
+ type: "uint256"
59836
+ }
59837
+ ],
59838
+ name: "StablecoinUpdated",
59839
+ type: "event"
59840
+ },
59841
+ {
59842
+ anonymous: false,
59843
+ inputs: [
59844
+ {
59845
+ indexed: true,
59846
+ internalType: "address",
59847
+ name: "user",
59848
+ type: "address"
59849
+ },
59850
+ {
59851
+ indexed: true,
59852
+ internalType: "address",
59853
+ name: "stablecoin",
59854
+ type: "address"
59855
+ },
59856
+ {
59857
+ indexed: false,
59858
+ internalType: "uint256",
59859
+ name: "stablecoinAmount",
59860
+ type: "uint256"
59861
+ },
59862
+ {
59863
+ indexed: false,
59864
+ internalType: "uint256",
59865
+ name: "ucdAmount",
59866
+ type: "uint256"
59867
+ },
59868
+ {
59869
+ indexed: false,
59870
+ internalType: "uint256",
59871
+ name: "fee",
59872
+ type: "uint256"
59873
+ },
59874
+ {
59875
+ indexed: false,
59876
+ internalType: "uint256",
59877
+ name: "timestamp",
59878
+ type: "uint256"
59879
+ }
59880
+ ],
59881
+ name: "Swap",
59882
+ type: "event"
59883
+ },
59884
+ {
59885
+ anonymous: false,
59886
+ inputs: [
59887
+ {
59888
+ indexed: false,
59889
+ internalType: "address",
59890
+ name: "account",
59891
+ type: "address"
59892
+ }
59893
+ ],
59894
+ name: "Unpaused",
59895
+ type: "event"
59896
+ },
59897
+ {
59898
+ anonymous: false,
59899
+ inputs: [
59900
+ {
59901
+ indexed: true,
59902
+ internalType: "address",
59903
+ name: "implementation",
59904
+ type: "address"
59905
+ }
59906
+ ],
59907
+ name: "Upgraded",
59908
+ type: "event"
59909
+ },
59910
+ {
59911
+ inputs: [],
59912
+ name: "BASIS_POINTS",
59913
+ outputs: [
59914
+ {
59915
+ internalType: "uint256",
59916
+ name: "",
59917
+ type: "uint256"
59918
+ }
59919
+ ],
59920
+ stateMutability: "view",
59921
+ type: "function"
59922
+ },
59923
+ {
59924
+ inputs: [],
59925
+ name: "DEFAULT_ADMIN_ROLE",
59926
+ outputs: [
59927
+ {
59928
+ internalType: "bytes32",
59929
+ name: "",
59930
+ type: "bytes32"
59931
+ }
59932
+ ],
59933
+ stateMutability: "view",
59934
+ type: "function"
59935
+ },
59936
+ {
59937
+ inputs: [],
59938
+ name: "EXCHANGE_RATE_SCALE",
59939
+ outputs: [
59940
+ {
59941
+ internalType: "uint256",
59942
+ name: "",
59943
+ type: "uint256"
59944
+ }
59945
+ ],
59946
+ stateMutability: "view",
59947
+ type: "function"
59948
+ },
59949
+ {
59950
+ inputs: [],
59951
+ name: "MAX_EXIT_FEE",
59952
+ outputs: [
59953
+ {
59954
+ internalType: "uint256",
59955
+ name: "",
59956
+ type: "uint256"
59957
+ }
59958
+ ],
59959
+ stateMutability: "view",
59960
+ type: "function"
59961
+ },
59962
+ {
59963
+ inputs: [],
59964
+ name: "MAX_RESERVE_DRIFT",
59965
+ outputs: [
59966
+ {
59967
+ internalType: "uint256",
59968
+ name: "",
59969
+ type: "uint256"
59970
+ }
59971
+ ],
59972
+ stateMutability: "view",
59973
+ type: "function"
59974
+ },
59975
+ {
59976
+ inputs: [],
59977
+ name: "UPGRADE_INTERFACE_VERSION",
59978
+ outputs: [
59979
+ {
59980
+ internalType: "string",
59981
+ name: "",
59982
+ type: "string"
59983
+ }
59984
+ ],
59985
+ stateMutability: "view",
59986
+ type: "function"
59987
+ },
59988
+ {
59989
+ inputs: [
59990
+ {
59991
+ internalType: "address",
59992
+ name: "stablecoin",
59993
+ type: "address"
59994
+ },
59995
+ {
59996
+ internalType: "uint256",
59997
+ name: "amount",
59998
+ type: "uint256"
59999
+ }
60000
+ ],
60001
+ name: "addReserves",
60002
+ outputs: [],
60003
+ stateMutability: "nonpayable",
60004
+ type: "function"
60005
+ },
60006
+ {
60007
+ inputs: [
60008
+ {
60009
+ internalType: "address",
60010
+ name: "stablecoin",
60011
+ type: "address"
60012
+ },
60013
+ {
60014
+ internalType: "uint256",
60015
+ name: "exchangeRate",
60016
+ type: "uint256"
60017
+ },
60018
+ {
60019
+ internalType: "uint256",
60020
+ name: "entryFeeBps",
60021
+ type: "uint256"
60022
+ },
60023
+ {
60024
+ internalType: "uint256",
60025
+ name: "exitFeeBps",
60026
+ type: "uint256"
60027
+ },
60028
+ {
60029
+ internalType: "uint8",
60030
+ name: "decimals",
60031
+ type: "uint8"
60032
+ },
60033
+ {
60034
+ internalType: "uint256",
60035
+ name: "minSwapAmount",
60036
+ type: "uint256"
60037
+ },
60038
+ {
60039
+ internalType: "uint256",
60040
+ name: "minRedeemAmount",
60041
+ type: "uint256"
60042
+ },
60043
+ {
60044
+ internalType: "uint256",
60045
+ name: "maxSwapAmount",
60046
+ type: "uint256"
60047
+ },
60048
+ {
60049
+ internalType: "uint256",
60050
+ name: "maxRedeemAmount",
60051
+ type: "uint256"
60052
+ }
60053
+ ],
60054
+ name: "addSupportedStablecoin",
60055
+ outputs: [],
60056
+ stateMutability: "nonpayable",
60057
+ type: "function"
60058
+ },
60059
+ {
60060
+ inputs: [
60061
+ {
60062
+ internalType: "address",
60063
+ name: "stablecoin",
60064
+ type: "address"
60065
+ },
60066
+ {
60067
+ internalType: "uint256",
60068
+ name: "ucdAmount",
60069
+ type: "uint256"
60070
+ }
60071
+ ],
60072
+ name: "canRedeem",
60073
+ outputs: [
60074
+ {
60075
+ internalType: "bool",
60076
+ name: "",
60077
+ type: "bool"
60078
+ }
60079
+ ],
60080
+ stateMutability: "view",
60081
+ type: "function"
60082
+ },
60083
+ {
60084
+ inputs: [],
60085
+ name: "controller",
60086
+ outputs: [
60087
+ {
60088
+ internalType: "contract IUCDController",
60089
+ name: "",
60090
+ type: "address"
60091
+ }
60092
+ ],
60093
+ stateMutability: "view",
60094
+ type: "function"
60095
+ },
60096
+ {
60097
+ inputs: [
60098
+ {
60099
+ internalType: "address",
60100
+ name: "",
60101
+ type: "address"
60102
+ }
60103
+ ],
60104
+ name: "exchangeRates",
60105
+ outputs: [
60106
+ {
60107
+ internalType: "uint256",
60108
+ name: "",
60109
+ type: "uint256"
60110
+ }
60111
+ ],
60112
+ stateMutability: "view",
60113
+ type: "function"
60114
+ },
60115
+ {
60116
+ inputs: [
60117
+ {
60118
+ internalType: "address",
60119
+ name: "",
60120
+ type: "address"
60121
+ }
60122
+ ],
60123
+ name: "exitFees",
60124
+ outputs: [
60125
+ {
60126
+ internalType: "uint256",
60127
+ name: "",
60128
+ type: "uint256"
60129
+ }
60130
+ ],
60131
+ stateMutability: "view",
60132
+ type: "function"
60133
+ },
60134
+ {
60135
+ inputs: [
60136
+ {
60137
+ internalType: "address",
60138
+ name: "",
60139
+ type: "address"
60140
+ }
60141
+ ],
60142
+ name: "fees",
60143
+ outputs: [
60144
+ {
60145
+ internalType: "uint256",
60146
+ name: "",
60147
+ type: "uint256"
60148
+ }
60149
+ ],
60150
+ stateMutability: "view",
60151
+ type: "function"
60152
+ },
60153
+ {
60154
+ inputs: [
60155
+ {
60156
+ internalType: "address",
60157
+ name: "stablecoin",
60158
+ type: "address"
60159
+ }
60160
+ ],
60161
+ name: "forceSyncReserves",
60162
+ outputs: [],
60163
+ stateMutability: "nonpayable",
60164
+ type: "function"
60165
+ },
60166
+ {
60167
+ inputs: [
60168
+ {
60169
+ internalType: "address",
60170
+ name: "stablecoin",
60171
+ type: "address"
60172
+ }
60173
+ ],
60174
+ name: "getAvailableReserves",
60175
+ outputs: [
60176
+ {
60177
+ internalType: "uint256",
60178
+ name: "",
60179
+ type: "uint256"
60180
+ }
60181
+ ],
60182
+ stateMutability: "view",
60183
+ type: "function"
60184
+ },
60185
+ {
60186
+ inputs: [
60187
+ {
60188
+ internalType: "address",
60189
+ name: "stablecoin",
60190
+ type: "address"
60191
+ },
60192
+ {
60193
+ internalType: "uint256",
60194
+ name: "ucdAmount",
60195
+ type: "uint256"
60196
+ }
60197
+ ],
60198
+ name: "getRedemptionQuote",
60199
+ outputs: [
60200
+ {
60201
+ internalType: "uint256",
60202
+ name: "stablecoinOut",
60203
+ type: "uint256"
60204
+ },
60205
+ {
60206
+ internalType: "uint256",
60207
+ name: "exitFee",
60208
+ type: "uint256"
60209
+ }
60210
+ ],
60211
+ stateMutability: "view",
60212
+ type: "function"
60213
+ },
60214
+ {
60215
+ inputs: [
60216
+ {
60217
+ internalType: "bytes32",
60218
+ name: "role",
60219
+ type: "bytes32"
60220
+ }
60221
+ ],
60222
+ name: "getRoleAdmin",
60223
+ outputs: [
60224
+ {
60225
+ internalType: "bytes32",
60226
+ name: "",
60227
+ type: "bytes32"
60228
+ }
60229
+ ],
60230
+ stateMutability: "view",
60231
+ type: "function"
60232
+ },
60233
+ {
60234
+ inputs: [
60235
+ {
60236
+ internalType: "address",
60237
+ name: "stablecoin",
60238
+ type: "address"
60239
+ },
60240
+ {
60241
+ internalType: "uint256",
60242
+ name: "amountIn",
60243
+ type: "uint256"
60244
+ }
60245
+ ],
60246
+ name: "getSwapQuote",
60247
+ outputs: [
60248
+ {
60249
+ internalType: "uint256",
60250
+ name: "ucdOut",
60251
+ type: "uint256"
60252
+ },
60253
+ {
60254
+ internalType: "uint256",
60255
+ name: "fee",
60256
+ type: "uint256"
60257
+ }
60258
+ ],
60259
+ stateMutability: "view",
60260
+ type: "function"
60261
+ },
60262
+ {
60263
+ inputs: [
60264
+ {
60265
+ internalType: "bytes32",
60266
+ name: "role",
60267
+ type: "bytes32"
60268
+ },
60269
+ {
60270
+ internalType: "address",
60271
+ name: "account",
60272
+ type: "address"
60273
+ }
60274
+ ],
60275
+ name: "grantRole",
60276
+ outputs: [],
60277
+ stateMutability: "nonpayable",
60278
+ type: "function"
60279
+ },
60280
+ {
60281
+ inputs: [
60282
+ {
60283
+ internalType: "bytes32",
60284
+ name: "role",
60285
+ type: "bytes32"
60286
+ },
60287
+ {
60288
+ internalType: "address",
60289
+ name: "account",
60290
+ type: "address"
60291
+ }
60292
+ ],
60293
+ name: "hasRole",
60294
+ outputs: [
60295
+ {
60296
+ internalType: "bool",
60297
+ name: "",
60298
+ type: "bool"
60299
+ }
60300
+ ],
60301
+ stateMutability: "view",
60302
+ type: "function"
60303
+ },
60304
+ {
60305
+ inputs: [
60306
+ {
60307
+ internalType: "address",
60308
+ name: "_controller",
60309
+ type: "address"
60310
+ },
60311
+ {
60312
+ internalType: "address",
60313
+ name: "_ucdToken",
60314
+ type: "address"
60315
+ },
60316
+ {
60317
+ internalType: "address",
60318
+ name: "_admin",
60319
+ type: "address"
60320
+ }
60321
+ ],
60322
+ name: "initialize",
60323
+ outputs: [],
60324
+ stateMutability: "nonpayable",
60325
+ type: "function"
60326
+ },
60327
+ {
60328
+ inputs: [
60329
+ {
60330
+ internalType: "bool",
60331
+ name: "_redeemEnabled",
60332
+ type: "bool"
60333
+ },
60334
+ {
60335
+ internalType: "address[]",
60336
+ name: "stablecoins",
60337
+ type: "address[]"
60338
+ },
60339
+ {
60340
+ internalType: "uint256[]",
60341
+ name: "initialExitFees",
60342
+ type: "uint256[]"
60343
+ }
60344
+ ],
60345
+ name: "initializeV2",
60346
+ outputs: [],
60347
+ stateMutability: "nonpayable",
60348
+ type: "function"
60349
+ },
60350
+ {
60351
+ inputs: [
60352
+ {
60353
+ internalType: "address",
60354
+ name: "",
60355
+ type: "address"
60356
+ }
60357
+ ],
60358
+ name: "lastOperationBlock",
60359
+ outputs: [
60360
+ {
60361
+ internalType: "uint256",
60362
+ name: "",
60363
+ type: "uint256"
60364
+ }
60365
+ ],
60366
+ stateMutability: "view",
60367
+ type: "function"
60368
+ },
60369
+ {
60370
+ inputs: [
60371
+ {
60372
+ internalType: "address",
60373
+ name: "",
60374
+ type: "address"
60375
+ }
60376
+ ],
60377
+ name: "maxRedeemAmounts",
60378
+ outputs: [
60379
+ {
60380
+ internalType: "uint256",
60381
+ name: "",
60382
+ type: "uint256"
60383
+ }
60384
+ ],
60385
+ stateMutability: "view",
60386
+ type: "function"
60387
+ },
60388
+ {
60389
+ inputs: [
60390
+ {
60391
+ internalType: "address",
60392
+ name: "",
60393
+ type: "address"
60394
+ }
60395
+ ],
60396
+ name: "maxSwapAmounts",
60397
+ outputs: [
60398
+ {
60399
+ internalType: "uint256",
60400
+ name: "",
60401
+ type: "uint256"
60402
+ }
60403
+ ],
60404
+ stateMutability: "view",
60405
+ type: "function"
60406
+ },
60407
+ {
60408
+ inputs: [
60409
+ {
60410
+ internalType: "address",
60411
+ name: "",
60412
+ type: "address"
60413
+ }
60414
+ ],
60415
+ name: "minRedeemAmounts",
60416
+ outputs: [
60417
+ {
60418
+ internalType: "uint256",
60419
+ name: "",
60420
+ type: "uint256"
60421
+ }
60422
+ ],
60423
+ stateMutability: "view",
60424
+ type: "function"
60425
+ },
60426
+ {
60427
+ inputs: [
60428
+ {
60429
+ internalType: "address",
60430
+ name: "",
60431
+ type: "address"
60432
+ }
60433
+ ],
60434
+ name: "minSwapAmounts",
60435
+ outputs: [
60436
+ {
60437
+ internalType: "uint256",
60438
+ name: "",
60439
+ type: "uint256"
60440
+ }
60441
+ ],
60442
+ stateMutability: "view",
60443
+ type: "function"
60444
+ },
60445
+ {
60446
+ inputs: [
60447
+ {
60448
+ internalType: "address",
60449
+ name: "",
60450
+ type: "address"
60451
+ }
60452
+ ],
60453
+ name: "operationCount",
60454
+ outputs: [
60455
+ {
60456
+ internalType: "uint256",
60457
+ name: "",
60458
+ type: "uint256"
60459
+ }
60460
+ ],
60461
+ stateMutability: "view",
60462
+ type: "function"
60463
+ },
60464
+ {
60465
+ inputs: [],
60466
+ name: "pause",
60467
+ outputs: [],
60468
+ stateMutability: "nonpayable",
60469
+ type: "function"
60470
+ },
60471
+ {
60472
+ inputs: [],
60473
+ name: "paused",
60474
+ outputs: [
60475
+ {
60476
+ internalType: "bool",
60477
+ name: "",
60478
+ type: "bool"
60479
+ }
60480
+ ],
60481
+ stateMutability: "view",
60482
+ type: "function"
60483
+ },
60484
+ {
60485
+ inputs: [],
60486
+ name: "proxiableUUID",
60487
+ outputs: [
60488
+ {
60489
+ internalType: "bytes32",
60490
+ name: "",
60491
+ type: "bytes32"
60492
+ }
60493
+ ],
60494
+ stateMutability: "view",
60495
+ type: "function"
60496
+ },
60497
+ {
60498
+ inputs: [
60499
+ {
60500
+ internalType: "address",
60501
+ name: "stablecoin",
60502
+ type: "address"
60503
+ },
60504
+ {
60505
+ internalType: "uint256",
60506
+ name: "ucdAmount",
60507
+ type: "uint256"
60508
+ },
60509
+ {
60510
+ internalType: "uint256",
60511
+ name: "minStablecoinOut",
60512
+ type: "uint256"
60513
+ }
60514
+ ],
60515
+ name: "redeem",
60516
+ outputs: [
60517
+ {
60518
+ internalType: "uint256",
60519
+ name: "stablecoinAmount",
60520
+ type: "uint256"
60521
+ }
60522
+ ],
60523
+ stateMutability: "nonpayable",
60524
+ type: "function"
60525
+ },
60526
+ {
60527
+ inputs: [],
60528
+ name: "redeemEnabled",
60529
+ outputs: [
60530
+ {
60531
+ internalType: "bool",
60532
+ name: "",
60533
+ type: "bool"
60534
+ }
60535
+ ],
60536
+ stateMutability: "view",
60537
+ type: "function"
60538
+ },
60539
+ {
60540
+ inputs: [
60541
+ {
60542
+ internalType: "address",
60543
+ name: "stablecoin",
60544
+ type: "address"
60545
+ }
60546
+ ],
60547
+ name: "removeSupportedStablecoin",
60548
+ outputs: [],
60549
+ stateMutability: "nonpayable",
60550
+ type: "function"
60551
+ },
60552
+ {
60553
+ inputs: [
60554
+ {
60555
+ internalType: "bytes32",
60556
+ name: "role",
60557
+ type: "bytes32"
60558
+ },
60559
+ {
60560
+ internalType: "address",
60561
+ name: "callerConfirmation",
60562
+ type: "address"
60563
+ }
60564
+ ],
60565
+ name: "renounceRole",
60566
+ outputs: [],
60567
+ stateMutability: "nonpayable",
60568
+ type: "function"
60569
+ },
60570
+ {
60571
+ inputs: [
60572
+ {
60573
+ internalType: "address",
60574
+ name: "",
60575
+ type: "address"
60576
+ }
60577
+ ],
60578
+ name: "reserves",
60579
+ outputs: [
60580
+ {
60581
+ internalType: "uint256",
60582
+ name: "",
60583
+ type: "uint256"
60584
+ }
60585
+ ],
60586
+ stateMutability: "view",
60587
+ type: "function"
60588
+ },
60589
+ {
60590
+ inputs: [
60591
+ {
60592
+ internalType: "bytes32",
60593
+ name: "role",
60594
+ type: "bytes32"
60595
+ },
60596
+ {
60597
+ internalType: "address",
60598
+ name: "account",
60599
+ type: "address"
60600
+ }
60601
+ ],
60602
+ name: "revokeRole",
60603
+ outputs: [],
60604
+ stateMutability: "nonpayable",
60605
+ type: "function"
60606
+ },
60607
+ {
60608
+ inputs: [
60609
+ {
60610
+ internalType: "bool",
60611
+ name: "enabled",
60612
+ type: "bool"
60613
+ }
60614
+ ],
60615
+ name: "setRedeemEnabled",
60616
+ outputs: [],
60617
+ stateMutability: "nonpayable",
60618
+ type: "function"
60619
+ },
60620
+ {
60621
+ inputs: [
60622
+ {
60623
+ internalType: "address",
60624
+ name: "",
60625
+ type: "address"
60626
+ }
60627
+ ],
60628
+ name: "stablecoinDecimals",
60629
+ outputs: [
60630
+ {
60631
+ internalType: "uint8",
60632
+ name: "",
60633
+ type: "uint8"
60634
+ }
60635
+ ],
60636
+ stateMutability: "view",
60637
+ type: "function"
60638
+ },
60639
+ {
60640
+ inputs: [
60641
+ {
60642
+ internalType: "address",
60643
+ name: "",
60644
+ type: "address"
60645
+ }
60646
+ ],
60647
+ name: "supportedStablecoins",
60648
+ outputs: [
60649
+ {
60650
+ internalType: "bool",
60651
+ name: "",
60652
+ type: "bool"
60653
+ }
60654
+ ],
60655
+ stateMutability: "view",
60656
+ type: "function"
60657
+ },
60658
+ {
60659
+ inputs: [
60660
+ {
60661
+ internalType: "bytes4",
60662
+ name: "interfaceId",
60663
+ type: "bytes4"
60664
+ }
60665
+ ],
60666
+ name: "supportsInterface",
60667
+ outputs: [
60668
+ {
60669
+ internalType: "bool",
60670
+ name: "",
60671
+ type: "bool"
60672
+ }
60673
+ ],
60674
+ stateMutability: "view",
60675
+ type: "function"
60676
+ },
60677
+ {
60678
+ inputs: [
60679
+ {
60680
+ internalType: "address",
60681
+ name: "stablecoin",
60682
+ type: "address"
60683
+ },
60684
+ {
60685
+ internalType: "uint256",
60686
+ name: "amountIn",
60687
+ type: "uint256"
60688
+ },
60689
+ {
60690
+ internalType: "uint256",
60691
+ name: "minUcdOut",
60692
+ type: "uint256"
60693
+ }
60694
+ ],
60695
+ name: "swap",
60696
+ outputs: [
60697
+ {
60698
+ internalType: "uint256",
60699
+ name: "ucdAmount",
60700
+ type: "uint256"
60701
+ }
60702
+ ],
60703
+ stateMutability: "nonpayable",
60704
+ type: "function"
60705
+ },
60706
+ {
60707
+ inputs: [
60708
+ {
60709
+ internalType: "address",
60710
+ name: "stablecoin",
60711
+ type: "address"
60712
+ }
60713
+ ],
60714
+ name: "syncReserves",
60715
+ outputs: [],
60716
+ stateMutability: "nonpayable",
60717
+ type: "function"
60718
+ },
60719
+ {
60720
+ inputs: [],
60721
+ name: "ucdDecimals",
60722
+ outputs: [
60723
+ {
60724
+ internalType: "uint8",
60725
+ name: "",
60726
+ type: "uint8"
60727
+ }
60728
+ ],
60729
+ stateMutability: "view",
60730
+ type: "function"
60731
+ },
60732
+ {
60733
+ inputs: [],
60734
+ name: "ucdToken",
60735
+ outputs: [
60736
+ {
60737
+ internalType: "address",
60738
+ name: "",
60739
+ type: "address"
60740
+ }
60741
+ ],
60742
+ stateMutability: "view",
60743
+ type: "function"
60744
+ },
60745
+ {
60746
+ inputs: [],
60747
+ name: "unpause",
60748
+ outputs: [],
60749
+ stateMutability: "nonpayable",
60750
+ type: "function"
60751
+ },
60752
+ {
60753
+ inputs: [
60754
+ {
60755
+ internalType: "address",
60756
+ name: "stablecoin",
60757
+ type: "address"
60758
+ },
60759
+ {
60760
+ internalType: "uint256",
60761
+ name: "exchangeRate",
60762
+ type: "uint256"
60763
+ },
60764
+ {
60765
+ internalType: "uint256",
60766
+ name: "entryFeeBps",
60767
+ type: "uint256"
60768
+ },
60769
+ {
60770
+ internalType: "uint256",
60771
+ name: "exitFeeBps",
60772
+ type: "uint256"
60773
+ },
60774
+ {
60775
+ internalType: "uint8",
60776
+ name: "decimals",
60777
+ type: "uint8"
60778
+ },
60779
+ {
60780
+ internalType: "uint256",
60781
+ name: "minSwapAmount",
60782
+ type: "uint256"
60783
+ },
60784
+ {
60785
+ internalType: "uint256",
60786
+ name: "minRedeemAmount",
60787
+ type: "uint256"
60788
+ },
60789
+ {
60790
+ internalType: "uint256",
60791
+ name: "maxSwapAmount",
60792
+ type: "uint256"
60793
+ },
60794
+ {
60795
+ internalType: "uint256",
60796
+ name: "maxRedeemAmount",
60797
+ type: "uint256"
60798
+ }
60799
+ ],
60800
+ name: "updateSupportedStablecoin",
60801
+ outputs: [],
60802
+ stateMutability: "nonpayable",
60803
+ type: "function"
60804
+ },
60805
+ {
60806
+ inputs: [
60807
+ {
60808
+ internalType: "address",
60809
+ name: "newImplementation",
60810
+ type: "address"
60811
+ },
60812
+ {
60813
+ internalType: "bytes",
60814
+ name: "data",
60815
+ type: "bytes"
60816
+ }
60817
+ ],
60818
+ name: "upgradeToAndCall",
60819
+ outputs: [],
60820
+ stateMutability: "payable",
60821
+ type: "function"
60822
+ },
60823
+ {
60824
+ inputs: [],
60825
+ name: "version",
60826
+ outputs: [
60827
+ {
60828
+ internalType: "string",
60829
+ name: "",
60830
+ type: "string"
60831
+ }
60832
+ ],
60833
+ stateMutability: "pure",
60834
+ type: "function"
60835
+ },
60836
+ {
60837
+ inputs: [
60838
+ {
60839
+ internalType: "address",
60840
+ name: "stablecoin",
60841
+ type: "address"
60842
+ },
60843
+ {
60844
+ internalType: "uint256",
60845
+ name: "amount",
60846
+ type: "uint256"
60847
+ }
60848
+ ],
60849
+ name: "withdrawStablecoin",
60850
+ outputs: [],
60851
+ stateMutability: "nonpayable",
60852
+ type: "function"
60853
+ }
60854
+ ];
60855
+ var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161347190816100f0823960805181818161195b0152611a2b0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce9146126e357806301ffc9a71461268c578063021d28931461263e5780630871b20614612605578063114249d2146105ab57806311d954f8146125dc57806313da3166146125a35780631f77bf651461256a578063248a9ca3146125435780632b83cccd1461211d5780632f2ff15d146120eb57806334e18125146120b257806336568abe1461206d5780633f4ba83a14611feb5780634451e89b14611ca25780634ebd25a514611c695780634f1ef286146119b057806352d1902d1461194857806354fd4d50146119095780635c975abb146118d95780638456cb591461186457806385c15d9a1461182b5780638bff608e146117f257806390ad8b40146117d657806391d148541461177d5780639baf58d2146117605780639f1d0f5914611315578063a217fddf146112f9578063ad3cb1cc146112b6578063b121cf7e14610fc2578063b492fc6914610ec8578063b9f637af14610cdd578063bf7d911914610c9e578063c0c53b8b146109b6578063c4c5f6241461090e578063c55f15ea146108eb578063cc1f8ffa146108b9578063cf46075e146107b9578063d21a74ff1461077c578063d2f8253614610759578063d547741f1461071e578063d5d3f78b146105e4578063d66bd524146105ab578063e1f1c4a71461058e578063ec2f96fe1461056a578063f385116d14610531578063f77c47911461050a578063faaebd21146104d1578063facdfb5e1461033b5763fc99bd9a1461024257600080fd5b346103385760403660031901126103385761025b6127ea565b9060243591610268612c82565b6001600160a01b03168082526002602052604082205490929060ff16156103255780156103165782825260076020526040822054926102a78285612b3d565b848110610307576001600160ff1b0381116102f857600080516020613445833981519152604085968493846102f59852600760205280838a205582519182526020820152a2309033906130c9565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b80fd5b5034610338576020366003190112610338576103556127ea565b61035d612d68565b610365612c82565b6001600160a01b03168082526002602052604082205460ff16156104bf57808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa9081156104b457849161047d575b508181111561046e576103cd82826129b3565b8215908115610419575b5050600080516020613445833981519152916040918486526007602052808387205582519182526020820152a260016000805160206133e58339815191525580f35b612710810290808204612710149015171561045a576064840291848304606414171561045a571161044b5738806103d7565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b61047881836129b3565b6103cd565b90506020813d6020116104ac575b816104986020938361287f565b810103126104a75751386103ba565b600080fd5b3d915061048b565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b5034610338576020366003190112610338576020906040906001600160a01b036104f96127ea565b168152600483522054604051908152f35b5034610338578060031936011261033857546040516001600160a01b039091168152602090f35b5034610338576020366003190112610338576020906040906001600160a01b036105596127ea565b168152600a83522054604051908152f35b5034610338578060031936011261033857602060ff60015460a01c16604051908152f35b503461033857806003193601126103385760206040516127108152f35b5034610338576020366003190112610338576020906040906001600160a01b036105d36127ea565b168152600783522054604051908152f35b5034610338576020366003190112610338576105fe6127ea565b610606612c82565b6001600160a01b03168082526002602052604082205460ff16156104bf5780825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806106fb578380f35b816040916000805160206134458339815191529352846020820152a23880808380f35b50346103385760403660031901126103385761075560043561073e612800565b9061075061074b82612a58565b612d1e565b613029565b5080f35b5034610338578060031936011261033857602060ff600854166040519015158152f35b50346103385760203660031901126103385760209060ff906040906001600160a01b036107a76127ea565b16815260058452205416604051908152f35b5034610338576020366003190112610338576107d36127ea565b6107db612d68565b6107e3612c82565b6001600160a01b03168082526002602052604082205460ff16156104bf57808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa9081156104b4578491610879575b50600080516020613445833981519152916040918486526007602052808387205582519182526020820152a260016000805160206133e58339815191525580f35b90506020813d6020116108b1575b816108946020938361287f565b810103126104a75751600080516020613445833981519152610838565b3d9150610887565b50346103385760403660031901126103385760206108e16108d86127ea565b60243590612b83565b6040519015158152f35b50346103385780600319360112610338576020604051670de0b6b3a76400008152f35b5034610338576040366003190112610338576109286127ea565b9060243591610935612c82565b6001600160a01b031680825260076020526040822054929081841061099f5780600080516020613445833981519152604086610975866102f598996129b3565b84895260076020528289205583885260076020528188205482519182526020820152a23390612dce565b5091604492633cb8e07360e01b8352600452602452fd5b5034610338576060366003190112610338576109d06127ea565b6109d8612800565b604435906001600160a01b03821690818303610c9a5760008051602061342583398151915254604081901c60ff161594906001600160401b031680159081610c92575b6001149081610c88575b159081610c7f575b50610c705760008051602061342583398151915280546001600160401b031916600117905584610c4b575b6001600160a01b0316908115610c3c576001600160a01b0316918215610c2d5715610c1e57610a856131f5565b610a8d6131f5565b610a956131f5565b60016000805160206133e583398151915255610aaf6131f5565b610ab76131f5565b84546001600160a01b0319908116919091178555600180549182168317905560405163313ce56760e01b8152909190602081600481855afa869181610bed575b50610b0b57633a24e95b60e11b8652600486fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16600681141580610be2575b610bd05750610b4781612e0a565b15610bc157610b5581612e86565b15610bc157610b6390612f0c565b15610bb257610b6f5780f35b60ff60401b19600080516020613425833981519152541660008051602061342583398151915255600080516020613305833981519152602060405160018152a180f35b63cf5a8e3360e01b8252600482fd5b63cf5a8e3360e01b8352600483fd5b63167738cf60e21b8452600452602483fd5b506012811415610b39565b610c1091925060203d602011610c17575b610c08818361287f565b810190612a88565b9038610af7565b503d610bfe565b630b5eba9f60e41b8552600485fd5b63c1ab6dc160e01b8652600486fd5b6336abb4df60e11b8652600486fd5b600080516020613425833981519152805460ff60401b1916600160401b179055610a58565b63f92ee8a960e01b8652600486fd5b90501538610a2d565b303b159150610a25565b869150610a1b565b8480fd5b50346103385760203660031901126103385760209060ff906040906001600160a01b03610cc96127ea565b168152600284522054166040519015158152f35b503461033857610cec3661291c565b98979694610cfe949194939293612c82565b6001600160a01b038816808a52600260205260408a205490989060ff1615610eb4578615610ea5576127108811610e8b576103e88211610e715760ff831690601282118015610e67575b610e535783610d569161310d565b85151580610e4a575b610e33578a151580610e2a575b610e1357926000805160206132c583398151915297969592828c95610e0d979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889612b4a565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10610d6c565b60448a8588637449915760e01b8352600452602452fd5b50838610610d5f565b63ca95039160e01b8b52600482905260248bfd5b5060068210610d48565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b503461033857604036600319011261033857610ee26127ea565b6001600160a01b0316808252600260205260408220546024359060ff1615610fae578015610f9f57612710610f64604085670de0b6b3a7640000610f53610f6c9688859a52600560205260ff858520541690809160128110610f79575b50508884526003602052848420549061296a565b04958152600460205220548461296a565b0480926129b3565b9082519182526020820152f35b610f98925060ff610f8c610f92926129c0565b166129d1565b9061296a565b3880610f3f565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033857610fd13661291c565b93610fe3999899979597939193612c82565b6001600160a01b038a16808a52600260205260408a205490989060ff166112a2578815611293578615610ea5576127108811610e8b576103e8811161127b5760ff82169a60128c118015611271575b61125d57803b1561124957826110479161310d565b84151580611240575b6112295785151580611220575b611209576040516370a0823160e01b8152306004820152999a98999860208a6024818e5afa998a156111fe578c9a6111ca575b506001600160ff1b038a116111bb57926000805160206132c583398151915297959261118b95928b60408f8f9d9b988e8083526002602052838320600160ff1982541617905580835260036020528c8484205580835260046020528d8484205580835260066020528584842055825260056020528282209060ff198254161790558d8152600c60205285828220558d8152600d60205286828220558d8152600e60205287828220558d8152600f60205288828220558d8152600760205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf666604080518b81528c6020820152a260405198899889612b4a565b0390a280611197578280f35b6040600080516020613445833981519152918151908582526020820152a238808280f35b63556e7a8160e01b8c5260048cfd5b9099506020813d6020116111f6575b816111e66020938361287f565b810103126104a757519838611090565b3d91506111d9565b6040513d8e823e3d90fd5b60448a858863dd85772b60e01b8352600452602452fd5b5083861061105d565b60448a8487637449915760e01b8352600452602452fd5b50828510611050565b63377e3f9960e21b8b5260048a905260248bfd5b63ca95039160e01b8b5260048c905260248bfd5b5060068c10611032565b631051834f60e11b8a526004526103e8602452604489fd5b63df407ac560e01b8a5260048afd5b6317f4215b60e21b8a52600489905260248afd5b50346103385780600319360112610338576112f560408051906112d9818361287f565b60058252640352e302e360dc1b602083015251918291826128d3565b0390f35b5034610338578060031936011261033857602090604051908152f35b50346103385761132436612825565b91611330939193612d68565b611338612da4565b33825260096020526040822054430361173e57338252600a60205260036040832054101561172f57338252600a602052604082206113768154612a79565b90555b6001600160a01b03168082526002602052604082205490919060ff16611692575b818152600260205260ff6040822054161561168057831561167157821561166257818152600c6020526040812054841061163e57818152600e6020526040812054801561162f578085116116175750818152600760205260408120546114008582612b3d565b818110611608576001600160ff1b0381116115f95760408492600080516020613445833981519152928486526007602052808387205582519182526020820152a261144d843033856130c9565b818152600560205260ff604082205416849060128110611598575b50611489670de0b6b3a764000091848452600360205260408420549061296a565b049082815260046020526114af6127106114a760408420548561296a565b0480936129b3565b93808510611580575080546001600160a01b0316803b1561157c5781809160846040518094819363ae494fa160e01b83523360048401528a60248401528960448401528b60648401525af180156115715761155c575b50507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b61153f602095604051918291339588429285612abc565b0390a360016000805160206133e583398151915255604051908152f35b61156782809261287f565b6103385780611505565b6040513d84823e3d90fd5b5080fd5b6371c4efed60e01b8252600485905260245260449150fd5b6115a89150610f8c60ff916129c0565b80156115e557806000190485116115d6576114896115cf670de0b6b3a7640000928761296a565b9150611468565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b631d7f2ac360e01b8252600485905260245260449150fd5b633b5db2f360e11b8252600482fd5b908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8152600490fd5b63162908e360e11b8152600490fd5b6024916374ed46ad60e01b8252600452fd5b919060405163313ce56760e01b8152602081600481855afa84918161170e575b506116c65763105482c760e21b8452600484fd5b92909192828252600560205260ff8060408420541691169081036116ea575061139a565b6044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b61172891925060203d602011610c1757610c08818361287f565b90386116b2565b63a74c1c5f60e01b8252600482fd5b3382526009602052436040832055338252600a60205260016040832055611379565b503461033857806003193601126103385760206040516103e88152f35b5034610338576040366003190112610338576040611799612800565b9160043581526000805160206133a5833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b5034610338578060031936011261033857602060405160648152f35b5034610338576020366003190112610338576020906040906001600160a01b0361181a6127ea565b168152600983522054604051908152f35b5034610338576020366003190112610338576020906040906001600160a01b036118536127ea565b168152600383522054604051908152f35b503461033857806003193601126103385761187d612cd0565b611885612da4565b600160ff196000805160206133c58339815191525416176000805160206133c5833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b5034610338578060031936011261033857602060ff6000805160206133c583398151915254166040519015158152f35b50346103385780600319360112610338576112f5604080519061192c818361287f565b60058252640322e302e360dc1b602083015251918291826128d3565b50346103385780600319360112610338577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036119a15760206040516000805160206133458339815191528152f35b63703e46dd60e11b8152600490fd5b506040366003190112610338576119c56127ea565b602435906001600160401b038211611c655736602383011215611c6557816004013590836119f2836128b8565b93611a00604051958661287f565b83855260208501933660248284010111611c6557806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115611c42575b50611c33578380526000805160206133a583398151915260209081526040808620336000908152925290205460ff1615611c1b576001600160a01b038116928315611c0c57813b15611bfd576040516352d1902d60e01b8152602081600481885afa869181611bc5575b50611ad957634c9c8ce360e01b86526004859052602486fd5b9384600080516020613345833981519152879603611bb35750823b15611ba15760008051602061334583398151915280546001600160a01b031916821790558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115611b86576107559382915190845af43d15611b7e573d91611b62836128b8565b92611b70604051948561287f565b83523d85602085013e613223565b606091613223565b5050505034611b925780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b8552600452602484fd5b632a87526960e21b8652600452602485fd5b9091506020813d602011611bf5575b81611be16020938361287f565b81010312611bf157519038611ac0565b8680fd5b3d9150611bd4565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b63e2517d3f60e01b8452336004526024849052604484fd5b63703e46dd60e11b8452600484fd5b600080516020613345833981519152546001600160a01b03161415905038611a56565b8280fd5b5034610338576020366003190112610338576020906040906001600160a01b03611c916127ea565b168152600e83522054604051908152f35b503461033857606036600319011261033857611cbc612816565b6024356001600160401b038111611c6557611cdb90369060040161284f565b916044356001600160401b038111610c9a57611cfb90369060040161284f565b6000805160206134258339815191529291925460ff8160401c16908115611fd3575b50610c705760008051602061342583398151915280546001600160481b0319166002600160401b01179055611d50612c82565b600b549160ff8316611fc457818603611fb557611d6c86612ad8565b92611d7a604051948561287f565b868452601f19611d8988612ad8565b01366020860137875b878110611ec0575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110611e1d57876000805160206132a5833981519152602089604051908152a160ff60401b19600080516020613425833981519152541660008051602061342583398151915255600080516020613305833981519152602060405160028152a180f35b80886000805160206134458339815191526040611e45611e40600196888d612aef565b612b15565b611e5085898c612aef565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783611e7d888d612b29565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201611db9565b611ece611e40828a8a612aef565b611ed9828689612aef565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615611fa1576103e88111611f895750906020602492604051938480926370a0823160e01b82523060048301525afa8015611f7e578a90611f48575b60019250611f418288612b29565b5201611d92565b509060203d8111611f77575b611f5e818361287f565b6020826000928101031261033857509060019151611f33565b503d611f54565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b60026001600160401b03919091161015905038611d1d565b5034610338578060031936011261033857612004612cd0565b6000805160206133c58339815191525460ff81161561205e5760ff19166000805160206133c5833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b638dfc202b60e01b8252600482fd5b503461033857604036600319011261033857612087612800565b336001600160a01b038216036120a35761075590600435613029565b63334bd91960e11b8252600482fd5b5034610338576020366003190112610338576020906040906001600160a01b036120da6127ea565b168152600c83522054604051908152f35b50346103385760403660031901126103385761075560043561210b612800565b9061211861074b82612a58565b612f92565b50346103385761212c36612825565b91612135612d68565b61213d612da4565b33845260096020526040842054430361252157338452600a60205260036040852054101561251257338452600a6020526040842061217b8154612a79565b90555b6001600160a01b03168084526002602052604084205490919060ff1661247a575b818452600260205260ff604085205416156124665760ff600854161561245757801561244857821561243957818452600d60205260408420548082106124215750818452600f60205260408420548015612412578082116123fb5750670de0b6b3a76400008102818104670de0b6b3a7640000036123e7578285526003602052604085205461222d91612993565b90828552600660205261224a6127106114a760408820548561296a565b93838652600560205260ff604087205416601281106123bc575b508085106123a557508285526007602052836040862054106123815782855260076020526040852054848110612372576000805160206134458339815191526040826122b18888956129b3565b848a52600760205280838b205582519182526020820152a284546001600160a01b0316803b1561236e578560405180926306888c6760e11b82528183816122fc883360048401612aa1565b03925af18015612363579160209661153f927f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf94612353575b5050612342863387612dce565b604051918291339588429285612abc565b8161235d9161287f565b38612335565b6040513d88823e3d90fd5b8580fd5b6308aed4ef60e31b8652600486fd5b82855260076020526040852054635960d22160e01b86526004526024849052604485fd5b6371c4efed60e01b86526004859052602452604485fd5b946123da6123d360ff610f8c6123e09597996129c0565b8092612993565b95612993565b9138612264565b634e487b7160e01b85526011600452602485fd5b625502a360e91b8552600491909152602452604483fd5b636c6ff70d60e11b8552600485fd5b6361767b8560e01b8552600491909152602452604483fd5b632cd84af360e01b8452600484fd5b63162908e360e11b8452600484fd5b630df65d9f60e01b8452600484fd5b6374ed46ad60e01b84526004829052602484fd5b60405163313ce56760e01b8152602081600481865afa8591816124f1575b506124ac5763105482c760e21b8552600485fd5b828552600560205260ff8060408720541691169081036124cc575061219f565b82855260056020526040852054631e43476360e11b865260ff16600452602452604484fd5b61250b91925060203d602011610c1757610c08818361287f565b9038612498565b63a74c1c5f60e01b8452600484fd5b3384526009602052436040852055338452600a6020526001604085205561217e565b5034610338576020366003190112610338576020612562600435612a58565b604051908152f35b5034610338576020366003190112610338576020906040906001600160a01b036125926127ea565b168152600f83522054604051908152f35b5034610338576020366003190112610338576020906040906001600160a01b036125cb6127ea565b168152600683522054604051908152f35b50346103385780600319360112610338576001546040516001600160a01b039091168152602090f35b5034610338576020366003190112610338576020906040906001600160a01b0361262d6127ea565b168152600d83522054604051908152f35b5034610338576020366003190112610338576000805160206132a58339815191526020612669612816565b612671612c82565b151560ff196008541660ff821617600855604051908152a180f35b50346103385760203660031901126103385760043563ffffffff60e01b811680910361157c57602090637965db0b60e01b81149081156126d2575b506040519015158152f35b6301ffc9a760e01b149050826126c7565b5034610338576040366003190112610338576126fd6127ea565b6001600160a01b03168082526002602052604082205460243592919060ff16156127d757670de0b6b3a7640000830292808404670de0b6b3a764000014901517156127c35760ff604061275d819584865260036020528286205490612993565b938381526006602052612781612710612779848420548861296a565b0480966129b3565b938152600560205220541660128110156127bc57906127aa6123d360ff610f8c6127b0956129c0565b92612993565b82519182526020820152f35b50906127b0565b634e487b7160e01b82526011600452602482fd5b6374ed46ad60e01b825260045260249150fd5b600435906001600160a01b03821682036104a757565b602435906001600160a01b03821682036104a757565b6004359081151582036104a757565b60609060031901126104a7576004356001600160a01b03811681036104a757906024359060443590565b9181601f840112156104a7578235916001600160401b0383116104a7576020808501948460051b0101116104a757565b601f909101601f19168101906001600160401b038211908210176128a257604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116128a257601f01601f191660200190565b91909160208152825180602083015260005b818110612906575060409293506000838284010152601f8019910116010190565b80602080928701015160408286010152016128e5565b6101209060031901126104a7576004356001600160a01b03811681036104a7579060243590604435906064359060843560ff811681036104a7579060a4359060c4359060e435906101043590565b8181029291811591840414171561297d57565b634e487b7160e01b600052601160045260246000fd5b811561299d570490565b634e487b7160e01b600052601260045260246000fd5b9190820391821161297d57565b60ff166012039060ff821161297d57565b8015612a525760009060208110600116604e821060011617612a4a57600a916001915b60018111612a21575082600019048211612a0d57500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116127c35760018416612a41575b80029260011c6129f4565b80920291612a36565b9050600a0a90565b50600190565b6000526000805160206133a583398151915260205260016040600020015490565b600019811461297d5760010190565b908160209103126104a7575160ff811681036104a75790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116128a25760051b60200190565b9190811015612aff5760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036104a75790565b8051821015612aff5760209160051b010190565b9190820180921161297d57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015612c75575b8015612c6d575b612c5b5781600052600f6020526040600020548015908115612c63575b50612c5b57612bf3926040918251948592839262f7fce960e01b845260048401612aa1565b0381305afa918215612c4f57600092612c1b575b506000526007602052604060002054101590565b9091506040813d604011612c47575b81612c376040938361287f565b810103126104a757519038612c07565b3d9150612c2a565b6040513d6000823e3d90fd5b505050600090565b9050831138612bce565b508215612bb1565b5060ff6008541615612baa565b3360009081526000805160206132e5833981519152602052604090205460ff1615612ca957565b63e2517d3f60e01b6000523360045260008051602061340583398151915260245260446000fd5b336000908152600080516020613365833981519152602052604090205460ff1615612cf757565b63e2517d3f60e01b6000523360045260008051602061338583398151915260245260446000fd5b60008181526000805160206133a58339815191526020908152604080832033845290915290205460ff1615612d505750565b63e2517d3f60e01b6000523360045260245260446000fd5b60026000805160206133e58339815191525414612d935760026000805160206133e583398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206133c58339815191525416612dbd57565b63d93c066560e01b60005260046000fd5b612e03612e089392612df560405194859263a9059cbb60e01b602085015260248401612aa1565b03601f19810184528361287f565b61319a565b565b6001600160a01b0381166000908152600080516020613325833981519152602052604090205460ff16612e80576001600160a01b0316600081815260008051602061332583398151915260205260408120805460ff191660011790553391906000805160206132858339815191528180a4600190565b50600090565b6001600160a01b03811660009081526000805160206132e5833981519152602052604090205460ff16612e80576001600160a01b031660008181526000805160206132e583398151915260205260408120805460ff19166001179055339190600080516020613405833981519152906000805160206132858339815191529080a4600190565b6001600160a01b0381166000908152600080516020613365833981519152602052604090205460ff16612e80576001600160a01b0316600081815260008051602061336583398151915260205260408120805460ff19166001179055339190600080516020613385833981519152906000805160206132858339815191529080a4600190565b60008181526000805160206133a5833981519152602090815260408083206001600160a01b038616845290915290205460ff166130225760008181526000805160206133a5833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291906000805160206132858339815191529080a4600190565b5050600090565b60008181526000805160206133a5833981519152602090815260408083206001600160a01b038616845290915290205460ff16156130225760008181526000805160206133a5833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152612e0891612e0360848361287f565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa60009281613179575b5061315057631eecbb6560e01b60005260046000fd5b60ff9182169116808203613162575050565b631e43476360e11b60005260045260245260446000fd5b61319391935060203d602011610c1757610c08818361287f565b913861313a565b906000602091828151910182855af115612c4f576000513d6131ec57506001600160a01b0381163b155b6131cb5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b600114156131c4565b60ff6000805160206134258339815191525460401c161561321257565b631afcd79f60e31b60005260046000fd5b90613249575080511561323857602081519101fd5b63d6bda27560e01b60005260046000fd5b8151158061327b575b61325a575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561325256fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629b16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431cc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2b7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc75442b0a96088b5456bc4ed01394c96a4feec0f883c9494257d76b96ab1c9b6b65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
60856
+ var isSuperArgs = (xs) => xs.length > 1;
60857
+ var SimplePSMV2__factory = class extends ContractFactory {
60858
+ constructor(...args) {
60859
+ if (isSuperArgs(args)) {
60860
+ super(...args);
60861
+ } else {
60862
+ super(_abi, _bytecode, args[0]);
60863
+ }
60864
+ }
60865
+ getDeployTransaction(overrides) {
60866
+ return super.getDeployTransaction(overrides || {});
60867
+ }
60868
+ deploy(overrides) {
60869
+ return super.deploy(overrides || {});
60870
+ }
60871
+ connect(runner) {
60872
+ return super.connect(runner);
60873
+ }
60874
+ static bytecode = _bytecode;
60875
+ static abi = _abi;
60876
+ static createInterface() {
60877
+ return new Interface(_abi);
60878
+ }
60879
+ static connect(address, runner) {
60880
+ return new Contract(address, _abi, runner);
60881
+ }
60882
+ };
60883
+
60884
+ // src/modules/mock/mock-token-manager.module.ts
60885
+ var MockTokenManager = class {
60886
+ config;
60887
+ constructor(config) {
60888
+ this.config = config;
60889
+ if (this.isProductionNetwork()) {
60890
+ log.warn("\u26A0\uFE0F MockTokenManager initialized on production network", {
60891
+ network: config.network
60892
+ });
60893
+ }
60894
+ }
60895
+ /**
60896
+ * Mint mock BTC tokens
60897
+ *
60898
+ * @param amount - Amount to mint in satoshis
60899
+ * @param recipient - Recipient address
60900
+ * @returns Transaction result
60901
+ */
60902
+ async mintMockBTC(amount, recipient) {
60903
+ if (this.config.debug) {
60904
+ log.info("\u{1FA99} Minting mock BTC", {
60905
+ amount: amount.toString(),
60906
+ recipient
60907
+ });
60908
+ }
60909
+ if (this.isProductionNetwork()) {
60910
+ return failure(
60911
+ new SDKError({
60912
+ message: "Cannot mint mock tokens on production network",
60913
+ category: "CONFIGURATION" /* CONFIGURATION */,
60914
+ severity: "HIGH" /* HIGH */,
60915
+ originalError: new Error("Production network detected")
60916
+ })
60917
+ );
60918
+ }
60919
+ return tryCatchAsync(
60920
+ async () => {
60921
+ const signerResult = this.config.contractManager.getSigner();
60922
+ if (!signerResult.success) {
60923
+ throw signerResult.error;
60924
+ }
60925
+ throw new Error("Mock BTC contract not yet integrated");
60926
+ },
60927
+ (error) => new SDKError({
60928
+ message: "Failed to mint mock BTC",
60929
+ category: "CONTRACT" /* CONTRACT */,
60930
+ severity: "MEDIUM" /* MEDIUM */,
60931
+ originalError: error instanceof Error ? error : new Error(String(error)),
60932
+ context: { amount: amount.toString(), recipient }
60933
+ })
60934
+ );
60935
+ }
60936
+ /**
60937
+ * Approve mock BTC spending
60938
+ *
60939
+ * @param spender - Spender address
60940
+ * @param amount - Amount to approve in satoshis
60941
+ * @returns Transaction result
60942
+ */
60943
+ async approveMockBTC(spender, amount) {
60944
+ if (this.config.debug) {
60945
+ log.info("\u2705 Approving mock BTC spending", {
60946
+ spender,
60947
+ amount: amount.toString()
60948
+ });
60949
+ }
60950
+ if (this.isProductionNetwork()) {
60951
+ return failure(
60952
+ new SDKError({
60953
+ message: "Cannot approve mock tokens on production network",
60954
+ category: "CONFIGURATION" /* CONFIGURATION */,
60955
+ severity: "HIGH" /* HIGH */,
60956
+ originalError: new Error("Production network detected")
60957
+ })
60958
+ );
60959
+ }
60960
+ return tryCatchAsync(
60961
+ async () => {
60962
+ const signerResult = this.config.contractManager.getSigner();
60963
+ if (!signerResult.success) {
60964
+ throw signerResult.error;
60965
+ }
60966
+ throw new Error("Mock BTC contract not yet integrated");
60967
+ },
60968
+ (error) => new SDKError({
60969
+ message: "Failed to approve mock BTC",
60970
+ category: "CONTRACT" /* CONTRACT */,
60971
+ severity: "MEDIUM" /* MEDIUM */,
60972
+ originalError: error instanceof Error ? error : new Error(String(error)),
60973
+ context: { spender, amount: amount.toString() }
60974
+ })
60975
+ );
60976
+ }
60977
+ /**
60978
+ * Get mock BTC balance
60979
+ *
60980
+ * @param address - Address to query
60981
+ * @returns Balance in satoshis
60982
+ */
60983
+ async getMockBTCBalance(address) {
60984
+ if (this.config.debug) {
60985
+ log.info("\u{1F50D} Querying mock BTC balance", { address });
60986
+ }
60987
+ return tryCatchAsync(
60988
+ async () => {
60989
+ throw new Error("Mock BTC contract not yet integrated");
60990
+ },
60991
+ (error) => new SDKError({
60992
+ message: "Failed to get mock BTC balance",
60993
+ category: "CONTRACT" /* CONTRACT */,
60994
+ severity: "MEDIUM" /* MEDIUM */,
60995
+ originalError: error instanceof Error ? error : new Error(String(error)),
60996
+ context: { address }
60997
+ })
60998
+ );
60999
+ }
61000
+ /**
61001
+ * Check if current network is production (mainnet)
61002
+ */
61003
+ isProductionNetwork() {
61004
+ return this.config.network.toLowerCase().includes("mainnet");
61005
+ }
61006
+ };
61007
+ function createMockTokenManager(config) {
61008
+ try {
61009
+ const manager = new MockTokenManager(config);
61010
+ return success(manager);
61011
+ } catch (error) {
61012
+ return failure(
61013
+ new SDKError({
61014
+ message: "Failed to create MockTokenManager",
61015
+ category: "INITIALIZATION" /* INITIALIZATION */,
61016
+ severity: "HIGH" /* HIGH */,
61017
+ originalError: error instanceof Error ? error : new Error(String(error))
61018
+ })
61019
+ );
61020
+ }
61021
+ }
61022
+
61023
+ // src/modules/diamond-hands-sdk.ts
61024
+ var import_dh_lit_actions2 = __toESM(require_pkg_src());
61025
+ import { LitOps } from "@gvnrdao/dh-lit-ops";
61026
+
61027
+ // src/utils/telegram-messaging.utils.ts
61028
+ var TelegramBot = null;
61029
+ try {
61030
+ if (typeof window === "undefined" && typeof global !== "undefined") {
61031
+ TelegramBot = __require("node-telegram-bot-api");
61032
+ }
61033
+ } catch (error) {
61034
+ console.warn("Telegram bot API not available:", error instanceof Error ? error.message : String(error));
61035
+ }
61036
+ function formatMintMessage(mintAmount, loanId, txHash) {
61037
+ return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
61038
+ }
61039
+ function formatPartialPaymentMessage(paymentAmount, loanId, txHash) {
61040
+ return `\u2705 DH SDK: ${paymentAmount} UCD was repaid for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
61041
+ }
61042
+ function formatPartialPaymentFailureMessage(paymentAmount, loanId, txHash) {
61043
+ const baseMessage = `\u274C DH SDK: FAILED to repay ${paymentAmount} UCD for loan id: ${loanId}`;
61044
+ if (txHash) {
61045
+ return `${baseMessage} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
61046
+ }
61047
+ return baseMessage;
61048
+ }
61049
+ function formatLoanCreationMessage(positionId, pkpId, vaultAddress) {
61050
+ const vault = vaultAddress || "unknown";
61051
+ return `\u2705 DH SDK: A new loan was created Id: ${positionId} Pkp: ${pkpId} Regtest BTC vault: ${vault}`;
61052
+ }
58913
61053
  function formatBTCWithdrawalFailureMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId) {
58914
61054
  const formattedAmount = formatBTCAmount(withdrawalAmount);
58915
61055
  return `\u274C DH SDK: BTC withdrawal FAILED: ${formattedAmount} from ${btcVault} to ${btcDestinationAddress} for loan id: ${loanId}`;
@@ -59035,7 +61175,8 @@ function normalizeTransactionReceipt(receipt) {
59035
61175
  transactionIndex: receiptObj.transactionIndex,
59036
61176
  gasUsed: receiptObj.gasUsed ? normalizeBigNumberish(receiptObj.gasUsed) : void 0,
59037
61177
  blockHash: receiptObj.blockHash,
59038
- transactionHash: receiptObj.transactionHash,
61178
+ transactionHash: receiptObj.transactionHash ?? receiptObj.hash,
61179
+ hash: receiptObj.hash ?? receiptObj.transactionHash,
59039
61180
  blockNumber: receiptObj.blockNumber,
59040
61181
  confirmations: receiptObj.confirmations,
59041
61182
  cumulativeGasUsed: receiptObj.cumulativeGasUsed ? normalizeBigNumberish(receiptObj.cumulativeGasUsed) : void 0,
@@ -64513,6 +66654,45 @@ Error data: ${errorData || "none"}`
64513
66654
  async getLoanEvents(positionId, filter) {
64514
66655
  return this.loanQuery.getLoanEvents(positionId, filter);
64515
66656
  }
66657
+ /**
66658
+ * Get protocol-wide events across all indexed entity types.
66659
+ * Returns a merged, sorted discriminated-union timeline.
66660
+ * Narrow to a position with filter.positionId, or restrict event kinds with filter.kinds.
66661
+ */
66662
+ async getAllEvents(filter) {
66663
+ return this.graphClient.getAllEvents(filter);
66664
+ }
66665
+ // ============================================================================
66666
+ // HIGH-LEVEL API - PSM (Peg Stability Module)
66667
+ // ============================================================================
66668
+ /**
66669
+ * Return PSM-supported stablecoins from the subgraph, including indexed reserves,
66670
+ * fees, exchange rate, and volume stats.
66671
+ *
66672
+ * @param onlySupported - When true (default) filters to currently-supported coins only.
66673
+ */
66674
+ async getPSMStablecoins(onlySupported = true) {
66675
+ return this.graphClient.getSupportedStablecoins(onlySupported);
66676
+ }
66677
+ /**
66678
+ * Return the live on-chain available reserve balance for a single stablecoin in the PSM.
66679
+ * Prefer this over the subgraph `reserves` field when freshness matters (e.g. pre-swap validation).
66680
+ *
66681
+ * @param stablecoinAddress - EVM address of the stablecoin to query.
66682
+ */
66683
+ async getPSMAvailableReserves(stablecoinAddress) {
66684
+ const psmAddress = this.config.contractAddresses?.simplePsmV2;
66685
+ if (!psmAddress) {
66686
+ throw new Error(
66687
+ "SimplePSMV2 address not configured \u2014 provide contractAddresses.simplePsmV2"
66688
+ );
66689
+ }
66690
+ const psm = SimplePSMV2__factory.connect(
66691
+ psmAddress,
66692
+ this.getProviderOrThrow()
66693
+ );
66694
+ return psm.getAvailableReserves(stablecoinAddress);
66695
+ }
64516
66696
  /**
64517
66697
  * Wait for the subgraph to index up to (and including) the given block number.
64518
66698
  * Call after on-chain actions (createLoan, mintUCD, etc.) before querying the subgraph.
@@ -65507,8 +67687,10 @@ var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
65507
67687
  })(PaymentType || {});
65508
67688
  var PositionStatus = /* @__PURE__ */ ((PositionStatus2) => {
65509
67689
  PositionStatus2["PENDING_DEPOSIT"] = "PENDING_DEPOSIT";
67690
+ PositionStatus2["PENDING_MINT"] = "PENDING_MINT";
65510
67691
  PositionStatus2["ACTIVE"] = "ACTIVE";
65511
67692
  PositionStatus2["EXPIRED"] = "EXPIRED";
67693
+ PositionStatus2["LIQUIDATABLE"] = "LIQUIDATABLE";
65512
67694
  PositionStatus2["LIQUIDATED"] = "LIQUIDATED";
65513
67695
  PositionStatus2["REPAID"] = "REPAID";
65514
67696
  PositionStatus2["CLOSED"] = "CLOSED";
@@ -65525,32 +67707,30 @@ function numericToPositionStatus(status) {
65525
67707
  case 0:
65526
67708
  return "PENDING_DEPOSIT" /* PENDING_DEPOSIT */;
65527
67709
  case 1:
65528
- return "ACTIVE" /* ACTIVE */;
67710
+ return "PENDING_MINT" /* PENDING_MINT */;
65529
67711
  case 2:
65530
- return "EXPIRED" /* EXPIRED */;
67712
+ return "ACTIVE" /* ACTIVE */;
65531
67713
  case 3:
65532
- return "LIQUIDATED" /* LIQUIDATED */;
67714
+ return "EXPIRED" /* EXPIRED */;
65533
67715
  case 4:
65534
- return "REPAID" /* REPAID */;
67716
+ return "LIQUIDATABLE" /* LIQUIDATABLE */;
65535
67717
  case 5:
67718
+ return "LIQUIDATED" /* LIQUIDATED */;
67719
+ case 6:
67720
+ return "REPAID" /* REPAID */;
67721
+ case 7:
65536
67722
  return "CLOSED" /* CLOSED */;
65537
67723
  default:
65538
67724
  throw new Error(`Invalid position status: ${status}`);
65539
67725
  }
65540
67726
  }
65541
67727
  var EventHelpers = {
65542
- /**
65543
- * Sort events by timestamp (descending by default)
65544
- */
65545
67728
  sortByTimestamp(events, direction = "desc") {
65546
67729
  return [...events].sort((a, b2) => {
65547
67730
  const diff = BigInt(a.timestamp) - BigInt(b2.timestamp);
65548
67731
  return direction === "asc" ? Number(diff) : -Number(diff);
65549
67732
  });
65550
67733
  },
65551
- /**
65552
- * Filter events by timestamp range
65553
- */
65554
67734
  filterByTimestamp(events, fromTimestamp, toTimestamp) {
65555
67735
  return events.filter((event) => {
65556
67736
  const ts = BigInt(event.timestamp);
@@ -65561,9 +67741,6 @@ var EventHelpers = {
65561
67741
  return true;
65562
67742
  });
65563
67743
  },
65564
- /**
65565
- * Filter events by block range
65566
- */
65567
67744
  filterByBlock(events, fromBlock, toBlock) {
65568
67745
  return events.filter((event) => {
65569
67746
  const block = BigInt(event.blockNumber);
@@ -65574,17 +67751,12 @@ var EventHelpers = {
65574
67751
  return true;
65575
67752
  });
65576
67753
  },
65577
- /**
65578
- * Get total count of all events
65579
- */
65580
67754
  getTotalCount(events) {
65581
- return events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length + events.operationFailures.length + events.mintRequests.length + events.burnRequests.length + events.collateralEvents.length + events.circuitBreakerEvents.length + events.termFeeUpdates.length + events.loanProtocolParamUpdates.length + events.maxLoanValueUpdates.length + events.btcPriceBoundsUpdates.length + events.perUserMintLimitUpdates.length;
67755
+ return (events.positionCreated ? 1 : 0) + events.payments.length + events.statusUpdates.length + (events.liquidation ? 1 : 0) + events.mints.length + events.withdrawals.length + events.renewals.length + events.operationFailures.length + events.mintRequests.length + events.burnRequests.length + events.collateralEvents.length;
65582
67756
  },
65583
- /**
65584
- * Merge and sort all events by timestamp
65585
- */
65586
67757
  getAllEventsSorted(events, direction = "desc") {
65587
67758
  const allEvents = [
67759
+ ...events.positionCreated ? [{ ...events.positionCreated, eventType: "positionCreated" }] : [],
65588
67760
  ...events.payments.map((e) => ({ ...e, eventType: "payment" })),
65589
67761
  ...events.statusUpdates.map((e) => ({ ...e, eventType: "status" })),
65590
67762
  ...events.liquidation ? [{ ...events.liquidation, eventType: "liquidation" }] : [],
@@ -65594,13 +67766,7 @@ var EventHelpers = {
65594
67766
  ...events.operationFailures.map((e) => ({ ...e, eventType: "operationFailure" })),
65595
67767
  ...events.mintRequests.map((e) => ({ ...e, eventType: "mintRequest" })),
65596
67768
  ...events.burnRequests.map((e) => ({ ...e, eventType: "burnRequest" })),
65597
- ...events.collateralEvents.map((e) => ({ ...e, eventType: "collateralEvent" })),
65598
- ...events.circuitBreakerEvents.map((e) => ({ ...e, eventType: "circuitBreaker" })),
65599
- ...events.termFeeUpdates.map((e) => ({ ...e, eventType: "termFeeUpdate" })),
65600
- ...events.loanProtocolParamUpdates.map((e) => ({ ...e, eventType: "loanProtocolParamUpdate" })),
65601
- ...events.maxLoanValueUpdates.map((e) => ({ ...e, eventType: "maxLoanValueUpdate" })),
65602
- ...events.btcPriceBoundsUpdates.map((e) => ({ ...e, eventType: "btcPriceBoundsUpdate" })),
65603
- ...events.perUserMintLimitUpdates.map((e) => ({ ...e, eventType: "perUserMintLimitUpdate" }))
67769
+ ...events.collateralEvents.map((e) => ({ ...e, eventType: "collateralEvent" }))
65604
67770
  ];
65605
67771
  return allEvents.sort((a, b2) => {
65606
67772
  const diff = BigInt(a.timestamp) - BigInt(b2.timestamp);