@gvnrdao/dh-sdk 0.0.247 → 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.js CHANGED
@@ -18799,7 +18799,7 @@ var require_wrappers = __commonJS({
18799
18799
  }
18800
18800
  };
18801
18801
  exports.ContractTransactionReceipt = ContractTransactionReceipt2;
18802
- var ContractTransactionResponse2 = class extends provider_js_1.TransactionResponse {
18802
+ var ContractTransactionResponse3 = class extends provider_js_1.TransactionResponse {
18803
18803
  #iface;
18804
18804
  /**
18805
18805
  * @_ignore:
@@ -18825,7 +18825,7 @@ var require_wrappers = __commonJS({
18825
18825
  return new ContractTransactionReceipt2(this.#iface, this.provider, receipt);
18826
18826
  }
18827
18827
  };
18828
- exports.ContractTransactionResponse = ContractTransactionResponse2;
18828
+ exports.ContractTransactionResponse = ContractTransactionResponse3;
18829
18829
  var ContractUnknownEventPayload2 = class extends index_js_1.EventPayload {
18830
18830
  /**
18831
18831
  * The log with no matching events.
@@ -31898,7 +31898,7 @@ ${errorReport}`);
31898
31898
  }
31899
31899
  init_debug_logger();
31900
31900
  init_session_signature_cache();
31901
- var import_ethers12 = require_lib2();
31901
+ var import_ethers13 = require_lib2();
31902
31902
  var ACTIVE_LOAN_LIQUIDATION_THRESHOLD_BPS = 13e3;
31903
31903
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
31904
31904
  var GRACE_PERIOD_DAYS = 30;
@@ -34215,12 +34215,12 @@ ${errorReport}`);
34215
34215
  }
34216
34216
  async function executeVaultSnapshot(params) {
34217
34217
  global.ethers = {
34218
- ...import_ethers12.ethers,
34218
+ ...import_ethers13.ethers,
34219
34219
  providers: {
34220
- StaticJsonRpcProvider: import_ethers12.ethers.JsonRpcProvider
34220
+ StaticJsonRpcProvider: import_ethers13.ethers.JsonRpcProvider
34221
34221
  },
34222
- Contract: import_ethers12.ethers.Contract,
34223
- utils: import_ethers12.ethers
34222
+ Contract: import_ethers13.ethers.Contract,
34223
+ utils: import_ethers13.ethers
34224
34224
  // v6 moved utils to top level
34225
34225
  };
34226
34226
  global.Lit = {
@@ -34408,7 +34408,7 @@ var init_deployment_addresses = __esm({
34408
34408
  AdminModule: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
34409
34409
  PositionManagerViews: "0x3b970E41a0668508B4B2ACb83653b2A402F745AE",
34410
34410
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
34411
- OperationAuthorizationRegistry: "0xb295050EBCE12aD5f228bB2C4C31fCb24a79257C",
34411
+ OperationAuthorizationRegistry: "0x75f36E772df9616d40b02092642744D6fd702Df8",
34412
34412
  PKPValidation: "0xC8Ca02238fbCDAEbE6dbF804461D43F46F9406F4",
34413
34413
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
34414
34414
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
@@ -34422,18 +34422,18 @@ var init_deployment_addresses = __esm({
34422
34422
  },
34423
34423
  upgraded: {
34424
34424
  PositionManager: {
34425
- previousImplementation: "0xcfaE3c5211a87A8d2eeb55F23b0BB7b43549529C",
34426
- newImplementation: "0xc7Bc4ead66D24C0a4dCe088176F0fC8DF54579d4",
34427
- upgradedAt: "2026-05-14T16:22:25.277Z",
34425
+ previousImplementation: "0x5492b2cE6138c1750BDD8DbB15Dc0ea00A5CF241",
34426
+ newImplementation: "0x623f3bDff8830d2161D3b5D42d38b39697c65eBE",
34427
+ upgradedAt: "2026-05-15T10:41:01.767Z",
34428
34428
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34429
34429
  reason: "Shared upgrade script: PositionManager implementation update"
34430
34430
  },
34431
34431
  LoanOperationsManagerModule: {
34432
- previousImplementation: "0x1db353Dad5818e00F073e4F73f66B6028Ee71DDC",
34433
- newImplementation: "0x3C1d7887858f106e43aa48bBF0D86C6EBA979980",
34434
- upgradedAt: "2026-05-14T16:24:49.712Z",
34432
+ previousImplementation: "0x3C1d7887858f106e43aa48bBF0D86C6EBA979980",
34433
+ newImplementation: "0xdEf0A042670834369d456c5fbE73ad2126008bD2",
34434
+ upgradedAt: "2026-05-15T10:37:26.881Z",
34435
34435
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34436
- reason: "Shared upgrade script: LoanOperationsManagerModule implementation update"
34436
+ reason: "Shared upgrade script: LoanOperationsManagerModule v1.4.0 (M-3 Chainlink cross-check)"
34437
34437
  },
34438
34438
  UCDController: {
34439
34439
  previousImplementation: "0x0F7c669c891C6534Bfef222B0A6bc9B71c256C58",
@@ -34464,9 +34464,9 @@ var init_deployment_addresses = __esm({
34464
34464
  reason: "Shared upgrade script: AdminModule implementation update"
34465
34465
  },
34466
34466
  PositionManagerViews: {
34467
- previousImplementation: "0x54daC12e074F5aef28399b152237284Df0A95099",
34468
- newImplementation: "0x92311E348730e30237cbF0a58FaD704F8f2B8101",
34469
- upgradedAt: "2026-05-14T16:20:25.552Z",
34467
+ previousImplementation: "0x92311E348730e30237cbF0a58FaD704F8f2B8101",
34468
+ newImplementation: "0xBd1F92F24E89cC55acFc422eCA0df00F68B99565",
34469
+ upgradedAt: "2026-05-14T18:42:37.153Z",
34470
34470
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34471
34471
  reason: "Shared upgrade script: PositionManagerViews implementation update"
34472
34472
  },
@@ -34485,9 +34485,9 @@ var init_deployment_addresses = __esm({
34485
34485
  reason: "Shared upgrade script: UCDToken implementation update"
34486
34486
  },
34487
34487
  PositionManagerCoreModule: {
34488
- previousImplementation: "0x99F6Ad03237Fa34e6D01aBf2F47af4B660e58cFD",
34489
- newImplementation: "0xE3B9747af371f459B4d68D30DE5e374040eb6339",
34490
- upgradedAt: "2026-05-14T16:06:36.711Z",
34488
+ previousImplementation: "0xE3B9747af371f459B4d68D30DE5e374040eb6339",
34489
+ newImplementation: "0x2e34353852d95f8D39aE648af817de9f750c84D6",
34490
+ upgradedAt: "2026-05-14T18:37:36.484Z",
34491
34491
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34492
34492
  reason: "Shared upgrade script: PositionManagerCoreModule implementation update"
34493
34493
  },
@@ -34499,9 +34499,9 @@ var init_deployment_addresses = __esm({
34499
34499
  reason: "Shared upgrade script: CollateralManagerModule implementation update"
34500
34500
  },
34501
34501
  LiquidationManagerModule: {
34502
- previousImplementation: "0x104a3bF95fC924f310a1e1C809fe2c8b71D08A1B",
34503
- newImplementation: "0x8E069E4A1deba9Ac021956F3cD771e9e65d756bb",
34504
- upgradedAt: "2026-05-14T16:12:24.858Z",
34502
+ previousImplementation: "0x8E069E4A1deba9Ac021956F3cD771e9e65d756bb",
34503
+ newImplementation: "0x15864ea3ECBe7E9FFa0a52b49c4dc7f258FA6300",
34504
+ upgradedAt: "2026-05-15T10:43:13.136Z",
34505
34505
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34506
34506
  reason: "Shared upgrade script: LiquidationManagerModule implementation update"
34507
34507
  },
@@ -34546,6 +34546,13 @@ var init_deployment_addresses = __esm({
34546
34546
  upgradedAt: "2026-05-14T16:30:13.519Z",
34547
34547
  upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34548
34548
  reason: "Shared upgrade script: PositionDelegateRegistry implementation update"
34549
+ },
34550
+ OperationAuthorizationRegistry: {
34551
+ previousImplementation: "0x982466844AfaBb4aCd8010e03330E8a38369F117",
34552
+ newImplementation: "0x9f8072d4672d643e39d8638478e900Fea1f2c81D",
34553
+ upgradedAt: "2026-05-15T08:49:01.387Z",
34554
+ upgradedBy: "0xF20986F02420EF443AE9BE5092FB8A4975cF3aA6",
34555
+ reason: "Shared upgrade script: OperationAuthorizationRegistry implementation update"
34549
34556
  }
34550
34557
  },
34551
34558
  history: {
@@ -34596,7 +34603,7 @@ var init_deployment_addresses = __esm({
34596
34603
  PKP_VALIDATION_REGISTRY: "0xC8Ca02238fbCDAEbE6dbF804461D43F46F9406F4",
34597
34604
  PKP_VALIDATION_CID_V1: "0x1220246b43f71828ed1cfdc455b6bd4fd9e7382251ea634589f8da9b12f61d40cd51",
34598
34605
  PKP_ETH_ADDRESS: "0x9624C46073E1d1F5AB975c67Fc899536d599bb57",
34599
- OPERATION_AUTHORIZATION_REGISTRY: "0xb295050EBCE12aD5f228bB2C4C31fCb24a79257C",
34606
+ OPERATION_AUTHORIZATION_REGISTRY: "0x75f36E772df9616d40b02092642744D6fd702Df8",
34600
34607
  UCD_MINT_VALIDATOR_ADDRESS: "0x4D9299055093938d0CD2F26C42A87260CB50adD8",
34601
34608
  UCD_MINT_VALIDATOR_VERSION: 1,
34602
34609
  BTC_WITHDRAWAL_VALIDATOR_ADDRESS: "0x7b9316cAA00B257F7CE30F7F6979bd6867BA9eE2",
@@ -34614,12 +34621,12 @@ var init_deployment_addresses = __esm({
34614
34621
  CIRCUIT_BREAKER_MODULE: "0x3D0B2cAE481821E57BA9CC3807bCC0d0D7F18bd8",
34615
34622
  ADMIN_MODULE: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
34616
34623
  UCD_CONTROLLER_IMPL: "0x9AFE20da679EA9877893c4A991c8087caE5F7e4C",
34617
- LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0x3C1d7887858f106e43aa48bBF0D86C6EBA979980",
34624
+ LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0xdEf0A042670834369d456c5fbE73ad2126008bD2",
34618
34625
  TERM_MANAGER_MODULE_IMPL: "0x309CE239A87ffFB31d4C720804e9908E482d4f10",
34619
34626
  CIRCUIT_BREAKER_MODULE_IMPL: "0x24C345841360EEe81C944c00e0E5c8f6CCc53C00",
34620
34627
  ADMIN_MODULE_IMPL: "0x70a500896A26E4e7CDb56886b9e6438e39DB5ae4",
34621
34628
  POSITION_MANAGER_VIEWS_IMPL: "0x92311E348730e30237cbF0a58FaD704F8f2B8101",
34622
- POSITION_MANAGER_IMPL: "0xc7Bc4ead66D24C0a4dCe088176F0fC8DF54579d4",
34629
+ POSITION_MANAGER_IMPL: "0x623f3bDff8830d2161D3b5D42d38b39697c65eBE",
34623
34630
  SIMPLE_PSM_V2: "0x19EcF7BA26e054fd4Ff06009A03070103dbBB058",
34624
34631
  SIMPLE_PSM_V2_IMPL: "0x0728434d86532FD67A4a7227958654C029b333F6",
34625
34632
  UCD_TOKEN_IMPL: "0x65c23B6fB5331ACeeC2d82328c6de7dB6b62bB65",
@@ -34645,7 +34652,8 @@ var init_deployment_addresses = __esm({
34645
34652
  POSITION_DELEGATE_REGISTRY_IMPL: "0xAE227De03D5aeDC870d6e096D9C6652E001a92aF",
34646
34653
  AGENT_MODULE: "0xefb8C29C1e7e92ed7d81a52dbedaed74e37fe380",
34647
34654
  FEE_RECIPIENT_REGISTRY: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
34648
- FEE_RECIPIENT_REGISTRY_IMPL: "0x974a0f64d572a4F4e1395aaeB22d1c2685D22459"
34655
+ FEE_RECIPIENT_REGISTRY_IMPL: "0x974a0f64d572a4F4e1395aaeB22d1c2685D22459",
34656
+ OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0x982466844AfaBb4aCd8010e03330E8a38369F117"
34649
34657
  }
34650
34658
  };
34651
34659
  SEPOLIA_CONTRACTS = {
@@ -34662,7 +34670,7 @@ var init_deployment_addresses = __esm({
34662
34670
  AdminModule: "0xAcd1f07915b17CA3727e7fE89BdF618A1545a1ed",
34663
34671
  PositionManagerViews: "0x3b970E41a0668508B4B2ACb83653b2A402F745AE",
34664
34672
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
34665
- OperationAuthorizationRegistry: "0xb295050EBCE12aD5f228bB2C4C31fCb24a79257C",
34673
+ OperationAuthorizationRegistry: "0x75f36E772df9616d40b02092642744D6fd702Df8",
34666
34674
  PKPValidation: "0xC8Ca02238fbCDAEbE6dbF804461D43F46F9406F4",
34667
34675
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
34668
34676
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
@@ -48541,6 +48549,109 @@ function _ContractBase() {
48541
48549
  var Contract = class extends _ContractBase() {
48542
48550
  };
48543
48551
 
48552
+ // node_modules/ethers/lib.esm/contract/factory.js
48553
+ var ContractFactory = class _ContractFactory {
48554
+ /**
48555
+ * The Contract Interface.
48556
+ */
48557
+ interface;
48558
+ /**
48559
+ * The Contract deployment bytecode. Often called the initcode.
48560
+ */
48561
+ bytecode;
48562
+ /**
48563
+ * The ContractRunner to deploy the Contract as.
48564
+ */
48565
+ runner;
48566
+ /**
48567
+ * Create a new **ContractFactory** with %%abi%% and %%bytecode%%,
48568
+ * optionally connected to %%runner%%.
48569
+ *
48570
+ * The %%bytecode%% may be the ``bytecode`` property within the
48571
+ * standard Solidity JSON output.
48572
+ */
48573
+ constructor(abi, bytecode, runner) {
48574
+ const iface = Interface.from(abi);
48575
+ if (bytecode instanceof Uint8Array) {
48576
+ bytecode = hexlify(getBytes(bytecode));
48577
+ } else {
48578
+ if (typeof bytecode === "object") {
48579
+ bytecode = bytecode.object;
48580
+ }
48581
+ if (!bytecode.startsWith("0x")) {
48582
+ bytecode = "0x" + bytecode;
48583
+ }
48584
+ bytecode = hexlify(getBytes(bytecode));
48585
+ }
48586
+ defineProperties(this, {
48587
+ bytecode,
48588
+ interface: iface,
48589
+ runner: runner || null
48590
+ });
48591
+ }
48592
+ attach(target) {
48593
+ return new BaseContract(target, this.interface, this.runner);
48594
+ }
48595
+ /**
48596
+ * Resolves to the transaction to deploy the contract, passing %%args%%
48597
+ * into the constructor.
48598
+ */
48599
+ async getDeployTransaction(...args) {
48600
+ let overrides = {};
48601
+ const fragment = this.interface.deploy;
48602
+ if (fragment.inputs.length + 1 === args.length) {
48603
+ overrides = await copyOverrides(args.pop());
48604
+ }
48605
+ if (fragment.inputs.length !== args.length) {
48606
+ throw new Error("incorrect number of arguments to constructor");
48607
+ }
48608
+ const resolvedArgs = await resolveArgs(this.runner, fragment.inputs, args);
48609
+ const data = concat([this.bytecode, this.interface.encodeDeploy(resolvedArgs)]);
48610
+ return Object.assign({}, overrides, { data });
48611
+ }
48612
+ /**
48613
+ * Resolves to the Contract deployed by passing %%args%% into the
48614
+ * constructor.
48615
+ *
48616
+ * This will resolve to the Contract before it has been deployed to the
48617
+ * network, so the [[BaseContract-waitForDeployment]] should be used before
48618
+ * sending any transactions to it.
48619
+ */
48620
+ async deploy(...args) {
48621
+ const tx = await this.getDeployTransaction(...args);
48622
+ assert(this.runner && typeof this.runner.sendTransaction === "function", "factory runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
48623
+ operation: "sendTransaction"
48624
+ });
48625
+ const sentTx = await this.runner.sendTransaction(tx);
48626
+ const address = getCreateAddress(sentTx);
48627
+ return new BaseContract(address, this.interface, this.runner, sentTx);
48628
+ }
48629
+ /**
48630
+ * Return a new **ContractFactory** with the same ABI and bytecode,
48631
+ * but connected to %%runner%%.
48632
+ */
48633
+ connect(runner) {
48634
+ return new _ContractFactory(this.interface, this.bytecode, runner);
48635
+ }
48636
+ /**
48637
+ * Create a new **ContractFactory** from the standard Solidity JSON output.
48638
+ */
48639
+ static fromSolidity(output, runner) {
48640
+ assertArgument(output != null, "bad compiler output", "output", output);
48641
+ if (typeof output === "string") {
48642
+ output = JSON.parse(output);
48643
+ }
48644
+ const abi = output.abi;
48645
+ let bytecode = "";
48646
+ if (output.bytecode) {
48647
+ bytecode = output.bytecode;
48648
+ } else if (output.evm && output.evm.bytecode) {
48649
+ bytecode = output.evm.bytecode;
48650
+ }
48651
+ return new this(abi, bytecode, runner);
48652
+ }
48653
+ };
48654
+
48544
48655
  // node_modules/ethers/lib.esm/providers/ens-resolver.js
48545
48656
  function getIpfsLink(link) {
48546
48657
  if (link.match(/^ipfs:\/\/ipfs\//i)) {
@@ -56139,7 +56250,8 @@ var LoanQuery = class {
56139
56250
  statusUpdates: events.statusUpdates.length,
56140
56251
  liquidated: !!events.liquidation,
56141
56252
  mints: events.mints.length,
56142
- feeDistributions: events.feeDistributions.length
56253
+ renewals: events.renewals.length,
56254
+ withdrawals: events.withdrawals.length
56143
56255
  });
56144
56256
  }
56145
56257
  return events;
@@ -58259,6 +58371,7 @@ var DiamondHandsGraph = class {
58259
58371
  orderDirection = "desc"
58260
58372
  } = filter || {};
58261
58373
  const shouldQuery = {
58374
+ positionCreated: !eventTypes || eventTypes.includes("positionCreated"),
58262
58375
  payment: !eventTypes || eventTypes.includes("payment"),
58263
58376
  status: !eventTypes || eventTypes.includes("status"),
58264
58377
  liquidation: !eventTypes || eventTypes.includes("liquidation"),
@@ -58268,13 +58381,7 @@ var DiamondHandsGraph = class {
58268
58381
  operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
58269
58382
  mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
58270
58383
  burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
58271
- collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
58272
- circuitBreaker: !eventTypes || eventTypes.includes("circuitBreaker"),
58273
- termFeeUpdate: !eventTypes || eventTypes.includes("termFeeUpdate"),
58274
- loanProtocolParamUpdate: !eventTypes || eventTypes.includes("loanProtocolParamUpdate"),
58275
- maxLoanValueUpdate: !eventTypes || eventTypes.includes("maxLoanValueUpdate"),
58276
- btcPriceBoundsUpdate: !eventTypes || eventTypes.includes("btcPriceBoundsUpdate"),
58277
- perUserMintLimitUpdate: !eventTypes || eventTypes.includes("perUserMintLimitUpdate")
58384
+ collateralEvent: !eventTypes || eventTypes.includes("collateralEvent")
58278
58385
  };
58279
58386
  const buildPositionWhereClause = () => {
58280
58387
  const conditions = [`position: "${positionId.toLowerCase()}"`];
@@ -58288,18 +58395,6 @@ var DiamondHandsGraph = class {
58288
58395
  conditions.push(`blockNumber_lte: "${toBlock}"`);
58289
58396
  return `where: { ${conditions.join(", ")} }`;
58290
58397
  };
58291
- const buildProtocolWhereClause = () => {
58292
- const conditions = [];
58293
- if (fromTimestamp)
58294
- conditions.push(`timestamp_gte: "${fromTimestamp}"`);
58295
- if (toTimestamp)
58296
- conditions.push(`timestamp_lte: "${toTimestamp}"`);
58297
- if (fromBlock)
58298
- conditions.push(`blockNumber_gte: "${fromBlock}"`);
58299
- if (toBlock)
58300
- conditions.push(`blockNumber_lte: "${toBlock}"`);
58301
- return conditions.length > 0 ? `where: { ${conditions.join(", ")} }` : "";
58302
- };
58303
58398
  const query = `
58304
58399
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
58305
58400
  position(id: $positionId) {
@@ -58309,7 +58404,6 @@ var DiamondHandsGraph = class {
58309
58404
  first: $limit,
58310
58405
  orderBy: timestamp,
58311
58406
  orderDirection: $orderDirection
58312
- ${buildProtocolWhereClause()}
58313
58407
  ) {
58314
58408
  id
58315
58409
  payer { id }
@@ -58321,15 +58415,13 @@ var DiamondHandsGraph = class {
58321
58415
  logIndex
58322
58416
  newDebt
58323
58417
  newCollateralRatio
58324
- }
58325
- ` : ""}
58418
+ }` : ""}
58326
58419
 
58327
58420
  ${shouldQuery.status ? `
58328
58421
  statusUpdates(
58329
58422
  first: $limit,
58330
58423
  orderBy: timestamp,
58331
58424
  orderDirection: $orderDirection
58332
- ${buildProtocolWhereClause()}
58333
58425
  ) {
58334
58426
  id
58335
58427
  oldStatus
@@ -58338,8 +58430,7 @@ var DiamondHandsGraph = class {
58338
58430
  timestamp
58339
58431
  blockNumber
58340
58432
  transactionHash
58341
- }
58342
- ` : ""}
58433
+ }` : ""}
58343
58434
 
58344
58435
  ${shouldQuery.liquidation ? `
58345
58436
  liquidation {
@@ -58353,8 +58444,7 @@ var DiamondHandsGraph = class {
58353
58444
  commitHash
58354
58445
  commitTimestamp
58355
58446
  revealDelay
58356
- }
58357
- ` : ""}
58447
+ }` : ""}
58358
58448
 
58359
58449
  ${shouldQuery.withdrawal ? `
58360
58450
  withdrawals(
@@ -58370,8 +58460,7 @@ var DiamondHandsGraph = class {
58370
58460
  blockNumber
58371
58461
  transactionHash
58372
58462
  logIndex
58373
- }
58374
- ` : ""}
58463
+ }` : ""}
58375
58464
 
58376
58465
  ${shouldQuery.renewal ? `
58377
58466
  renewals(
@@ -58387,8 +58476,7 @@ var DiamondHandsGraph = class {
58387
58476
  blockNumber
58388
58477
  transactionHash
58389
58478
  logIndex
58390
- }
58391
- ` : ""}
58479
+ }` : ""}
58392
58480
 
58393
58481
  ${shouldQuery.operationFailure ? `
58394
58482
  operationFailures(
@@ -58405,8 +58493,7 @@ var DiamondHandsGraph = class {
58405
58493
  blockNumber
58406
58494
  transactionHash
58407
58495
  logIndex
58408
- }
58409
- ` : ""}
58496
+ }` : ""}
58410
58497
 
58411
58498
  ${shouldQuery.mintRequest ? `
58412
58499
  mintRequests(
@@ -58428,8 +58515,7 @@ var DiamondHandsGraph = class {
58428
58515
  blockNumber
58429
58516
  transactionHash
58430
58517
  logIndex
58431
- }
58432
- ` : ""}
58518
+ }` : ""}
58433
58519
 
58434
58520
  ${shouldQuery.burnRequest ? `
58435
58521
  burnRequests(
@@ -58448,10 +58534,27 @@ var DiamondHandsGraph = class {
58448
58534
  blockNumber
58449
58535
  transactionHash
58450
58536
  logIndex
58451
- }
58452
- ` : ""}
58537
+ }` : ""}
58453
58538
  }
58454
58539
 
58540
+ ${shouldQuery.positionCreated ? `
58541
+ positionCreatedEvents(
58542
+ ${buildPositionWhereClause()}
58543
+ first: 1,
58544
+ orderBy: timestamp,
58545
+ orderDirection: asc
58546
+ ) {
58547
+ id
58548
+ pkpId
58549
+ borrower { id }
58550
+ requestedCollateralRatio
58551
+ selectedTerm
58552
+ expiryAt
58553
+ timestamp
58554
+ blockNumber
58555
+ transactionHash
58556
+ }` : ""}
58557
+
58455
58558
  ${shouldQuery.mint ? `
58456
58559
  ucdmintEvents(
58457
58560
  ${buildPositionWhereClause()}
@@ -58467,8 +58570,7 @@ var DiamondHandsGraph = class {
58467
58570
  timestamp
58468
58571
  blockNumber
58469
58572
  transactionHash
58470
- }
58471
- ` : ""}
58573
+ }` : ""}
58472
58574
 
58473
58575
  ${shouldQuery.collateralEvent ? `
58474
58576
  collateralEvents(
@@ -58486,116 +58588,7 @@ var DiamondHandsGraph = class {
58486
58588
  blockNumber
58487
58589
  transactionHash
58488
58590
  logIndex
58489
- }
58490
- ` : ""}
58491
-
58492
- ${shouldQuery.circuitBreaker ? `
58493
- circuitBreakerEvents(
58494
- ${buildProtocolWhereClause()}
58495
- first: $limit,
58496
- orderBy: timestamp,
58497
- orderDirection: $orderDirection
58498
- ) {
58499
- id
58500
- isActivated
58501
- admin
58502
- reason
58503
- timestamp
58504
- blockNumber
58505
- transactionHash
58506
- }
58507
- ` : ""}
58508
-
58509
- ${shouldQuery.termFeeUpdate ? `
58510
- termFeeUpdates(
58511
- ${buildProtocolWhereClause()}
58512
- first: $limit,
58513
- orderBy: timestamp,
58514
- orderDirection: $orderDirection
58515
- ) {
58516
- id
58517
- term { id }
58518
- oldOriginationFee
58519
- newOriginationFee
58520
- oldExtensionFee
58521
- newExtensionFee
58522
- timestamp
58523
- blockNumber
58524
- transactionHash
58525
- }
58526
- ` : ""}
58527
-
58528
- ${shouldQuery.loanProtocolParamUpdate ? `
58529
- loanProtocolParamUpdates(
58530
- ${buildProtocolWhereClause()}
58531
- first: $limit,
58532
- orderBy: timestamp,
58533
- orderDirection: $orderDirection
58534
- ) {
58535
- id
58536
- oldLiquidationThreshold
58537
- newLiquidationThreshold
58538
- oldMinimumLoanValueUcd
58539
- newMinimumLoanValueUcd
58540
- caller
58541
- timestamp
58542
- blockNumber
58543
- transactionHash
58544
- }
58545
- ` : ""}
58546
-
58547
- ${shouldQuery.maxLoanValueUpdate ? `
58548
- maxLoanValueUpdates(
58549
- ${buildProtocolWhereClause()}
58550
- first: $limit,
58551
- orderBy: timestamp,
58552
- orderDirection: $orderDirection
58553
- ) {
58554
- id
58555
- oldValueUcd
58556
- newValueUcd
58557
- caller
58558
- timestamp
58559
- blockNumber
58560
- transactionHash
58561
- }
58562
- ` : ""}
58563
-
58564
- ${shouldQuery.btcPriceBoundsUpdate ? `
58565
- btcPriceBoundsUpdates(
58566
- ${buildProtocolWhereClause()}
58567
- first: $limit,
58568
- orderBy: timestamp,
58569
- orderDirection: $orderDirection
58570
- ) {
58571
- id
58572
- oldMinBound
58573
- newMinBound
58574
- oldMaxBound
58575
- newMaxBound
58576
- caller
58577
- timestamp
58578
- blockNumber
58579
- transactionHash
58580
- }
58581
- ` : ""}
58582
-
58583
- ${shouldQuery.perUserMintLimitUpdate ? `
58584
- perUserDailyMintLimitUpdates(
58585
- ${buildProtocolWhereClause()}
58586
- first: $limit,
58587
- orderBy: timestamp,
58588
- orderDirection: $orderDirection
58589
- ) {
58590
- id
58591
- oldLimit
58592
- newLimit
58593
- updatedBy
58594
- timestamp
58595
- blockNumber
58596
- transactionHash
58597
- }
58598
- ` : ""}
58591
+ }` : ""}
58599
58592
  }
58600
58593
  `;
58601
58594
  const variables = {
@@ -58604,6 +58597,19 @@ var DiamondHandsGraph = class {
58604
58597
  orderDirection
58605
58598
  };
58606
58599
  const result = await this.client.execute(query, variables);
58600
+ const rawCreated = result.positionCreatedEvents?.[0];
58601
+ const positionCreated = rawCreated ? {
58602
+ id: rawCreated.id,
58603
+ positionId,
58604
+ pkpId: rawCreated.pkpId,
58605
+ borrower: rawCreated.borrower.id,
58606
+ requestedCollateralRatio: rawCreated.requestedCollateralRatio,
58607
+ selectedTerm: rawCreated.selectedTerm,
58608
+ expiryAt: rawCreated.expiryAt,
58609
+ timestamp: rawCreated.timestamp,
58610
+ blockNumber: rawCreated.blockNumber,
58611
+ transactionHash: rawCreated.transactionHash
58612
+ } : void 0;
58607
58613
  const payments = (result.position?.payments || []).map(
58608
58614
  (p) => ({
58609
58615
  id: p.id,
@@ -58664,17 +58670,19 @@ var DiamondHandsGraph = class {
58664
58670
  transactionHash: w.transactionHash,
58665
58671
  logIndex: w.logIndex
58666
58672
  }));
58667
- const renewals = (result.position?.renewals || []).map((r) => ({
58668
- id: r.id,
58669
- positionId,
58670
- extensionTerm: r.extensionTerm,
58671
- extensionFee: r.extensionFee,
58672
- newExpiryDate: r.newExpiryDate,
58673
- timestamp: r.timestamp,
58674
- blockNumber: r.blockNumber,
58675
- transactionHash: r.transactionHash,
58676
- logIndex: r.logIndex
58677
- }));
58673
+ const renewals = (result.position?.renewals || []).map(
58674
+ (r) => ({
58675
+ id: r.id,
58676
+ positionId,
58677
+ extensionTerm: r.extensionTerm,
58678
+ extensionFee: r.extensionFee,
58679
+ newExpiryDate: r.newExpiryDate,
58680
+ timestamp: r.timestamp,
58681
+ blockNumber: r.blockNumber,
58682
+ transactionHash: r.transactionHash,
58683
+ logIndex: r.logIndex
58684
+ })
58685
+ );
58678
58686
  const operationFailures = (result.position?.operationFailures || []).map((o) => ({
58679
58687
  id: o.id,
58680
58688
  positionId,
@@ -58730,69 +58738,10 @@ var DiamondHandsGraph = class {
58730
58738
  transactionHash: c.transactionHash,
58731
58739
  logIndex: c.logIndex
58732
58740
  }));
58733
- const circuitBreakerEvents = (result.circuitBreakerEvents || []).map((cb) => ({
58734
- id: cb.id,
58735
- isActivated: cb.isActivated,
58736
- admin: cb.admin,
58737
- reason: cb.reason,
58738
- timestamp: cb.timestamp,
58739
- blockNumber: cb.blockNumber,
58740
- transactionHash: cb.transactionHash
58741
- }));
58742
- const termFeeUpdates = (result.termFeeUpdates || []).map((t) => ({
58743
- id: t.id,
58744
- termMonths: t.term.id,
58745
- oldOriginationFee: t.oldOriginationFee,
58746
- newOriginationFee: t.newOriginationFee,
58747
- oldExtensionFee: t.oldExtensionFee,
58748
- newExtensionFee: t.newExtensionFee,
58749
- timestamp: t.timestamp,
58750
- blockNumber: t.blockNumber,
58751
- transactionHash: t.transactionHash
58752
- }));
58753
- const loanProtocolParamUpdates = (result.loanProtocolParamUpdates || []).map((p) => ({
58754
- id: p.id,
58755
- oldLiquidationThreshold: p.oldLiquidationThreshold,
58756
- newLiquidationThreshold: p.newLiquidationThreshold,
58757
- oldMinimumLoanValueUcd: p.oldMinimumLoanValueUcd,
58758
- newMinimumLoanValueUcd: p.newMinimumLoanValueUcd,
58759
- caller: p.caller,
58760
- timestamp: p.timestamp,
58761
- blockNumber: p.blockNumber,
58762
- transactionHash: p.transactionHash
58763
- }));
58764
- const maxLoanValueUpdates = (result.maxLoanValueUpdates || []).map((m) => ({
58765
- id: m.id,
58766
- oldValueUcd: m.oldValueUcd,
58767
- newValueUcd: m.newValueUcd,
58768
- caller: m.caller,
58769
- timestamp: m.timestamp,
58770
- blockNumber: m.blockNumber,
58771
- transactionHash: m.transactionHash
58772
- }));
58773
- const btcPriceBoundsUpdates = (result.btcPriceBoundsUpdates || []).map((b2) => ({
58774
- id: b2.id,
58775
- oldMinBound: b2.oldMinBound,
58776
- newMinBound: b2.newMinBound,
58777
- oldMaxBound: b2.oldMaxBound,
58778
- newMaxBound: b2.newMaxBound,
58779
- caller: b2.caller,
58780
- timestamp: b2.timestamp,
58781
- blockNumber: b2.blockNumber,
58782
- transactionHash: b2.transactionHash
58783
- }));
58784
- const perUserMintLimitUpdates = (result.perUserDailyMintLimitUpdates || []).map((p) => ({
58785
- id: p.id,
58786
- oldLimit: p.oldLimit,
58787
- newLimit: p.newLimit,
58788
- updatedBy: p.updatedBy,
58789
- timestamp: p.timestamp,
58790
- blockNumber: p.blockNumber,
58791
- transactionHash: p.transactionHash
58792
- }));
58793
- 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;
58741
+ 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;
58794
58742
  return {
58795
58743
  positionId,
58744
+ positionCreated,
58796
58745
  payments,
58797
58746
  statusUpdates,
58798
58747
  liquidation,
@@ -58803,187 +58752,2378 @@ var DiamondHandsGraph = class {
58803
58752
  mintRequests,
58804
58753
  burnRequests,
58805
58754
  collateralEvents,
58806
- circuitBreakerEvents,
58807
- termFeeUpdates,
58808
- loanProtocolParamUpdates,
58809
- maxLoanValueUpdates,
58810
- btcPriceBoundsUpdates,
58811
- perUserMintLimitUpdates,
58812
- feeDistributions: [],
58813
58755
  totalEvents
58814
58756
  };
58815
58757
  }
58816
- };
58817
-
58818
- // src/modules/mock/mock-token-manager.module.ts
58819
- var MockTokenManager = class {
58820
- config;
58821
- constructor(config) {
58822
- this.config = config;
58823
- if (this.isProductionNetwork()) {
58824
- log.warn("\u26A0\uFE0F MockTokenManager initialized on production network", {
58825
- network: config.network
58826
- });
58827
- }
58828
- }
58758
+ // ============================================================================
58759
+ // Protocol-wide Events
58760
+ // ============================================================================
58829
58761
  /**
58830
- * Mint mock BTC tokens
58762
+ * Retrieve events across the full protocol, optionally narrowed to a position.
58763
+ * Returns a merged, sorted discriminated-union timeline suitable for explorers.
58831
58764
  *
58832
- * @param amount - Amount to mint in satoshis
58833
- * @param recipient - Recipient address
58834
- * @returns Transaction result
58765
+ * Protocol-global admin events (circuit breaker, term fees, etc.) are included
58766
+ * by default; pass `kinds` to restrict.
58835
58767
  */
58836
- async mintMockBTC(amount, recipient) {
58837
- if (this.config.debug) {
58838
- log.info("\u{1FA99} Minting mock BTC", {
58839
- amount: amount.toString(),
58840
- recipient
58841
- });
58768
+ async getAllEvents(filter) {
58769
+ const {
58770
+ positionId,
58771
+ kinds,
58772
+ fromTimestamp,
58773
+ toTimestamp,
58774
+ fromBlock,
58775
+ toBlock,
58776
+ limit = 1e3,
58777
+ orderDirection = "desc"
58778
+ } = filter || {};
58779
+ const includeKind = (k) => !kinds || kinds.includes(k);
58780
+ const buildTimeWhereClause = (extra = []) => {
58781
+ const conditions = [...extra];
58782
+ if (fromTimestamp)
58783
+ conditions.push(`timestamp_gte: "${fromTimestamp}"`);
58784
+ if (toTimestamp)
58785
+ conditions.push(`timestamp_lte: "${toTimestamp}"`);
58786
+ if (fromBlock)
58787
+ conditions.push(`blockNumber_gte: "${fromBlock}"`);
58788
+ if (toBlock)
58789
+ conditions.push(`blockNumber_lte: "${toBlock}"`);
58790
+ return conditions.length > 0 ? `where: { ${conditions.join(", ")} }` : "";
58791
+ };
58792
+ const positionFilter = positionId ? [`position: "${positionId.toLowerCase()}"`] : [];
58793
+ const query = `
58794
+ query GetAllEvents($limit: Int!, $orderDirection: OrderDirection!) {
58795
+
58796
+ ${includeKind("position") ? `
58797
+ positionCreatedEvents(
58798
+ ${buildTimeWhereClause(positionFilter)}
58799
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58800
+ ) {
58801
+ id
58802
+ position { id }
58803
+ pkpId
58804
+ borrower { id }
58805
+ requestedCollateralRatio
58806
+ selectedTerm
58807
+ expiryAt
58808
+ timestamp
58809
+ blockNumber
58810
+ transactionHash
58811
+ }
58812
+ positionStatusUpdates: positionStatusUpdates(
58813
+ ${buildTimeWhereClause(positionFilter)}
58814
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58815
+ ) {
58816
+ id
58817
+ position { id }
58818
+ oldStatus
58819
+ newStatus
58820
+ timestamp
58821
+ blockNumber
58822
+ transactionHash
58823
+ }
58824
+ renewalEvents: renewalEvents(
58825
+ ${buildTimeWhereClause(positionFilter)}
58826
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58827
+ ) {
58828
+ id
58829
+ position { id }
58830
+ extensionTerm
58831
+ extensionFee
58832
+ newExpiryDate
58833
+ timestamp
58834
+ blockNumber
58835
+ transactionHash
58836
+ }` : ""}
58837
+
58838
+ ${includeKind("payment") ? `
58839
+ payments(
58840
+ ${buildTimeWhereClause(positionFilter)}
58841
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58842
+ ) {
58843
+ id
58844
+ position { id }
58845
+ payer { id }
58846
+ amount
58847
+ type
58848
+ newDebt
58849
+ newCollateralRatio
58850
+ timestamp
58851
+ blockNumber
58852
+ transactionHash
58853
+ }` : ""}
58854
+
58855
+ ${includeKind("liquidation") ? `
58856
+ liquidations(
58857
+ ${buildTimeWhereClause(positionFilter)}
58858
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58859
+ ) {
58860
+ id
58861
+ position { id }
58862
+ liquidator
58863
+ liquidatedAmount
58864
+ collateralSeized
58865
+ timestamp
58866
+ blockNumber
58867
+ transactionHash
58868
+ }` : ""}
58869
+
58870
+ ${includeKind("collateral") ? `
58871
+ collateralEvents(
58872
+ ${buildTimeWhereClause(positionFilter)}
58873
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58874
+ ) {
58875
+ id
58876
+ position { id }
58877
+ eventType
58878
+ networkFee
58879
+ remainingCollateral
58880
+ timestamp
58881
+ blockNumber
58882
+ transactionHash
58883
+ }` : ""}
58884
+
58885
+ ${includeKind("mint") ? `
58886
+ ucdmintEvents(
58887
+ ${buildTimeWhereClause(positionFilter)}
58888
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58889
+ ) {
58890
+ id
58891
+ position { id }
58892
+ amount
58893
+ minter { id }
58894
+ isCommunityMint
58895
+ timestamp
58896
+ blockNumber
58897
+ transactionHash
58898
+ }` : ""}
58899
+
58900
+ ${includeKind("withdrawal") ? `
58901
+ withdrawalEvents: withdrawalEvents(
58902
+ ${buildTimeWhereClause(positionFilter)}
58903
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58904
+ ) {
58905
+ id
58906
+ position { id }
58907
+ withdrawalAmount
58908
+ withdrawalAddress
58909
+ timestamp
58910
+ blockNumber
58911
+ transactionHash
58912
+ }` : ""}
58913
+
58914
+ ${includeKind("psm") ? `
58915
+ psmTransactions(
58916
+ ${buildTimeWhereClause()}
58917
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58918
+ ) {
58919
+ id
58920
+ type
58921
+ user
58922
+ stablecoinAmount
58923
+ ucdAmount
58924
+ timestamp
58925
+ blockNumber
58926
+ transactionHash
58927
+ }` : ""}
58928
+
58929
+ ${includeKind("admin") ? `
58930
+ circuitBreakerEvents(
58931
+ ${buildTimeWhereClause()}
58932
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58933
+ ) {
58934
+ id
58935
+ isActivated
58936
+ admin
58937
+ timestamp
58938
+ blockNumber
58939
+ transactionHash
58940
+ }
58941
+ termFeeUpdates(
58942
+ ${buildTimeWhereClause()}
58943
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58944
+ ) {
58945
+ id
58946
+ term { id }
58947
+ oldOriginationFee
58948
+ newOriginationFee
58949
+ timestamp
58950
+ blockNumber
58951
+ transactionHash
58952
+ }
58953
+ loanProtocolParamUpdates(
58954
+ ${buildTimeWhereClause()}
58955
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58956
+ ) {
58957
+ id
58958
+ newLiquidationThreshold
58959
+ newMinimumLoanValueUcd
58960
+ caller
58961
+ timestamp
58962
+ blockNumber
58963
+ transactionHash
58964
+ }
58965
+ maxLoanValueUpdates(
58966
+ ${buildTimeWhereClause()}
58967
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58968
+ ) {
58969
+ id
58970
+ newValueUcd
58971
+ caller
58972
+ timestamp
58973
+ blockNumber
58974
+ transactionHash
58975
+ }
58976
+ btcPriceBoundsUpdates(
58977
+ ${buildTimeWhereClause()}
58978
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58979
+ ) {
58980
+ id
58981
+ newMinBound
58982
+ newMaxBound
58983
+ caller
58984
+ timestamp
58985
+ blockNumber
58986
+ transactionHash
58987
+ }
58988
+ perUserDailyMintLimitUpdates(
58989
+ ${buildTimeWhereClause()}
58990
+ first: $limit, orderBy: timestamp, orderDirection: $orderDirection
58991
+ ) {
58992
+ id
58993
+ newLimit
58994
+ updatedBy
58995
+ timestamp
58996
+ blockNumber
58997
+ transactionHash
58998
+ }` : ""}
58999
+ }
59000
+ `;
59001
+ const result = await this.client.execute(query, {
59002
+ limit,
59003
+ orderDirection
59004
+ });
59005
+ const events = [];
59006
+ for (const e of result.positionCreatedEvents || []) {
59007
+ events.push({ kind: "position", subkind: "created", positionId: e.position.id, ...e });
58842
59008
  }
58843
- if (this.isProductionNetwork()) {
58844
- return failure(
58845
- new SDKError({
58846
- message: "Cannot mint mock tokens on production network",
58847
- category: "CONFIGURATION" /* CONFIGURATION */,
58848
- severity: "HIGH" /* HIGH */,
58849
- originalError: new Error("Production network detected")
58850
- })
58851
- );
59009
+ for (const e of result.positionStatusUpdates || []) {
59010
+ events.push({ kind: "position", subkind: "status", positionId: e.position.id, ...e });
58852
59011
  }
58853
- return tryCatchAsync(
58854
- async () => {
58855
- const signerResult = this.config.contractManager.getSigner();
58856
- if (!signerResult.success) {
58857
- throw signerResult.error;
58858
- }
58859
- throw new Error("Mock BTC contract not yet integrated");
58860
- },
58861
- (error) => new SDKError({
58862
- message: "Failed to mint mock BTC",
58863
- category: "CONTRACT" /* CONTRACT */,
58864
- severity: "MEDIUM" /* MEDIUM */,
58865
- originalError: error instanceof Error ? error : new Error(String(error)),
58866
- context: { amount: amount.toString(), recipient }
58867
- })
58868
- );
58869
- }
58870
- /**
58871
- * Approve mock BTC spending
58872
- *
58873
- * @param spender - Spender address
58874
- * @param amount - Amount to approve in satoshis
58875
- * @returns Transaction result
58876
- */
58877
- async approveMockBTC(spender, amount) {
58878
- if (this.config.debug) {
58879
- log.info("\u2705 Approving mock BTC spending", {
58880
- spender,
58881
- amount: amount.toString()
58882
- });
59012
+ for (const e of result.renewalEvents || []) {
59013
+ events.push({ kind: "position", subkind: "renewed", positionId: e.position.id, ...e });
58883
59014
  }
58884
- if (this.isProductionNetwork()) {
58885
- return failure(
58886
- new SDKError({
58887
- message: "Cannot approve mock tokens on production network",
58888
- category: "CONFIGURATION" /* CONFIGURATION */,
58889
- severity: "HIGH" /* HIGH */,
58890
- originalError: new Error("Production network detected")
58891
- })
58892
- );
59015
+ for (const e of result.payments || []) {
59016
+ events.push({ kind: "payment", positionId: e.position.id, ...e });
58893
59017
  }
58894
- return tryCatchAsync(
58895
- async () => {
58896
- const signerResult = this.config.contractManager.getSigner();
58897
- if (!signerResult.success) {
58898
- throw signerResult.error;
58899
- }
58900
- throw new Error("Mock BTC contract not yet integrated");
58901
- },
58902
- (error) => new SDKError({
58903
- message: "Failed to approve mock BTC",
58904
- category: "CONTRACT" /* CONTRACT */,
58905
- severity: "MEDIUM" /* MEDIUM */,
58906
- originalError: error instanceof Error ? error : new Error(String(error)),
58907
- context: { spender, amount: amount.toString() }
58908
- })
58909
- );
58910
- }
58911
- /**
58912
- * Get mock BTC balance
58913
- *
58914
- * @param address - Address to query
58915
- * @returns Balance in satoshis
58916
- */
58917
- async getMockBTCBalance(address) {
58918
- if (this.config.debug) {
58919
- log.info("\u{1F50D} Querying mock BTC balance", { address });
59018
+ for (const e of result.liquidations || []) {
59019
+ events.push({ kind: "liquidation", positionId: e.position.id, ...e });
58920
59020
  }
58921
- return tryCatchAsync(
58922
- async () => {
58923
- throw new Error("Mock BTC contract not yet integrated");
58924
- },
58925
- (error) => new SDKError({
58926
- message: "Failed to get mock BTC balance",
58927
- category: "CONTRACT" /* CONTRACT */,
58928
- severity: "MEDIUM" /* MEDIUM */,
58929
- originalError: error instanceof Error ? error : new Error(String(error)),
58930
- context: { address }
58931
- })
58932
- );
58933
- }
58934
- /**
58935
- * Check if current network is production (mainnet)
58936
- */
58937
- isProductionNetwork() {
58938
- return this.config.network.toLowerCase().includes("mainnet");
59021
+ for (const e of result.collateralEvents || []) {
59022
+ events.push({ kind: "collateral", positionId: e.position.id, ...e });
59023
+ }
59024
+ for (const e of result.ucdmintEvents || []) {
59025
+ events.push({ kind: "mint", positionId: e.position.id, ...e });
59026
+ }
59027
+ for (const e of result.withdrawalEvents || []) {
59028
+ events.push({ kind: "withdrawal", positionId: e.position.id, ...e });
59029
+ }
59030
+ for (const e of result.psmTransactions || []) {
59031
+ const subkind = e.type === "SWAP" ? "swap" : "redeem";
59032
+ events.push({ kind: "psm", subkind, ...e });
59033
+ }
59034
+ for (const e of result.circuitBreakerEvents || []) {
59035
+ events.push({ kind: "admin", subkind: "circuitBreaker", ...e });
59036
+ }
59037
+ for (const e of result.termFeeUpdates || []) {
59038
+ events.push({ kind: "admin", subkind: "termFee", ...e });
59039
+ }
59040
+ for (const e of result.loanProtocolParamUpdates || []) {
59041
+ events.push({ kind: "admin", subkind: "loanParams", ...e });
59042
+ }
59043
+ for (const e of result.maxLoanValueUpdates || []) {
59044
+ events.push({ kind: "admin", subkind: "maxLoanValue", ...e });
59045
+ }
59046
+ for (const e of result.btcPriceBoundsUpdates || []) {
59047
+ events.push({ kind: "admin", subkind: "btcBounds", ...e });
59048
+ }
59049
+ for (const e of result.perUserDailyMintLimitUpdates || []) {
59050
+ events.push({ kind: "admin", subkind: "mintLimit", ...e });
59051
+ }
59052
+ events.sort((a, b2) => {
59053
+ const diff = BigInt(a.timestamp) - BigInt(b2.timestamp);
59054
+ return orderDirection === "asc" ? Number(diff) : -Number(diff);
59055
+ });
59056
+ const byKind = {};
59057
+ for (const e of events) {
59058
+ byKind[e.kind] = (byKind[e.kind] ?? 0) + 1;
59059
+ }
59060
+ return { events, totalEvents: events.length, byKind };
58939
59061
  }
58940
59062
  };
58941
- function createMockTokenManager(config) {
58942
- try {
58943
- const manager = new MockTokenManager(config);
58944
- return success(manager);
58945
- } catch (error) {
58946
- return failure(
58947
- new SDKError({
58948
- message: "Failed to create MockTokenManager",
58949
- category: "INITIALIZATION" /* INITIALIZATION */,
58950
- severity: "HIGH" /* HIGH */,
58951
- originalError: error instanceof Error ? error : new Error(String(error))
58952
- })
58953
- );
58954
- }
58955
- }
58956
-
58957
- // src/modules/diamond-hands-sdk.ts
58958
- var import_dh_lit_ops = require("@gvnrdao/dh-lit-ops");
58959
- var import_dh_lit_actions2 = __toESM(require_pkg_src());
58960
59063
 
58961
- // src/utils/telegram-messaging.utils.ts
58962
- var TelegramBot = null;
58963
- try {
58964
- if (typeof window === "undefined" && typeof global !== "undefined") {
58965
- TelegramBot = require("node-telegram-bot-api");
58966
- }
58967
- } catch (error) {
58968
- console.warn("Telegram bot API not available:", error instanceof Error ? error.message : String(error));
58969
- }
58970
- function formatMintMessage(mintAmount, loanId, txHash) {
58971
- return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
58972
- }
58973
- function formatPartialPaymentMessage(paymentAmount, loanId, txHash) {
58974
- return `\u2705 DH SDK: ${paymentAmount} UCD was repaid for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
58975
- }
58976
- function formatPartialPaymentFailureMessage(paymentAmount, loanId, txHash) {
58977
- const baseMessage = `\u274C DH SDK: FAILED to repay ${paymentAmount} UCD for loan id: ${loanId}`;
58978
- if (txHash) {
58979
- return `${baseMessage} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
58980
- }
58981
- return baseMessage;
58982
- }
58983
- function formatLoanCreationMessage(positionId, pkpId, vaultAddress) {
58984
- const vault = vaultAddress || "unknown";
58985
- return `\u2705 DH SDK: A new loan was created Id: ${positionId} Pkp: ${pkpId} Regtest BTC vault: ${vault}`;
58986
- }
59064
+ // src/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.ts
59065
+ var _abi = [
59066
+ {
59067
+ inputs: [],
59068
+ stateMutability: "nonpayable",
59069
+ type: "constructor"
59070
+ },
59071
+ {
59072
+ inputs: [
59073
+ {
59074
+ internalType: "uint256",
59075
+ name: "amount",
59076
+ type: "uint256"
59077
+ },
59078
+ {
59079
+ internalType: "uint256",
59080
+ name: "maximum",
59081
+ type: "uint256"
59082
+ }
59083
+ ],
59084
+ name: "AboveMaxRedeem",
59085
+ type: "error"
59086
+ },
59087
+ {
59088
+ inputs: [
59089
+ {
59090
+ internalType: "uint256",
59091
+ name: "amount",
59092
+ type: "uint256"
59093
+ },
59094
+ {
59095
+ internalType: "uint256",
59096
+ name: "maximum",
59097
+ type: "uint256"
59098
+ }
59099
+ ],
59100
+ name: "AboveMaxSwap",
59101
+ type: "error"
59102
+ },
59103
+ {
59104
+ inputs: [],
59105
+ name: "AccessControlBadConfirmation",
59106
+ type: "error"
59107
+ },
59108
+ {
59109
+ inputs: [
59110
+ {
59111
+ internalType: "address",
59112
+ name: "account",
59113
+ type: "address"
59114
+ },
59115
+ {
59116
+ internalType: "bytes32",
59117
+ name: "neededRole",
59118
+ type: "bytes32"
59119
+ }
59120
+ ],
59121
+ name: "AccessControlUnauthorizedAccount",
59122
+ type: "error"
59123
+ },
59124
+ {
59125
+ inputs: [
59126
+ {
59127
+ internalType: "address",
59128
+ name: "target",
59129
+ type: "address"
59130
+ }
59131
+ ],
59132
+ name: "AddressEmptyCode",
59133
+ type: "error"
59134
+ },
59135
+ {
59136
+ inputs: [],
59137
+ name: "ArrayLengthMismatch",
59138
+ type: "error"
59139
+ },
59140
+ {
59141
+ inputs: [
59142
+ {
59143
+ internalType: "uint256",
59144
+ name: "amount",
59145
+ type: "uint256"
59146
+ },
59147
+ {
59148
+ internalType: "uint256",
59149
+ name: "minimum",
59150
+ type: "uint256"
59151
+ }
59152
+ ],
59153
+ name: "BelowMinRedeem",
59154
+ type: "error"
59155
+ },
59156
+ {
59157
+ inputs: [
59158
+ {
59159
+ internalType: "uint256",
59160
+ name: "amount",
59161
+ type: "uint256"
59162
+ },
59163
+ {
59164
+ internalType: "uint256",
59165
+ name: "minimum",
59166
+ type: "uint256"
59167
+ }
59168
+ ],
59169
+ name: "BelowMinSwap",
59170
+ type: "error"
59171
+ },
59172
+ {
59173
+ inputs: [
59174
+ {
59175
+ internalType: "uint8",
59176
+ name: "provided",
59177
+ type: "uint8"
59178
+ },
59179
+ {
59180
+ internalType: "uint8",
59181
+ name: "actual",
59182
+ type: "uint8"
59183
+ }
59184
+ ],
59185
+ name: "DecimalsMismatch",
59186
+ type: "error"
59187
+ },
59188
+ {
59189
+ inputs: [],
59190
+ name: "DecimalsQueryFailed",
59191
+ type: "error"
59192
+ },
59193
+ {
59194
+ inputs: [
59195
+ {
59196
+ internalType: "address",
59197
+ name: "implementation",
59198
+ type: "address"
59199
+ }
59200
+ ],
59201
+ name: "ERC1967InvalidImplementation",
59202
+ type: "error"
59203
+ },
59204
+ {
59205
+ inputs: [],
59206
+ name: "ERC1967NonPayable",
59207
+ type: "error"
59208
+ },
59209
+ {
59210
+ inputs: [],
59211
+ name: "EnforcedPause",
59212
+ type: "error"
59213
+ },
59214
+ {
59215
+ inputs: [
59216
+ {
59217
+ internalType: "uint256",
59218
+ name: "fee",
59219
+ type: "uint256"
59220
+ },
59221
+ {
59222
+ internalType: "uint256",
59223
+ name: "max",
59224
+ type: "uint256"
59225
+ }
59226
+ ],
59227
+ name: "EntryFeeTooHigh",
59228
+ type: "error"
59229
+ },
59230
+ {
59231
+ inputs: [
59232
+ {
59233
+ internalType: "uint256",
59234
+ name: "fee",
59235
+ type: "uint256"
59236
+ },
59237
+ {
59238
+ internalType: "uint256",
59239
+ name: "max",
59240
+ type: "uint256"
59241
+ }
59242
+ ],
59243
+ name: "ExitFeeTooHigh",
59244
+ type: "error"
59245
+ },
59246
+ {
59247
+ inputs: [],
59248
+ name: "ExpectedPause",
59249
+ type: "error"
59250
+ },
59251
+ {
59252
+ inputs: [],
59253
+ name: "FailedCall",
59254
+ type: "error"
59255
+ },
59256
+ {
59257
+ inputs: [],
59258
+ name: "FailedToGetStablecoinDecimals",
59259
+ type: "error"
59260
+ },
59261
+ {
59262
+ inputs: [],
59263
+ name: "FailedToGetUCDDecimals",
59264
+ type: "error"
59265
+ },
59266
+ {
59267
+ inputs: [],
59268
+ name: "InitialBalanceTooLarge",
59269
+ type: "error"
59270
+ },
59271
+ {
59272
+ inputs: [
59273
+ {
59274
+ internalType: "uint256",
59275
+ name: "available",
59276
+ type: "uint256"
59277
+ },
59278
+ {
59279
+ internalType: "uint256",
59280
+ name: "required",
59281
+ type: "uint256"
59282
+ }
59283
+ ],
59284
+ name: "InsufficientReserves",
59285
+ type: "error"
59286
+ },
59287
+ {
59288
+ inputs: [],
59289
+ name: "InvalidAddress",
59290
+ type: "error"
59291
+ },
59292
+ {
59293
+ inputs: [],
59294
+ name: "InvalidAdmin",
59295
+ type: "error"
59296
+ },
59297
+ {
59298
+ inputs: [],
59299
+ name: "InvalidAmount",
59300
+ type: "error"
59301
+ },
59302
+ {
59303
+ inputs: [],
59304
+ name: "InvalidController",
59305
+ type: "error"
59306
+ },
59307
+ {
59308
+ inputs: [
59309
+ {
59310
+ internalType: "uint8",
59311
+ name: "decimals",
59312
+ type: "uint8"
59313
+ }
59314
+ ],
59315
+ name: "InvalidDecimals",
59316
+ type: "error"
59317
+ },
59318
+ {
59319
+ inputs: [],
59320
+ name: "InvalidExchangeRate",
59321
+ type: "error"
59322
+ },
59323
+ {
59324
+ inputs: [],
59325
+ name: "InvalidInitialization",
59326
+ type: "error"
59327
+ },
59328
+ {
59329
+ inputs: [],
59330
+ name: "InvalidStablecoinAddress",
59331
+ type: "error"
59332
+ },
59333
+ {
59334
+ inputs: [],
59335
+ name: "InvalidToken",
59336
+ type: "error"
59337
+ },
59338
+ {
59339
+ inputs: [
59340
+ {
59341
+ internalType: "uint8",
59342
+ name: "decimals",
59343
+ type: "uint8"
59344
+ }
59345
+ ],
59346
+ name: "InvalidUCDDecimals",
59347
+ type: "error"
59348
+ },
59349
+ {
59350
+ inputs: [
59351
+ {
59352
+ internalType: "uint256",
59353
+ name: "maximum",
59354
+ type: "uint256"
59355
+ },
59356
+ {
59357
+ internalType: "uint256",
59358
+ name: "minimum",
59359
+ type: "uint256"
59360
+ }
59361
+ ],
59362
+ name: "MaxRedeemBelowMin",
59363
+ type: "error"
59364
+ },
59365
+ {
59366
+ inputs: [],
59367
+ name: "MaxRedeemCapDisabled",
59368
+ type: "error"
59369
+ },
59370
+ {
59371
+ inputs: [
59372
+ {
59373
+ internalType: "uint256",
59374
+ name: "maximum",
59375
+ type: "uint256"
59376
+ },
59377
+ {
59378
+ internalType: "uint256",
59379
+ name: "minimum",
59380
+ type: "uint256"
59381
+ }
59382
+ ],
59383
+ name: "MaxSwapBelowMin",
59384
+ type: "error"
59385
+ },
59386
+ {
59387
+ inputs: [],
59388
+ name: "MaxSwapCapDisabled",
59389
+ type: "error"
59390
+ },
59391
+ {
59392
+ inputs: [],
59393
+ name: "NormalizationOverflow",
59394
+ type: "error"
59395
+ },
59396
+ {
59397
+ inputs: [],
59398
+ name: "NotContract",
59399
+ type: "error"
59400
+ },
59401
+ {
59402
+ inputs: [],
59403
+ name: "NotInitializing",
59404
+ type: "error"
59405
+ },
59406
+ {
59407
+ inputs: [],
59408
+ name: "RateLimitExceeded",
59409
+ type: "error"
59410
+ },
59411
+ {
59412
+ inputs: [],
59413
+ name: "RedemptionsPaused",
59414
+ type: "error"
59415
+ },
59416
+ {
59417
+ inputs: [],
59418
+ name: "ReentrancyGuardReentrantCall",
59419
+ type: "error"
59420
+ },
59421
+ {
59422
+ inputs: [],
59423
+ name: "ReserveOverflow",
59424
+ type: "error"
59425
+ },
59426
+ {
59427
+ inputs: [],
59428
+ name: "ReserveTooLarge",
59429
+ type: "error"
59430
+ },
59431
+ {
59432
+ inputs: [],
59433
+ name: "ReserveUnderflow",
59434
+ type: "error"
59435
+ },
59436
+ {
59437
+ inputs: [
59438
+ {
59439
+ internalType: "address",
59440
+ name: "token",
59441
+ type: "address"
59442
+ }
59443
+ ],
59444
+ name: "SafeERC20FailedOperation",
59445
+ type: "error"
59446
+ },
59447
+ {
59448
+ inputs: [
59449
+ {
59450
+ internalType: "uint256",
59451
+ name: "got",
59452
+ type: "uint256"
59453
+ },
59454
+ {
59455
+ internalType: "uint256",
59456
+ name: "minimum",
59457
+ type: "uint256"
59458
+ }
59459
+ ],
59460
+ name: "SlippageExceeded",
59461
+ type: "error"
59462
+ },
59463
+ {
59464
+ inputs: [],
59465
+ name: "SlippageProtectionRequired",
59466
+ type: "error"
59467
+ },
59468
+ {
59469
+ inputs: [
59470
+ {
59471
+ internalType: "address",
59472
+ name: "stablecoin",
59473
+ type: "address"
59474
+ }
59475
+ ],
59476
+ name: "StablecoinAlreadySupported",
59477
+ type: "error"
59478
+ },
59479
+ {
59480
+ inputs: [
59481
+ {
59482
+ internalType: "address",
59483
+ name: "stablecoin",
59484
+ type: "address"
59485
+ }
59486
+ ],
59487
+ name: "StablecoinNotContract",
59488
+ type: "error"
59489
+ },
59490
+ {
59491
+ inputs: [
59492
+ {
59493
+ internalType: "address",
59494
+ name: "stablecoin",
59495
+ type: "address"
59496
+ }
59497
+ ],
59498
+ name: "StablecoinNotSupported",
59499
+ type: "error"
59500
+ },
59501
+ {
59502
+ inputs: [
59503
+ {
59504
+ internalType: "address",
59505
+ name: "stablecoin",
59506
+ type: "address"
59507
+ }
59508
+ ],
59509
+ name: "StablecoinNotSupportedInV1",
59510
+ type: "error"
59511
+ },
59512
+ {
59513
+ inputs: [],
59514
+ name: "SyncDriftTooLarge",
59515
+ type: "error"
59516
+ },
59517
+ {
59518
+ inputs: [],
59519
+ name: "UUPSUnauthorizedCallContext",
59520
+ type: "error"
59521
+ },
59522
+ {
59523
+ inputs: [
59524
+ {
59525
+ internalType: "bytes32",
59526
+ name: "slot",
59527
+ type: "bytes32"
59528
+ }
59529
+ ],
59530
+ name: "UUPSUnsupportedProxiableUUID",
59531
+ type: "error"
59532
+ },
59533
+ {
59534
+ inputs: [],
59535
+ name: "UnexpectedRoleGrantFailure",
59536
+ type: "error"
59537
+ },
59538
+ {
59539
+ inputs: [],
59540
+ name: "V2AlreadyInitialized",
59541
+ type: "error"
59542
+ },
59543
+ {
59544
+ inputs: [
59545
+ {
59546
+ internalType: "uint256",
59547
+ name: "amount",
59548
+ type: "uint256"
59549
+ },
59550
+ {
59551
+ internalType: "uint256",
59552
+ name: "reserves",
59553
+ type: "uint256"
59554
+ }
59555
+ ],
59556
+ name: "WithdrawalExceedsReserves",
59557
+ type: "error"
59558
+ },
59559
+ {
59560
+ anonymous: false,
59561
+ inputs: [
59562
+ {
59563
+ indexed: true,
59564
+ internalType: "address",
59565
+ name: "stablecoin",
59566
+ type: "address"
59567
+ },
59568
+ {
59569
+ indexed: false,
59570
+ internalType: "uint256",
59571
+ name: "oldFee",
59572
+ type: "uint256"
59573
+ },
59574
+ {
59575
+ indexed: false,
59576
+ internalType: "uint256",
59577
+ name: "newFee",
59578
+ type: "uint256"
59579
+ }
59580
+ ],
59581
+ name: "EntryFeeUpdated",
59582
+ type: "event"
59583
+ },
59584
+ {
59585
+ anonymous: false,
59586
+ inputs: [
59587
+ {
59588
+ indexed: true,
59589
+ internalType: "address",
59590
+ name: "stablecoin",
59591
+ type: "address"
59592
+ },
59593
+ {
59594
+ indexed: false,
59595
+ internalType: "uint256",
59596
+ name: "oldRate",
59597
+ type: "uint256"
59598
+ },
59599
+ {
59600
+ indexed: false,
59601
+ internalType: "uint256",
59602
+ name: "newRate",
59603
+ type: "uint256"
59604
+ }
59605
+ ],
59606
+ name: "ExchangeRateUpdated",
59607
+ type: "event"
59608
+ },
59609
+ {
59610
+ anonymous: false,
59611
+ inputs: [
59612
+ {
59613
+ indexed: true,
59614
+ internalType: "address",
59615
+ name: "stablecoin",
59616
+ type: "address"
59617
+ },
59618
+ {
59619
+ indexed: false,
59620
+ internalType: "uint256",
59621
+ name: "oldFee",
59622
+ type: "uint256"
59623
+ },
59624
+ {
59625
+ indexed: false,
59626
+ internalType: "uint256",
59627
+ name: "newFee",
59628
+ type: "uint256"
59629
+ }
59630
+ ],
59631
+ name: "ExitFeeUpdated",
59632
+ type: "event"
59633
+ },
59634
+ {
59635
+ anonymous: false,
59636
+ inputs: [
59637
+ {
59638
+ indexed: false,
59639
+ internalType: "uint64",
59640
+ name: "version",
59641
+ type: "uint64"
59642
+ }
59643
+ ],
59644
+ name: "Initialized",
59645
+ type: "event"
59646
+ },
59647
+ {
59648
+ anonymous: false,
59649
+ inputs: [
59650
+ {
59651
+ indexed: false,
59652
+ internalType: "address",
59653
+ name: "account",
59654
+ type: "address"
59655
+ }
59656
+ ],
59657
+ name: "Paused",
59658
+ type: "event"
59659
+ },
59660
+ {
59661
+ anonymous: false,
59662
+ inputs: [
59663
+ {
59664
+ indexed: true,
59665
+ internalType: "address",
59666
+ name: "user",
59667
+ type: "address"
59668
+ },
59669
+ {
59670
+ indexed: true,
59671
+ internalType: "address",
59672
+ name: "stablecoin",
59673
+ type: "address"
59674
+ },
59675
+ {
59676
+ indexed: false,
59677
+ internalType: "uint256",
59678
+ name: "ucdAmount",
59679
+ type: "uint256"
59680
+ },
59681
+ {
59682
+ indexed: false,
59683
+ internalType: "uint256",
59684
+ name: "stablecoinAmount",
59685
+ type: "uint256"
59686
+ },
59687
+ {
59688
+ indexed: false,
59689
+ internalType: "uint256",
59690
+ name: "exitFee",
59691
+ type: "uint256"
59692
+ },
59693
+ {
59694
+ indexed: false,
59695
+ internalType: "uint256",
59696
+ name: "timestamp",
59697
+ type: "uint256"
59698
+ }
59699
+ ],
59700
+ name: "Redeem",
59701
+ type: "event"
59702
+ },
59703
+ {
59704
+ anonymous: false,
59705
+ inputs: [
59706
+ {
59707
+ indexed: false,
59708
+ internalType: "bool",
59709
+ name: "enabled",
59710
+ type: "bool"
59711
+ }
59712
+ ],
59713
+ name: "RedemptionStatusChanged",
59714
+ type: "event"
59715
+ },
59716
+ {
59717
+ anonymous: false,
59718
+ inputs: [
59719
+ {
59720
+ indexed: true,
59721
+ internalType: "address",
59722
+ name: "stablecoin",
59723
+ type: "address"
59724
+ },
59725
+ {
59726
+ indexed: false,
59727
+ internalType: "uint256",
59728
+ name: "oldReserve",
59729
+ type: "uint256"
59730
+ },
59731
+ {
59732
+ indexed: false,
59733
+ internalType: "uint256",
59734
+ name: "newReserve",
59735
+ type: "uint256"
59736
+ }
59737
+ ],
59738
+ name: "ReserveUpdated",
59739
+ type: "event"
59740
+ },
59741
+ {
59742
+ anonymous: false,
59743
+ inputs: [
59744
+ {
59745
+ indexed: true,
59746
+ internalType: "bytes32",
59747
+ name: "role",
59748
+ type: "bytes32"
59749
+ },
59750
+ {
59751
+ indexed: true,
59752
+ internalType: "bytes32",
59753
+ name: "previousAdminRole",
59754
+ type: "bytes32"
59755
+ },
59756
+ {
59757
+ indexed: true,
59758
+ internalType: "bytes32",
59759
+ name: "newAdminRole",
59760
+ type: "bytes32"
59761
+ }
59762
+ ],
59763
+ name: "RoleAdminChanged",
59764
+ type: "event"
59765
+ },
59766
+ {
59767
+ anonymous: false,
59768
+ inputs: [
59769
+ {
59770
+ indexed: true,
59771
+ internalType: "bytes32",
59772
+ name: "role",
59773
+ type: "bytes32"
59774
+ },
59775
+ {
59776
+ indexed: true,
59777
+ internalType: "address",
59778
+ name: "account",
59779
+ type: "address"
59780
+ },
59781
+ {
59782
+ indexed: true,
59783
+ internalType: "address",
59784
+ name: "sender",
59785
+ type: "address"
59786
+ }
59787
+ ],
59788
+ name: "RoleGranted",
59789
+ type: "event"
59790
+ },
59791
+ {
59792
+ anonymous: false,
59793
+ inputs: [
59794
+ {
59795
+ indexed: true,
59796
+ internalType: "bytes32",
59797
+ name: "role",
59798
+ type: "bytes32"
59799
+ },
59800
+ {
59801
+ indexed: true,
59802
+ internalType: "address",
59803
+ name: "account",
59804
+ type: "address"
59805
+ },
59806
+ {
59807
+ indexed: true,
59808
+ internalType: "address",
59809
+ name: "sender",
59810
+ type: "address"
59811
+ }
59812
+ ],
59813
+ name: "RoleRevoked",
59814
+ type: "event"
59815
+ },
59816
+ {
59817
+ anonymous: false,
59818
+ inputs: [
59819
+ {
59820
+ indexed: true,
59821
+ internalType: "address",
59822
+ name: "stablecoin",
59823
+ type: "address"
59824
+ },
59825
+ {
59826
+ indexed: false,
59827
+ internalType: "uint256",
59828
+ name: "exchangeRate",
59829
+ type: "uint256"
59830
+ },
59831
+ {
59832
+ indexed: false,
59833
+ internalType: "uint256",
59834
+ name: "fee",
59835
+ type: "uint256"
59836
+ }
59837
+ ],
59838
+ name: "StablecoinAdded",
59839
+ type: "event"
59840
+ },
59841
+ {
59842
+ anonymous: false,
59843
+ inputs: [
59844
+ {
59845
+ indexed: true,
59846
+ internalType: "address",
59847
+ name: "stablecoin",
59848
+ type: "address"
59849
+ }
59850
+ ],
59851
+ name: "StablecoinRemoved",
59852
+ type: "event"
59853
+ },
59854
+ {
59855
+ anonymous: false,
59856
+ inputs: [
59857
+ {
59858
+ indexed: true,
59859
+ internalType: "address",
59860
+ name: "stablecoin",
59861
+ type: "address"
59862
+ },
59863
+ {
59864
+ indexed: false,
59865
+ internalType: "uint256",
59866
+ name: "exchangeRate",
59867
+ type: "uint256"
59868
+ },
59869
+ {
59870
+ indexed: false,
59871
+ internalType: "uint256",
59872
+ name: "entryFeeBps",
59873
+ type: "uint256"
59874
+ },
59875
+ {
59876
+ indexed: false,
59877
+ internalType: "uint256",
59878
+ name: "exitFeeBps",
59879
+ type: "uint256"
59880
+ },
59881
+ {
59882
+ indexed: false,
59883
+ internalType: "uint8",
59884
+ name: "decimals",
59885
+ type: "uint8"
59886
+ },
59887
+ {
59888
+ indexed: false,
59889
+ internalType: "uint256",
59890
+ name: "minSwapAmount",
59891
+ type: "uint256"
59892
+ },
59893
+ {
59894
+ indexed: false,
59895
+ internalType: "uint256",
59896
+ name: "minRedeemAmount",
59897
+ type: "uint256"
59898
+ },
59899
+ {
59900
+ indexed: false,
59901
+ internalType: "uint256",
59902
+ name: "maxSwapAmount",
59903
+ type: "uint256"
59904
+ },
59905
+ {
59906
+ indexed: false,
59907
+ internalType: "uint256",
59908
+ name: "maxRedeemAmount",
59909
+ type: "uint256"
59910
+ }
59911
+ ],
59912
+ name: "StablecoinUpdated",
59913
+ type: "event"
59914
+ },
59915
+ {
59916
+ anonymous: false,
59917
+ inputs: [
59918
+ {
59919
+ indexed: true,
59920
+ internalType: "address",
59921
+ name: "user",
59922
+ type: "address"
59923
+ },
59924
+ {
59925
+ indexed: true,
59926
+ internalType: "address",
59927
+ name: "stablecoin",
59928
+ type: "address"
59929
+ },
59930
+ {
59931
+ indexed: false,
59932
+ internalType: "uint256",
59933
+ name: "stablecoinAmount",
59934
+ type: "uint256"
59935
+ },
59936
+ {
59937
+ indexed: false,
59938
+ internalType: "uint256",
59939
+ name: "ucdAmount",
59940
+ type: "uint256"
59941
+ },
59942
+ {
59943
+ indexed: false,
59944
+ internalType: "uint256",
59945
+ name: "fee",
59946
+ type: "uint256"
59947
+ },
59948
+ {
59949
+ indexed: false,
59950
+ internalType: "uint256",
59951
+ name: "timestamp",
59952
+ type: "uint256"
59953
+ }
59954
+ ],
59955
+ name: "Swap",
59956
+ type: "event"
59957
+ },
59958
+ {
59959
+ anonymous: false,
59960
+ inputs: [
59961
+ {
59962
+ indexed: false,
59963
+ internalType: "address",
59964
+ name: "account",
59965
+ type: "address"
59966
+ }
59967
+ ],
59968
+ name: "Unpaused",
59969
+ type: "event"
59970
+ },
59971
+ {
59972
+ anonymous: false,
59973
+ inputs: [
59974
+ {
59975
+ indexed: true,
59976
+ internalType: "address",
59977
+ name: "implementation",
59978
+ type: "address"
59979
+ }
59980
+ ],
59981
+ name: "Upgraded",
59982
+ type: "event"
59983
+ },
59984
+ {
59985
+ inputs: [],
59986
+ name: "BASIS_POINTS",
59987
+ outputs: [
59988
+ {
59989
+ internalType: "uint256",
59990
+ name: "",
59991
+ type: "uint256"
59992
+ }
59993
+ ],
59994
+ stateMutability: "view",
59995
+ type: "function"
59996
+ },
59997
+ {
59998
+ inputs: [],
59999
+ name: "DEFAULT_ADMIN_ROLE",
60000
+ outputs: [
60001
+ {
60002
+ internalType: "bytes32",
60003
+ name: "",
60004
+ type: "bytes32"
60005
+ }
60006
+ ],
60007
+ stateMutability: "view",
60008
+ type: "function"
60009
+ },
60010
+ {
60011
+ inputs: [],
60012
+ name: "EXCHANGE_RATE_SCALE",
60013
+ outputs: [
60014
+ {
60015
+ internalType: "uint256",
60016
+ name: "",
60017
+ type: "uint256"
60018
+ }
60019
+ ],
60020
+ stateMutability: "view",
60021
+ type: "function"
60022
+ },
60023
+ {
60024
+ inputs: [],
60025
+ name: "MAX_EXIT_FEE",
60026
+ outputs: [
60027
+ {
60028
+ internalType: "uint256",
60029
+ name: "",
60030
+ type: "uint256"
60031
+ }
60032
+ ],
60033
+ stateMutability: "view",
60034
+ type: "function"
60035
+ },
60036
+ {
60037
+ inputs: [],
60038
+ name: "MAX_RESERVE_DRIFT",
60039
+ outputs: [
60040
+ {
60041
+ internalType: "uint256",
60042
+ name: "",
60043
+ type: "uint256"
60044
+ }
60045
+ ],
60046
+ stateMutability: "view",
60047
+ type: "function"
60048
+ },
60049
+ {
60050
+ inputs: [],
60051
+ name: "UPGRADE_INTERFACE_VERSION",
60052
+ outputs: [
60053
+ {
60054
+ internalType: "string",
60055
+ name: "",
60056
+ type: "string"
60057
+ }
60058
+ ],
60059
+ stateMutability: "view",
60060
+ type: "function"
60061
+ },
60062
+ {
60063
+ inputs: [
60064
+ {
60065
+ internalType: "address",
60066
+ name: "stablecoin",
60067
+ type: "address"
60068
+ },
60069
+ {
60070
+ internalType: "uint256",
60071
+ name: "amount",
60072
+ type: "uint256"
60073
+ }
60074
+ ],
60075
+ name: "addReserves",
60076
+ outputs: [],
60077
+ stateMutability: "nonpayable",
60078
+ type: "function"
60079
+ },
60080
+ {
60081
+ inputs: [
60082
+ {
60083
+ internalType: "address",
60084
+ name: "stablecoin",
60085
+ type: "address"
60086
+ },
60087
+ {
60088
+ internalType: "uint256",
60089
+ name: "exchangeRate",
60090
+ type: "uint256"
60091
+ },
60092
+ {
60093
+ internalType: "uint256",
60094
+ name: "entryFeeBps",
60095
+ type: "uint256"
60096
+ },
60097
+ {
60098
+ internalType: "uint256",
60099
+ name: "exitFeeBps",
60100
+ type: "uint256"
60101
+ },
60102
+ {
60103
+ internalType: "uint8",
60104
+ name: "decimals",
60105
+ type: "uint8"
60106
+ },
60107
+ {
60108
+ internalType: "uint256",
60109
+ name: "minSwapAmount",
60110
+ type: "uint256"
60111
+ },
60112
+ {
60113
+ internalType: "uint256",
60114
+ name: "minRedeemAmount",
60115
+ type: "uint256"
60116
+ },
60117
+ {
60118
+ internalType: "uint256",
60119
+ name: "maxSwapAmount",
60120
+ type: "uint256"
60121
+ },
60122
+ {
60123
+ internalType: "uint256",
60124
+ name: "maxRedeemAmount",
60125
+ type: "uint256"
60126
+ }
60127
+ ],
60128
+ name: "addSupportedStablecoin",
60129
+ outputs: [],
60130
+ stateMutability: "nonpayable",
60131
+ type: "function"
60132
+ },
60133
+ {
60134
+ inputs: [
60135
+ {
60136
+ internalType: "address",
60137
+ name: "stablecoin",
60138
+ type: "address"
60139
+ },
60140
+ {
60141
+ internalType: "uint256",
60142
+ name: "ucdAmount",
60143
+ type: "uint256"
60144
+ }
60145
+ ],
60146
+ name: "canRedeem",
60147
+ outputs: [
60148
+ {
60149
+ internalType: "bool",
60150
+ name: "",
60151
+ type: "bool"
60152
+ }
60153
+ ],
60154
+ stateMutability: "view",
60155
+ type: "function"
60156
+ },
60157
+ {
60158
+ inputs: [],
60159
+ name: "controller",
60160
+ outputs: [
60161
+ {
60162
+ internalType: "contract IUCDController",
60163
+ name: "",
60164
+ type: "address"
60165
+ }
60166
+ ],
60167
+ stateMutability: "view",
60168
+ type: "function"
60169
+ },
60170
+ {
60171
+ inputs: [
60172
+ {
60173
+ internalType: "address",
60174
+ name: "",
60175
+ type: "address"
60176
+ }
60177
+ ],
60178
+ name: "exchangeRates",
60179
+ outputs: [
60180
+ {
60181
+ internalType: "uint256",
60182
+ name: "",
60183
+ type: "uint256"
60184
+ }
60185
+ ],
60186
+ stateMutability: "view",
60187
+ type: "function"
60188
+ },
60189
+ {
60190
+ inputs: [
60191
+ {
60192
+ internalType: "address",
60193
+ name: "",
60194
+ type: "address"
60195
+ }
60196
+ ],
60197
+ name: "exitFees",
60198
+ outputs: [
60199
+ {
60200
+ internalType: "uint256",
60201
+ name: "",
60202
+ type: "uint256"
60203
+ }
60204
+ ],
60205
+ stateMutability: "view",
60206
+ type: "function"
60207
+ },
60208
+ {
60209
+ inputs: [
60210
+ {
60211
+ internalType: "address",
60212
+ name: "",
60213
+ type: "address"
60214
+ }
60215
+ ],
60216
+ name: "fees",
60217
+ outputs: [
60218
+ {
60219
+ internalType: "uint256",
60220
+ name: "",
60221
+ type: "uint256"
60222
+ }
60223
+ ],
60224
+ stateMutability: "view",
60225
+ type: "function"
60226
+ },
60227
+ {
60228
+ inputs: [
60229
+ {
60230
+ internalType: "address",
60231
+ name: "stablecoin",
60232
+ type: "address"
60233
+ }
60234
+ ],
60235
+ name: "forceSyncReserves",
60236
+ outputs: [],
60237
+ stateMutability: "nonpayable",
60238
+ type: "function"
60239
+ },
60240
+ {
60241
+ inputs: [
60242
+ {
60243
+ internalType: "address",
60244
+ name: "stablecoin",
60245
+ type: "address"
60246
+ }
60247
+ ],
60248
+ name: "getAvailableReserves",
60249
+ outputs: [
60250
+ {
60251
+ internalType: "uint256",
60252
+ name: "",
60253
+ type: "uint256"
60254
+ }
60255
+ ],
60256
+ stateMutability: "view",
60257
+ type: "function"
60258
+ },
60259
+ {
60260
+ inputs: [
60261
+ {
60262
+ internalType: "address",
60263
+ name: "stablecoin",
60264
+ type: "address"
60265
+ },
60266
+ {
60267
+ internalType: "uint256",
60268
+ name: "ucdAmount",
60269
+ type: "uint256"
60270
+ }
60271
+ ],
60272
+ name: "getRedemptionQuote",
60273
+ outputs: [
60274
+ {
60275
+ internalType: "uint256",
60276
+ name: "stablecoinOut",
60277
+ type: "uint256"
60278
+ },
60279
+ {
60280
+ internalType: "uint256",
60281
+ name: "exitFee",
60282
+ type: "uint256"
60283
+ }
60284
+ ],
60285
+ stateMutability: "view",
60286
+ type: "function"
60287
+ },
60288
+ {
60289
+ inputs: [
60290
+ {
60291
+ internalType: "bytes32",
60292
+ name: "role",
60293
+ type: "bytes32"
60294
+ }
60295
+ ],
60296
+ name: "getRoleAdmin",
60297
+ outputs: [
60298
+ {
60299
+ internalType: "bytes32",
60300
+ name: "",
60301
+ type: "bytes32"
60302
+ }
60303
+ ],
60304
+ stateMutability: "view",
60305
+ type: "function"
60306
+ },
60307
+ {
60308
+ inputs: [
60309
+ {
60310
+ internalType: "address",
60311
+ name: "stablecoin",
60312
+ type: "address"
60313
+ },
60314
+ {
60315
+ internalType: "uint256",
60316
+ name: "amountIn",
60317
+ type: "uint256"
60318
+ }
60319
+ ],
60320
+ name: "getSwapQuote",
60321
+ outputs: [
60322
+ {
60323
+ internalType: "uint256",
60324
+ name: "ucdOut",
60325
+ type: "uint256"
60326
+ },
60327
+ {
60328
+ internalType: "uint256",
60329
+ name: "fee",
60330
+ type: "uint256"
60331
+ }
60332
+ ],
60333
+ stateMutability: "view",
60334
+ type: "function"
60335
+ },
60336
+ {
60337
+ inputs: [
60338
+ {
60339
+ internalType: "bytes32",
60340
+ name: "role",
60341
+ type: "bytes32"
60342
+ },
60343
+ {
60344
+ internalType: "address",
60345
+ name: "account",
60346
+ type: "address"
60347
+ }
60348
+ ],
60349
+ name: "grantRole",
60350
+ outputs: [],
60351
+ stateMutability: "nonpayable",
60352
+ type: "function"
60353
+ },
60354
+ {
60355
+ inputs: [
60356
+ {
60357
+ internalType: "bytes32",
60358
+ name: "role",
60359
+ type: "bytes32"
60360
+ },
60361
+ {
60362
+ internalType: "address",
60363
+ name: "account",
60364
+ type: "address"
60365
+ }
60366
+ ],
60367
+ name: "hasRole",
60368
+ outputs: [
60369
+ {
60370
+ internalType: "bool",
60371
+ name: "",
60372
+ type: "bool"
60373
+ }
60374
+ ],
60375
+ stateMutability: "view",
60376
+ type: "function"
60377
+ },
60378
+ {
60379
+ inputs: [
60380
+ {
60381
+ internalType: "address",
60382
+ name: "_controller",
60383
+ type: "address"
60384
+ },
60385
+ {
60386
+ internalType: "address",
60387
+ name: "_ucdToken",
60388
+ type: "address"
60389
+ },
60390
+ {
60391
+ internalType: "address",
60392
+ name: "_admin",
60393
+ type: "address"
60394
+ }
60395
+ ],
60396
+ name: "initialize",
60397
+ outputs: [],
60398
+ stateMutability: "nonpayable",
60399
+ type: "function"
60400
+ },
60401
+ {
60402
+ inputs: [
60403
+ {
60404
+ internalType: "bool",
60405
+ name: "_redeemEnabled",
60406
+ type: "bool"
60407
+ },
60408
+ {
60409
+ internalType: "address[]",
60410
+ name: "stablecoins",
60411
+ type: "address[]"
60412
+ },
60413
+ {
60414
+ internalType: "uint256[]",
60415
+ name: "initialExitFees",
60416
+ type: "uint256[]"
60417
+ }
60418
+ ],
60419
+ name: "initializeV2",
60420
+ outputs: [],
60421
+ stateMutability: "nonpayable",
60422
+ type: "function"
60423
+ },
60424
+ {
60425
+ inputs: [
60426
+ {
60427
+ internalType: "address",
60428
+ name: "",
60429
+ type: "address"
60430
+ }
60431
+ ],
60432
+ name: "lastOperationBlock",
60433
+ outputs: [
60434
+ {
60435
+ internalType: "uint256",
60436
+ name: "",
60437
+ type: "uint256"
60438
+ }
60439
+ ],
60440
+ stateMutability: "view",
60441
+ type: "function"
60442
+ },
60443
+ {
60444
+ inputs: [
60445
+ {
60446
+ internalType: "address",
60447
+ name: "",
60448
+ type: "address"
60449
+ }
60450
+ ],
60451
+ name: "maxRedeemAmounts",
60452
+ outputs: [
60453
+ {
60454
+ internalType: "uint256",
60455
+ name: "",
60456
+ type: "uint256"
60457
+ }
60458
+ ],
60459
+ stateMutability: "view",
60460
+ type: "function"
60461
+ },
60462
+ {
60463
+ inputs: [
60464
+ {
60465
+ internalType: "address",
60466
+ name: "",
60467
+ type: "address"
60468
+ }
60469
+ ],
60470
+ name: "maxSwapAmounts",
60471
+ outputs: [
60472
+ {
60473
+ internalType: "uint256",
60474
+ name: "",
60475
+ type: "uint256"
60476
+ }
60477
+ ],
60478
+ stateMutability: "view",
60479
+ type: "function"
60480
+ },
60481
+ {
60482
+ inputs: [
60483
+ {
60484
+ internalType: "address",
60485
+ name: "",
60486
+ type: "address"
60487
+ }
60488
+ ],
60489
+ name: "minRedeemAmounts",
60490
+ outputs: [
60491
+ {
60492
+ internalType: "uint256",
60493
+ name: "",
60494
+ type: "uint256"
60495
+ }
60496
+ ],
60497
+ stateMutability: "view",
60498
+ type: "function"
60499
+ },
60500
+ {
60501
+ inputs: [
60502
+ {
60503
+ internalType: "address",
60504
+ name: "",
60505
+ type: "address"
60506
+ }
60507
+ ],
60508
+ name: "minSwapAmounts",
60509
+ outputs: [
60510
+ {
60511
+ internalType: "uint256",
60512
+ name: "",
60513
+ type: "uint256"
60514
+ }
60515
+ ],
60516
+ stateMutability: "view",
60517
+ type: "function"
60518
+ },
60519
+ {
60520
+ inputs: [
60521
+ {
60522
+ internalType: "address",
60523
+ name: "",
60524
+ type: "address"
60525
+ }
60526
+ ],
60527
+ name: "operationCount",
60528
+ outputs: [
60529
+ {
60530
+ internalType: "uint256",
60531
+ name: "",
60532
+ type: "uint256"
60533
+ }
60534
+ ],
60535
+ stateMutability: "view",
60536
+ type: "function"
60537
+ },
60538
+ {
60539
+ inputs: [],
60540
+ name: "pause",
60541
+ outputs: [],
60542
+ stateMutability: "nonpayable",
60543
+ type: "function"
60544
+ },
60545
+ {
60546
+ inputs: [],
60547
+ name: "paused",
60548
+ outputs: [
60549
+ {
60550
+ internalType: "bool",
60551
+ name: "",
60552
+ type: "bool"
60553
+ }
60554
+ ],
60555
+ stateMutability: "view",
60556
+ type: "function"
60557
+ },
60558
+ {
60559
+ inputs: [],
60560
+ name: "proxiableUUID",
60561
+ outputs: [
60562
+ {
60563
+ internalType: "bytes32",
60564
+ name: "",
60565
+ type: "bytes32"
60566
+ }
60567
+ ],
60568
+ stateMutability: "view",
60569
+ type: "function"
60570
+ },
60571
+ {
60572
+ inputs: [
60573
+ {
60574
+ internalType: "address",
60575
+ name: "stablecoin",
60576
+ type: "address"
60577
+ },
60578
+ {
60579
+ internalType: "uint256",
60580
+ name: "ucdAmount",
60581
+ type: "uint256"
60582
+ },
60583
+ {
60584
+ internalType: "uint256",
60585
+ name: "minStablecoinOut",
60586
+ type: "uint256"
60587
+ }
60588
+ ],
60589
+ name: "redeem",
60590
+ outputs: [
60591
+ {
60592
+ internalType: "uint256",
60593
+ name: "stablecoinAmount",
60594
+ type: "uint256"
60595
+ }
60596
+ ],
60597
+ stateMutability: "nonpayable",
60598
+ type: "function"
60599
+ },
60600
+ {
60601
+ inputs: [],
60602
+ name: "redeemEnabled",
60603
+ outputs: [
60604
+ {
60605
+ internalType: "bool",
60606
+ name: "",
60607
+ type: "bool"
60608
+ }
60609
+ ],
60610
+ stateMutability: "view",
60611
+ type: "function"
60612
+ },
60613
+ {
60614
+ inputs: [
60615
+ {
60616
+ internalType: "address",
60617
+ name: "stablecoin",
60618
+ type: "address"
60619
+ }
60620
+ ],
60621
+ name: "removeSupportedStablecoin",
60622
+ outputs: [],
60623
+ stateMutability: "nonpayable",
60624
+ type: "function"
60625
+ },
60626
+ {
60627
+ inputs: [
60628
+ {
60629
+ internalType: "bytes32",
60630
+ name: "role",
60631
+ type: "bytes32"
60632
+ },
60633
+ {
60634
+ internalType: "address",
60635
+ name: "callerConfirmation",
60636
+ type: "address"
60637
+ }
60638
+ ],
60639
+ name: "renounceRole",
60640
+ outputs: [],
60641
+ stateMutability: "nonpayable",
60642
+ type: "function"
60643
+ },
60644
+ {
60645
+ inputs: [
60646
+ {
60647
+ internalType: "address",
60648
+ name: "",
60649
+ type: "address"
60650
+ }
60651
+ ],
60652
+ name: "reserves",
60653
+ outputs: [
60654
+ {
60655
+ internalType: "uint256",
60656
+ name: "",
60657
+ type: "uint256"
60658
+ }
60659
+ ],
60660
+ stateMutability: "view",
60661
+ type: "function"
60662
+ },
60663
+ {
60664
+ inputs: [
60665
+ {
60666
+ internalType: "bytes32",
60667
+ name: "role",
60668
+ type: "bytes32"
60669
+ },
60670
+ {
60671
+ internalType: "address",
60672
+ name: "account",
60673
+ type: "address"
60674
+ }
60675
+ ],
60676
+ name: "revokeRole",
60677
+ outputs: [],
60678
+ stateMutability: "nonpayable",
60679
+ type: "function"
60680
+ },
60681
+ {
60682
+ inputs: [
60683
+ {
60684
+ internalType: "bool",
60685
+ name: "enabled",
60686
+ type: "bool"
60687
+ }
60688
+ ],
60689
+ name: "setRedeemEnabled",
60690
+ outputs: [],
60691
+ stateMutability: "nonpayable",
60692
+ type: "function"
60693
+ },
60694
+ {
60695
+ inputs: [
60696
+ {
60697
+ internalType: "address",
60698
+ name: "",
60699
+ type: "address"
60700
+ }
60701
+ ],
60702
+ name: "stablecoinDecimals",
60703
+ outputs: [
60704
+ {
60705
+ internalType: "uint8",
60706
+ name: "",
60707
+ type: "uint8"
60708
+ }
60709
+ ],
60710
+ stateMutability: "view",
60711
+ type: "function"
60712
+ },
60713
+ {
60714
+ inputs: [
60715
+ {
60716
+ internalType: "address",
60717
+ name: "",
60718
+ type: "address"
60719
+ }
60720
+ ],
60721
+ name: "supportedStablecoins",
60722
+ outputs: [
60723
+ {
60724
+ internalType: "bool",
60725
+ name: "",
60726
+ type: "bool"
60727
+ }
60728
+ ],
60729
+ stateMutability: "view",
60730
+ type: "function"
60731
+ },
60732
+ {
60733
+ inputs: [
60734
+ {
60735
+ internalType: "bytes4",
60736
+ name: "interfaceId",
60737
+ type: "bytes4"
60738
+ }
60739
+ ],
60740
+ name: "supportsInterface",
60741
+ outputs: [
60742
+ {
60743
+ internalType: "bool",
60744
+ name: "",
60745
+ type: "bool"
60746
+ }
60747
+ ],
60748
+ stateMutability: "view",
60749
+ type: "function"
60750
+ },
60751
+ {
60752
+ inputs: [
60753
+ {
60754
+ internalType: "address",
60755
+ name: "stablecoin",
60756
+ type: "address"
60757
+ },
60758
+ {
60759
+ internalType: "uint256",
60760
+ name: "amountIn",
60761
+ type: "uint256"
60762
+ },
60763
+ {
60764
+ internalType: "uint256",
60765
+ name: "minUcdOut",
60766
+ type: "uint256"
60767
+ }
60768
+ ],
60769
+ name: "swap",
60770
+ outputs: [
60771
+ {
60772
+ internalType: "uint256",
60773
+ name: "ucdAmount",
60774
+ type: "uint256"
60775
+ }
60776
+ ],
60777
+ stateMutability: "nonpayable",
60778
+ type: "function"
60779
+ },
60780
+ {
60781
+ inputs: [
60782
+ {
60783
+ internalType: "address",
60784
+ name: "stablecoin",
60785
+ type: "address"
60786
+ }
60787
+ ],
60788
+ name: "syncReserves",
60789
+ outputs: [],
60790
+ stateMutability: "nonpayable",
60791
+ type: "function"
60792
+ },
60793
+ {
60794
+ inputs: [],
60795
+ name: "ucdDecimals",
60796
+ outputs: [
60797
+ {
60798
+ internalType: "uint8",
60799
+ name: "",
60800
+ type: "uint8"
60801
+ }
60802
+ ],
60803
+ stateMutability: "view",
60804
+ type: "function"
60805
+ },
60806
+ {
60807
+ inputs: [],
60808
+ name: "ucdToken",
60809
+ outputs: [
60810
+ {
60811
+ internalType: "address",
60812
+ name: "",
60813
+ type: "address"
60814
+ }
60815
+ ],
60816
+ stateMutability: "view",
60817
+ type: "function"
60818
+ },
60819
+ {
60820
+ inputs: [],
60821
+ name: "unpause",
60822
+ outputs: [],
60823
+ stateMutability: "nonpayable",
60824
+ type: "function"
60825
+ },
60826
+ {
60827
+ inputs: [
60828
+ {
60829
+ internalType: "address",
60830
+ name: "stablecoin",
60831
+ type: "address"
60832
+ },
60833
+ {
60834
+ internalType: "uint256",
60835
+ name: "exchangeRate",
60836
+ type: "uint256"
60837
+ },
60838
+ {
60839
+ internalType: "uint256",
60840
+ name: "entryFeeBps",
60841
+ type: "uint256"
60842
+ },
60843
+ {
60844
+ internalType: "uint256",
60845
+ name: "exitFeeBps",
60846
+ type: "uint256"
60847
+ },
60848
+ {
60849
+ internalType: "uint8",
60850
+ name: "decimals",
60851
+ type: "uint8"
60852
+ },
60853
+ {
60854
+ internalType: "uint256",
60855
+ name: "minSwapAmount",
60856
+ type: "uint256"
60857
+ },
60858
+ {
60859
+ internalType: "uint256",
60860
+ name: "minRedeemAmount",
60861
+ type: "uint256"
60862
+ },
60863
+ {
60864
+ internalType: "uint256",
60865
+ name: "maxSwapAmount",
60866
+ type: "uint256"
60867
+ },
60868
+ {
60869
+ internalType: "uint256",
60870
+ name: "maxRedeemAmount",
60871
+ type: "uint256"
60872
+ }
60873
+ ],
60874
+ name: "updateSupportedStablecoin",
60875
+ outputs: [],
60876
+ stateMutability: "nonpayable",
60877
+ type: "function"
60878
+ },
60879
+ {
60880
+ inputs: [
60881
+ {
60882
+ internalType: "address",
60883
+ name: "newImplementation",
60884
+ type: "address"
60885
+ },
60886
+ {
60887
+ internalType: "bytes",
60888
+ name: "data",
60889
+ type: "bytes"
60890
+ }
60891
+ ],
60892
+ name: "upgradeToAndCall",
60893
+ outputs: [],
60894
+ stateMutability: "payable",
60895
+ type: "function"
60896
+ },
60897
+ {
60898
+ inputs: [],
60899
+ name: "version",
60900
+ outputs: [
60901
+ {
60902
+ internalType: "string",
60903
+ name: "",
60904
+ type: "string"
60905
+ }
60906
+ ],
60907
+ stateMutability: "pure",
60908
+ type: "function"
60909
+ },
60910
+ {
60911
+ inputs: [
60912
+ {
60913
+ internalType: "address",
60914
+ name: "stablecoin",
60915
+ type: "address"
60916
+ },
60917
+ {
60918
+ internalType: "uint256",
60919
+ name: "amount",
60920
+ type: "uint256"
60921
+ }
60922
+ ],
60923
+ name: "withdrawStablecoin",
60924
+ outputs: [],
60925
+ stateMutability: "nonpayable",
60926
+ type: "function"
60927
+ }
60928
+ ];
60929
+ var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161347190816100f0823960805181818161195b0152611a2b0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce9146126e357806301ffc9a71461268c578063021d28931461263e5780630871b20614612605578063114249d2146105ab57806311d954f8146125dc57806313da3166146125a35780631f77bf651461256a578063248a9ca3146125435780632b83cccd1461211d5780632f2ff15d146120eb57806334e18125146120b257806336568abe1461206d5780633f4ba83a14611feb5780634451e89b14611ca25780634ebd25a514611c695780634f1ef286146119b057806352d1902d1461194857806354fd4d50146119095780635c975abb146118d95780638456cb591461186457806385c15d9a1461182b5780638bff608e146117f257806390ad8b40146117d657806391d148541461177d5780639baf58d2146117605780639f1d0f5914611315578063a217fddf146112f9578063ad3cb1cc146112b6578063b121cf7e14610fc2578063b492fc6914610ec8578063b9f637af14610cdd578063bf7d911914610c9e578063c0c53b8b146109b6578063c4c5f6241461090e578063c55f15ea146108eb578063cc1f8ffa146108b9578063cf46075e146107b9578063d21a74ff1461077c578063d2f8253614610759578063d547741f1461071e578063d5d3f78b146105e4578063d66bd524146105ab578063e1f1c4a71461058e578063ec2f96fe1461056a578063f385116d14610531578063f77c47911461050a578063faaebd21146104d1578063facdfb5e1461033b5763fc99bd9a1461024257600080fd5b346103385760403660031901126103385761025b6127ea565b9060243591610268612c82565b6001600160a01b03168082526002602052604082205490929060ff16156103255780156103165782825260076020526040822054926102a78285612b3d565b848110610307576001600160ff1b0381116102f857600080516020613445833981519152604085968493846102f59852600760205280838a205582519182526020820152a2309033906130c9565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b80fd5b5034610338576020366003190112610338576103556127ea565b61035d612d68565b610365612c82565b6001600160a01b03168082526002602052604082205460ff16156104bf57808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa9081156104b457849161047d575b508181111561046e576103cd82826129b3565b8215908115610419575b5050600080516020613445833981519152916040918486526007602052808387205582519182526020820152a260016000805160206133e58339815191525580f35b612710810290808204612710149015171561045a576064840291848304606414171561045a571161044b5738806103d7565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b61047881836129b3565b6103cd565b90506020813d6020116104ac575b816104986020938361287f565b810103126104a75751386103ba565b600080fd5b3d915061048b565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b5034610338576020366003190112610338576020906040906001600160a01b036104f96127ea565b168152600483522054604051908152f35b5034610338578060031936011261033857546040516001600160a01b039091168152602090f35b5034610338576020366003190112610338576020906040906001600160a01b036105596127ea565b168152600a83522054604051908152f35b5034610338578060031936011261033857602060ff60015460a01c16604051908152f35b503461033857806003193601126103385760206040516127108152f35b5034610338576020366003190112610338576020906040906001600160a01b036105d36127ea565b168152600783522054604051908152f35b5034610338576020366003190112610338576105fe6127ea565b610606612c82565b6001600160a01b03168082526002602052604082205460ff16156104bf5780825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806106fb578380f35b816040916000805160206134458339815191529352846020820152a23880808380f35b50346103385760403660031901126103385761075560043561073e612800565b9061075061074b82612a58565b612d1e565b613029565b5080f35b5034610338578060031936011261033857602060ff600854166040519015158152f35b50346103385760203660031901126103385760209060ff906040906001600160a01b036107a76127ea565b16815260058452205416604051908152f35b5034610338576020366003190112610338576107d36127ea565b6107db612d68565b6107e3612c82565b6001600160a01b03168082526002602052604082205460ff16156104bf57808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa9081156104b4578491610879575b50600080516020613445833981519152916040918486526007602052808387205582519182526020820152a260016000805160206133e58339815191525580f35b90506020813d6020116108b1575b816108946020938361287f565b810103126104a75751600080516020613445833981519152610838565b3d9150610887565b50346103385760403660031901126103385760206108e16108d86127ea565b60243590612b83565b6040519015158152f35b50346103385780600319360112610338576020604051670de0b6b3a76400008152f35b5034610338576040366003190112610338576109286127ea565b9060243591610935612c82565b6001600160a01b031680825260076020526040822054929081841061099f5780600080516020613445833981519152604086610975866102f598996129b3565b84895260076020528289205583885260076020528188205482519182526020820152a23390612dce565b5091604492633cb8e07360e01b8352600452602452fd5b5034610338576060366003190112610338576109d06127ea565b6109d8612800565b604435906001600160a01b03821690818303610c9a5760008051602061342583398151915254604081901c60ff161594906001600160401b031680159081610c92575b6001149081610c88575b159081610c7f575b50610c705760008051602061342583398151915280546001600160401b031916600117905584610c4b575b6001600160a01b0316908115610c3c576001600160a01b0316918215610c2d5715610c1e57610a856131f5565b610a8d6131f5565b610a956131f5565b60016000805160206133e583398151915255610aaf6131f5565b610ab76131f5565b84546001600160a01b0319908116919091178555600180549182168317905560405163313ce56760e01b8152909190602081600481855afa869181610bed575b50610b0b57633a24e95b60e11b8652600486fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16600681141580610be2575b610bd05750610b4781612e0a565b15610bc157610b5581612e86565b15610bc157610b6390612f0c565b15610bb257610b6f5780f35b60ff60401b19600080516020613425833981519152541660008051602061342583398151915255600080516020613305833981519152602060405160018152a180f35b63cf5a8e3360e01b8252600482fd5b63cf5a8e3360e01b8352600483fd5b63167738cf60e21b8452600452602483fd5b506012811415610b39565b610c1091925060203d602011610c17575b610c08818361287f565b810190612a88565b9038610af7565b503d610bfe565b630b5eba9f60e41b8552600485fd5b63c1ab6dc160e01b8652600486fd5b6336abb4df60e11b8652600486fd5b600080516020613425833981519152805460ff60401b1916600160401b179055610a58565b63f92ee8a960e01b8652600486fd5b90501538610a2d565b303b159150610a25565b869150610a1b565b8480fd5b50346103385760203660031901126103385760209060ff906040906001600160a01b03610cc96127ea565b168152600284522054166040519015158152f35b503461033857610cec3661291c565b98979694610cfe949194939293612c82565b6001600160a01b038816808a52600260205260408a205490989060ff1615610eb4578615610ea5576127108811610e8b576103e88211610e715760ff831690601282118015610e67575b610e535783610d569161310d565b85151580610e4a575b610e33578a151580610e2a575b610e1357926000805160206132c583398151915297969592828c95610e0d979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889612b4a565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10610d6c565b60448a8588637449915760e01b8352600452602452fd5b50838610610d5f565b63ca95039160e01b8b52600482905260248bfd5b5060068210610d48565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b503461033857604036600319011261033857610ee26127ea565b6001600160a01b0316808252600260205260408220546024359060ff1615610fae578015610f9f57612710610f64604085670de0b6b3a7640000610f53610f6c9688859a52600560205260ff858520541690809160128110610f79575b50508884526003602052848420549061296a565b04958152600460205220548461296a565b0480926129b3565b9082519182526020820152f35b610f98925060ff610f8c610f92926129c0565b166129d1565b9061296a565b3880610f3f565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033857610fd13661291c565b93610fe3999899979597939193612c82565b6001600160a01b038a16808a52600260205260408a205490989060ff166112a2578815611293578615610ea5576127108811610e8b576103e8811161127b5760ff82169a60128c118015611271575b61125d57803b1561124957826110479161310d565b84151580611240575b6112295785151580611220575b611209576040516370a0823160e01b8152306004820152999a98999860208a6024818e5afa998a156111fe578c9a6111ca575b506001600160ff1b038a116111bb57926000805160206132c583398151915297959261118b95928b60408f8f9d9b988e8083526002602052838320600160ff1982541617905580835260036020528c8484205580835260046020528d8484205580835260066020528584842055825260056020528282209060ff198254161790558d8152600c60205285828220558d8152600d60205286828220558d8152600e60205287828220558d8152600f60205288828220558d8152600760205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf666604080518b81528c6020820152a260405198899889612b4a565b0390a280611197578280f35b6040600080516020613445833981519152918151908582526020820152a238808280f35b63556e7a8160e01b8c5260048cfd5b9099506020813d6020116111f6575b816111e66020938361287f565b810103126104a757519838611090565b3d91506111d9565b6040513d8e823e3d90fd5b60448a858863dd85772b60e01b8352600452602452fd5b5083861061105d565b60448a8487637449915760e01b8352600452602452fd5b50828510611050565b63377e3f9960e21b8b5260048a905260248bfd5b63ca95039160e01b8b5260048c905260248bfd5b5060068c10611032565b631051834f60e11b8a526004526103e8602452604489fd5b63df407ac560e01b8a5260048afd5b6317f4215b60e21b8a52600489905260248afd5b50346103385780600319360112610338576112f560408051906112d9818361287f565b60058252640352e302e360dc1b602083015251918291826128d3565b0390f35b5034610338578060031936011261033857602090604051908152f35b50346103385761132436612825565b91611330939193612d68565b611338612da4565b33825260096020526040822054430361173e57338252600a60205260036040832054101561172f57338252600a602052604082206113768154612a79565b90555b6001600160a01b03168082526002602052604082205490919060ff16611692575b818152600260205260ff6040822054161561168057831561167157821561166257818152600c6020526040812054841061163e57818152600e6020526040812054801561162f578085116116175750818152600760205260408120546114008582612b3d565b818110611608576001600160ff1b0381116115f95760408492600080516020613445833981519152928486526007602052808387205582519182526020820152a261144d843033856130c9565b818152600560205260ff604082205416849060128110611598575b50611489670de0b6b3a764000091848452600360205260408420549061296a565b049082815260046020526114af6127106114a760408420548561296a565b0480936129b3565b93808510611580575080546001600160a01b0316803b1561157c5781809160846040518094819363ae494fa160e01b83523360048401528a60248401528960448401528b60648401525af180156115715761155c575b50507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b61153f602095604051918291339588429285612abc565b0390a360016000805160206133e583398151915255604051908152f35b61156782809261287f565b6103385780611505565b6040513d84823e3d90fd5b5080fd5b6371c4efed60e01b8252600485905260245260449150fd5b6115a89150610f8c60ff916129c0565b80156115e557806000190485116115d6576114896115cf670de0b6b3a7640000928761296a565b9150611468565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b631d7f2ac360e01b8252600485905260245260449150fd5b633b5db2f360e11b8252600482fd5b908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8152600490fd5b63162908e360e11b8152600490fd5b6024916374ed46ad60e01b8252600452fd5b919060405163313ce56760e01b8152602081600481855afa84918161170e575b506116c65763105482c760e21b8452600484fd5b92909192828252600560205260ff8060408420541691169081036116ea575061139a565b6044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b61172891925060203d602011610c1757610c08818361287f565b90386116b2565b63a74c1c5f60e01b8252600482fd5b3382526009602052436040832055338252600a60205260016040832055611379565b503461033857806003193601126103385760206040516103e88152f35b5034610338576040366003190112610338576040611799612800565b9160043581526000805160206133a5833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b5034610338578060031936011261033857602060405160648152f35b5034610338576020366003190112610338576020906040906001600160a01b0361181a6127ea565b168152600983522054604051908152f35b5034610338576020366003190112610338576020906040906001600160a01b036118536127ea565b168152600383522054604051908152f35b503461033857806003193601126103385761187d612cd0565b611885612da4565b600160ff196000805160206133c58339815191525416176000805160206133c5833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b5034610338578060031936011261033857602060ff6000805160206133c583398151915254166040519015158152f35b50346103385780600319360112610338576112f5604080519061192c818361287f565b60058252640322e302e360dc1b602083015251918291826128d3565b50346103385780600319360112610338577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036119a15760206040516000805160206133458339815191528152f35b63703e46dd60e11b8152600490fd5b506040366003190112610338576119c56127ea565b602435906001600160401b038211611c655736602383011215611c6557816004013590836119f2836128b8565b93611a00604051958661287f565b83855260208501933660248284010111611c6557806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115611c42575b50611c33578380526000805160206133a583398151915260209081526040808620336000908152925290205460ff1615611c1b576001600160a01b038116928315611c0c57813b15611bfd576040516352d1902d60e01b8152602081600481885afa869181611bc5575b50611ad957634c9c8ce360e01b86526004859052602486fd5b9384600080516020613345833981519152879603611bb35750823b15611ba15760008051602061334583398151915280546001600160a01b031916821790558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115611b86576107559382915190845af43d15611b7e573d91611b62836128b8565b92611b70604051948561287f565b83523d85602085013e613223565b606091613223565b5050505034611b925780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b8552600452602484fd5b632a87526960e21b8652600452602485fd5b9091506020813d602011611bf5575b81611be16020938361287f565b81010312611bf157519038611ac0565b8680fd5b3d9150611bd4565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b63e2517d3f60e01b8452336004526024849052604484fd5b63703e46dd60e11b8452600484fd5b600080516020613345833981519152546001600160a01b03161415905038611a56565b8280fd5b5034610338576020366003190112610338576020906040906001600160a01b03611c916127ea565b168152600e83522054604051908152f35b503461033857606036600319011261033857611cbc612816565b6024356001600160401b038111611c6557611cdb90369060040161284f565b916044356001600160401b038111610c9a57611cfb90369060040161284f565b6000805160206134258339815191529291925460ff8160401c16908115611fd3575b50610c705760008051602061342583398151915280546001600160481b0319166002600160401b01179055611d50612c82565b600b549160ff8316611fc457818603611fb557611d6c86612ad8565b92611d7a604051948561287f565b868452601f19611d8988612ad8565b01366020860137875b878110611ec0575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110611e1d57876000805160206132a5833981519152602089604051908152a160ff60401b19600080516020613425833981519152541660008051602061342583398151915255600080516020613305833981519152602060405160028152a180f35b80886000805160206134458339815191526040611e45611e40600196888d612aef565b612b15565b611e5085898c612aef565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783611e7d888d612b29565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201611db9565b611ece611e40828a8a612aef565b611ed9828689612aef565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615611fa1576103e88111611f895750906020602492604051938480926370a0823160e01b82523060048301525afa8015611f7e578a90611f48575b60019250611f418288612b29565b5201611d92565b509060203d8111611f77575b611f5e818361287f565b6020826000928101031261033857509060019151611f33565b503d611f54565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b60026001600160401b03919091161015905038611d1d565b5034610338578060031936011261033857612004612cd0565b6000805160206133c58339815191525460ff81161561205e5760ff19166000805160206133c5833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b638dfc202b60e01b8252600482fd5b503461033857604036600319011261033857612087612800565b336001600160a01b038216036120a35761075590600435613029565b63334bd91960e11b8252600482fd5b5034610338576020366003190112610338576020906040906001600160a01b036120da6127ea565b168152600c83522054604051908152f35b50346103385760403660031901126103385761075560043561210b612800565b9061211861074b82612a58565b612f92565b50346103385761212c36612825565b91612135612d68565b61213d612da4565b33845260096020526040842054430361252157338452600a60205260036040852054101561251257338452600a6020526040842061217b8154612a79565b90555b6001600160a01b03168084526002602052604084205490919060ff1661247a575b818452600260205260ff604085205416156124665760ff600854161561245757801561244857821561243957818452600d60205260408420548082106124215750818452600f60205260408420548015612412578082116123fb5750670de0b6b3a76400008102818104670de0b6b3a7640000036123e7578285526003602052604085205461222d91612993565b90828552600660205261224a6127106114a760408820548561296a565b93838652600560205260ff604087205416601281106123bc575b508085106123a557508285526007602052836040862054106123815782855260076020526040852054848110612372576000805160206134458339815191526040826122b18888956129b3565b848a52600760205280838b205582519182526020820152a284546001600160a01b0316803b1561236e578560405180926306888c6760e11b82528183816122fc883360048401612aa1565b03925af18015612363579160209661153f927f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf94612353575b5050612342863387612dce565b604051918291339588429285612abc565b8161235d9161287f565b38612335565b6040513d88823e3d90fd5b8580fd5b6308aed4ef60e31b8652600486fd5b82855260076020526040852054635960d22160e01b86526004526024849052604485fd5b6371c4efed60e01b86526004859052602452604485fd5b946123da6123d360ff610f8c6123e09597996129c0565b8092612993565b95612993565b9138612264565b634e487b7160e01b85526011600452602485fd5b625502a360e91b8552600491909152602452604483fd5b636c6ff70d60e11b8552600485fd5b6361767b8560e01b8552600491909152602452604483fd5b632cd84af360e01b8452600484fd5b63162908e360e11b8452600484fd5b630df65d9f60e01b8452600484fd5b6374ed46ad60e01b84526004829052602484fd5b60405163313ce56760e01b8152602081600481865afa8591816124f1575b506124ac5763105482c760e21b8552600485fd5b828552600560205260ff8060408720541691169081036124cc575061219f565b82855260056020526040852054631e43476360e11b865260ff16600452602452604484fd5b61250b91925060203d602011610c1757610c08818361287f565b9038612498565b63a74c1c5f60e01b8452600484fd5b3384526009602052436040852055338452600a6020526001604085205561217e565b5034610338576020366003190112610338576020612562600435612a58565b604051908152f35b5034610338576020366003190112610338576020906040906001600160a01b036125926127ea565b168152600f83522054604051908152f35b5034610338576020366003190112610338576020906040906001600160a01b036125cb6127ea565b168152600683522054604051908152f35b50346103385780600319360112610338576001546040516001600160a01b039091168152602090f35b5034610338576020366003190112610338576020906040906001600160a01b0361262d6127ea565b168152600d83522054604051908152f35b5034610338576020366003190112610338576000805160206132a58339815191526020612669612816565b612671612c82565b151560ff196008541660ff821617600855604051908152a180f35b50346103385760203660031901126103385760043563ffffffff60e01b811680910361157c57602090637965db0b60e01b81149081156126d2575b506040519015158152f35b6301ffc9a760e01b149050826126c7565b5034610338576040366003190112610338576126fd6127ea565b6001600160a01b03168082526002602052604082205460243592919060ff16156127d757670de0b6b3a7640000830292808404670de0b6b3a764000014901517156127c35760ff604061275d819584865260036020528286205490612993565b938381526006602052612781612710612779848420548861296a565b0480966129b3565b938152600560205220541660128110156127bc57906127aa6123d360ff610f8c6127b0956129c0565b92612993565b82519182526020820152f35b50906127b0565b634e487b7160e01b82526011600452602482fd5b6374ed46ad60e01b825260045260249150fd5b600435906001600160a01b03821682036104a757565b602435906001600160a01b03821682036104a757565b6004359081151582036104a757565b60609060031901126104a7576004356001600160a01b03811681036104a757906024359060443590565b9181601f840112156104a7578235916001600160401b0383116104a7576020808501948460051b0101116104a757565b601f909101601f19168101906001600160401b038211908210176128a257604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116128a257601f01601f191660200190565b91909160208152825180602083015260005b818110612906575060409293506000838284010152601f8019910116010190565b80602080928701015160408286010152016128e5565b6101209060031901126104a7576004356001600160a01b03811681036104a7579060243590604435906064359060843560ff811681036104a7579060a4359060c4359060e435906101043590565b8181029291811591840414171561297d57565b634e487b7160e01b600052601160045260246000fd5b811561299d570490565b634e487b7160e01b600052601260045260246000fd5b9190820391821161297d57565b60ff166012039060ff821161297d57565b8015612a525760009060208110600116604e821060011617612a4a57600a916001915b60018111612a21575082600019048211612a0d57500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116127c35760018416612a41575b80029260011c6129f4565b80920291612a36565b9050600a0a90565b50600190565b6000526000805160206133a583398151915260205260016040600020015490565b600019811461297d5760010190565b908160209103126104a7575160ff811681036104a75790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116128a25760051b60200190565b9190811015612aff5760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036104a75790565b8051821015612aff5760209160051b010190565b9190820180921161297d57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015612c75575b8015612c6d575b612c5b5781600052600f6020526040600020548015908115612c63575b50612c5b57612bf3926040918251948592839262f7fce960e01b845260048401612aa1565b0381305afa918215612c4f57600092612c1b575b506000526007602052604060002054101590565b9091506040813d604011612c47575b81612c376040938361287f565b810103126104a757519038612c07565b3d9150612c2a565b6040513d6000823e3d90fd5b505050600090565b9050831138612bce565b508215612bb1565b5060ff6008541615612baa565b3360009081526000805160206132e5833981519152602052604090205460ff1615612ca957565b63e2517d3f60e01b6000523360045260008051602061340583398151915260245260446000fd5b336000908152600080516020613365833981519152602052604090205460ff1615612cf757565b63e2517d3f60e01b6000523360045260008051602061338583398151915260245260446000fd5b60008181526000805160206133a58339815191526020908152604080832033845290915290205460ff1615612d505750565b63e2517d3f60e01b6000523360045260245260446000fd5b60026000805160206133e58339815191525414612d935760026000805160206133e583398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206133c58339815191525416612dbd57565b63d93c066560e01b60005260046000fd5b612e03612e089392612df560405194859263a9059cbb60e01b602085015260248401612aa1565b03601f19810184528361287f565b61319a565b565b6001600160a01b0381166000908152600080516020613325833981519152602052604090205460ff16612e80576001600160a01b0316600081815260008051602061332583398151915260205260408120805460ff191660011790553391906000805160206132858339815191528180a4600190565b50600090565b6001600160a01b03811660009081526000805160206132e5833981519152602052604090205460ff16612e80576001600160a01b031660008181526000805160206132e583398151915260205260408120805460ff19166001179055339190600080516020613405833981519152906000805160206132858339815191529080a4600190565b6001600160a01b0381166000908152600080516020613365833981519152602052604090205460ff16612e80576001600160a01b0316600081815260008051602061336583398151915260205260408120805460ff19166001179055339190600080516020613385833981519152906000805160206132858339815191529080a4600190565b60008181526000805160206133a5833981519152602090815260408083206001600160a01b038616845290915290205460ff166130225760008181526000805160206133a5833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291906000805160206132858339815191529080a4600190565b5050600090565b60008181526000805160206133a5833981519152602090815260408083206001600160a01b038616845290915290205460ff16156130225760008181526000805160206133a5833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152612e0891612e0360848361287f565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa60009281613179575b5061315057631eecbb6560e01b60005260046000fd5b60ff9182169116808203613162575050565b631e43476360e11b60005260045260245260446000fd5b61319391935060203d602011610c1757610c08818361287f565b913861313a565b906000602091828151910182855af115612c4f576000513d6131ec57506001600160a01b0381163b155b6131cb5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b600114156131c4565b60ff6000805160206134258339815191525460401c161561321257565b631afcd79f60e31b60005260046000fd5b90613249575080511561323857602081519101fd5b63d6bda27560e01b60005260046000fd5b8151158061327b575b61325a575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561325256fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629b16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431cc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2b7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc75442b0a96088b5456bc4ed01394c96a4feec0f883c9494257d76b96ab1c9b6b65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
60930
+ var isSuperArgs = (xs) => xs.length > 1;
60931
+ var SimplePSMV2__factory = class extends ContractFactory {
60932
+ constructor(...args) {
60933
+ if (isSuperArgs(args)) {
60934
+ super(...args);
60935
+ } else {
60936
+ super(_abi, _bytecode, args[0]);
60937
+ }
60938
+ }
60939
+ getDeployTransaction(overrides) {
60940
+ return super.getDeployTransaction(overrides || {});
60941
+ }
60942
+ deploy(overrides) {
60943
+ return super.deploy(overrides || {});
60944
+ }
60945
+ connect(runner) {
60946
+ return super.connect(runner);
60947
+ }
60948
+ static bytecode = _bytecode;
60949
+ static abi = _abi;
60950
+ static createInterface() {
60951
+ return new Interface(_abi);
60952
+ }
60953
+ static connect(address, runner) {
60954
+ return new Contract(address, _abi, runner);
60955
+ }
60956
+ };
60957
+
60958
+ // src/modules/mock/mock-token-manager.module.ts
60959
+ var MockTokenManager = class {
60960
+ config;
60961
+ constructor(config) {
60962
+ this.config = config;
60963
+ if (this.isProductionNetwork()) {
60964
+ log.warn("\u26A0\uFE0F MockTokenManager initialized on production network", {
60965
+ network: config.network
60966
+ });
60967
+ }
60968
+ }
60969
+ /**
60970
+ * Mint mock BTC tokens
60971
+ *
60972
+ * @param amount - Amount to mint in satoshis
60973
+ * @param recipient - Recipient address
60974
+ * @returns Transaction result
60975
+ */
60976
+ async mintMockBTC(amount, recipient) {
60977
+ if (this.config.debug) {
60978
+ log.info("\u{1FA99} Minting mock BTC", {
60979
+ amount: amount.toString(),
60980
+ recipient
60981
+ });
60982
+ }
60983
+ if (this.isProductionNetwork()) {
60984
+ return failure(
60985
+ new SDKError({
60986
+ message: "Cannot mint mock tokens on production network",
60987
+ category: "CONFIGURATION" /* CONFIGURATION */,
60988
+ severity: "HIGH" /* HIGH */,
60989
+ originalError: new Error("Production network detected")
60990
+ })
60991
+ );
60992
+ }
60993
+ return tryCatchAsync(
60994
+ async () => {
60995
+ const signerResult = this.config.contractManager.getSigner();
60996
+ if (!signerResult.success) {
60997
+ throw signerResult.error;
60998
+ }
60999
+ throw new Error("Mock BTC contract not yet integrated");
61000
+ },
61001
+ (error) => new SDKError({
61002
+ message: "Failed to mint mock BTC",
61003
+ category: "CONTRACT" /* CONTRACT */,
61004
+ severity: "MEDIUM" /* MEDIUM */,
61005
+ originalError: error instanceof Error ? error : new Error(String(error)),
61006
+ context: { amount: amount.toString(), recipient }
61007
+ })
61008
+ );
61009
+ }
61010
+ /**
61011
+ * Approve mock BTC spending
61012
+ *
61013
+ * @param spender - Spender address
61014
+ * @param amount - Amount to approve in satoshis
61015
+ * @returns Transaction result
61016
+ */
61017
+ async approveMockBTC(spender, amount) {
61018
+ if (this.config.debug) {
61019
+ log.info("\u2705 Approving mock BTC spending", {
61020
+ spender,
61021
+ amount: amount.toString()
61022
+ });
61023
+ }
61024
+ if (this.isProductionNetwork()) {
61025
+ return failure(
61026
+ new SDKError({
61027
+ message: "Cannot approve mock tokens on production network",
61028
+ category: "CONFIGURATION" /* CONFIGURATION */,
61029
+ severity: "HIGH" /* HIGH */,
61030
+ originalError: new Error("Production network detected")
61031
+ })
61032
+ );
61033
+ }
61034
+ return tryCatchAsync(
61035
+ async () => {
61036
+ const signerResult = this.config.contractManager.getSigner();
61037
+ if (!signerResult.success) {
61038
+ throw signerResult.error;
61039
+ }
61040
+ throw new Error("Mock BTC contract not yet integrated");
61041
+ },
61042
+ (error) => new SDKError({
61043
+ message: "Failed to approve mock BTC",
61044
+ category: "CONTRACT" /* CONTRACT */,
61045
+ severity: "MEDIUM" /* MEDIUM */,
61046
+ originalError: error instanceof Error ? error : new Error(String(error)),
61047
+ context: { spender, amount: amount.toString() }
61048
+ })
61049
+ );
61050
+ }
61051
+ /**
61052
+ * Get mock BTC balance
61053
+ *
61054
+ * @param address - Address to query
61055
+ * @returns Balance in satoshis
61056
+ */
61057
+ async getMockBTCBalance(address) {
61058
+ if (this.config.debug) {
61059
+ log.info("\u{1F50D} Querying mock BTC balance", { address });
61060
+ }
61061
+ return tryCatchAsync(
61062
+ async () => {
61063
+ throw new Error("Mock BTC contract not yet integrated");
61064
+ },
61065
+ (error) => new SDKError({
61066
+ message: "Failed to get mock BTC balance",
61067
+ category: "CONTRACT" /* CONTRACT */,
61068
+ severity: "MEDIUM" /* MEDIUM */,
61069
+ originalError: error instanceof Error ? error : new Error(String(error)),
61070
+ context: { address }
61071
+ })
61072
+ );
61073
+ }
61074
+ /**
61075
+ * Check if current network is production (mainnet)
61076
+ */
61077
+ isProductionNetwork() {
61078
+ return this.config.network.toLowerCase().includes("mainnet");
61079
+ }
61080
+ };
61081
+ function createMockTokenManager(config) {
61082
+ try {
61083
+ const manager = new MockTokenManager(config);
61084
+ return success(manager);
61085
+ } catch (error) {
61086
+ return failure(
61087
+ new SDKError({
61088
+ message: "Failed to create MockTokenManager",
61089
+ category: "INITIALIZATION" /* INITIALIZATION */,
61090
+ severity: "HIGH" /* HIGH */,
61091
+ originalError: error instanceof Error ? error : new Error(String(error))
61092
+ })
61093
+ );
61094
+ }
61095
+ }
61096
+
61097
+ // src/modules/diamond-hands-sdk.ts
61098
+ var import_dh_lit_ops = require("@gvnrdao/dh-lit-ops");
61099
+ var import_dh_lit_actions2 = __toESM(require_pkg_src());
61100
+
61101
+ // src/utils/telegram-messaging.utils.ts
61102
+ var TelegramBot = null;
61103
+ try {
61104
+ if (typeof window === "undefined" && typeof global !== "undefined") {
61105
+ TelegramBot = require("node-telegram-bot-api");
61106
+ }
61107
+ } catch (error) {
61108
+ console.warn("Telegram bot API not available:", error instanceof Error ? error.message : String(error));
61109
+ }
61110
+ function formatMintMessage(mintAmount, loanId, txHash) {
61111
+ return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
61112
+ }
61113
+ function formatPartialPaymentMessage(paymentAmount, loanId, txHash) {
61114
+ return `\u2705 DH SDK: ${paymentAmount} UCD was repaid for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
61115
+ }
61116
+ function formatPartialPaymentFailureMessage(paymentAmount, loanId, txHash) {
61117
+ const baseMessage = `\u274C DH SDK: FAILED to repay ${paymentAmount} UCD for loan id: ${loanId}`;
61118
+ if (txHash) {
61119
+ return `${baseMessage} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
61120
+ }
61121
+ return baseMessage;
61122
+ }
61123
+ function formatLoanCreationMessage(positionId, pkpId, vaultAddress) {
61124
+ const vault = vaultAddress || "unknown";
61125
+ return `\u2705 DH SDK: A new loan was created Id: ${positionId} Pkp: ${pkpId} Regtest BTC vault: ${vault}`;
61126
+ }
58987
61127
  function formatBTCWithdrawalFailureMessage(withdrawalAmount, btcVault, btcDestinationAddress, loanId) {
58988
61128
  const formattedAmount = formatBTCAmount(withdrawalAmount);
58989
61129
  return `\u274C DH SDK: BTC withdrawal FAILED: ${formattedAmount} from ${btcVault} to ${btcDestinationAddress} for loan id: ${loanId}`;
@@ -59109,7 +61249,8 @@ function normalizeTransactionReceipt(receipt) {
59109
61249
  transactionIndex: receiptObj.transactionIndex,
59110
61250
  gasUsed: receiptObj.gasUsed ? normalizeBigNumberish(receiptObj.gasUsed) : void 0,
59111
61251
  blockHash: receiptObj.blockHash,
59112
- transactionHash: receiptObj.transactionHash,
61252
+ transactionHash: receiptObj.transactionHash ?? receiptObj.hash,
61253
+ hash: receiptObj.hash ?? receiptObj.transactionHash,
59113
61254
  blockNumber: receiptObj.blockNumber,
59114
61255
  confirmations: receiptObj.confirmations,
59115
61256
  cumulativeGasUsed: receiptObj.cumulativeGasUsed ? normalizeBigNumberish(receiptObj.cumulativeGasUsed) : void 0,
@@ -61380,44 +63521,13 @@ Error data: ${errorData || "none"}`
61380
63521
  let litActionResult;
61381
63522
  const liquidatorAddress = await this.getSignerOrThrow().getAddress();
61382
63523
  try {
61383
- if (this.config.debug) {
61384
- log.info(
61385
- `\u{1F310} Calling liquidation server endpoint: ${this.config.serviceEndpoint}/api/lit/liquidation/authorize`
61386
- );
61387
- }
61388
- const response = await fetch(
61389
- `${this.config.serviceEndpoint}/api/lit/liquidation/authorize`,
61390
- {
61391
- method: "POST",
61392
- headers: {
61393
- "Content-Type": "application/json"
61394
- },
61395
- body: JSON.stringify({
61396
- positionId: request.positionId,
61397
- liquidatorAddress,
61398
- chain: this.config.chain || "sepolia",
61399
- publicKey: pkpData.publicKey,
61400
- contractAddresses: {
61401
- PositionManager: contractAddresses.positionManager,
61402
- LoanOperationsManagerModule: contractAddresses.loanOperationsManager,
61403
- TermManagerModule: contractAddresses.termManager,
61404
- UCDController: contractAddresses.ucdController,
61405
- LiquidationManagerModule: contractAddresses.liquidationManager
61406
- },
61407
- rpcUrl: request.rpcUrl || this.config.ethRpcUrl,
61408
- priceProviders: this.config.priceProviders,
61409
- pkpTokenId: pkpData.tokenId,
61410
- pkpEthAddress: pkpData.ethAddress,
61411
- devMode: this.config.debug
61412
- })
61413
- }
61414
- );
61415
- litActionResult = await response.json().catch(() => null);
61416
- if (!response.ok && !litActionResult) {
61417
- throw new Error(
61418
- `Server responded with ${response.status}: ${response.statusText}`
61419
- );
61420
- }
63524
+ litActionResult = await this.requestLiquidationAuthorization({
63525
+ positionId: request.positionId,
63526
+ liquidatorAddress,
63527
+ pkpData,
63528
+ contractAddresses,
63529
+ rpcUrl: request.rpcUrl
63530
+ });
61421
63531
  if (this.config.debug) {
61422
63532
  log.info(`\u2705 Server response received:`, {
61423
63533
  approved: litActionResult.approved,
@@ -61893,6 +64003,40 @@ Error data: ${errorData || "none"}`
61893
64003
  }
61894
64004
  await new Promise((resolve) => setTimeout(resolve, 15e3));
61895
64005
  }
64006
+ if (this.config.debug) {
64007
+ log.info(` \u{1F504} Requesting fresh reveal-time liquidation authorization...`);
64008
+ }
64009
+ let revealResult;
64010
+ try {
64011
+ revealResult = await this.requestLiquidationAuthorization({
64012
+ positionId: request.positionId,
64013
+ liquidatorAddress,
64014
+ pkpData,
64015
+ contractAddresses,
64016
+ rpcUrl: request.rpcUrl
64017
+ });
64018
+ } catch (serverError) {
64019
+ return {
64020
+ success: false,
64021
+ error: `Failed to obtain reveal-time liquidation authorization: ${serverError instanceof Error ? serverError.message : String(serverError)}`,
64022
+ positionId: request.positionId,
64023
+ wasLiquidated: false
64024
+ };
64025
+ }
64026
+ if (!revealResult || !revealResult.approved || !revealResult.signature) {
64027
+ return {
64028
+ success: false,
64029
+ error: revealResult?.reason || revealResult?.error || "Position no longer liquidatable at reveal time",
64030
+ positionId: request.positionId,
64031
+ wasLiquidated: false,
64032
+ notLiquidatedReason: revealResult?.reason || "Not liquidatable at reveal time"
64033
+ };
64034
+ }
64035
+ const revealQuantumTimestamp = BigInt(revealResult.timestamp || "0");
64036
+ const revealBtcPrice = BigInt(revealResult.btcPrice || "0");
64037
+ const revealBtcAmountSats = BigInt(
64038
+ (revealResult.btcAmountSats || "0").toString()
64039
+ );
61896
64040
  if (this.config.debug) {
61897
64041
  log.info(` \u{1F513} Executing reveal phase...`);
61898
64042
  }
@@ -61900,21 +64044,19 @@ Error data: ${errorData || "none"}`
61900
64044
  if (this.config.debug) {
61901
64045
  log.info(` \u{1F513} Reveal params`, {
61902
64046
  positionId: positionIdBytes32,
61903
- qtTimestamp: quantumTimestamp.toString(),
61904
- btcPrice: btcPrice.toString(),
61905
- btcAmountSats: (litActionResult.btcAmountSats || "0").toString(),
64047
+ qtTimestamp: revealQuantumTimestamp.toString(),
64048
+ btcPrice: revealBtcPrice.toString(),
64049
+ btcAmountSats: revealBtcAmountSats.toString(),
61906
64050
  deadline: revealDeadline,
61907
- hasSignature: !!litActionResult.signature
64051
+ hasSignature: !!revealResult.signature
61908
64052
  });
61909
64053
  }
61910
64054
  const revealTx = await positionManager["revealAndLiquidate"](
61911
64055
  positionIdBytes32,
61912
- BigInt(quantumTimestamp.toString()),
61913
- BigInt(btcPrice.toString()),
61914
- BigInt(
61915
- (litActionResult.btcAmountSats || "0").toString()
61916
- ),
61917
- litActionResult.signature || "0x",
64056
+ revealQuantumTimestamp,
64057
+ revealBtcPrice,
64058
+ revealBtcAmountSats,
64059
+ revealResult.signature || "0x",
61918
64060
  BigInt(revealDeadline.toString()),
61919
64061
  { gasLimit: 7e5 }
61920
64062
  // Fixed gas limit avoids lagged-RPC estimateGas failures near timing boundary
@@ -64586,6 +66728,45 @@ Error data: ${errorData || "none"}`
64586
66728
  async getLoanEvents(positionId, filter) {
64587
66729
  return this.loanQuery.getLoanEvents(positionId, filter);
64588
66730
  }
66731
+ /**
66732
+ * Get protocol-wide events across all indexed entity types.
66733
+ * Returns a merged, sorted discriminated-union timeline.
66734
+ * Narrow to a position with filter.positionId, or restrict event kinds with filter.kinds.
66735
+ */
66736
+ async getAllEvents(filter) {
66737
+ return this.graphClient.getAllEvents(filter);
66738
+ }
66739
+ // ============================================================================
66740
+ // HIGH-LEVEL API - PSM (Peg Stability Module)
66741
+ // ============================================================================
66742
+ /**
66743
+ * Return PSM-supported stablecoins from the subgraph, including indexed reserves,
66744
+ * fees, exchange rate, and volume stats.
66745
+ *
66746
+ * @param onlySupported - When true (default) filters to currently-supported coins only.
66747
+ */
66748
+ async getPSMStablecoins(onlySupported = true) {
66749
+ return this.graphClient.getSupportedStablecoins(onlySupported);
66750
+ }
66751
+ /**
66752
+ * Return the live on-chain available reserve balance for a single stablecoin in the PSM.
66753
+ * Prefer this over the subgraph `reserves` field when freshness matters (e.g. pre-swap validation).
66754
+ *
66755
+ * @param stablecoinAddress - EVM address of the stablecoin to query.
66756
+ */
66757
+ async getPSMAvailableReserves(stablecoinAddress) {
66758
+ const psmAddress = this.config.contractAddresses?.simplePsmV2;
66759
+ if (!psmAddress) {
66760
+ throw new Error(
66761
+ "SimplePSMV2 address not configured \u2014 provide contractAddresses.simplePsmV2"
66762
+ );
66763
+ }
66764
+ const psm = SimplePSMV2__factory.connect(
66765
+ psmAddress,
66766
+ this.getProviderOrThrow()
66767
+ );
66768
+ return psm.getAvailableReserves(stablecoinAddress);
66769
+ }
64589
66770
  /**
64590
66771
  * Wait for the subgraph to index up to (and including) the given block number.
64591
66772
  * Call after on-chain actions (createLoan, mintUCD, etc.) before querying the subgraph.
@@ -65336,6 +67517,47 @@ Error data: ${errorData || "none"}`
65336
67517
  const randomDelay = Number(randomValue % BigInt(MAX_RANDOM_DELAY));
65337
67518
  return MIN_REVEAL_DELAY + randomDelay;
65338
67519
  }
67520
+ /**
67521
+ * Call the liquidation validator server endpoint to obtain a signed authorization
67522
+ * (signature + quantumTimestamp + btcPrice + btcAmountSats) for the current market state.
67523
+ * Invoked once at commit time and again at reveal time (H-7: reveal requires a fresh
67524
+ * signature so it cannot execute against a stale commit-time BTC vault snapshot).
67525
+ */
67526
+ async requestLiquidationAuthorization(params) {
67527
+ const endpoint = `${this.config.serviceEndpoint}/api/lit/liquidation/authorize`;
67528
+ if (this.config.debug) {
67529
+ log.info(`\u{1F310} Calling liquidation server endpoint: ${endpoint}`);
67530
+ }
67531
+ const response = await fetch(endpoint, {
67532
+ method: "POST",
67533
+ headers: { "Content-Type": "application/json" },
67534
+ body: JSON.stringify({
67535
+ positionId: params.positionId,
67536
+ liquidatorAddress: params.liquidatorAddress,
67537
+ chain: this.config.chain || "sepolia",
67538
+ publicKey: params.pkpData.publicKey,
67539
+ contractAddresses: {
67540
+ PositionManager: params.contractAddresses.positionManager,
67541
+ LoanOperationsManagerModule: params.contractAddresses.loanOperationsManager,
67542
+ TermManagerModule: params.contractAddresses.termManager,
67543
+ UCDController: params.contractAddresses.ucdController,
67544
+ LiquidationManagerModule: params.contractAddresses.liquidationManager
67545
+ },
67546
+ rpcUrl: params.rpcUrl || this.config.ethRpcUrl,
67547
+ priceProviders: this.config.priceProviders,
67548
+ pkpTokenId: params.pkpData.tokenId,
67549
+ pkpEthAddress: params.pkpData.ethAddress,
67550
+ devMode: this.config.debug
67551
+ })
67552
+ });
67553
+ const result = await response.json().catch(() => null);
67554
+ if (!response.ok && !result) {
67555
+ throw new Error(
67556
+ `Server responded with ${response.status}: ${response.statusText}`
67557
+ );
67558
+ }
67559
+ return result;
67560
+ }
65339
67561
  /**
65340
67562
  * Calculate the exact reveal delay by replicating LiquidationManager._calculateRandomizedDelay.
65341
67563
  * Reads vrfSeeds[positionId] from the contract and applies the same two-step keccak256 formula.
@@ -65539,8 +67761,10 @@ var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
65539
67761
  })(PaymentType || {});
65540
67762
  var PositionStatus = /* @__PURE__ */ ((PositionStatus2) => {
65541
67763
  PositionStatus2["PENDING_DEPOSIT"] = "PENDING_DEPOSIT";
67764
+ PositionStatus2["PENDING_MINT"] = "PENDING_MINT";
65542
67765
  PositionStatus2["ACTIVE"] = "ACTIVE";
65543
67766
  PositionStatus2["EXPIRED"] = "EXPIRED";
67767
+ PositionStatus2["LIQUIDATABLE"] = "LIQUIDATABLE";
65544
67768
  PositionStatus2["LIQUIDATED"] = "LIQUIDATED";
65545
67769
  PositionStatus2["REPAID"] = "REPAID";
65546
67770
  PositionStatus2["CLOSED"] = "CLOSED";
@@ -65557,32 +67781,30 @@ function numericToPositionStatus(status) {
65557
67781
  case 0:
65558
67782
  return "PENDING_DEPOSIT" /* PENDING_DEPOSIT */;
65559
67783
  case 1:
65560
- return "ACTIVE" /* ACTIVE */;
67784
+ return "PENDING_MINT" /* PENDING_MINT */;
65561
67785
  case 2:
65562
- return "EXPIRED" /* EXPIRED */;
67786
+ return "ACTIVE" /* ACTIVE */;
65563
67787
  case 3:
65564
- return "LIQUIDATED" /* LIQUIDATED */;
67788
+ return "EXPIRED" /* EXPIRED */;
65565
67789
  case 4:
65566
- return "REPAID" /* REPAID */;
67790
+ return "LIQUIDATABLE" /* LIQUIDATABLE */;
65567
67791
  case 5:
67792
+ return "LIQUIDATED" /* LIQUIDATED */;
67793
+ case 6:
67794
+ return "REPAID" /* REPAID */;
67795
+ case 7:
65568
67796
  return "CLOSED" /* CLOSED */;
65569
67797
  default:
65570
67798
  throw new Error(`Invalid position status: ${status}`);
65571
67799
  }
65572
67800
  }
65573
67801
  var EventHelpers = {
65574
- /**
65575
- * Sort events by timestamp (descending by default)
65576
- */
65577
67802
  sortByTimestamp(events, direction = "desc") {
65578
67803
  return [...events].sort((a, b2) => {
65579
67804
  const diff = BigInt(a.timestamp) - BigInt(b2.timestamp);
65580
67805
  return direction === "asc" ? Number(diff) : -Number(diff);
65581
67806
  });
65582
67807
  },
65583
- /**
65584
- * Filter events by timestamp range
65585
- */
65586
67808
  filterByTimestamp(events, fromTimestamp, toTimestamp) {
65587
67809
  return events.filter((event) => {
65588
67810
  const ts = BigInt(event.timestamp);
@@ -65593,9 +67815,6 @@ var EventHelpers = {
65593
67815
  return true;
65594
67816
  });
65595
67817
  },
65596
- /**
65597
- * Filter events by block range
65598
- */
65599
67818
  filterByBlock(events, fromBlock, toBlock) {
65600
67819
  return events.filter((event) => {
65601
67820
  const block = BigInt(event.blockNumber);
@@ -65606,17 +67825,12 @@ var EventHelpers = {
65606
67825
  return true;
65607
67826
  });
65608
67827
  },
65609
- /**
65610
- * Get total count of all events
65611
- */
65612
67828
  getTotalCount(events) {
65613
- 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;
67829
+ 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;
65614
67830
  },
65615
- /**
65616
- * Merge and sort all events by timestamp
65617
- */
65618
67831
  getAllEventsSorted(events, direction = "desc") {
65619
67832
  const allEvents = [
67833
+ ...events.positionCreated ? [{ ...events.positionCreated, eventType: "positionCreated" }] : [],
65620
67834
  ...events.payments.map((e) => ({ ...e, eventType: "payment" })),
65621
67835
  ...events.statusUpdates.map((e) => ({ ...e, eventType: "status" })),
65622
67836
  ...events.liquidation ? [{ ...events.liquidation, eventType: "liquidation" }] : [],
@@ -65626,13 +67840,7 @@ var EventHelpers = {
65626
67840
  ...events.operationFailures.map((e) => ({ ...e, eventType: "operationFailure" })),
65627
67841
  ...events.mintRequests.map((e) => ({ ...e, eventType: "mintRequest" })),
65628
67842
  ...events.burnRequests.map((e) => ({ ...e, eventType: "burnRequest" })),
65629
- ...events.collateralEvents.map((e) => ({ ...e, eventType: "collateralEvent" })),
65630
- ...events.circuitBreakerEvents.map((e) => ({ ...e, eventType: "circuitBreaker" })),
65631
- ...events.termFeeUpdates.map((e) => ({ ...e, eventType: "termFeeUpdate" })),
65632
- ...events.loanProtocolParamUpdates.map((e) => ({ ...e, eventType: "loanProtocolParamUpdate" })),
65633
- ...events.maxLoanValueUpdates.map((e) => ({ ...e, eventType: "maxLoanValueUpdate" })),
65634
- ...events.btcPriceBoundsUpdates.map((e) => ({ ...e, eventType: "btcPriceBoundsUpdate" })),
65635
- ...events.perUserMintLimitUpdates.map((e) => ({ ...e, eventType: "perUserMintLimitUpdate" }))
67843
+ ...events.collateralEvents.map((e) => ({ ...e, eventType: "collateralEvent" }))
65636
67844
  ];
65637
67845
  return allEvents.sort((a, b2) => {
65638
67846
  const diff = BigInt(a.timestamp) - BigInt(b2.timestamp);