@gvnrdao/dh-sdk 0.0.87 → 0.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -663,6 +663,7 @@ interface BaseSDKConfig {
663
663
  */
664
664
  litActionExecution?: 'ipfs' | 'code';
665
665
  ucdMintValidatorCid?: string;
666
+ btcWithdrawalCid?: string;
666
667
  defaultSelectedTermMonths?: number;
667
668
  telegram?: {
668
669
  chatId: string;
@@ -908,8 +909,8 @@ declare namespace IPositionManager {
908
909
  };
909
910
  }
910
911
  interface PositionManagerInterface extends Interface {
911
- getFunction(nameOrSignature: "ADMIN_ROLE" | "COMMUNITY_FEE_DISTRIBUTOR_ROLE" | "COMMUNITY_MINTER_ROLE" | "DEFAULT_ADMIN_ROLE" | "EMERGENCY_PAUSE_ROLE" | "LIQUIDATOR_ROLE" | "ORACLE_UPDATER_ROLE" | "UPGRADE_INTERFACE_VERSION" | "VERSION" | "_performExtensionValidation" | "admin" | "calculateCollateralRatio" | "circuitBreaker" | "collateral" | "commitLiquidation" | "communityManager" | "core" | "createLoan" | "createLoanWithDynamicCollateral" | "createPosition" | "extendPosition" | "getExpiredLoanLiquidationThreshold" | "getPKPLoanParams" | "getPKPPositionData" | "getPositionDetails" | "getPositionStatus" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isExpiredLoanLiquidatable" | "liquidatePosition" | "liquidation" | "loanOps" | "makePartialPayment" | "paused" | "pkpValidationRegistry" | "proxiableUUID" | "renounceRole" | "repayPosition" | "revealAndLiquidate" | "revokeRole" | "setPKPValidationRegistry" | "supportsInterface" | "termManager" | "updateDebtFromLoanOps" | "updateModules" | "updatePosition" | "updatePositionStatusFromLoanOps" | "upgradeToAndCall" | "validatePKPLogic" | "validateUpgrade" | "views" | "withdrawBTC"): FunctionFragment;
912
- getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "Initialized" | "IntegrityCheckFailed" | "LoanCreatedWithDynamicCollateral" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded"): EventFragment;
912
+ getFunction(nameOrSignature: "ADMIN_ROLE" | "COMMUNITY_FEE_DISTRIBUTOR_ROLE" | "COMMUNITY_MINTER_ROLE" | "DEFAULT_ADMIN_ROLE" | "EMERGENCY_PAUSE_ROLE" | "LIQUIDATOR_ROLE" | "ORACLE_UPDATER_ROLE" | "UPGRADE_INTERFACE_VERSION" | "VERSION" | "_performExtensionValidation" | "admin" | "authorizationRegistry" | "calculateCollateralRatio" | "circuitBreaker" | "collateral" | "commitLiquidation" | "communityManager" | "core" | "createLoan" | "createLoanWithDynamicCollateral" | "createPosition" | "extendPosition" | "getExpiredLoanLiquidationThreshold" | "getPKPLoanParams" | "getPKPPositionData" | "getPositionDetails" | "getPositionStatus" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isExpiredLoanLiquidatable" | "liquidatePosition" | "liquidation" | "loanOps" | "makePartialPayment" | "paused" | "pkpValidationRegistry" | "proxiableUUID" | "renounceRole" | "repayPosition" | "revealAndLiquidate" | "revokeRole" | "setAuthorizationRegistry" | "setPKPValidationRegistry" | "supportsInterface" | "termManager" | "updateDebtFromLoanOps" | "updateModules" | "updatePosition" | "updatePositionStatusFromLoanOps" | "upgradeToAndCall" | "validatePKPLogic" | "validateUpgrade" | "views" | "withdrawBTC"): FunctionFragment;
913
+ getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "Initialized" | "IntegrityCheckFailed" | "LoanCreatedWithDynamicCollateral" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded" | "WithdrawBTCSignatureDebug"): EventFragment;
913
914
  encodeFunctionData(functionFragment: "ADMIN_ROLE", values?: undefined): string;
914
915
  encodeFunctionData(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", values?: undefined): string;
915
916
  encodeFunctionData(functionFragment: "COMMUNITY_MINTER_ROLE", values?: undefined): string;
@@ -921,6 +922,7 @@ interface PositionManagerInterface extends Interface {
921
922
  encodeFunctionData(functionFragment: "VERSION", values?: undefined): string;
922
923
  encodeFunctionData(functionFragment: "_performExtensionValidation", values: [IPositionManagerCore.PositionStruct, BigNumberish]): string;
923
924
  encodeFunctionData(functionFragment: "admin", values?: undefined): string;
925
+ encodeFunctionData(functionFragment: "authorizationRegistry", values?: undefined): string;
924
926
  encodeFunctionData(functionFragment: "calculateCollateralRatio", values: [BytesLike]): string;
925
927
  encodeFunctionData(functionFragment: "circuitBreaker", values?: undefined): string;
926
928
  encodeFunctionData(functionFragment: "collateral", values?: undefined): string;
@@ -963,6 +965,7 @@ interface PositionManagerInterface extends Interface {
963
965
  encodeFunctionData(functionFragment: "repayPosition", values: [BytesLike, BigNumberish]): string;
964
966
  encodeFunctionData(functionFragment: "revealAndLiquidate", values: [BytesLike, BigNumberish, BigNumberish]): string;
965
967
  encodeFunctionData(functionFragment: "revokeRole", values: [BytesLike, AddressLike]): string;
968
+ encodeFunctionData(functionFragment: "setAuthorizationRegistry", values: [AddressLike]): string;
966
969
  encodeFunctionData(functionFragment: "setPKPValidationRegistry", values: [AddressLike]): string;
967
970
  encodeFunctionData(functionFragment: "supportsInterface", values: [BytesLike]): string;
968
971
  encodeFunctionData(functionFragment: "termManager", values?: undefined): string;
@@ -982,7 +985,14 @@ interface PositionManagerInterface extends Interface {
982
985
  encodeFunctionData(functionFragment: "validatePKPLogic", values: [BytesLike]): string;
983
986
  encodeFunctionData(functionFragment: "validateUpgrade", values: [AddressLike]): string;
984
987
  encodeFunctionData(functionFragment: "views", values?: undefined): string;
985
- encodeFunctionData(functionFragment: "withdrawBTC", values: [BytesLike, string, BigNumberish]): string;
988
+ encodeFunctionData(functionFragment: "withdrawBTC", values: [
989
+ BytesLike,
990
+ string,
991
+ BigNumberish,
992
+ BigNumberish,
993
+ BigNumberish,
994
+ BytesLike
995
+ ]): string;
986
996
  decodeFunctionResult(functionFragment: "ADMIN_ROLE", data: BytesLike): Result$2;
987
997
  decodeFunctionResult(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", data: BytesLike): Result$2;
988
998
  decodeFunctionResult(functionFragment: "COMMUNITY_MINTER_ROLE", data: BytesLike): Result$2;
@@ -994,6 +1004,7 @@ interface PositionManagerInterface extends Interface {
994
1004
  decodeFunctionResult(functionFragment: "VERSION", data: BytesLike): Result$2;
995
1005
  decodeFunctionResult(functionFragment: "_performExtensionValidation", data: BytesLike): Result$2;
996
1006
  decodeFunctionResult(functionFragment: "admin", data: BytesLike): Result$2;
1007
+ decodeFunctionResult(functionFragment: "authorizationRegistry", data: BytesLike): Result$2;
997
1008
  decodeFunctionResult(functionFragment: "calculateCollateralRatio", data: BytesLike): Result$2;
998
1009
  decodeFunctionResult(functionFragment: "circuitBreaker", data: BytesLike): Result$2;
999
1010
  decodeFunctionResult(functionFragment: "collateral", data: BytesLike): Result$2;
@@ -1025,6 +1036,7 @@ interface PositionManagerInterface extends Interface {
1025
1036
  decodeFunctionResult(functionFragment: "repayPosition", data: BytesLike): Result$2;
1026
1037
  decodeFunctionResult(functionFragment: "revealAndLiquidate", data: BytesLike): Result$2;
1027
1038
  decodeFunctionResult(functionFragment: "revokeRole", data: BytesLike): Result$2;
1039
+ decodeFunctionResult(functionFragment: "setAuthorizationRegistry", data: BytesLike): Result$2;
1028
1040
  decodeFunctionResult(functionFragment: "setPKPValidationRegistry", data: BytesLike): Result$2;
1029
1041
  decodeFunctionResult(functionFragment: "supportsInterface", data: BytesLike): Result$2;
1030
1042
  decodeFunctionResult(functionFragment: "termManager", data: BytesLike): Result$2;
@@ -1469,6 +1481,39 @@ declare namespace UpgradedEvent$1 {
1469
1481
  type Log = TypedEventLog<Event>;
1470
1482
  type LogDescription = TypedLogDescription<Event>;
1471
1483
  }
1484
+ declare namespace WithdrawBTCSignatureDebugEvent {
1485
+ type InputTuple = [
1486
+ positionId: BytesLike,
1487
+ messageHash: BytesLike,
1488
+ expectedPkp: AddressLike,
1489
+ recoveredPkp: AddressLike,
1490
+ isValid: boolean,
1491
+ btcPrice: BigNumberish,
1492
+ quantumTimestamp: BigNumberish
1493
+ ];
1494
+ type OutputTuple = [
1495
+ positionId: string,
1496
+ messageHash: string,
1497
+ expectedPkp: string,
1498
+ recoveredPkp: string,
1499
+ isValid: boolean,
1500
+ btcPrice: bigint,
1501
+ quantumTimestamp: bigint
1502
+ ];
1503
+ interface OutputObject {
1504
+ positionId: string;
1505
+ messageHash: string;
1506
+ expectedPkp: string;
1507
+ recoveredPkp: string;
1508
+ isValid: boolean;
1509
+ btcPrice: bigint;
1510
+ quantumTimestamp: bigint;
1511
+ }
1512
+ type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
1513
+ type Filter = TypedDeferredTopicFilter<Event>;
1514
+ type Log = TypedEventLog<Event>;
1515
+ type LogDescription = TypedLogDescription<Event>;
1516
+ }
1472
1517
  interface PositionManager extends BaseContract {
1473
1518
  connect(runner?: ContractRunner | null): PositionManager;
1474
1519
  waitForDeployment(): Promise<this>;
@@ -1508,6 +1553,7 @@ interface PositionManager extends BaseContract {
1508
1553
  }
1509
1554
  ], "view">;
1510
1555
  admin: TypedContractMethod<[], [string], "view">;
1556
+ authorizationRegistry: TypedContractMethod<[], [string], "view">;
1511
1557
  calculateCollateralRatio: TypedContractMethod<[
1512
1558
  positionId: BytesLike
1513
1559
  ], [
@@ -1653,6 +1699,11 @@ interface PositionManager extends BaseContract {
1653
1699
  ], [
1654
1700
  void
1655
1701
  ], "nonpayable">;
1702
+ setAuthorizationRegistry: TypedContractMethod<[
1703
+ registry: AddressLike
1704
+ ], [
1705
+ void
1706
+ ], "nonpayable">;
1656
1707
  setPKPValidationRegistry: TypedContractMethod<[
1657
1708
  registry: AddressLike
1658
1709
  ], [
@@ -1710,7 +1761,10 @@ interface PositionManager extends BaseContract {
1710
1761
  withdrawBTC: TypedContractMethod<[
1711
1762
  positionId: BytesLike,
1712
1763
  withdrawalAddress: string,
1713
- networkFee: BigNumberish
1764
+ networkFee: BigNumberish,
1765
+ quantumTimestamp: BigNumberish,
1766
+ btcPrice: BigNumberish,
1767
+ withdrawalValidatorSignature: BytesLike
1714
1768
  ], [
1715
1769
  boolean
1716
1770
  ], "nonpayable">;
@@ -1741,6 +1795,7 @@ interface PositionManager extends BaseContract {
1741
1795
  }
1742
1796
  ], "view">;
1743
1797
  getFunction(nameOrSignature: "admin"): TypedContractMethod<[], [string], "view">;
1798
+ getFunction(nameOrSignature: "authorizationRegistry"): TypedContractMethod<[], [string], "view">;
1744
1799
  getFunction(nameOrSignature: "calculateCollateralRatio"): TypedContractMethod<[positionId: BytesLike], [bigint], "view">;
1745
1800
  getFunction(nameOrSignature: "circuitBreaker"): TypedContractMethod<[], [string], "view">;
1746
1801
  getFunction(nameOrSignature: "collateral"): TypedContractMethod<[], [string], "view">;
@@ -1866,6 +1921,7 @@ interface PositionManager extends BaseContract {
1866
1921
  ], [
1867
1922
  void
1868
1923
  ], "nonpayable">;
1924
+ getFunction(nameOrSignature: "setAuthorizationRegistry"): TypedContractMethod<[registry: AddressLike], [void], "nonpayable">;
1869
1925
  getFunction(nameOrSignature: "setPKPValidationRegistry"): TypedContractMethod<[registry: AddressLike], [void], "nonpayable">;
1870
1926
  getFunction(nameOrSignature: "supportsInterface"): TypedContractMethod<[interfaceId: BytesLike], [boolean], "view">;
1871
1927
  getFunction(nameOrSignature: "termManager"): TypedContractMethod<[], [string], "view">;
@@ -1911,7 +1967,10 @@ interface PositionManager extends BaseContract {
1911
1967
  getFunction(nameOrSignature: "withdrawBTC"): TypedContractMethod<[
1912
1968
  positionId: BytesLike,
1913
1969
  withdrawalAddress: string,
1914
- networkFee: BigNumberish
1970
+ networkFee: BigNumberish,
1971
+ quantumTimestamp: BigNumberish,
1972
+ btcPrice: BigNumberish,
1973
+ withdrawalValidatorSignature: BytesLike
1915
1974
  ], [
1916
1975
  boolean
1917
1976
  ], "nonpayable">;
@@ -1937,6 +1996,7 @@ interface PositionManager extends BaseContract {
1937
1996
  getEvent(key: "UCDMinted"): TypedContractEvent<UCDMintedEvent$1.InputTuple, UCDMintedEvent$1.OutputTuple, UCDMintedEvent$1.OutputObject>;
1938
1997
  getEvent(key: "Unpaused"): TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
1939
1998
  getEvent(key: "Upgraded"): TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1999
+ getEvent(key: "WithdrawBTCSignatureDebug"): TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1940
2000
  filters: {
1941
2001
  "CollateralRatioUpdated(bytes32,uint256,uint256)": TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
1942
2002
  CollateralRatioUpdated: TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
@@ -1982,6 +2042,8 @@ interface PositionManager extends BaseContract {
1982
2042
  Unpaused: TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
1983
2043
  "Upgraded(address)": TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1984
2044
  Upgraded: TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
2045
+ "WithdrawBTCSignatureDebug(bytes32,bytes32,address,address,bool,uint256,uint256)": TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
2046
+ WithdrawBTCSignatureDebug: TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1985
2047
  };
1986
2048
  }
1987
2049
 
@@ -4911,6 +4973,7 @@ declare class DiamondHandsSDK {
4911
4973
  private readonly bitcoinOperations;
4912
4974
  private readonly mockTokenManager?;
4913
4975
  private readonly graphClient;
4976
+ private readonly btcWithdrawalCid;
4914
4977
  private isInitialized;
4915
4978
  private isDisposed;
4916
4979
  /**
@@ -5080,6 +5143,16 @@ declare class DiamondHandsSDK {
5080
5143
  * @returns Partial payment result with transaction details
5081
5144
  */
5082
5145
  partPayment(request: PartialPaymentRequest): Promise<PartialPaymentResult>;
5146
+ /**
5147
+ * Withdraw Bitcoin from a position
5148
+ *
5149
+ * @param positionId - Position identifier
5150
+ * @param withdrawalAddress - Bitcoin address to send BTC to
5151
+ * @param withdrawalAmount - Amount to withdraw in satoshis (REQUIRED)
5152
+ * @param networkFee - Network fee for Bitcoin transaction in satoshis (REQUIRED)
5153
+ * @returns Withdrawal result with transaction details
5154
+ */
5155
+ withdrawBTC(positionId: string, withdrawalAddress: string, withdrawalAmount: number, networkFee: number): Promise<BTCWithdrawalResult>;
5083
5156
  /**
5084
5157
  * Get loan data by position ID
5085
5158
  *
@@ -5109,6 +5182,18 @@ declare class DiamondHandsSDK {
5109
5182
  * @returns Array of active loans
5110
5183
  */
5111
5184
  getActiveLoans(): Promise<Result$1<PaginatedLoansResponse, SDKError>>;
5185
+ /**
5186
+ * Get all loans with pagination
5187
+ *
5188
+ * @param pagination - Pagination parameters (page, maxRows)
5189
+ * @param enrichBalance - Whether to enrich loans with Bitcoin balance (not used currently)
5190
+ * @param source - Data source: "subgraph" (default) or "contract"
5191
+ * @returns Array of loans for the specified page
5192
+ */
5193
+ getLoansAll(pagination?: {
5194
+ page?: number;
5195
+ maxRows?: number;
5196
+ }, enrichBalance?: boolean, source?: "subgraph" | "contract"): Promise<LoanData[]>;
5112
5197
  /**
5113
5198
  * Get all events for a loan position from the subgraph
5114
5199
  */
@@ -5309,6 +5394,8 @@ interface WithdrawBTCAuthParams extends BaseAuthParams {
5309
5394
  destinationAddress: string;
5310
5395
  /** Amount to withdraw in satoshis */
5311
5396
  amount: Satoshis;
5397
+ /** Network fee for Bitcoin transaction in satoshis */
5398
+ networkFee: Satoshis;
5312
5399
  /** PKP public key */
5313
5400
  publicKey: string;
5314
5401
  }
@@ -6388,6 +6475,10 @@ declare class LoanQuery {
6388
6475
  * @returns Paginated loans response
6389
6476
  */
6390
6477
  getLoans(filters?: LoanQueryFilters, pagination?: PaginationParams): Promise<Result$1<PaginatedLoansResponse, SDKError>>;
6478
+ /**
6479
+ * Map numeric status to string for subgraph queries
6480
+ */
6481
+ private mapStatusToString;
6391
6482
  /**
6392
6483
  * Get loans for a borrower
6393
6484
  *
@@ -6410,10 +6501,6 @@ declare class LoanQuery {
6410
6501
  * This method is kept for potential future use but no longer sets btcAmount
6411
6502
  */
6412
6503
  private enrichLoanWithBalance;
6413
- /**
6414
- * Get total loans count for pagination
6415
- */
6416
- private getTotalLoansCount;
6417
6504
  /**
6418
6505
  * Get all events for a loan position
6419
6506
  *
package/dist/index.d.ts CHANGED
@@ -663,6 +663,7 @@ interface BaseSDKConfig {
663
663
  */
664
664
  litActionExecution?: 'ipfs' | 'code';
665
665
  ucdMintValidatorCid?: string;
666
+ btcWithdrawalCid?: string;
666
667
  defaultSelectedTermMonths?: number;
667
668
  telegram?: {
668
669
  chatId: string;
@@ -908,8 +909,8 @@ declare namespace IPositionManager {
908
909
  };
909
910
  }
910
911
  interface PositionManagerInterface extends Interface {
911
- getFunction(nameOrSignature: "ADMIN_ROLE" | "COMMUNITY_FEE_DISTRIBUTOR_ROLE" | "COMMUNITY_MINTER_ROLE" | "DEFAULT_ADMIN_ROLE" | "EMERGENCY_PAUSE_ROLE" | "LIQUIDATOR_ROLE" | "ORACLE_UPDATER_ROLE" | "UPGRADE_INTERFACE_VERSION" | "VERSION" | "_performExtensionValidation" | "admin" | "calculateCollateralRatio" | "circuitBreaker" | "collateral" | "commitLiquidation" | "communityManager" | "core" | "createLoan" | "createLoanWithDynamicCollateral" | "createPosition" | "extendPosition" | "getExpiredLoanLiquidationThreshold" | "getPKPLoanParams" | "getPKPPositionData" | "getPositionDetails" | "getPositionStatus" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isExpiredLoanLiquidatable" | "liquidatePosition" | "liquidation" | "loanOps" | "makePartialPayment" | "paused" | "pkpValidationRegistry" | "proxiableUUID" | "renounceRole" | "repayPosition" | "revealAndLiquidate" | "revokeRole" | "setPKPValidationRegistry" | "supportsInterface" | "termManager" | "updateDebtFromLoanOps" | "updateModules" | "updatePosition" | "updatePositionStatusFromLoanOps" | "upgradeToAndCall" | "validatePKPLogic" | "validateUpgrade" | "views" | "withdrawBTC"): FunctionFragment;
912
- getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "Initialized" | "IntegrityCheckFailed" | "LoanCreatedWithDynamicCollateral" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded"): EventFragment;
912
+ getFunction(nameOrSignature: "ADMIN_ROLE" | "COMMUNITY_FEE_DISTRIBUTOR_ROLE" | "COMMUNITY_MINTER_ROLE" | "DEFAULT_ADMIN_ROLE" | "EMERGENCY_PAUSE_ROLE" | "LIQUIDATOR_ROLE" | "ORACLE_UPDATER_ROLE" | "UPGRADE_INTERFACE_VERSION" | "VERSION" | "_performExtensionValidation" | "admin" | "authorizationRegistry" | "calculateCollateralRatio" | "circuitBreaker" | "collateral" | "commitLiquidation" | "communityManager" | "core" | "createLoan" | "createLoanWithDynamicCollateral" | "createPosition" | "extendPosition" | "getExpiredLoanLiquidationThreshold" | "getPKPLoanParams" | "getPKPPositionData" | "getPositionDetails" | "getPositionStatus" | "getRoleAdmin" | "grantRole" | "hasRole" | "initialize" | "isExpiredLoanLiquidatable" | "liquidatePosition" | "liquidation" | "loanOps" | "makePartialPayment" | "paused" | "pkpValidationRegistry" | "proxiableUUID" | "renounceRole" | "repayPosition" | "revealAndLiquidate" | "revokeRole" | "setAuthorizationRegistry" | "setPKPValidationRegistry" | "supportsInterface" | "termManager" | "updateDebtFromLoanOps" | "updateModules" | "updatePosition" | "updatePositionStatusFromLoanOps" | "upgradeToAndCall" | "validatePKPLogic" | "validateUpgrade" | "views" | "withdrawBTC"): FunctionFragment;
913
+ getEvent(nameOrSignatureOrTopic: "CollateralRatioUpdated" | "Initialized" | "IntegrityCheckFailed" | "LoanCreatedWithDynamicCollateral" | "ModulesUpdatedBatch" | "PKPLogicValidated" | "PKPValidationRegistryUpdated" | "PartialPaymentMade" | "Paused" | "PositionClosed" | "PositionCreated" | "PositionLiquidated" | "PositionRenewed" | "PositionRepaid" | "PositionStatusUpdated" | "PositionUpdated" | "RoleAdminChanged" | "RoleGranted" | "RoleRevoked" | "UCDMinted" | "Unpaused" | "Upgraded" | "WithdrawBTCSignatureDebug"): EventFragment;
913
914
  encodeFunctionData(functionFragment: "ADMIN_ROLE", values?: undefined): string;
914
915
  encodeFunctionData(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", values?: undefined): string;
915
916
  encodeFunctionData(functionFragment: "COMMUNITY_MINTER_ROLE", values?: undefined): string;
@@ -921,6 +922,7 @@ interface PositionManagerInterface extends Interface {
921
922
  encodeFunctionData(functionFragment: "VERSION", values?: undefined): string;
922
923
  encodeFunctionData(functionFragment: "_performExtensionValidation", values: [IPositionManagerCore.PositionStruct, BigNumberish]): string;
923
924
  encodeFunctionData(functionFragment: "admin", values?: undefined): string;
925
+ encodeFunctionData(functionFragment: "authorizationRegistry", values?: undefined): string;
924
926
  encodeFunctionData(functionFragment: "calculateCollateralRatio", values: [BytesLike]): string;
925
927
  encodeFunctionData(functionFragment: "circuitBreaker", values?: undefined): string;
926
928
  encodeFunctionData(functionFragment: "collateral", values?: undefined): string;
@@ -963,6 +965,7 @@ interface PositionManagerInterface extends Interface {
963
965
  encodeFunctionData(functionFragment: "repayPosition", values: [BytesLike, BigNumberish]): string;
964
966
  encodeFunctionData(functionFragment: "revealAndLiquidate", values: [BytesLike, BigNumberish, BigNumberish]): string;
965
967
  encodeFunctionData(functionFragment: "revokeRole", values: [BytesLike, AddressLike]): string;
968
+ encodeFunctionData(functionFragment: "setAuthorizationRegistry", values: [AddressLike]): string;
966
969
  encodeFunctionData(functionFragment: "setPKPValidationRegistry", values: [AddressLike]): string;
967
970
  encodeFunctionData(functionFragment: "supportsInterface", values: [BytesLike]): string;
968
971
  encodeFunctionData(functionFragment: "termManager", values?: undefined): string;
@@ -982,7 +985,14 @@ interface PositionManagerInterface extends Interface {
982
985
  encodeFunctionData(functionFragment: "validatePKPLogic", values: [BytesLike]): string;
983
986
  encodeFunctionData(functionFragment: "validateUpgrade", values: [AddressLike]): string;
984
987
  encodeFunctionData(functionFragment: "views", values?: undefined): string;
985
- encodeFunctionData(functionFragment: "withdrawBTC", values: [BytesLike, string, BigNumberish]): string;
988
+ encodeFunctionData(functionFragment: "withdrawBTC", values: [
989
+ BytesLike,
990
+ string,
991
+ BigNumberish,
992
+ BigNumberish,
993
+ BigNumberish,
994
+ BytesLike
995
+ ]): string;
986
996
  decodeFunctionResult(functionFragment: "ADMIN_ROLE", data: BytesLike): Result$2;
987
997
  decodeFunctionResult(functionFragment: "COMMUNITY_FEE_DISTRIBUTOR_ROLE", data: BytesLike): Result$2;
988
998
  decodeFunctionResult(functionFragment: "COMMUNITY_MINTER_ROLE", data: BytesLike): Result$2;
@@ -994,6 +1004,7 @@ interface PositionManagerInterface extends Interface {
994
1004
  decodeFunctionResult(functionFragment: "VERSION", data: BytesLike): Result$2;
995
1005
  decodeFunctionResult(functionFragment: "_performExtensionValidation", data: BytesLike): Result$2;
996
1006
  decodeFunctionResult(functionFragment: "admin", data: BytesLike): Result$2;
1007
+ decodeFunctionResult(functionFragment: "authorizationRegistry", data: BytesLike): Result$2;
997
1008
  decodeFunctionResult(functionFragment: "calculateCollateralRatio", data: BytesLike): Result$2;
998
1009
  decodeFunctionResult(functionFragment: "circuitBreaker", data: BytesLike): Result$2;
999
1010
  decodeFunctionResult(functionFragment: "collateral", data: BytesLike): Result$2;
@@ -1025,6 +1036,7 @@ interface PositionManagerInterface extends Interface {
1025
1036
  decodeFunctionResult(functionFragment: "repayPosition", data: BytesLike): Result$2;
1026
1037
  decodeFunctionResult(functionFragment: "revealAndLiquidate", data: BytesLike): Result$2;
1027
1038
  decodeFunctionResult(functionFragment: "revokeRole", data: BytesLike): Result$2;
1039
+ decodeFunctionResult(functionFragment: "setAuthorizationRegistry", data: BytesLike): Result$2;
1028
1040
  decodeFunctionResult(functionFragment: "setPKPValidationRegistry", data: BytesLike): Result$2;
1029
1041
  decodeFunctionResult(functionFragment: "supportsInterface", data: BytesLike): Result$2;
1030
1042
  decodeFunctionResult(functionFragment: "termManager", data: BytesLike): Result$2;
@@ -1469,6 +1481,39 @@ declare namespace UpgradedEvent$1 {
1469
1481
  type Log = TypedEventLog<Event>;
1470
1482
  type LogDescription = TypedLogDescription<Event>;
1471
1483
  }
1484
+ declare namespace WithdrawBTCSignatureDebugEvent {
1485
+ type InputTuple = [
1486
+ positionId: BytesLike,
1487
+ messageHash: BytesLike,
1488
+ expectedPkp: AddressLike,
1489
+ recoveredPkp: AddressLike,
1490
+ isValid: boolean,
1491
+ btcPrice: BigNumberish,
1492
+ quantumTimestamp: BigNumberish
1493
+ ];
1494
+ type OutputTuple = [
1495
+ positionId: string,
1496
+ messageHash: string,
1497
+ expectedPkp: string,
1498
+ recoveredPkp: string,
1499
+ isValid: boolean,
1500
+ btcPrice: bigint,
1501
+ quantumTimestamp: bigint
1502
+ ];
1503
+ interface OutputObject {
1504
+ positionId: string;
1505
+ messageHash: string;
1506
+ expectedPkp: string;
1507
+ recoveredPkp: string;
1508
+ isValid: boolean;
1509
+ btcPrice: bigint;
1510
+ quantumTimestamp: bigint;
1511
+ }
1512
+ type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
1513
+ type Filter = TypedDeferredTopicFilter<Event>;
1514
+ type Log = TypedEventLog<Event>;
1515
+ type LogDescription = TypedLogDescription<Event>;
1516
+ }
1472
1517
  interface PositionManager extends BaseContract {
1473
1518
  connect(runner?: ContractRunner | null): PositionManager;
1474
1519
  waitForDeployment(): Promise<this>;
@@ -1508,6 +1553,7 @@ interface PositionManager extends BaseContract {
1508
1553
  }
1509
1554
  ], "view">;
1510
1555
  admin: TypedContractMethod<[], [string], "view">;
1556
+ authorizationRegistry: TypedContractMethod<[], [string], "view">;
1511
1557
  calculateCollateralRatio: TypedContractMethod<[
1512
1558
  positionId: BytesLike
1513
1559
  ], [
@@ -1653,6 +1699,11 @@ interface PositionManager extends BaseContract {
1653
1699
  ], [
1654
1700
  void
1655
1701
  ], "nonpayable">;
1702
+ setAuthorizationRegistry: TypedContractMethod<[
1703
+ registry: AddressLike
1704
+ ], [
1705
+ void
1706
+ ], "nonpayable">;
1656
1707
  setPKPValidationRegistry: TypedContractMethod<[
1657
1708
  registry: AddressLike
1658
1709
  ], [
@@ -1710,7 +1761,10 @@ interface PositionManager extends BaseContract {
1710
1761
  withdrawBTC: TypedContractMethod<[
1711
1762
  positionId: BytesLike,
1712
1763
  withdrawalAddress: string,
1713
- networkFee: BigNumberish
1764
+ networkFee: BigNumberish,
1765
+ quantumTimestamp: BigNumberish,
1766
+ btcPrice: BigNumberish,
1767
+ withdrawalValidatorSignature: BytesLike
1714
1768
  ], [
1715
1769
  boolean
1716
1770
  ], "nonpayable">;
@@ -1741,6 +1795,7 @@ interface PositionManager extends BaseContract {
1741
1795
  }
1742
1796
  ], "view">;
1743
1797
  getFunction(nameOrSignature: "admin"): TypedContractMethod<[], [string], "view">;
1798
+ getFunction(nameOrSignature: "authorizationRegistry"): TypedContractMethod<[], [string], "view">;
1744
1799
  getFunction(nameOrSignature: "calculateCollateralRatio"): TypedContractMethod<[positionId: BytesLike], [bigint], "view">;
1745
1800
  getFunction(nameOrSignature: "circuitBreaker"): TypedContractMethod<[], [string], "view">;
1746
1801
  getFunction(nameOrSignature: "collateral"): TypedContractMethod<[], [string], "view">;
@@ -1866,6 +1921,7 @@ interface PositionManager extends BaseContract {
1866
1921
  ], [
1867
1922
  void
1868
1923
  ], "nonpayable">;
1924
+ getFunction(nameOrSignature: "setAuthorizationRegistry"): TypedContractMethod<[registry: AddressLike], [void], "nonpayable">;
1869
1925
  getFunction(nameOrSignature: "setPKPValidationRegistry"): TypedContractMethod<[registry: AddressLike], [void], "nonpayable">;
1870
1926
  getFunction(nameOrSignature: "supportsInterface"): TypedContractMethod<[interfaceId: BytesLike], [boolean], "view">;
1871
1927
  getFunction(nameOrSignature: "termManager"): TypedContractMethod<[], [string], "view">;
@@ -1911,7 +1967,10 @@ interface PositionManager extends BaseContract {
1911
1967
  getFunction(nameOrSignature: "withdrawBTC"): TypedContractMethod<[
1912
1968
  positionId: BytesLike,
1913
1969
  withdrawalAddress: string,
1914
- networkFee: BigNumberish
1970
+ networkFee: BigNumberish,
1971
+ quantumTimestamp: BigNumberish,
1972
+ btcPrice: BigNumberish,
1973
+ withdrawalValidatorSignature: BytesLike
1915
1974
  ], [
1916
1975
  boolean
1917
1976
  ], "nonpayable">;
@@ -1937,6 +1996,7 @@ interface PositionManager extends BaseContract {
1937
1996
  getEvent(key: "UCDMinted"): TypedContractEvent<UCDMintedEvent$1.InputTuple, UCDMintedEvent$1.OutputTuple, UCDMintedEvent$1.OutputObject>;
1938
1997
  getEvent(key: "Unpaused"): TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
1939
1998
  getEvent(key: "Upgraded"): TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1999
+ getEvent(key: "WithdrawBTCSignatureDebug"): TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1940
2000
  filters: {
1941
2001
  "CollateralRatioUpdated(bytes32,uint256,uint256)": TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
1942
2002
  CollateralRatioUpdated: TypedContractEvent<CollateralRatioUpdatedEvent.InputTuple, CollateralRatioUpdatedEvent.OutputTuple, CollateralRatioUpdatedEvent.OutputObject>;
@@ -1982,6 +2042,8 @@ interface PositionManager extends BaseContract {
1982
2042
  Unpaused: TypedContractEvent<UnpausedEvent$1.InputTuple, UnpausedEvent$1.OutputTuple, UnpausedEvent$1.OutputObject>;
1983
2043
  "Upgraded(address)": TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
1984
2044
  Upgraded: TypedContractEvent<UpgradedEvent$1.InputTuple, UpgradedEvent$1.OutputTuple, UpgradedEvent$1.OutputObject>;
2045
+ "WithdrawBTCSignatureDebug(bytes32,bytes32,address,address,bool,uint256,uint256)": TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
2046
+ WithdrawBTCSignatureDebug: TypedContractEvent<WithdrawBTCSignatureDebugEvent.InputTuple, WithdrawBTCSignatureDebugEvent.OutputTuple, WithdrawBTCSignatureDebugEvent.OutputObject>;
1985
2047
  };
1986
2048
  }
1987
2049
 
@@ -4911,6 +4973,7 @@ declare class DiamondHandsSDK {
4911
4973
  private readonly bitcoinOperations;
4912
4974
  private readonly mockTokenManager?;
4913
4975
  private readonly graphClient;
4976
+ private readonly btcWithdrawalCid;
4914
4977
  private isInitialized;
4915
4978
  private isDisposed;
4916
4979
  /**
@@ -5080,6 +5143,16 @@ declare class DiamondHandsSDK {
5080
5143
  * @returns Partial payment result with transaction details
5081
5144
  */
5082
5145
  partPayment(request: PartialPaymentRequest): Promise<PartialPaymentResult>;
5146
+ /**
5147
+ * Withdraw Bitcoin from a position
5148
+ *
5149
+ * @param positionId - Position identifier
5150
+ * @param withdrawalAddress - Bitcoin address to send BTC to
5151
+ * @param withdrawalAmount - Amount to withdraw in satoshis (REQUIRED)
5152
+ * @param networkFee - Network fee for Bitcoin transaction in satoshis (REQUIRED)
5153
+ * @returns Withdrawal result with transaction details
5154
+ */
5155
+ withdrawBTC(positionId: string, withdrawalAddress: string, withdrawalAmount: number, networkFee: number): Promise<BTCWithdrawalResult>;
5083
5156
  /**
5084
5157
  * Get loan data by position ID
5085
5158
  *
@@ -5109,6 +5182,18 @@ declare class DiamondHandsSDK {
5109
5182
  * @returns Array of active loans
5110
5183
  */
5111
5184
  getActiveLoans(): Promise<Result$1<PaginatedLoansResponse, SDKError>>;
5185
+ /**
5186
+ * Get all loans with pagination
5187
+ *
5188
+ * @param pagination - Pagination parameters (page, maxRows)
5189
+ * @param enrichBalance - Whether to enrich loans with Bitcoin balance (not used currently)
5190
+ * @param source - Data source: "subgraph" (default) or "contract"
5191
+ * @returns Array of loans for the specified page
5192
+ */
5193
+ getLoansAll(pagination?: {
5194
+ page?: number;
5195
+ maxRows?: number;
5196
+ }, enrichBalance?: boolean, source?: "subgraph" | "contract"): Promise<LoanData[]>;
5112
5197
  /**
5113
5198
  * Get all events for a loan position from the subgraph
5114
5199
  */
@@ -5309,6 +5394,8 @@ interface WithdrawBTCAuthParams extends BaseAuthParams {
5309
5394
  destinationAddress: string;
5310
5395
  /** Amount to withdraw in satoshis */
5311
5396
  amount: Satoshis;
5397
+ /** Network fee for Bitcoin transaction in satoshis */
5398
+ networkFee: Satoshis;
5312
5399
  /** PKP public key */
5313
5400
  publicKey: string;
5314
5401
  }
@@ -6388,6 +6475,10 @@ declare class LoanQuery {
6388
6475
  * @returns Paginated loans response
6389
6476
  */
6390
6477
  getLoans(filters?: LoanQueryFilters, pagination?: PaginationParams): Promise<Result$1<PaginatedLoansResponse, SDKError>>;
6478
+ /**
6479
+ * Map numeric status to string for subgraph queries
6480
+ */
6481
+ private mapStatusToString;
6391
6482
  /**
6392
6483
  * Get loans for a borrower
6393
6484
  *
@@ -6410,10 +6501,6 @@ declare class LoanQuery {
6410
6501
  * This method is kept for potential future use but no longer sets btcAmount
6411
6502
  */
6412
6503
  private enrichLoanWithBalance;
6413
- /**
6414
- * Get total loans count for pagination
6415
- */
6416
- private getTotalLoansCount;
6417
6504
  /**
6418
6505
  * Get all events for a loan position
6419
6506
  *