@gvnrdao/dh-sdk 0.0.131 → 0.0.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -12708,73 +12708,70 @@ var init_deployment_addresses = __esm({
12708
12708
  SEPOLIA_DEPLOYMENT = {
12709
12709
  "network": "sepolia",
12710
12710
  "chainId": 11155111,
12711
- "timestamp": "2025-12-08T20:44:11.397Z",
12711
+ "timestamp": "2026-01-12T18:16:06.851Z",
12712
12712
  "deployer": "",
12713
12713
  "contracts": {
12714
- "UpgradeValidator": "0x865843ec94a6444Ad6f6b8Ca389c03D4a2D96e67",
12714
+ "UpgradeValidator": "0x2eE5F81f828C6AC9a8F979327680893C9fd11a2f",
12715
12715
  "UCDToken": "0x86060fa5b3e01e003b8afd9c1295f1f444a7dc60",
12716
12716
  "UCDController": "0x8956368203475DeECA21bc79F5FDeA249937E20C",
12717
- "PriceFeedConsumer": "0xbAB704d9d2F701aE3ec0B39ded1F1a27ba3544EE",
12718
- "BTCProofValidator": "0x760DD5b1524d1C907e03A99A02C6b9634c569aE8",
12719
- "UCDMintingRewards": "0x92ea837DCF6e757cA19D524f02b49A4650FAaB46",
12720
- "PositionManagerCoreModule": "0xAA2893395159550730C02075D5a7b5F905464c7b",
12721
- "TermManagerModule": "0x89a2ffBE000e0dcfd4D5893592fC8d7D07E43618",
12722
- "LoanOperationsManagerModule": "0x0644ae669DaA9aB7561d59d902a5F0811230a83c",
12723
- "CollateralManagerModule": "0xc11E2c128F2Be64AD1D020eA188973CFBeADAcb9",
12724
- "LiquidationManagerModule": "0xa8608AB8b6F16947F5379f1971e0851A436a856A",
12725
- "CircuitBreakerModule": "0xB522e59e750C4B84b3E7Ed5E9176A4B9c89704Ec",
12726
- "CommunityManagerModule": "0x6C022640Afe32B853FC908066da7a160B71FE864",
12727
- "AdminModule": "0xB570bf6a5ae0589c0E67eBdc09e17e2eFba90f0b",
12728
- "PositionManagerViews": "0xdc7e1Db596B3A787386d144aCE485F02BBb43bA7",
12729
- "PositionManager": "0x2d654736b8fcc385BD27Bf5b936A7c92Ea951Cc8",
12730
- "OperationAuthorizationRegistry": "0xE55b4d77b235155cF534A28e897Ddc028395B8F9",
12731
- "PKPValidation": "0x0d448F827b1803865F6D4135Fb5FBcD285D34Aac"
12717
+ "PriceFeedConsumer": "0x6eFB125c2bbC6fAc66a765cd017940b0dE5A9A54",
12718
+ "UCDMintingRewards": "0x2b51EBee507f83B59fbceeaa12AC6F725d19A33f",
12719
+ "PositionManagerCoreModule": "0x3db72154cd37b64194f35a239866b0A3aADd60B5",
12720
+ "TermManagerModule": "0x4Ec79Ca3ef3bAd4a474310e1228a06bCD5a8c5A6",
12721
+ "LoanOperationsManagerModule": "0x2618C73d6F7Bc8eD6CB4Bcf7a769f1ce58f5158c",
12722
+ "CollateralManagerModule": "0x0EDd9206D653de80Ac2df4784750b93490532104",
12723
+ "LiquidationManagerModule": "0x4C4a4E308D3108c5b4fA424A30BaB1E072712B8F",
12724
+ "CircuitBreakerModule": "0x6E6b14412ac206590aB810Df3b5bC7915904eC90",
12725
+ "CommunityManagerModule": "0x93994136a18aFe2e9ee4C8F797408bD1a6F884b7",
12726
+ "AdminModule": "0xa7b8a2b253D28689215B726889062850D44377e5",
12727
+ "PositionManagerViews": "0xd954267B1f78B0aD26184A6aDdAc0C4421fA52F3",
12728
+ "PositionManager": "0xf4E026844c8830a618933324aa098ce278Aa88e1",
12729
+ "OperationAuthorizationRegistry": "0xfAd27cAeD4a31826CC9d8cD11F5E0995274157e0",
12730
+ "PKPValidation": "0xf218a50eF679Dccd64d557ec5F935c928A334109"
12732
12731
  }
12733
12732
  };
12734
12733
  SEPOLIA_CONTRACTS = {
12735
- "UpgradeValidator": "0x865843ec94a6444Ad6f6b8Ca389c03D4a2D96e67",
12734
+ "UpgradeValidator": "0x2eE5F81f828C6AC9a8F979327680893C9fd11a2f",
12736
12735
  "UCDToken": "0x86060fa5b3e01e003b8afd9c1295f1f444a7dc60",
12737
12736
  "UCDController": "0x8956368203475DeECA21bc79F5FDeA249937E20C",
12738
- "PriceFeedConsumer": "0xbAB704d9d2F701aE3ec0B39ded1F1a27ba3544EE",
12739
- "BTCProofValidator": "0x760DD5b1524d1C907e03A99A02C6b9634c569aE8",
12740
- "UCDMintingRewards": "0x92ea837DCF6e757cA19D524f02b49A4650FAaB46",
12741
- "PositionManagerCoreModule": "0xAA2893395159550730C02075D5a7b5F905464c7b",
12742
- "TermManagerModule": "0x89a2ffBE000e0dcfd4D5893592fC8d7D07E43618",
12743
- "LoanOperationsManagerModule": "0x0644ae669DaA9aB7561d59d902a5F0811230a83c",
12744
- "CollateralManagerModule": "0xc11E2c128F2Be64AD1D020eA188973CFBeADAcb9",
12745
- "LiquidationManagerModule": "0xa8608AB8b6F16947F5379f1971e0851A436a856A",
12746
- "CircuitBreakerModule": "0xB522e59e750C4B84b3E7Ed5E9176A4B9c89704Ec",
12747
- "CommunityManagerModule": "0x6C022640Afe32B853FC908066da7a160B71FE864",
12748
- "AdminModule": "0xB570bf6a5ae0589c0E67eBdc09e17e2eFba90f0b",
12749
- "PositionManagerViews": "0xdc7e1Db596B3A787386d144aCE485F02BBb43bA7",
12750
- "PositionManager": "0x2d654736b8fcc385BD27Bf5b936A7c92Ea951Cc8",
12751
- "OperationAuthorizationRegistry": "0xE55b4d77b235155cF534A28e897Ddc028395B8F9",
12752
- "PKPValidation": "0x0d448F827b1803865F6D4135Fb5FBcD285D34Aac"
12737
+ "PriceFeedConsumer": "0x6eFB125c2bbC6fAc66a765cd017940b0dE5A9A54",
12738
+ "UCDMintingRewards": "0x2b51EBee507f83B59fbceeaa12AC6F725d19A33f",
12739
+ "PositionManagerCoreModule": "0x3db72154cd37b64194f35a239866b0A3aADd60B5",
12740
+ "TermManagerModule": "0x4Ec79Ca3ef3bAd4a474310e1228a06bCD5a8c5A6",
12741
+ "LoanOperationsManagerModule": "0x2618C73d6F7Bc8eD6CB4Bcf7a769f1ce58f5158c",
12742
+ "CollateralManagerModule": "0x0EDd9206D653de80Ac2df4784750b93490532104",
12743
+ "LiquidationManagerModule": "0x4C4a4E308D3108c5b4fA424A30BaB1E072712B8F",
12744
+ "CircuitBreakerModule": "0x6E6b14412ac206590aB810Df3b5bC7915904eC90",
12745
+ "CommunityManagerModule": "0x93994136a18aFe2e9ee4C8F797408bD1a6F884b7",
12746
+ "AdminModule": "0xa7b8a2b253D28689215B726889062850D44377e5",
12747
+ "PositionManagerViews": "0xd954267B1f78B0aD26184A6aDdAc0C4421fA52F3",
12748
+ "PositionManager": "0xf4E026844c8830a618933324aa098ce278Aa88e1",
12749
+ "OperationAuthorizationRegistry": "0xfAd27cAeD4a31826CC9d8cD11F5E0995274157e0",
12750
+ "PKPValidation": "0xf218a50eF679Dccd64d557ec5F935c928A334109"
12753
12751
  };
12754
12752
  LOCALHOST_DEPLOYMENT = {
12755
12753
  "network": "localhost",
12756
12754
  "chainId": 31337,
12757
- "timestamp": "2025-12-11T16:44:37.280Z",
12755
+ "timestamp": "2026-01-12T17:28:59.972Z",
12758
12756
  "deployer": "",
12759
12757
  "contracts": {
12760
12758
  "UpgradeValidator": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
12761
12759
  "UCDToken": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
12762
12760
  "UCDController": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
12763
12761
  "PriceFeedConsumer": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
12764
- "BTCProofValidator": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
12765
- "UCDMintingRewards": "0x9A676e781A523b5d0C0e43731313A708CB607508",
12766
- "PositionManagerCoreModule": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
12767
- "TermManagerModule": "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
12768
- "LoanOperationsManagerModule": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
12769
- "CollateralManagerModule": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
12770
- "LiquidationManagerModule": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
12771
- "CircuitBreakerModule": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
12772
- "CommunityManagerModule": "0xc5a5C42992dECbae36851359345FE25997F5C42d",
12773
- "AdminModule": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
12774
- "PositionManagerViews": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
12775
- "PositionManager": "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
12776
- "OperationAuthorizationRegistry": "0x5eb3Bc0a489C5A8288765d2336659EbCA68FCd00",
12777
- "PKPValidation": "0x4c5859f0F772848b2D91F1D83E2Fe57935348029"
12762
+ "UCDMintingRewards": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
12763
+ "PositionManagerCoreModule": "0x9A676e781A523b5d0C0e43731313A708CB607508",
12764
+ "TermManagerModule": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
12765
+ "LoanOperationsManagerModule": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
12766
+ "CollateralManagerModule": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
12767
+ "LiquidationManagerModule": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
12768
+ "CircuitBreakerModule": "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
12769
+ "CommunityManagerModule": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
12770
+ "AdminModule": "0xc5a5C42992dECbae36851359345FE25997F5C42d",
12771
+ "PositionManagerViews": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933",
12772
+ "PositionManager": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
12773
+ "OperationAuthorizationRegistry": "0x8f86403A4DE0BB5791fa46B8e795C547942fE4Cf",
12774
+ "PKPValidation": "0x36C02dA8a0983159322a80FFE9F24b1acfF8B570"
12778
12775
  }
12779
12776
  };
12780
12777
  LOCALHOST_CONTRACTS = {
@@ -12782,20 +12779,19 @@ var init_deployment_addresses = __esm({
12782
12779
  "UCDToken": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
12783
12780
  "UCDController": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
12784
12781
  "PriceFeedConsumer": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
12785
- "BTCProofValidator": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
12786
- "UCDMintingRewards": "0x9A676e781A523b5d0C0e43731313A708CB607508",
12787
- "PositionManagerCoreModule": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
12788
- "TermManagerModule": "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
12789
- "LoanOperationsManagerModule": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
12790
- "CollateralManagerModule": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
12791
- "LiquidationManagerModule": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
12792
- "CircuitBreakerModule": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
12793
- "CommunityManagerModule": "0xc5a5C42992dECbae36851359345FE25997F5C42d",
12794
- "AdminModule": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
12795
- "PositionManagerViews": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
12796
- "PositionManager": "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
12797
- "OperationAuthorizationRegistry": "0x5eb3Bc0a489C5A8288765d2336659EbCA68FCd00",
12798
- "PKPValidation": "0x4c5859f0F772848b2D91F1D83E2Fe57935348029"
12782
+ "UCDMintingRewards": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
12783
+ "PositionManagerCoreModule": "0x9A676e781A523b5d0C0e43731313A708CB607508",
12784
+ "TermManagerModule": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
12785
+ "LoanOperationsManagerModule": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
12786
+ "CollateralManagerModule": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
12787
+ "LiquidationManagerModule": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
12788
+ "CircuitBreakerModule": "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
12789
+ "CommunityManagerModule": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
12790
+ "AdminModule": "0xc5a5C42992dECbae36851359345FE25997F5C42d",
12791
+ "PositionManagerViews": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933",
12792
+ "PositionManager": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
12793
+ "OperationAuthorizationRegistry": "0x8f86403A4DE0BB5791fa46B8e795C547942fE4Cf",
12794
+ "PKPValidation": "0x36C02dA8a0983159322a80FFE9F24b1acfF8B570"
12799
12795
  };
12800
12796
  ALL_DEPLOYMENTS = {
12801
12797
  sepolia: SEPOLIA_DEPLOYMENT,
@@ -12838,7 +12834,6 @@ function getBrowserSafeConfig() {
12838
12834
  CommunityManagerModule: "",
12839
12835
  LiquidationManagerModule: "",
12840
12836
  UCDToken: "",
12841
- BTCProofValidator: "",
12842
12837
  PriceFeedConsumer: "",
12843
12838
  MockUSDC: "",
12844
12839
  MockUSDT: ""
@@ -12914,7 +12909,6 @@ function getSepoliaConfig() {
12914
12909
  logNetworkConfig("log", "[NetworkConfig] Sepolia contracts:", {
12915
12910
  PositionManager: SEPOLIA_CONTRACTS.PositionManager,
12916
12911
  UCDToken: SEPOLIA_CONTRACTS.UCDToken,
12917
- BTCProofValidator: SEPOLIA_CONTRACTS.BTCProofValidator,
12918
12912
  PriceFeedConsumer: SEPOLIA_CONTRACTS.PriceFeedConsumer
12919
12913
  });
12920
12914
  return {
@@ -12924,6 +12918,7 @@ function getSepoliaConfig() {
12924
12918
  name: "sepolia",
12925
12919
  rpcUrls: [],
12926
12920
  litNetwork: "datil",
12921
+ validatorVersion: 9,
12927
12922
  contractAddresses: {
12928
12923
  positionManager: SEPOLIA_CONTRACTS.PositionManager || "",
12929
12924
  positionManagerCore: SEPOLIA_CONTRACTS.PositionManagerCoreModule || "",
@@ -12938,12 +12933,11 @@ function getSepoliaConfig() {
12938
12933
  liquidationManager: SEPOLIA_CONTRACTS.LiquidationManagerModule || "",
12939
12934
  ucdToken: SEPOLIA_CONTRACTS.UCDToken || "",
12940
12935
  ucdController: SEPOLIA_CONTRACTS.UCDController || "",
12941
- btcProofValidator: SEPOLIA_CONTRACTS.BTCProofValidator || "",
12942
12936
  priceFeedConsumer: SEPOLIA_CONTRACTS.PriceFeedConsumer || "",
12943
12937
  operationAuthorizationRegistry: SEPOLIA_CONTRACTS.OperationAuthorizationRegistry || ""
12944
12938
  },
12945
12939
  subgraphs: {
12946
- diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/v0.3.0-1765544881"
12940
+ diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/version/latest"
12947
12941
  },
12948
12942
  // litNetwork: "datil-test",
12949
12943
  debug: true
@@ -12958,7 +12952,6 @@ function getMainnetConfig() {
12958
12952
  chainId: 1,
12959
12953
  name: "mainnet",
12960
12954
  rpcUrls: [
12961
- "https://eth-mainnet.g.alchemy.com/v2/demo",
12962
12955
  "https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
12963
12956
  ],
12964
12957
  contractAddresses: {
@@ -12972,7 +12965,6 @@ function getMainnetConfig() {
12972
12965
  communityManager: contracts.CommunityManagerModule || "",
12973
12966
  liquidationManager: contracts.LiquidationManagerModule || "",
12974
12967
  ucdToken: contracts.UCDToken || "",
12975
- btcProofValidator: contracts.BTCProofValidator || "",
12976
12968
  priceFeedConsumer: contracts.PriceFeedConsumer || "",
12977
12969
  operationAuthorizationRegistry: contracts.OperationAuthorizationRegistry || ""
12978
12970
  },
@@ -12997,14 +12989,8 @@ function getLocalhostConfig() {
12997
12989
  );
12998
12990
  logNetworkConfig("log", "[NetworkConfig] Localhost contracts:", {
12999
12991
  PositionManager: getAddress3("POSITION_MANAGER_ADDRESS", "PositionManager"),
13000
- PositionManagerCore: getAddress3(
13001
- "POSITION_MANAGER_CORE_ADDRESS",
13002
- "PositionManagerCoreModule"
13003
- ),
13004
- LoanOperationsManagerModule: getAddress3(
13005
- "LOAN_OPERATIONS_MANAGER_ADDRESS",
13006
- "LoanOperationsManagerModule"
13007
- ),
12992
+ PositionManagerCore: getAddress3("POSITION_MANAGER_CORE_ADDRESS", "PositionManagerCoreModule"),
12993
+ LoanOperationsManagerModule: getAddress3("LOAN_OPERATIONS_MANAGER_ADDRESS", "LoanOperationsManagerModule"),
13008
12994
  TermManagerModule: getAddress3("TERM_MANAGER_ADDRESS", "TermManagerModule"),
13009
12995
  UCDToken: getAddress3("UCD_TOKEN_ADDRESS", "UCDToken")
13010
12996
  });
@@ -13015,53 +13001,22 @@ function getLocalhostConfig() {
13015
13001
  name: "localhost",
13016
13002
  rpcUrls: ["http://localhost:8545"],
13017
13003
  contractAddresses: {
13018
- positionManager: getAddress3(
13019
- "POSITION_MANAGER_ADDRESS",
13020
- "PositionManager"
13021
- ),
13022
- positionManagerCore: getAddress3(
13023
- "POSITION_MANAGER_CORE_ADDRESS",
13024
- "PositionManagerCoreModule"
13025
- ),
13026
- positionManagerViews: getAddress3(
13027
- "POSITION_MANAGER_VIEWS_ADDRESS",
13028
- "PositionManagerViews"
13029
- ),
13004
+ positionManager: getAddress3("POSITION_MANAGER_ADDRESS", "PositionManager"),
13005
+ positionManagerCore: getAddress3("POSITION_MANAGER_CORE_ADDRESS", "PositionManagerCoreModule"),
13006
+ positionManagerViews: getAddress3("POSITION_MANAGER_VIEWS_ADDRESS", "PositionManagerViews"),
13030
13007
  simplePsmV2: getAddress3("SIMPLE_PSM_V2_ADDRESS", "SimplePSMV2"),
13031
- loanOperationsManager: getAddress3(
13032
- "LOAN_OPERATIONS_MANAGER_ADDRESS",
13033
- "LoanOperationsManagerModule"
13034
- ),
13008
+ loanOperationsManager: getAddress3("LOAN_OPERATIONS_MANAGER_ADDRESS", "LoanOperationsManagerModule"),
13035
13009
  termManager: getAddress3("TERM_MANAGER_ADDRESS", "TermManagerModule"),
13036
- circuitBreaker: getAddress3(
13037
- "CIRCUIT_BREAKER_ADDRESS",
13038
- "CircuitBreakerModule"
13039
- ),
13040
- communityManager: getAddress3(
13041
- "COMMUNITY_MANAGER_ADDRESS",
13042
- "CommunityManagerModule"
13043
- ),
13044
- liquidationManager: getAddress3(
13045
- "LIQUIDATION_MANAGER_ADDRESS",
13046
- "LiquidationManagerModule"
13047
- ),
13010
+ circuitBreaker: getAddress3("CIRCUIT_BREAKER_ADDRESS", "CircuitBreakerModule"),
13011
+ communityManager: getAddress3("COMMUNITY_MANAGER_ADDRESS", "CommunityManagerModule"),
13012
+ liquidationManager: getAddress3("LIQUIDATION_MANAGER_ADDRESS", "LiquidationManagerModule"),
13048
13013
  ucdToken: getAddress3("UCD_TOKEN_ADDRESS", "UCDToken"),
13049
13014
  ucdController: getAddress3("UCD_CONTROLLER_ADDRESS", "UCDController"),
13050
- btcProofValidator: getAddress3(
13051
- "BTC_PROOF_VALIDATOR_ADDRESS",
13052
- "BTCProofValidator"
13053
- ),
13054
- priceFeedConsumer: getAddress3(
13055
- "PRICE_FEED_CONSUMER_ADDRESS",
13056
- "PriceFeedConsumer"
13057
- ),
13058
- operationAuthorizationRegistry: getAddress3(
13059
- "OPERATION_AUTHORIZATION_REGISTRY_ADDRESS",
13060
- "OperationAuthorizationRegistry"
13061
- )
13015
+ priceFeedConsumer: getAddress3("PRICE_FEED_CONSUMER_ADDRESS", "PriceFeedConsumer"),
13016
+ operationAuthorizationRegistry: getAddress3("OPERATION_AUTHORIZATION_REGISTRY_ADDRESS", "OperationAuthorizationRegistry")
13062
13017
  },
13063
13018
  subgraphs: {
13064
- diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/v0.3.0-1765544881"
13019
+ diamondHandsUrl: "https://api.studio.thegraph.com/query/65258/diamond-hands/version/latest"
13065
13020
  },
13066
13021
  litNetwork: "datil",
13067
13022
  debug: true
@@ -29228,6 +29183,42 @@ async function generateMintAuthorization(positionId, amount, chainId, mode, sign
29228
29183
  mode
29229
29184
  };
29230
29185
  }
29186
+ async function generatePaymentAuthorization(positionId, amount, chainId, mode, signer) {
29187
+ const timestamp = calculateNextQuantumTimestamp();
29188
+ const action = "make-payment";
29189
+ const actionHash = ethers_exports.utils.keccak256(ethers_exports.utils.toUtf8Bytes(action));
29190
+ const types = [
29191
+ "bytes32",
29192
+ // positionId
29193
+ "uint256",
29194
+ // timestamp
29195
+ "uint256",
29196
+ // chainId
29197
+ "uint256",
29198
+ // amount
29199
+ "bytes32"
29200
+ // actionHash
29201
+ ];
29202
+ const values = [
29203
+ positionId,
29204
+ timestamp,
29205
+ chainId,
29206
+ amount.toString(),
29207
+ actionHash
29208
+ ];
29209
+ const messageHash = ethers_exports.utils.solidityKeccak256(types, values);
29210
+ const messageHashBytes = ethers_exports.utils.arrayify(messageHash);
29211
+ const signature2 = await signer.signMessage(messageHashBytes);
29212
+ return {
29213
+ positionId,
29214
+ timestamp,
29215
+ chainId,
29216
+ amount: amount.toString(),
29217
+ action,
29218
+ signature: signature2,
29219
+ mode
29220
+ };
29221
+ }
29231
29222
  async function getPKPPublicKeyFromTokenId(pkpTokenId, provider) {
29232
29223
  let yellowstoneProvider;
29233
29224
  if (provider) {
@@ -36562,6 +36553,11 @@ var _abi = [
36562
36553
  name: "BtcPriceTooHigh",
36563
36554
  type: "error"
36564
36555
  },
36556
+ {
36557
+ inputs: [],
36558
+ name: "CollateralAmountMismatch",
36559
+ type: "error"
36560
+ },
36565
36561
  {
36566
36562
  inputs: [],
36567
36563
  name: "CollateralOverflow",
@@ -36651,29 +36647,44 @@ var _abi = [
36651
36647
  },
36652
36648
  {
36653
36649
  inputs: [],
36654
- name: "InsufficientAllowance",
36650
+ name: "InsufficientBalance",
36655
36651
  type: "error"
36656
36652
  },
36657
36653
  {
36658
36654
  inputs: [],
36659
- name: "InsufficientBalance",
36655
+ name: "IntegrityCheckFailed",
36660
36656
  type: "error"
36661
36657
  },
36662
36658
  {
36663
36659
  inputs: [],
36664
- name: "IntegrityCheckFailed",
36660
+ name: "InvalidAddress",
36665
36661
  type: "error"
36666
36662
  },
36667
36663
  {
36668
36664
  inputs: [],
36669
- name: "InvalidAddress",
36665
+ name: "InvalidBytes32",
36666
+ type: "error"
36667
+ },
36668
+ {
36669
+ inputs: [],
36670
+ name: "InvalidCollateralAmount",
36671
+ type: "error"
36672
+ },
36673
+ {
36674
+ inputs: [],
36675
+ name: "InvalidInitialization",
36676
+ type: "error"
36677
+ },
36678
+ {
36679
+ inputs: [],
36680
+ name: "InvalidPositionId",
36670
36681
  type: "error"
36671
36682
  },
36672
36683
  {
36673
36684
  inputs: [
36674
36685
  {
36675
36686
  internalType: "uint256",
36676
- name: "amount",
36687
+ name: "price",
36677
36688
  type: "uint256"
36678
36689
  },
36679
36690
  {
@@ -36687,22 +36698,12 @@ var _abi = [
36687
36698
  type: "uint256"
36688
36699
  }
36689
36700
  ],
36690
- name: "InvalidAmount",
36701
+ name: "InvalidPrice",
36691
36702
  type: "error"
36692
36703
  },
36693
36704
  {
36694
36705
  inputs: [],
36695
- name: "InvalidBytes32",
36696
- type: "error"
36697
- },
36698
- {
36699
- inputs: [],
36700
- name: "InvalidInitialization",
36701
- type: "error"
36702
- },
36703
- {
36704
- inputs: [],
36705
- name: "InvalidPositionId",
36706
+ name: "InvalidRequestedExpiryDate",
36706
36707
  type: "error"
36707
36708
  },
36708
36709
  {
@@ -36747,11 +36748,6 @@ var _abi = [
36747
36748
  name: "InvalidValidatorSignature",
36748
36749
  type: "error"
36749
36750
  },
36750
- {
36751
- inputs: [],
36752
- name: "ModuleCallFailed",
36753
- type: "error"
36754
- },
36755
36751
  {
36756
36752
  inputs: [],
36757
36753
  name: "MultiplicationOverflow",
@@ -36886,17 +36882,23 @@ var _abi = [
36886
36882
  {
36887
36883
  indexed: false,
36888
36884
  internalType: "uint256",
36889
- name: "oldRatio",
36885
+ name: "collateralValue",
36890
36886
  type: "uint256"
36891
36887
  },
36892
36888
  {
36893
36889
  indexed: false,
36894
36890
  internalType: "uint256",
36895
- name: "newRatio",
36891
+ name: "quantumTimestamp",
36892
+ type: "uint256"
36893
+ },
36894
+ {
36895
+ indexed: false,
36896
+ internalType: "uint256",
36897
+ name: "confirmedAt",
36896
36898
  type: "uint256"
36897
36899
  }
36898
36900
  ],
36899
- name: "CollateralRatioUpdated",
36901
+ name: "BalanceConfirmed",
36900
36902
  type: "event"
36901
36903
  },
36902
36904
  {
@@ -36931,37 +36933,6 @@ var _abi = [
36931
36933
  name: "Initialized",
36932
36934
  type: "event"
36933
36935
  },
36934
- {
36935
- anonymous: false,
36936
- inputs: [
36937
- {
36938
- indexed: true,
36939
- internalType: "bytes32",
36940
- name: "positionId",
36941
- type: "bytes32"
36942
- },
36943
- {
36944
- indexed: false,
36945
- internalType: "string",
36946
- name: "checkType",
36947
- type: "string"
36948
- },
36949
- {
36950
- indexed: false,
36951
- internalType: "string",
36952
- name: "reason",
36953
- type: "string"
36954
- },
36955
- {
36956
- indexed: false,
36957
- internalType: "uint256",
36958
- name: "timestamp",
36959
- type: "uint256"
36960
- }
36961
- ],
36962
- name: "IntegrityCheckFailed",
36963
- type: "event"
36964
- },
36965
36936
  {
36966
36937
  anonymous: false,
36967
36938
  inputs: [
@@ -37051,12 +37022,6 @@ var _abi = [
37051
37022
  internalType: "uint256",
37052
37023
  name: "remainingDebt",
37053
37024
  type: "uint256"
37054
- },
37055
- {
37056
- indexed: false,
37057
- internalType: "uint256",
37058
- name: "newCollateralRatio",
37059
- type: "uint256"
37060
37025
  }
37061
37026
  ],
37062
37027
  name: "PartialPaymentMade",
@@ -37615,6 +37580,11 @@ var _abi = [
37615
37580
  internalType: "uint256",
37616
37581
  name: "btcPrice",
37617
37582
  type: "uint256"
37583
+ },
37584
+ {
37585
+ internalType: "uint256",
37586
+ name: "availableBTCBalance",
37587
+ type: "uint256"
37618
37588
  }
37619
37589
  ],
37620
37590
  name: "_performExtensionValidation",
@@ -37669,25 +37639,6 @@ var _abi = [
37669
37639
  stateMutability: "view",
37670
37640
  type: "function"
37671
37641
  },
37672
- {
37673
- inputs: [
37674
- {
37675
- internalType: "bytes32",
37676
- name: "positionId",
37677
- type: "bytes32"
37678
- }
37679
- ],
37680
- name: "calculateCollateralRatio",
37681
- outputs: [
37682
- {
37683
- internalType: "uint256",
37684
- name: "",
37685
- type: "uint256"
37686
- }
37687
- ],
37688
- stateMutability: "view",
37689
- type: "function"
37690
- },
37691
37642
  {
37692
37643
  inputs: [],
37693
37644
  name: "circuitBreaker",
@@ -37735,9 +37686,19 @@ var _abi = [
37735
37686
  type: "bytes32"
37736
37687
  },
37737
37688
  {
37738
- internalType: "bytes32",
37739
- name: "commitHash",
37740
- type: "bytes32"
37689
+ internalType: "uint256",
37690
+ name: "quantumTimestamp",
37691
+ type: "uint256"
37692
+ },
37693
+ {
37694
+ internalType: "uint256",
37695
+ name: "btcPrice",
37696
+ type: "uint256"
37697
+ },
37698
+ {
37699
+ internalType: "bytes",
37700
+ name: "liquidationValidatorSignature",
37701
+ type: "bytes"
37741
37702
  }
37742
37703
  ],
37743
37704
  name: "commitLiquidation",
@@ -37758,6 +37719,75 @@ var _abi = [
37758
37719
  stateMutability: "view",
37759
37720
  type: "function"
37760
37721
  },
37722
+ {
37723
+ inputs: [
37724
+ {
37725
+ internalType: "bytes32",
37726
+ name: "positionId",
37727
+ type: "bytes32"
37728
+ },
37729
+ {
37730
+ internalType: "bytes32",
37731
+ name: "actionHash",
37732
+ type: "bytes32"
37733
+ },
37734
+ {
37735
+ internalType: "bytes32",
37736
+ name: "authorizedSpendsHash",
37737
+ type: "bytes32"
37738
+ },
37739
+ {
37740
+ internalType: "bytes32",
37741
+ name: "ucdDebtHash",
37742
+ type: "bytes32"
37743
+ },
37744
+ {
37745
+ internalType: "bytes32",
37746
+ name: "contractHash",
37747
+ type: "bytes32"
37748
+ },
37749
+ {
37750
+ internalType: "uint256",
37751
+ name: "btcPrice",
37752
+ type: "uint256"
37753
+ },
37754
+ {
37755
+ internalType: "uint256",
37756
+ name: "mintAmount",
37757
+ type: "uint256"
37758
+ },
37759
+ {
37760
+ internalType: "uint256",
37761
+ name: "mintFee",
37762
+ type: "uint256"
37763
+ },
37764
+ {
37765
+ internalType: "uint256",
37766
+ name: "newCollateral",
37767
+ type: "uint256"
37768
+ },
37769
+ {
37770
+ internalType: "uint256",
37771
+ name: "newDebt",
37772
+ type: "uint256"
37773
+ },
37774
+ {
37775
+ internalType: "uint256",
37776
+ name: "quantumTimestamp",
37777
+ type: "uint256"
37778
+ }
37779
+ ],
37780
+ name: "computeMintMessageHash",
37781
+ outputs: [
37782
+ {
37783
+ internalType: "bytes32",
37784
+ name: "",
37785
+ type: "bytes32"
37786
+ }
37787
+ ],
37788
+ stateMutability: "pure",
37789
+ type: "function"
37790
+ },
37761
37791
  {
37762
37792
  inputs: [],
37763
37793
  name: "core",
@@ -37837,6 +37867,11 @@ var _abi = [
37837
37867
  name: "btcPrice",
37838
37868
  type: "uint256"
37839
37869
  },
37870
+ {
37871
+ internalType: "uint256",
37872
+ name: "availableBTCBalance",
37873
+ type: "uint256"
37874
+ },
37840
37875
  {
37841
37876
  internalType: "bytes",
37842
37877
  name: "extensionValidatorSignature",
@@ -37874,80 +37909,13 @@ var _abi = [
37874
37909
  type: "function"
37875
37910
  },
37876
37911
  {
37877
- inputs: [
37878
- {
37879
- internalType: "bytes32",
37880
- name: "",
37881
- type: "bytes32"
37882
- }
37883
- ],
37884
- name: "getPKPLoanParams",
37885
- outputs: [
37886
- {
37887
- internalType: "uint256",
37888
- name: "",
37889
- type: "uint256"
37890
- },
37891
- {
37892
- internalType: "uint256",
37893
- name: "",
37894
- type: "uint256"
37895
- },
37896
- {
37897
- internalType: "uint256",
37898
- name: "",
37899
- type: "uint256"
37900
- }
37901
- ],
37902
- stateMutability: "pure",
37903
- type: "function"
37904
- },
37905
- {
37906
- inputs: [
37907
- {
37908
- internalType: "bytes32",
37909
- name: "",
37910
- type: "bytes32"
37911
- }
37912
- ],
37913
- name: "getPKPPositionData",
37912
+ inputs: [],
37913
+ name: "getMintMessageHashParameters",
37914
37914
  outputs: [
37915
37915
  {
37916
- components: [
37917
- {
37918
- internalType: "bytes32",
37919
- name: "positionId",
37920
- type: "bytes32"
37921
- },
37922
- {
37923
- internalType: "address",
37924
- name: "borrower",
37925
- type: "address"
37926
- },
37927
- {
37928
- internalType: "uint256",
37929
- name: "amount",
37930
- type: "uint256"
37931
- },
37932
- {
37933
- internalType: "uint32",
37934
- name: "requestedCollateralRatio",
37935
- type: "uint32"
37936
- },
37937
- {
37938
- internalType: "uint16",
37939
- name: "selectedTerm",
37940
- type: "uint16"
37941
- },
37942
- {
37943
- internalType: "uint40",
37944
- name: "createdAt",
37945
- type: "uint40"
37946
- }
37947
- ],
37948
- internalType: "struct IPositionManager.PKPPositionData",
37916
+ internalType: "string[]",
37949
37917
  name: "",
37950
- type: "tuple"
37918
+ type: "string[]"
37951
37919
  }
37952
37920
  ],
37953
37921
  stateMutability: "pure",
@@ -37961,7 +37929,7 @@ var _abi = [
37961
37929
  type: "bytes32"
37962
37930
  }
37963
37931
  ],
37964
- name: "getPositionDetails",
37932
+ name: "getPositionById",
37965
37933
  outputs: [
37966
37934
  {
37967
37935
  components: [
@@ -38023,16 +37991,16 @@ var _abi = [
38023
37991
  inputs: [
38024
37992
  {
38025
37993
  internalType: "bytes32",
38026
- name: "positionId",
37994
+ name: "pkpId",
38027
37995
  type: "bytes32"
38028
37996
  }
38029
37997
  ],
38030
- name: "getPositionStatus",
37998
+ name: "getPositionByPkp",
38031
37999
  outputs: [
38032
38000
  {
38033
- internalType: "enum LoanStatusLib.LoanStatus",
38001
+ internalType: "bytes32",
38034
38002
  name: "",
38035
- type: "uint8"
38003
+ type: "bytes32"
38036
38004
  }
38037
38005
  ],
38038
38006
  stateMutability: "view",
@@ -38194,6 +38162,40 @@ var _abi = [
38194
38162
  type: "bytes32"
38195
38163
  }
38196
38164
  ],
38165
+ name: "isExtensionPending",
38166
+ outputs: [
38167
+ {
38168
+ internalType: "bool",
38169
+ name: "",
38170
+ type: "bool"
38171
+ }
38172
+ ],
38173
+ stateMutability: "view",
38174
+ type: "function"
38175
+ },
38176
+ {
38177
+ inputs: [
38178
+ {
38179
+ internalType: "bytes32",
38180
+ name: "positionId",
38181
+ type: "bytes32"
38182
+ },
38183
+ {
38184
+ internalType: "uint256",
38185
+ name: "btcPrice",
38186
+ type: "uint256"
38187
+ },
38188
+ {
38189
+ internalType: "uint256",
38190
+ name: "quantumTimestamp",
38191
+ type: "uint256"
38192
+ },
38193
+ {
38194
+ internalType: "bytes",
38195
+ name: "liquidationValidatorSignature",
38196
+ type: "bytes"
38197
+ }
38198
+ ],
38197
38199
  name: "liquidatePosition",
38198
38200
  outputs: [
38199
38201
  {
@@ -38242,9 +38244,93 @@ var _abi = [
38242
38244
  internalType: "uint256",
38243
38245
  name: "paymentAmount",
38244
38246
  type: "uint256"
38247
+ },
38248
+ {
38249
+ internalType: "uint256",
38250
+ name: "quantumTimestamp",
38251
+ type: "uint256"
38252
+ },
38253
+ {
38254
+ internalType: "uint256",
38255
+ name: "btcPrice",
38256
+ type: "uint256"
38257
+ },
38258
+ {
38259
+ internalType: "bytes",
38260
+ name: "paymentValidatorSignature",
38261
+ type: "bytes"
38262
+ }
38263
+ ],
38264
+ name: "makePayment",
38265
+ outputs: [
38266
+ {
38267
+ internalType: "bool",
38268
+ name: "",
38269
+ type: "bool"
38270
+ }
38271
+ ],
38272
+ stateMutability: "nonpayable",
38273
+ type: "function"
38274
+ },
38275
+ {
38276
+ inputs: [
38277
+ {
38278
+ internalType: "bytes32",
38279
+ name: "positionId",
38280
+ type: "bytes32"
38281
+ },
38282
+ {
38283
+ internalType: "uint256",
38284
+ name: "mintAmount",
38285
+ type: "uint256"
38286
+ },
38287
+ {
38288
+ internalType: "uint256",
38289
+ name: "mintFee",
38290
+ type: "uint256"
38291
+ },
38292
+ {
38293
+ internalType: "uint256",
38294
+ name: "newDebt",
38295
+ type: "uint256"
38296
+ },
38297
+ {
38298
+ internalType: "uint256",
38299
+ name: "newCollateral",
38300
+ type: "uint256"
38301
+ },
38302
+ {
38303
+ internalType: "uint256",
38304
+ name: "btcPrice",
38305
+ type: "uint256"
38306
+ },
38307
+ {
38308
+ internalType: "bytes32",
38309
+ name: "authorizedSpendsHash",
38310
+ type: "bytes32"
38311
+ },
38312
+ {
38313
+ internalType: "bytes32",
38314
+ name: "ucdDebtHash",
38315
+ type: "bytes32"
38316
+ },
38317
+ {
38318
+ internalType: "bytes32",
38319
+ name: "contractHash",
38320
+ type: "bytes32"
38321
+ },
38322
+ {
38323
+ internalType: "uint256",
38324
+ name: "quantumTimestamp",
38325
+ type: "uint256"
38326
+ },
38327
+ {
38328
+ internalType: "bytes",
38329
+ name: "mintValidatorSignature",
38330
+ type: "bytes"
38245
38331
  }
38246
38332
  ],
38247
- name: "makePartialPayment",
38333
+ name: "mintUCD",
38248
38334
  outputs: [
38249
38335
  {
38250
38336
  internalType: "bool",
@@ -38321,33 +38407,19 @@ var _abi = [
38321
38407
  },
38322
38408
  {
38323
38409
  internalType: "uint256",
38324
- name: "repaymentAmount",
38410
+ name: "quantumTimestamp",
38325
38411
  type: "uint256"
38326
- }
38327
- ],
38328
- name: "repayPosition",
38329
- outputs: [
38330
- {
38331
- internalType: "bool",
38332
- name: "",
38333
- type: "bool"
38334
- }
38335
- ],
38336
- stateMutability: "nonpayable",
38337
- type: "function"
38338
- },
38339
- {
38340
- inputs: [
38341
- {
38342
- internalType: "bytes32",
38343
- name: "positionId",
38344
- type: "bytes32"
38345
38412
  },
38346
38413
  {
38347
38414
  internalType: "uint256",
38348
- name: "nonce",
38415
+ name: "btcPrice",
38349
38416
  type: "uint256"
38350
38417
  },
38418
+ {
38419
+ internalType: "bytes",
38420
+ name: "liquidationValidatorSignature",
38421
+ type: "bytes"
38422
+ },
38351
38423
  {
38352
38424
  internalType: "uint256",
38353
38425
  name: "deadline",
@@ -38441,6 +38513,34 @@ var _abi = [
38441
38513
  stateMutability: "view",
38442
38514
  type: "function"
38443
38515
  },
38516
+ {
38517
+ inputs: [
38518
+ {
38519
+ internalType: "bytes32",
38520
+ name: "positionId",
38521
+ type: "bytes32"
38522
+ },
38523
+ {
38524
+ internalType: "uint256",
38525
+ name: "collateralValue",
38526
+ type: "uint256"
38527
+ },
38528
+ {
38529
+ internalType: "uint256",
38530
+ name: "quantumTimestamp",
38531
+ type: "uint256"
38532
+ },
38533
+ {
38534
+ internalType: "bytes",
38535
+ name: "signature",
38536
+ type: "bytes"
38537
+ }
38538
+ ],
38539
+ name: "updateBalance",
38540
+ outputs: [],
38541
+ stateMutability: "nonpayable",
38542
+ type: "function"
38543
+ },
38444
38544
  {
38445
38545
  inputs: [
38446
38546
  {
@@ -38507,30 +38607,6 @@ var _abi = [
38507
38607
  stateMutability: "nonpayable",
38508
38608
  type: "function"
38509
38609
  },
38510
- {
38511
- inputs: [
38512
- {
38513
- internalType: "bytes32",
38514
- name: "positionId",
38515
- type: "bytes32"
38516
- },
38517
- {
38518
- internalType: "uint256",
38519
- name: "newDebt",
38520
- type: "uint256"
38521
- }
38522
- ],
38523
- name: "updatePosition",
38524
- outputs: [
38525
- {
38526
- internalType: "bool",
38527
- name: "",
38528
- type: "bool"
38529
- }
38530
- ],
38531
- stateMutability: "nonpayable",
38532
- type: "function"
38533
- },
38534
38610
  {
38535
38611
  inputs: [
38536
38612
  {
@@ -38569,32 +38645,23 @@ var _abi = [
38569
38645
  },
38570
38646
  {
38571
38647
  inputs: [
38648
+ {
38649
+ internalType: "bytes4",
38650
+ name: "selector",
38651
+ type: "bytes4"
38652
+ },
38572
38653
  {
38573
38654
  internalType: "bytes32",
38574
- name: "pkpId",
38655
+ name: "messageHash",
38575
38656
  type: "bytes32"
38576
- }
38577
- ],
38578
- name: "validatePKPLogic",
38579
- outputs: [
38580
- {
38581
- internalType: "bool",
38582
- name: "",
38583
- type: "bool"
38584
- }
38585
- ],
38586
- stateMutability: "view",
38587
- type: "function"
38588
- },
38589
- {
38590
- inputs: [
38657
+ },
38591
38658
  {
38592
- internalType: "address",
38593
- name: "newImplementation",
38594
- type: "address"
38659
+ internalType: "bytes",
38660
+ name: "signature",
38661
+ type: "bytes"
38595
38662
  }
38596
38663
  ],
38597
- name: "validateUpgrade",
38664
+ name: "verifyAuthorization",
38598
38665
  outputs: [
38599
38666
  {
38600
38667
  internalType: "bool",
@@ -38642,6 +38709,11 @@ var _abi = [
38642
38709
  name: "ucdDebtHash",
38643
38710
  type: "bytes32"
38644
38711
  },
38712
+ {
38713
+ internalType: "bytes32",
38714
+ name: "contractBundleHash",
38715
+ type: "bytes32"
38716
+ },
38645
38717
  {
38646
38718
  internalType: "string",
38647
38719
  name: "withdrawalAddress",
@@ -38700,7 +38772,7 @@ var _abi = [
38700
38772
  type: "function"
38701
38773
  }
38702
38774
  ];
38703
- var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b604051615b7590816100f0823960805181818161192e0152611b2b0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a714610387578063043fe8fc1461038257806306f89d441461037d578063096ec4b0146103785780630c995dc314610373578063105250411461036e57806316d8887a1461036957806316efd941146103645780631732d3301461035f5780631f0b0fb31461035a578063248a9ca3146103555780632f2ff15d1461035057806336568abe1461034b578063389b0b9b14610346578063393d92cc146103415780634a54e00a1461033c5780634f1ef2861461033757806352d1902d146103325780635c975abb1461032d5780635e4936e8146103285780636068b5d114610323578063667fe2651461031e57806374cb36e61461031957806375b238fc146103145780638d3487551461030f5780638e7d27601461030a5780638ffee9cd1461030557806391d148541461030057806396b9b99d146102fb5780639b91c47a146102f65780639b9d30c1146102f1578063a217fddf146102ec578063a9eadc52146102e7578063aa4fec70146102e2578063ad3cb1cc146102dd578063c12e1291146102d8578063c306b378146102d3578063cdeb3fcf146102ce578063d0e8ce82146102c9578063d547741f146102c4578063d65e880d146102bf578063d8dfeb45146102ba578063d9cb25a2146102b5578063ddccaa3a146102b0578063e6726da8146102ab578063e7f9caa5146102a6578063eaf7762c146102a1578063f005e7671461029c578063f0afc1b814610297578063f2dfbf6614610292578063f2f4eb261461028d578063f851a44014610288578063fb7c6a0f14610283578063fd5252381461027e5763ffa1ad741461027957600080fd5b6135c1565b61354e565b613525565b6134fc565b6134d3565b6134aa565b613441565b613418565b6132fb565b613279565b613106565b612e05565b612da1565b612d78565b612d4f565b612d1b565b612cb7565b612bae565b612aad565b612a05565b6129a9565b612924565b6128fb565b6128cc565b612891565b612330565b61222c565b6121db565b611fec565b611f55565b611e03565b611d4d565b611d24565b611cc1565b611c22565b611ba1565b611b71565b611b18565b6118dc565b611803565b6117da565b6111d2565b61115b565b611120565b6110fa565b610b34565b610af9565b610ad0565b610aa7565b610a0d565b6109df565b610578565b6104d5565b61040c565b346103dd5760203660031901126103dd5760043563ffffffff60e01b81168091036103dd57602090637965db0b60e01b81149081156103cc575b506040519015158152f35b6301ffc9a760e01b149050386103c1565b600080fd5b6001600160a01b031690565b6001600160a01b038116036103dd57565b359061040a826103ee565b565b346103dd5760203660031901126103dd57600435610429816103ee565b6104316146aa565b6001600160a01b0316801561048757600b80546001600160a01b0319811683179091553391906001600160a01b03167f440ec6c0da0791f6d650579df27149ce4ffc4f4fbf63e9a8bcd45dacdbf338a2600080a4005b63e6c4247b60e01b60005260046000fd5b600811156104a257565b634e487b7160e01b600052602160045260246000fd5b9060088210156104a25752565b60208101929161040a91906104b8565b346103dd5760203660031901126103dd576008546040516301be275160e21b8152600480359082015290602090829060249082906001600160a01b03165afa801561057357600090610536575b61053290604051918291826104c5565b0390f35b506020813d60201161056b575b8161055060209383611842565b810103126103dd576105329051610566816129f0565b610522565b3d9150610543565b613702565b346103dd5760403660031901126103dd57600435602435610597614821565b61059f61484b565b6105a761489b565b33600052600a6020526040600020544311156109b8576105c7818361492c565b6105da6105d56006546103e2565b6103e2565b803b156103dd5760405163102d617560e01b81526004810183905260006024820181905290918290604490829084905af18015610573576109a3575b506106256105d56000546103e2565b604051638d34875560e01b81526004810184905290600090829060249082905afa90811561057357600091610988575b50805115610977576080015133906001600160a01b0390610675906103e2565b16036109665761068b6106878361495d565b1590565b61087c57600460206106a16105d56001546103e2565b60405163023b2a9f60e31b815292839182905afa90811561057357600091610937575b506001600160a01b03166106da82303384614b17565b61070760206106ed6105d56001546103e2565b6040518093819263095ea7b360e01b8352600483016138b0565b03816000865af180156105735761074f92602092859261091c575b506107316105d56001546103e2565b600060405180968195829463095ea7b360e01b8452600484016138ca565b03925af180156105735760009260209261079492610901575b506107776105d56001546103e2565b906040519485809481936296ec4b60e41b835289600484016138e5565b03925af1908115610573576000916108d2575b50156108c1576107bb6105d56000546103e2565b604051638d34875560e01b815260048101839052600081602481855afa80156105735760409160009161089e575b50015161088d576107fc6106878361495d565b61087c57803b156103dd57604051637f15208d60e01b815290600090829081838161082a88600483016138f6565b03925af1801561057357610861575b50436108443361370e565b5561084d614918565b610855614887565b60405160018152602090f35b80610870600061087693611842565b80610a9c565b80610839565b6334b110b160e11b60005260046000fd5b630a0b0d7960e01b60005260046000fd5b6108bb91503d806000833e6108b38183611842565b8101906137a2565b386107e9565b633badd6bb60e21b60005260046000fd5b6108f4915060203d6020116108fa575b6108ec8183611842565b81019061389c565b386107a7565b503d6108e2565b61091790843d86116108fa576108ec8183611842565b610768565b61093290843d86116108fa576108ec8183611842565b610722565b610959915060203d60201161095f575b6109518183611842565b81019061387a565b386106c4565b503d610947565b631963d1e760e31b60005260046000fd5b636ec9be1160e01b60005260046000fd5b61099d91503d806000833e6108b38183611842565b38610655565b8061087060006109b293611842565b38610616565b633b53d1db60e01b60005260046000fd5b6040919493926060820195825260208201520152565b346103dd5760203660031901126103dd5760405162461bcd60e51b815280610a0960048201613951565b0390fd5b346103dd5760203660031901126103dd57600435610a2a816103ee565b600754604051631052504160e01b81526001600160a01b0392831660048201529160209183916024918391165afa80156105735761053291600091610a7d575b5060405191829182901515815260200190565b610a96915060203d6020116108fa576108ec8183611842565b38610a6a565b60009103126103dd57565b346103dd5760003660031901126103dd5760206040516000805160206159008339815191528152f35b346103dd5760003660031901126103dd576006546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd5760206040517f9792fdc19ab98adfa72ab2fa98d342618c661e01c406979c105b31eda87f5e6f8152f35b346103dd5760403660031901126103dd57602435600435610b53614821565b610b5b61484b565b610b6361489b565b610b716105d56006546103e2565b803b156103dd5760405163102d617560e01b81526004810184905260006024820181905290918290604490829084905af18015610573576110e5575b50610bbc6105d56000546103e2565b604051638d34875560e01b81526004810183905290600090829060249082905afa908115610573576000916110cc575b50610bfa60808201516103e2565b61012082015190610c0a82610498565b610c1b604084015180948787614bb1565b610c276106878561495d565b61087c57336001600160a01b039091160361096657610c4581614cbb565b60046020610c576105d56001546103e2565b60405163023b2a9f60e31b815292839182905afa908115610573576000916110ad575b506040516370a0823160e01b81526001600160a01b03919091169060208180610ca633600483016128e8565b0381855afa801561057357869160009161108e575b501061107d57604051636eb1769f60e11b8152336004820152306024820152602081604481855afa801561057357869160009161105e575b501061104d57600490610d0886303384614b17565b6020610d186105d56001546103e2565b60405163b1d3354f60e01b815293849182905afa9182156105735760009261102c575b5060405163095ea7b360e01b81529060208280610d5b86600483016138b0565b03816000855af190811561057357610d96936020938993611011575b50600060405180968195829463095ea7b360e01b8452600484016138ca565b03925af1801561057357610ff4575b50610db46105d56001546103e2565b9160405163696c86cd60e01b8152602081600481875afa90811561057357610de6928791600093610fd3575b50614d82565b919092602060405180926380fd423960e01b825281600081610e0c8c8c600484016138e5565b03925af190811561057357600091610fb4575b5015610fa3576004906020610e386105d56001546103e2565b60405163100c48d360e21b815293849182905afa801561057357838592610e6794600093610f72575b50614da2565b90610f12575b610e9e575b6000805160206159e083398151915291610e936040519283923397846109c9565b0390a361084d614918565b610eac6105d56000546103e2565b91823b156103dd5760006040518094637f15208d60e01b8252818381610ed58a600483016138f6565b03925af1928315610573576000805160206159e083398151915293610efd575b509150610e72565b806108706000610f0c93611842565b38610ef5565b610f206105d56000546103e2565b803b156103dd5760006040518092637f15208d60e01b8252818381610f488b6004830161390d565b03925af1801561057357610f5d575b50610e6d565b806108706000610f6c93611842565b38610f57565b610f9591935060203d602011610f9c575b610f8d8183611842565b810190613976565b9138610e61565b503d610f83565b63d0806ec760e01b60005260046000fd5b610fcd915060203d6020116108fa576108ec8183611842565b38610e1f565b610fed91935060203d602011610f9c57610f8d8183611842565b9138610de0565b61100c9060203d6020116108fa576108ec8183611842565b610da5565b61102790853d87116108fa576108ec8183611842565b610d77565b61104691925060203d60201161095f576109518183611842565b9038610d3b565b6313be252b60e01b60005260046000fd5b611077915060203d602011610f9c57610f8d8183611842565b38610cf3565b631e9acf1760e31b60005260046000fd5b6110a7915060203d602011610f9c57610f8d8183611842565b38610cbb565b6110c6915060203d60201161095f576109518183611842565b38610c7a565b6110df913d8091833e6108b38183611842565b38610bec565b8061087060006110f493611842565b38610bad565b346103dd5760203660031901126103dd576020611118600435613995565b604051908152f35b346103dd5760403660031901126103dd57611159602435600435611143826103ee565b61115461114f82613995565b6147d9565b615173565b005b346103dd5760403660031901126103dd5760043560243561117b816103ee565b336001600160a01b0382160361119457611159916151f9565b63334bd91960e11b60005260046000fd5b9181601f840112156103dd578235916001600160401b0383116103dd57602083818601950101116103dd57565b346103dd5760a03660031901126103dd576064356004356024356044356084356001600160401b0381116103dd5761120e9036906004016111a5565b611216614821565b61121e61484b565b33600052600a6020526040600020544311156109b85761123d85615288565b611246846152a0565b85156104875764e8d4a51000861080156117cb575b61088d57604051602081019061128681611278878b8a8c88612b92565b03601f198101835282611842565b5190206112976105d5600c546103e2565b926001600160a01b038416156117ba576020916112c86040519485938493636b80155f60e01b8552600485016139d7565b0381855afa9081156105735760009161179b575b501561178a57803b156103dd57604051630e62cc9360e21b8152916000918391829084908290611310908a600484016138e5565b03925af1801561057357611775575b5061132e6105d56004546103e2565b604051634977ff8b60e11b81526004810183905290602090829060249082905afa90811561057357600091611756575b50156117455761137761137083613985565b5460ff1690565b611734576113896105d56000546103e2565b604051638d34875560e01b8152600481018490529390600090859060249082905afa93841561057357600094611719575b506113c860808501516103e2565b610120850151946113d886610498565b6113f76113ed60a083015164ffffffffff1690565b64ffffffffff1690565b91815115610977576001600160a01b0316953387036109665761141981610498565b60028114159081611704575b506116f3578360809161144761143a88613985565b805460ff19166001179055565b611465604051958693849363cdeb3fcf60e01b855260048501613a41565b0381305afa6000816000946000936116b9575b506114d15785611486613af6565b6308c379a0146114b8575b61149d6114a791613985565b805460ff19169055565b633a4f184b60e11b60005260046000fd5b6114c0613b14565b156114915761149d6114a791613985565b926114e06105d56000546103e2565b803b156103dd5760405163fa5fa16360e01b815291600091839182908490829061150e908d600484016138e5565b03925af18015610573576116a4575b5061152c6105d56000546103e2565b91823b156103dd5760006040518094630d7ad17360e41b8252818381611556888d600484016138e5565b03925af1928315610573576115709361168f575b50615303565b9161157f6105d56001546103e2565b60405163b1d3354f60e01b8152602081600481855afa90811561057357600091611670575b50836115ee575b50506115d8600080516020615b20833981519152936115cc61149d87613985565b604051938493846109c9565b0390a3436115e53361370e565b55610855614887565b6001600160a01b0316803b156103dd57836000916116239383604051809681958294633c37699760e21b8452600484016138ca565b03925af1908161165b575b5061164457637101508d60e11b60005260046000fd5b6115d8600080516020615b208339815191526115ab565b80610870600061166a93611842565b3861162e565b611689915060203d60201161095f576109518183611842565b386115a4565b80610870600061169e93611842565b3861156a565b8061087060006116b393611842565b3861151d565b915093506116df915060803d6080116116ec575b6116d78183611842565b810190613a1f565b9492905090939138611478565b503d6116cd565b63a8a168bf60e01b60005260046000fd5b6003915061171181610498565b141538611425565b61172d91943d8091833e6108b38183611842565b92386113ba565b6358c8679f60e01b60005260046000fd5b63559bd01960e01b60005260046000fd5b61176f915060203d6020116108fa576108ec8183611842565b3861135e565b80610870600061178493611842565b3861131f565b636227817160e01b60005260046000fd5b6117b4915060203d6020116108fa576108ec8183611842565b386112dc565b639cef199b60e01b60005260046000fd5b50655af3107a4000861161125b565b346103dd5760003660031901126103dd576001546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd576004546040516001600160a01b039091168152602090f35b634e487b7160e01b600052604160045260246000fd5b601f909101601f19168101906001600160401b0382119082101761186557604052565b61182c565b6040519061040a61012083611842565b6040519061040a61014083611842565b6001600160401b03811161186557601f01601f191660200190565b9291926118b18261188a565b916118bf6040519384611842565b8294818452818301116103dd578281602093846000960137010152565b60403660031901126103dd576004356118f4816103ee565b6024356001600160401b0381116103dd57366023820112156103dd576119249036906024816004013591016118a5565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115611af5575b50611ae457611966614718565b6119746105d56007546103e2565b6001600160a01b038116156104875760206040518092631052504160e01b825281806119a388600483016128e8565b03915afa60009181611ac3575b50611ab5576119bd613af6565b6308c379a014611a4d575b60405162461bcd60e51b815260206004820152605160248201527f41646d696e2076616c69646174696f6e206661696c65643a20556e6b6e6f776e60448201527f206572726f7220286c696b656c7920726571756972652866616c73652920696e6064820152702076616c6964617465557067726164652960781b608482015260a490fd5b611a55613b14565b80611a6057506119c8565b60405178020b236b4b7103b30b634b230ba34b7b7103330b4b632b21d1603d1b6020820152610a0991611a9d908290611278906039830190615341565b60405162461bcd60e51b815291829160048301612995565b1561088d5761115991615358565b611add91925060203d6020116108fa576108ec8183611842565b90386119b0565b63703e46dd60e11b60005260046000fd5b6000805160206159c0833981519152546001600160a01b03161415905038611959565b346103dd5760003660031901126103dd577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003611ae45760206040516000805160206159c08339815191528152f35b346103dd5760003660031901126103dd57602060ff600080516020615aa083398151915254166040519015158152f35b346103dd5760203660031901126103dd57600854604051630bc926dd60e31b8152600480359082015290602090829060249082906001600160a01b03165afa80156105735761053291600091611c03575b506040519081529081906020820190565b611c1c915060203d602011610f9c57610f8d8183611842565b38611bf2565b346103dd5760c03660031901126103dd576004356024356001600160401b0381116103dd57611c559036906004016111a5565b90916044356001600160401b0381116103dd57611c769036906004016111a5565b93606435939091906001600160401b0385116103dd5761053295611ca1611cb19636906004016111a5565b9390926084359560a43597613b89565b6040519081529081906020820190565b346103dd5760203660031901126103dd5760085460405163667fe26560e01b8152600480359082015290602090829060249082906001600160a01b03165afa80156105735761053291600091610a7d575060405191829182901515815260200190565b346103dd5760003660031901126103dd576005546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd576020604051600080516020615ae08339815191528152f35b61040a909291926101008061012083019580518452602081015160208501526040810151604085015260018060a01b03606082015116606085015264ffffffffff6080820151166080850152611dda60a082015160a086019064ffffffffff169052565b60c08181015161ffff169085015260e08181015164ffffffffff169085015201519101906104b8565b346103dd5760203660031901126103dd57611e526000600435611e24613e48565b50611e326105d583546103e2565b6040518080958194638d34875560e01b8352600483019190602083019252565b03915afa90811561057357600091611f3c575b5080519060208101519060408101516080820151611e82906103e2565b60a083015164ffffffffff1660c084015164ffffffffff169160e0850151611eab9061ffff1690565b93610100860151611ec09064ffffffffff1690565b95610120015196611ed088610498565b611ed861186a565b988952602089015260408801526001600160a01b0316606087015264ffffffffff16608086015264ffffffffff1660a085015261ffff1660c084015264ffffffffff1660e0830152611f2e906101008301613e9d565b604051610532819282611d76565b611f4f913d8091833e6108b38183611842565b38611e65565b346103dd5760006040366003190112611fe95760043581602435611f7761476b565b611f7f61484b565b611f89818461553b565b6003546001600160a01b031692833b15611fe757604490836040519586948593630473e93b60e51b8552600485015260248401525af18015610573578290611fd7575b611fd4614887565b80f35b611fe091611842565b3881611fcc565b825b80fd5b346103dd5760e03660031901126103dd57600435612009816103ee565b60243590612016826103ee565b60443591612023836103ee565b60643561202f816103ee565b6084359161203c836103ee565b60a43591612049836103ee565b60c43594612056866103ee565b61205e6146aa565b61206781615555565b61207083615555565b61207987615555565b61208282615555565b61208b85615555565b61209484615555565b61209d86615555565b6120ab6105d56007546103e2565b91823b156103dd57604051638ffee9cd60e01b81526001600160a01b038381166004830152858116602483015289811660448301528281166064830152878116608483015286811660a4830152881660c482015295928660e4815a6000948591f1918215610573576121959861214f6121799661214161215d946121879b61216b986121c6575b506001600160a01b0316613609565b6001600160a01b031661362b565b6001600160a01b031661364d565b6001600160a01b031661366f565b6001600160a01b0316613691565b6001600160a01b03166136b3565b6001600160a01b03166136d5565b6040516007815233907fc5ec6eb3c84a615de1792ae2858fe498e7c3c8e4986fef4ae3cbf1f8d2c68bca90602090a2005b8061087060006121d593611842565b38612132565b346103dd5760403660031901126103dd57602060ff612220602435600435612202826103ee565b600052600080516020615a6083398151915284526040600020613728565b54166040519015158152f35b346103dd5760203660031901126103dd5760043560046122506105d56008546103e2565b60206122606105d56001546103e2565b60405163696c86cd60e01b815293849182905afa908115610573576122b99360409360009361230f575b5083518095819482936358ca394160e01b84526004840160409060009294936060820195825260208201520152565b03915afa801561057357610532916000916122df57506040519081529081906020820190565b612301915060403d604011612308575b6122f98183611842565b810190613ea9565b5038611bf2565b503d6122ef565b61232991935060203d602011610f9c57610f8d8183611842565b913861228a565b346103dd5760403660031901126103dd576004356001600160401b0381116103dd57806004019061016060031982360301126103dd576024356001600160401b0381116103dd576123859036906004016111a5565b61238d614821565b61239561484b565b8335926123a184615288565b60248101356123af81615288565b6044820135916123be83615288565b6064810135916123cd83615288565b60848201926123ee6123e96123e2868c613ec3565b36916118a5565b615594565b6101048301359485156104875764e8d4a5100086108015612882575b61088d578861241a8b9687613ec3565b60a4870135968960c4820135998a60e48401359a8b92610124860161243e91613ec3565b9690956101440161244e90613f03565b976040519b8c9b60208d019e8f9c6124659d613f0d565b03601f19810182526124779082611842565b519020600c54612486906103e2565b61248f906103e2565b906001600160a01b038216156117ba5760405163b538e81760e01b8152634dc8e23d60e11b6004820152606081602481865afa80156105735787926020928a92612855575b506124f36040519485938493636b80155f60e01b8552600485016139fb565b0381855afa90811561057357600091612836575b501561178a57803b156103dd57604051630e62cc9360e21b815291600091839182908490829061253b908d600484016138e5565b03925af1801561057357612821575b506125596105d56006546103e2565b803b156103dd576000604051809263102d617560e01b825281838161258c60048201906000602060408401938281520152565b03925af180156105735761280c575b506125aa6105d56000546103e2565b604051638d34875560e01b8152600481018790529290600090849060249082905afa928315610573576000936127f1575b50825115610977576125f060808401516103e2565b336001600160a01b03909116036109665761260d6106878761495d565b61087c5760408301918251612766575b50505061012001805161262f81610498565b61263881610498565b15159081612746575b81612726575b81612707575b506126f6576126879360209260006126696105d56002546103e2565b9260405197889586948593634dc8e23d60e11b85526004850161400b565b03925af1918215610573576000926126d5575b50816126bf575b610532826126ad614887565b60405191829182901515815260200190565b6106876126cb9161495d565b61087c57386126a1565b6126ef91925060203d6020116108fa576108ec8183611842565b903861269a565b63e047416960e01b60005260046000fd5b600691505161271581610498565b61271e81610498565b14153861264d565b90506002815161273581610498565b61273e81610498565b141590612647565b90506001815161275581610498565b61275e81610498565b141590612641565b9161277661277e926004946155f4565b905190615684565b602061278e6105d56001546103e2565b60405163100c48d360e21b815293849182905afa918215610573576000926127d0575b50106127bf5738808061261d565b635e31938360e11b60005260046000fd5b6127ea91925060203d602011610f9c57610f8d8183611842565b90386127b1565b61280591933d8091833e6108b38183611842565b91386125db565b80610870600061281b93611842565b3861259b565b80610870600061283093611842565b3861254a565b61284f915060203d6020116108fa576108ec8183611842565b38612507565b6128769060603d60601161287b575b61286e8183611842565b810190613f7b565b6124d4565b503d612864565b50655af3107a4000861161240a565b346103dd5760003660031901126103dd5760206040517f75027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc8152f35b346103dd5760003660031901126103dd57602060405160008152f35b6001600160a01b03909116815260200190565b346103dd5760003660031901126103dd57600b546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd5760206040516000805160206159208339815191528152f35b60005b8381106129605750506000910152565b8181015183820152602001612950565b906020916129898151809281855285808601910161294d565b601f01601f1916010190565b9060206129a6928181520190612970565b90565b346103dd5760003660031901126103dd5761053260408051906129cc8183611842565b60058252640352e302e360dc1b602083015251918291602083526020830190612970565b600811156103dd57565b359061040a826129f0565b346103dd5760403660031901126103dd57602435600435612a25826129f0565b600154612a4990612a42906105d5906001600160a01b03166103e2565b33146140d7565b612a54811515614136565b612a626105d56000546103e2565b91823b156103dd57612a8e9260009283604051809681958294637f15208d60e01b84526004840161393b565b03925af1801561057357612a9e57005b80610870600061115993611842565b346103dd576101403660031901126103dd57611159600435612ace816103ee565b602435612ada816103ee565b604435612ae6816103ee565b606435612af2816103ee565b608435612afe816103ee565b60a43590612b0b826103ee565b60c43592612b18846103ee565b60e43594612b25866103ee565b6101043596612b33886103ee565b6101243598612b418a6103ee565b614178565b9080601f830112156103dd578160206129a6933591016118a5565b64ffffffffff8116036103dd57565b359061040a82612b61565b61ffff8116036103dd57565b359061040a82612b7b565b9094939260609260808301968352602083015260408201520152565b346103dd5760603660031901126103dd576004356001600160401b0381116103dd5761014060031982360301126103dd57612be761187a565b6004820135815260248201356020820152604482013560408201526064820135906001600160401b0382116103dd57612c9561012461053294612c33612ca79560043691840101612b46565b6060850152612c44608482016103ff565b6080850152612c5560a48201612b70565b60a0850152612c6660c48201612b70565b60c0850152612c7760e48201612b87565b60e0850152612c896101048201612b70565b610100850152016129fa565b61012082015260243560443591614483565b9060409492945194859485612b92565b346103dd5760203660031901126103dd57600435612cd36146aa565b612cdc81615288565b806000526009602052604060002060ff19815416905533907f81a106317e7bcc4bb0d00469e38615879068b044d72620ca9aec13ad478ccb6c600080a3005b346103dd5760403660031901126103dd57611159602435600435612d3e826103ee565b612d4a61114f82613995565b6151f9565b346103dd5760003660031901126103dd576008546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd576002546040516001600160a01b039091168152602090f35b346103dd5760203660031901126103dd57600435612dbe816103ee565b612dc66146aa565b6001600160a01b0316801561048757600c80546001600160a01b031916919091179055005b60609060031901126103dd57600435906024359060443590565b346103dd57612e1336612deb565b919060018060a01b03612e2a6105d56001546103e2565b1680156104875733036130f557612e456105d56000546103e2565b92612e4f846103e2565b1561048757604051638d34875560e01b815260048101849052600081602481885afa908115610573576000916130dc575b50805115610977576001600160801b03831161088d5764ffffffffff821161088d5760c081015164ffffffffff1694803b156103dd576000604051809263fa5fa16360e01b8252818381612ed88a8c600484016138e5565b03925af18015610573576130c7575b5082158015906130ba575b612f8b575b50506000612f2c92612f0c6105d583546103e2565b6040518080968194638d34875560e01b8352600483019190602083019252565b03915afa91821561057357600092612f6e575b5060408201510361088d5764ffffffffff612f6360c08293015164ffffffffff1690565b921691161061088d57005b612f849192503d806000833e6108b38183611842565b9038612f3f565b60408101511561304f575b6101209150018051612fa781610498565b612fb081610498565b15908115613031575b50612fc6575b3880612ef7565b612fd46105d56000546103e2565b91823b156103dd5760006040518094637f15208d60e01b8252818381612ffd876004830161390d565b03925af190811561057357612f2c9360009261301d575b50925050612fbf565b806108708461302b93611842565b38613014565b600191505161303f81610498565b61304881610498565b1438612fb9565b61305d6105d56000546103e2565b803b156103dd576040516390da939b60e01b815292600091849182908490829061308b908b600484016138e5565b03925af191821561057357610120926130a5575b50612f96565b8061087060006130b493611842565b3861309f565b5060408101511515612ef2565b8061087060006130d693611842565b38612ee7565b6130ef913d8091833e6108b38183611842565b38612e80565b63ea8e4eb560e01b60005260046000fd5b346103dd5760403660031901126103dd5760243560043561312561484b565b6131336105d56000546103e2565b604051638d34875560e01b81526004810183905290600090829060249082905afa908115610573576131729160809160009161325e575b5001516103e2565b336001600160a01b0390911603610966576131916105d56001546103e2565b9060206040518093631cce4db560e31b8252816000816131b58988600484016138e5565b03925af19182156105735760009261323d575b50816131da57610532826126ad614887565b6131e86105d56000546103e2565b92833b156103dd57613214936000928360405180978195829463fa5fa16360e01b8452600484016138e5565b03925af19182156105735761053292156126a15780610870600061323793611842565b386126a1565b61325791925060203d6020116108fa576108ec8183611842565b90386131c8565b61327391503d806000833e6108b38183611842565b3861316a565b346103dd576132bb602061328c36612deb565b60085460405163e7f9caa560e01b81529586946001600160a01b039092169385938493909190600485016109c9565b03915afa908115610573576000916132dc575b506040519015158152602090f35b6132f5915060203d6020116108fa576108ec8183611842565b386132ce565b346103dd5760203660031901126103dd5760043561331761476b565b61331f61484b565b61332761489b565b61333081615288565b61333e6105d56003546103e2565b604051633abddd8b60e21b81526004810183905290602090829081600081602481015b03925af1908115610573576000916133f9575b508061338f575b61053290613387614918565b6126ad614887565b61339d6105d56000546103e2565b803b156103dd57604051637f15208d60e01b81529260009184918290849082906133ca9060048301613924565b03925af191821561057357610532926133e4575b5061337b565b8061087060006133f393611842565b386133de565b613412915060203d6020116108fa576108ec8183611842565b38613374565b346103dd5760003660031901126103dd576020604051600080516020615a808339815191528152f35b346103dd5760203660031901126103dd5760405160c081016001600160401b038111828210176118655760009160a091604052828152826020820152826040820152826060820152826080820152015260405162461bcd60e51b815280610a0960048201613951565b346103dd5760003660031901126103dd576003546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd576000546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd576007546040516001600160a01b039091168152602090f35b346103dd5760003660031901126103dd57600c546040516001600160a01b039091168152602090f35b346103dd5761355c36612deb565b9061356561476b565b61356d61484b565b61357561489b565b82156135b057613361916020916135906105d56003546103e2565b906000604051809681958294631faa4a4760e31b84528a600485016109c9565b637bb0b62160e01b60005260046000fd5b346103dd5760003660031901126103dd5761053260408051906135e48183611842565b60068252650312e302e31360d41b602083015251918291602083526020830190612970565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b519061040a826129f0565b6040513d6000823e3d90fd5b6001600160a01b03166000908152600a6020526040902090565b9060018060a01b0316600052602052604060002090565b81601f820112156103dd5780516137558161188a565b926137636040519485611842565b818452602082840101116103dd576129a6916020808501910161294d565b519061040a826103ee565b519061040a82612b61565b519061040a82612b7b565b6020818303126103dd578051906001600160401b0382116103dd5701610140818303126103dd576137d161187a565b9181518352602082015160208401526040820151604084015260608201519160018060401b0383116103dd5761380f6101209261387194830161373f565b606085015261382060808201613781565b608085015261383160a0820161378c565b60a085015261384260c0820161378c565b60c085015261385360e08201613797565b60e0850152613865610100820161378c565b610100850152016136f7565b61012082015290565b908160209103126103dd57516129a6816103ee565b519081151582036103dd57565b908160209103126103dd576129a69061388f565b6001600160a01b0390911681526000602082015260400190565b6001600160a01b039091168152602081019190915260400190565b908152602081019190915260400190565b90815260408101919061040a9060200160066104b8565b90815260408101919061040a9060200160026104b8565b90815260408101919061040a9060200160056104b8565b90815260408101929161040a91602001906104b8565b60609060208152600a60208201526919195c1c9958d85d195960b21b60408201520190565b908160209103126103dd575190565b6000526009602052604060002090565b600052600080516020615a6083398151915260205260016040600020015490565b908060209392818452848401376000828201840152601f01601f1916010190565b6060906129a6949263389b0b9b60e01b8252602082015281604082015201916139b6565b6060906129a69492634dc8e23d60e11b8252602082015281604082015201916139b6565b91908260809103126103dd578151916020810151916060604083015192015190565b604091949392946060825280516060830152602081015160808301528281015160a0830152613aec610120613a87606084015161014060c08701526101a0860190612970565b60808401516001600160a01b031660e08601529260a081015164ffffffffff1661010086015260c081015164ffffffffff168583015260e081015161ffff1661014086015261010081015164ffffffffff1661016086015201516101808401906104b8565b9460208201520152565b60009060033d11613b0357565b905060046000803e60005160e01c90565b600060443d106129a6576040513d600319016004823e8051916001600160401b0383113d602485011117613b83578183018051909390916001600160401b038311613b7b573d84016003190185840160200111613b7b57506129a692910160200190611842565b949350505050565b92915050565b95969794929793909193613b9b61484b565b613ba3614821565b33600052600a6020526040600020544311156109b857613bda81613bc83688876118a5565b613bd336868e6118a5565b908a615494565b801561174557613bee6105d56004546103e2565b604051634977ff8b60e11b81526004810183905290602090829060249082905afa90811561057357600091613d8e575b501561174557613c326105d56000546103e2565b604051631e1778ad60e11b8152600481018990529096906020816024818b5afa90811561057357600091613d6f575b50613d5e57613c71600b546103e2565b6001600160a01b0381161561048757868b868b613cb68e8b8a613c986105d560209a6103e2565b966040519a8b998a98899863728e8bbb60e01b8a5260048a01613dad565b03915afa90811561057357600091613d3f575b501561088d57602097600094613cf8936040519b8c9a8b998a986306f4597160e21b8a52339260048b01613df3565b03925af190811561057357600091613d20575b5043613d163361370e565b559061040a614887565b613d39915060203d602011610f9c57610f8d8183611842565b38613d0b565b613d58915060203d6020116108fa576108ec8183611842565b38613cc9565b630dd1bc8b60e31b60005260046000fd5b613d88915060203d602011610f9c57610f8d8183611842565b38613c61565b613da7915060203d6020116108fa576108ec8183611842565b38613c1e565b9694906129a6989692613de59594613dd2928a5260a060208b015260a08a01916139b6565b92604088015286830360608801526139b6565b9260808185039101526139b6565b999897939194613e1b60a09896613e359560c08e613e439b96815281602082015201916139b6565b926001808a1b031660408c01528a830360608c01526139b6565b9187830360808901526139b6565b930152565b6040519061012082016001600160401b03811183821017611865576040526000610100838281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201520152565b60088210156104a25752565b91908260409103126103dd576129a660208351930161388f565b903590601e19813603018212156103dd57018035906001600160401b0382116103dd576020019181360383136103dd57565b63ffffffff8116036103dd57565b356129a681613ef5565b9b969792956101609d9e9d60808e613f749c976101409f9a63ffffffff9f9a9697613f5098845260208401526040830152606082015201526101608d01916139b6565b9560a08b015260c08a015260e08901526101008801528683036101208801526139b6565b9416910152565b908160609103126103dd5760405190606082016001600160401b0381118382101761186557613fc69160409182528051613fb4816103ee565b8452602081015160208501520161388f565b604082015290565b9035601e19823603018112156103dd570160208101919035906001600160401b0382116103dd5781360383136103dd57565b359061040a82613ef5565b916129a693919260408152833560408201526020840135606082015260408401356080820152606084013560a08201526140ca6140bc6101406140b561406a61405760808a018a613fce565b61016060c08901526101a08801916139b6565b60a089013560e087015260c089013561010087015260e0890135610120870152610100890135838701526140a26101208a018a613fce565b878303603f1901610160890152906139b6565b9601614000565b63ffffffff16610180830152565b60208185039101526139b6565b156140de57565b60405162461bcd60e51b815260206004820152602a60248201527f4f6e6c79206c6f616e206f7065726174696f6e73206d616e616765722063616e6044820152692063616c6c207468697360b01b6064820152608490fd5b1561413d57565b60405162461bcd60e51b8152602060048201526013602482015272125b9d985b1a59081c1bdcda5d1a5bdb881251606a1b6044820152606490fd5b97959391989694929098600080516020615b0083398151915254996141a360ff8c60401c1615151590565b9a6001600160401b031680159081614293575b6001149081614289575b159081614280575b5061426f57600080516020615b0083398151915280546001600160401b03191660011790556141fb998b61424a5761429b565b61420157565b600080516020615b00833981519152805460ff60401b19169055604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1565b600080516020615b00833981519152805460ff60401b1916600160401b17905561429b565b63f92ee8a960e01b60005260046000fd5b905015386141c8565b303b1591506141c0565b8c91506141b6565b989793929896919094966142ad6157f7565b6142b561570f565b6142bd6157f7565b6142c56157f7565b6142cd615825565b6001600160a01b0316948515610487576001600160a01b0316908115610487576001600160a01b0316988915610487576001600160a01b0316928315610487576001600160a01b0316968715610487576001600160a01b0316958615610487576001600160a01b0316918215610487576001600160a01b0316938415610487576001600160a01b0316958615610487576001600160a01b03891615610487576143a86143f6986143a36143b29661439e6144239e6143996143ad986143946143d49e613609565b61362b565b61364d565b61366f565b613691565b6136b3565b6136d5565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6143ff81614de6565b5061440981614e7f565b5061441381614f3c565b5061441d81614ff9565b506150b6565b50565b51906001600160581b03821682036103dd57565b91908260409103126103dd576129a6602061445484614426565b9301614426565b634e487b7160e01b600052601160045260246000fd5b9190820180921161447e57565b61445b565b90923033036130f557600261012083015161449d81610498565b6144a681610498565b1461467c575b6144ba6105d56004546103e2565b604080516353f366c760e01b81526004810187905291829060249082905afa9081156105735760009161464b575b506040830180519091614506916001600160581b039091169061571f565b94614525614515878451615791565b9561452087826157b6565b6155c3565b91516145356105d56001546103e2565b60405163100c48d360e21b81529091602082600481865afa908115610573576145679260009261462a575b50856157db565b6146195760206004916040519283809263100c48d360e21b82525afa80156105735761459d916000916145fa575b5086846157db565b6145e9576145c76145c060e06145b6886145cc96615684565b96015161ffff1690565b61ffff1690565b614471565b9061ffff82116145d857565b6319a4c60960e21b60005260046000fd5b631300e8bd60e21b60005260046000fd5b614613915060203d602011610f9c57610f8d8183611842565b38614595565b63e5cace4160e01b60005260046000fd5b61464491925060203d602011610f9c57610f8d8183611842565b9038614560565b61466d915060403d604011614675575b6146658183611842565b81019061443a565b9050386144e8565b503d61465b565b6146926113ed61010084015164ffffffffff1690565b4211156144ac5763088502f160e21b60005260046000fd5b600080516020615ae0833981519152600052600080516020615a6083398151915260205260ff6146e833600080516020615960833981519152613728565b5416156146f157565b63e2517d3f60e01b60005233600452600080516020615ae083398151915260245260446000fd5b60008052600080516020615a6083398151915260205260ff614748336000805160206159a0833981519152613728565b54161561475157565b63e2517d3f60e01b60005233600452600060245260446000fd5b600080516020615900833981519152600052600080516020615a6083398151915260205260ff6147a933600080516020615a20833981519152613728565b5416156147b257565b63e2517d3f60e01b6000523360045260008051602061590083398151915260245260446000fd5b80600052600080516020615a6083398151915260205260ff6147ff336040600020613728565b5416156148095750565b63e2517d3f60e01b6000523360045260245260446000fd5b60ff600080516020615aa0833981519152541661483a57565b63d93c066560e01b60005260046000fd5b6002600080516020615ac08339815191525414614876576002600080516020615ac083398151915255565b633ee5aeb560e01b60005260046000fd5b6001600080516020615ac083398151915255565b600260008051602061594083398151915254146148c657600260008051602061594083398151915255565b60405162461bcd60e51b8152602060048201526024808201527f476c6f62616c5265656e7472616e637947756172643a207265656e7472616e746044820152640818d85b1b60da1b6064820152608490fd5b600160008051602061594083398151915255565b61493590615288565b801561493e5750565b6346f4384b60e01b600052600452600160245260001960445260646000fd5b61496b6105d56000546103e2565b604051638d34875560e01b81526004810183905290600090829060249082905afa90811561057357600091614afc575b5081815103614a5257608001516001600160a01b03906149ba906103e2565b16156149c65750600190565b600080516020615a4083398151915260405180614a3e4282919060608352601060608401526f34b73b30b634b22fb137b93937bbb2b960811b608084015260a06020840152601860a084015277426f72726f7765722061646472657373206973207a65726f60401b60c0840152604060e08401930152565b0390a263e6c4247b60e01b60005260046000fd5b50600080516020615a4083398151915260405180614ae8428291906060835260146060840152730e0dee6d2e8d2dedcbed2c8bedad2e6dac2e8c6d60631b608084015260a06020840152602a60a08401527f506f736974696f6e20494420646f6573206e6f74206d617463682073746f726560c08401526932103837b9b4ba34b7b760b11b60e084015260406101008401930152565b0390a2630a0b0d7960e01b60005260046000fd5b614b1191503d806000833e6108b38183611842565b3861499b565b6040516323b872dd60e01b60208083019182526001600160a01b0394851660248401529490931660448201526064808201959095529384529260009190614b5f608482611842565b519082855af115613702576000513d614ba857506001600160a01b0381163b155b614b875750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614b80565b9190911561413d578115614c65575115614c26571015614bcd57565b60405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7420616d6f756e74206d757374206265206c657373207468616e60448201526a081d1bdd185b081919589d60aa1b6064820152608490fd5b60405162461bcd60e51b8152602060048201526017602482015276141bdcda5d1a5bdb88191bd95cc81b9bdd08195e1a5cdd604a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152602860248201527f5061796d656e7420616d6f756e74206d7573742062652067726561746572207460448201526768616e207a65726f60c01b6064820152608490fd5b614cc481610498565b60018114159081614d6c575b81614d56575b81614d41575b50614ce357565b60405162461bcd60e51b815260206004820152603060248201527f506f736974696f6e20737461747573206e6f7420656c696769626c6520666f7260448201526f081c185c9d1a585b081c185e5b595b9d60821b6064820152608490fd5b60049150614d4e81610498565b141538614cdc565b9050614d6181610498565b600381141590614cd6565b9050614d7781610498565b600281141590614cd0565b929190830392831161447e5782614d9d6129a69260006155f4565b615684565b9392909160009260009560088110156104a257600414614dcf575b505015614dc8579190565b9150600190565b1015614ddd575b3880614dbd565b60019150614dd6565b60008052600080516020615a6083398151915260205260ff614e16826000805160206159a0833981519152613728565b5416614e795760008052600080516020615a60833981519152602052614e4a816000805160206159a0833981519152613728565b805460ff1916600117905533906001600160a01b031660006000805160206158e08339815191528180a4600190565b50600090565b600080516020615900833981519152600052600080516020615a6083398151915260205260ff614ebd82600080516020615a20833981519152613728565b5416614e7957600080516020615900833981519152600052600080516020615a60833981519152602052614eff81600080516020615a20833981519152613728565b805460ff1916600117905533906001600160a01b03166000805160206159008339815191526000805160206158e0833981519152600080a4600190565b600080516020615ae0833981519152600052600080516020615a6083398151915260205260ff614f7a82600080516020615960833981519152613728565b5416614e7957600080516020615ae0833981519152600052600080516020615a60833981519152602052614fbc81600080516020615960833981519152613728565b805460ff1916600117905533906001600160a01b0316600080516020615ae08339815191526000805160206158e0833981519152600080a4600190565b600080516020615a80833981519152600052600080516020615a6083398151915260205260ff61503782600080516020615a00833981519152613728565b5416614e7957600080516020615a80833981519152600052600080516020615a6083398151915260205261507981600080516020615a00833981519152613728565b805460ff1916600117905533906001600160a01b0316600080516020615a808339815191526000805160206158e0833981519152600080a4600190565b600080516020615920833981519152600052600080516020615a6083398151915260205260ff6150f482600080516020615980833981519152613728565b5416614e7957600080516020615920833981519152600052600080516020615a6083398151915260205261513681600080516020615980833981519152613728565b805460ff1916600117905533906001600160a01b03166000805160206159208339815191526000805160206158e0833981519152600080a4600190565b80600052600080516020615a6083398151915260205260ff615199836040600020613728565b54166151f25780600052600080516020615a608339815191526020526151c3826040600020613728565b805460ff1916600117905533916001600160a01b0316906000805160206158e0833981519152600080a4600190565b5050600090565b80600052600080516020615a6083398151915260205260ff61521f836040600020613728565b5416156151f25780600052600080516020615a6083398151915260205261524a826040600020613728565b805460ff1916905533916001600160a01b0316907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a4600190565b1561528f57565b6379ec0ed760e11b60005260046000fd5b6001811080156152d0575b6152b25750565b6304a45adb60e51b6000526004526001602452603c60445260646000fd5b50603c81116152ab565b9060648202918083046064149015171561447e57565b8181029291811591840414171561447e57565b90600c811461532f5762278d0081029080820462278d00149015171561447e57810180911161447e5790565b506301e13380810180911161447e5790565b906153546020928281519485920161294d565b0190565b6040516352d1902d60e01b81529091906020816004816001600160a01b0387165afa60009181615473575b506153a657634c9c8ce360e01b6000526001600160a01b03831660045260246000fd5b6000805160206159c0833981519152810361545f5750813b1561543d576000805160206159c083398151915280546001600160a01b0319166001600160a01b0384169081179091557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115615423576144239161583c565b50503461542c57565b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60009081526001600160a01b0391909116600452602490fd5b632a87526960e21b60005260045260246000fd5b61548d91925060203d602011610f9c57610f8d8183611842565b9038615383565b61549d90615288565b8051156155035760409051106154c7576154b690615594565b806154be5750565b61040a906152a0565b60405163df70480560e01b815260206004820152601360248201527214da59db985d1d5c99481d1bdbc81cda1bdc9d606a1b6044820152606490fd5b60405163df70480560e01b815260206004820152600f60248201526e456d707479207369676e617475726560881b6044820152606490fd5b61554490615288565b8061554c5750565b61040a90615288565b6001600160a01b038116908115615583573b1561556f5750565b630fb15bad60e11b60005260045260246000fd5b63d92e233d60e01b60005260046000fd5b80511561559e5750565b60405163df70480560e01b815260206004820152908190610a09906024830190612970565b6a084595161401484a00000081116155e357156001171561447e57600090565b63128df78360e01b60005260046000fd5b660775f05a0740008111615673576a084595161401484a00000082116155e357801580159081615647575b50615636576129a691615631916152f0565b6152da565b63450d49cd60e01b60005260046000fd5b905061565d57606481600019040482113861561f565b634e487b7160e01b600052601260045260246000fd5b63e9ec682160e01b60005260046000fd5b81156156fe5768327cb2734119d3b7a9601e1b81116156ed577e068db8bac710cb295e9e1b089a027525460aa64c2f837b4a2339c0ebedfa4381116156dc57612710810290808204612710149015171561447e570490565b633da428df60e21b60005260046000fd5b638a94304d60e01b60005260046000fd5b6323d359a360e01b60005260046000fd5b6157176157f7565b6148876157f7565b68327cb2734119d3b7a9601e1b81116156ed5761271082116157805780158015908161576d575b5061575c5761271091615758916152f0565b0490565b6340c0d6e560e11b60005260046000fd5b905061565d578060001904821138615746565b637186728f60e11b60005260046000fd5b9081019081811161447e5781106157a55790565b636be580af60e11b60005260046000fd5b6a084595161401484a000000106155e35768327cb2734119d3b7a9601e1b106156ed57565b9080156157ef576157eb91615684565b1090565b505050600090565b60ff600080516020615b008339815191525460401c161561581457565b631afcd79f60e31b60005260046000fd5b600080516020615940833981519152541561491857565b6000806129a693602081519101845af43d1561587a573d9161585d8361188a565b9261586b6040519485611842565b83523d6000602085013e61587e565b6060915b906158a4575080511561589357602081519101fd5b63d6bda27560e01b60005260046000fd5b815115806158d6575b6158b5575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b156158ad56fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5e17fc5225d4a099df75359ce1f405503ca79498a8dc46a7d583235a0ee45c16f4a222f146e17d7057e96450fc67f08ce8569fd5cf3b62a23983c4f4b9e497f35cd165352ca420415a2423a5a15f077145431fc21aec9b84cb1b8800541a5c26b16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c1b3eac282bb4080c159156c6faa9df237c5a80b4a568c4661ea2010de1eb2caeb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6bf041ce7315b71466c179f7fc4077ed77a42f41efde0131e3efff105022d90ecd6c996ba66d0dbb3c38dbaaac7d192f7d41593dd02b55a9147053192322b1d3b615dc3ea5d9654acb949989a0a9587a0da8cd03451c0368cc676ec7c08dd814fe150c42386d13e75f861a07555c8c65c8c90c810c4da557e735871a287ec51c02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268004ad5455c7a5edb25c14b61cc4d6429153aab5507800334ac05d65e9828801bf3cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00aaae1071a267a66db1d9c0714498307791bc0f693f5b254c861d95ca60503b6da2646970667358221220d2f7f06cd861c383ad08fa87abbc1d38c7b875bcb50757ad808653144887c86064736f6c634300081c0033";
38775
+ var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b604051615d5490816100f082396080518181816115dd01526117ed0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b60003560e01c8063018af3091461037757806301ffc9a714610372578063043fe8fc1461036d57806309d2b0ae1461036857806316d8887a1461036357806316efd9411461035e5780631732d33014610359578063248a9ca3146103545780632f2ff15d1461034f57806336568abe1461034a578063393d92cc1461034557806344c8b85214610340578063487c02b41461033b5780634a54e00a146103365780634f1ef2861461033157806352d1902d1461032c578063544ba5af146103275780635c975abb146103225780635e4936e81461031d5780636068b5d11461031857806363ba8cec146103135780636a89edad1461030e5780636b80155f1461030957806374cb36e61461030457806375b238fc146102ff5780638179dc38146102fa5780638ffee9cd146102f557806391d14854146102f05780639b9d30c1146102eb578063a217fddf146102e6578063a9a52888146102e1578063a9eadc52146102dc578063aa4fec70146102d7578063ad3cb1cc146102d2578063b1517664146102cd578063c12e1291146102c8578063c306b378146102c3578063d0e8ce82146102be578063d547741f146102b9578063d65e880d146102b4578063d6810242146102af578063d7d9f4b0146102aa578063d8dfeb45146102a5578063d9cb25a2146102a0578063dc5632531461029b578063dd74ac7a14610296578063ddccaa3a14610291578063e7f9caa51461028c578063f005e76714610287578063f2dfbf6614610282578063f2f4eb261461027d578063f851a44014610278578063fb7c6a0f146102735763ffa1ad741461026e57600080fd5b612fe7565b612fbe565b612f95565b612f6c565b612f43565b612f1a565b612e98565b612b67565b612b1c565b6129ca565b6128c6565b61289d565b612708565b61266f565b612646565b612612565b6125ae565b612515565b61246d565b61240c565b6123c5565b61238b565b612362565b61230e565b6122f2565b6122b7565b612266565b612077565b611f6a565b611ec1565b611e98565b611de0565b611ca0565b611b1e565b611a44565b6119e3565b6119b3565b611833565b6117da565b61158b565b6114b2565b6111a1565b611120565b6110f7565b6110ad565b611072565b61104c565b611011565b610fe8565b610fbf565b610ab9565b610a2d565b6109b0565b6103ae565b9181601f840112156103a9578235916001600160401b0383116103a957602083818601950101116103a957565b600080fd5b346103a95760c03660031901126103a95760843560043560243560643560443560a4356001600160401b0381116103a9576103ed90369060040161037c565b91906103f761429d565b6103ff6142c7565b33600052600a6020526040600020544311156109885761045292869161042483614317565b61042d8661432f565b6104398487898661438a565b610444600c54610a03565b61044d816143a4565b6143c5565b610465610460600454610a03565b610a03565b604051634977ff8b60e11b81526004810184905290602090829060249082905afa90811561085057600091610959575b5015610948576104ae6104a784613084565b5460ff1690565b610937576104c0610460600054610a03565b604051638d34875560e01b81526004810185905290600090829060249082905afa90811561085057600091610916575b506104fe6080820151610a03565b906101208101519561050f87612910565b61052e61052460a084015164ffffffffff1690565b64ffffffffff1690565b92825115610905576001600160a01b0316963388036108f45761055081612910565b600281141590816108df575b506108ce57816105b8869261058460206080960151828b61057e600154610a03565b9261461a565b61059d6105908a613084565b805460ff19166001179055565b60405163102f3b8760e31b81529687948594600486016131fc565b0381305afa600081600094600093610894575b5061062457856105d96132b8565b6308c379a01461060b575b6105f06105fa91613084565b805460ff19169055565b633a4f184b60e11b60005260046000fd5b6106136132d6565b156105e4576105f06105fa91613084565b92610633610460600054610a03565b803b156103a95760405163fa5fa16360e01b8152916000918391829084908290610661908d6004840161334b565b03925af180156108505761087f575b5061067f610460600054610a03565b91823b156103a95760006040518094630d7ad17360e41b82528183816106a9888d6004840161334b565b03925af1928315610850576106c39361086a575b50614754565b916106d2610460600054610a03565b803b156103a9576000604051809263b222bec960e01b82528183816106fb8a8c6004840161334b565b03925af1801561085057610855575b50610719610460600154610a03565b60405163b1d3354f60e01b8152602081600481855afa90811561085057600091610821575b5083610799575b5050610772600080516020615cff833981519152936107666105f087613084565b6040519384938461338c565b0390a34361077f3361302f565b55610788614303565b6040516001815280602081015b0390f35b6001600160a01b0316803b156103a957836000916107ce9383604051809681958294633c37699760e21b845260048401613371565b03925af19081610806575b506107ef57637101508d60e11b60005260046000fd5b610772600080516020615cff833981519152610745565b80610815600061081b936114f1565b80610fb4565b386107d9565b610843915060203d602011610849575b61083b81836114f1565b81019061335c565b3861073e565b503d610831565b613078565b806108156000610864936114f1565b3861070a565b806108156000610879936114f1565b386106bd565b80610815600061088e936114f1565b38610670565b915093506108ba915060803d6080116108c7575b6108b281836114f1565b8101906131da565b94929050909391386105cb565b503d6108a8565b63a8a168bf60e01b60005260046000fd5b600391506108ec81612910565b14153861055c565b631963d1e760e31b60005260046000fd5b636ec9be1160e01b60005260046000fd5b610931913d8091833e61092981836114f1565b810190613102565b386104f0565b6358c8679f60e01b60005260046000fd5b63559bd01960e01b60005260046000fd5b61097b915060203d602011610981575b61097381836114f1565b810190613060565b38610495565b503d610969565b633b53d1db60e01b60005260046000fd5b600435906001600160e01b0319821682036103a957565b346103a95760203660031901126103a95760206001600160e01b03196109d4610999565b16637965db0b60e01b81149081156109f2575b506040519015158152f35b6301ffc9a760e01b149050386109e7565b6001600160a01b031690565b6001600160a01b038116036103a957565b3590610a2b82610a0f565b565b346103a95760203660031901126103a957600435610a4a81610a0f565b610a52614792565b6001600160a01b03168015610aa857600b80546001600160a01b0319811683179091553391906001600160a01b03167f440ec6c0da0791f6d650579df27149ce4ffc4f4fbf63e9a8bcd45dacdbf338a2600080a4005b63e6c4247b60e01b60005260046000fd5b346103a95760a03660031901126103a9576024356004356044356064356084356001600160401b0381116103a957610af590369060040161037c565b610afd61429d565b610b056142c7565b610b0d614909565b610b1b610460600654610a03565b803b156103a95760405163102d617560e01b81526004810188905260006024820181905290918290604490829084905af1801561085057610f9f575b50610b618361432f565b8315610f8e57848491610b9393610b7a8987868661438a565b610b85600c54610a03565b610b8e816143a4565b614492565b610ba1610460600054610a03565b604051638d34875560e01b81526004810185905290600090829060249082905afa90811561085057600091610f75575b50610bdf6080820151610a03565b61012082015190610bef82612910565b610c0060408401518094898961499a565b610c10610c0c87614a99565b1590565b908115610f61575b50610f5057610c2690614b28565b60046020610c38610460600154610a03565b60405163023b2a9f60e31b815292839182905afa90811561085057600091610f31575b506040516370a0823160e01b81526001600160a01b0391909116929060208180610c88336004830161234f565b0381875afa8015610850578791600091610f12575b50108015610ea9575b610e9857600492610cb987303384614bef565b6020610cc9610460600154610a03565b60405163b1d3354f60e01b815295869182905afa93841561085057600094610e77575b5060405163095ea7b360e01b81526001600160a01b03851660048201526000602482015290602082806044810103816000855af190811561085057610d54956020938a93610e5c575b50600060405180988195829463095ea7b360e01b845260048401613371565b03925af19283156108505786602093610d7692610da696610e41575b506134b5565b93610d85610460600154610a03565b9060006040518096819582946322de8a2d60e01b84528c8c60048601611f4e565b03925af190811561085057600091610e22575b5015610e1157610df27f58c8fcf57870633c97de2da7d6e74c7544b530d15779c0d107edd9933747ec519160405191829133968361334b565b0390a3610dfd614986565b610e05614303565b60405160018152602090f35b63d0806ec760e01b60005260046000fd5b610e3b915060203d6020116109815761097381836114f1565b38610db9565b610e5790863d88116109815761097381836114f1565b610d70565b610e7290853d87116109815761097381836114f1565b610d35565b610e9191945060203d6020116108495761083b81836114f1565b9238610cec565b631e9acf1760e31b60005260046000fd5b50604051636eb1769f60e11b8152336004820152306024820152602081604481875afa8015610850578791600091610ee3575b5010610ca6565b610f05915060203d602011610f0b575b610efd81836114f1565b810190613490565b38610edc565b503d610ef3565b610f2b915060203d602011610f0b57610efd81836114f1565b38610c9d565b610f4a915060203d6020116108495761083b81836114f1565b38610c5b565b6334b110b160e11b60005260046000fd5b6001600160a01b0316331415905038610c18565b610f88913d8091833e61092981836114f1565b38610bd1565b630a0b0d7960e01b60005260046000fd5b806108156000610fae936114f1565b38610b57565b60009103126103a957565b346103a95760003660031901126103a9576020604051600080516020615b1f8339815191528152f35b346103a95760003660031901126103a9576006546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a95760206040517f9792fdc19ab98adfa72ab2fa98d342618c661e01c406979c105b31eda87f5e6f8152f35b346103a95760203660031901126103a957602061106a6004356134c7565b604051908152f35b346103a95760403660031901126103a9576110ab60243560043561109582610a0f565b6110a66110a1826134c7565b6148c1565b615016565b005b346103a95760403660031901126103a9576004356024356110cd81610a0f565b336001600160a01b038216036110e6576110ab9161509c565b63334bd91960e11b60005260046000fd5b346103a95760003660031901126103a9576001546040516001600160a01b039091168152602090f35b346103a95760203660031901126103a957600054604051631e1778ad60e11b8152600480359082015290602090829060249082906001600160a01b03165afa80156108505761079591600091611182575b506040519081529081906020820190565b61119b915060203d602011610f0b57610efd81836114f1565b38611171565b346103a95760403660031901126103a9576004356001600160401b0381116103a9578060040161018060031983360301126103a9576024356001600160401b0381116103a9576111f590369060040161037c565b6111fd61429d565b6112056142c7565b82359261121184614317565b61121e6024860135614317565b61122b6044860135614317565b6112386064860135614317565b61125761125261124b60a48801846134e8565b3691611554565b61512b565b610124850135926112678461432f565b611297611273836151d0565b868584611281600c54610a03565b9361128b856143a4565b6101048c0135946144ca565b6112a5610460600654610a03565b803b156103a9576000604051809263102d617560e01b82528183816112d860048201906000602060408401938281520152565b03925af180156108505761149d575b506112f6610460600054610a03565b604051638d34875560e01b8152600481018790529490600090869060249082905afa94851561085057600095611482575b508451156109055761133c6080860151610a03565b336001600160a01b03909116036108f457611359610c0c87614a99565b610f505760e46004970135604086015195602061137a610460600154610a03565b60405163100c48d360e21b81529a8b9182905afa988915610850576113f4996020986113c695610120956113b694600094611463575b50615262565b01516113c181612910565b61529b565b60006113d6610460600254610a03565b926040519788958694859363121f00ad60e21b855260048501613586565b03925af191821561085057600092611442575b508161142c575b6107958261141a614303565b60405191829182901515815260200190565b610c0c61143891614a99565b610f50573861140e565b61145c91925060203d6020116109815761097381836114f1565b9038611407565b61147b9194508c3d8e11610f0b57610efd81836114f1565b92386113b0565b61149691953d8091833e61092981836114f1565b9338611327565b8061081560006114ac936114f1565b386112e7565b346103a95760003660031901126103a9576004546040516001600160a01b039091168152602090f35b634e487b7160e01b600052604160045260246000fd5b601f909101601f19168101906001600160401b0382119082101761151457604052565b6114db565b60405190610a2b610140836114f1565b60405190610a2b610120836114f1565b6001600160401b03811161151457601f01601f191660200190565b92919261156082611539565b9161156e60405193846114f1565b8294818452818301116103a9578281602093846000960137010152565b60403660031901126103a9576004356115a381610a0f565b6024356001600160401b0381116103a957366023820112156103a9576115d3903690602481600401359101611554565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163081149081156117b7575b506117a657611615614800565b611623610460600754610a03565b6001600160a01b03811615610aa85760206040518092631052504160e01b82528180611652886004830161234f565b03915afa60009181611785575b506117775761166c6132b8565b6308c379a014611701575b60405162461bcd60e51b815260206004820152605160248201527f41646d696e2076616c69646174696f6e206661696c65643a20556e6b6e6f776e60448201527f206572726f7220286c696b656c7920726571756972652866616c73652920696e6064820152702076616c6964617465557067726164652960781b60848201528060a481015b0390fd5b6117096132d6565b806117145750611677565b60405178020b236b4b7103b30b634b230ba34b7b7103330b4b632b21d1603d1b60208201526116fd9161175f908290611751906039830190615302565b03601f1981018352826114f1565b60405162461bcd60e51b8152918291600483016123b4565b15610f8e576110ab91615319565b61179f91925060203d6020116109815761097381836114f1565b903861165f565b63703e46dd60e11b60005260046000fd5b600080516020615bdf833981519152546001600160a01b03161415905038611608565b346103a95760003660031901126103a9577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036117a6576020604051600080516020615bdf8339815191528152f35b346103a95760a03660031901126103a9576004356024356064356044356001600160401b0382116103a95761186e602092369060040161037c565b93909160006084359261187f614853565b6118876142c7565b61188f614909565b61189888614317565b6118a18361432f565b6118cc818989886118b3888585615455565b6118be600c54610a03565b6118c7816143a4565b614502565b6118fc6118dd610460600354610a03565b946040519889978896879563544ba5af60e01b87528d6004880161365e565b03925af190811561085057600091611994575b508061192a575b61079590611922614986565b61141a614303565b611938610460600054610a03565b803b156103a957604051637f15208d60e01b8152926000918491829084908290611965906004830161368d565b03925af1918215610850576107959261197f575b50611916565b80610815600061198e936114f1565b38611979565b6119ad915060203d6020116109815761097381836114f1565b3861190f565b346103a95760003660031901126103a957602060ff600080516020615c7f83398151915254166040519015158152f35b346103a95760203660031901126103a957600854604051630bc926dd60e31b8152600480359082015290602090829060249082906001600160a01b03165afa8015610850576107959160009161118257506040519081529081906020820190565b346103a95760c03660031901126103a9576004356024356001600160401b0381116103a957611a7790369060040161037c565b90916044356001600160401b0381116103a957611a9890369060040161037c565b93606435939091906001600160401b0385116103a95761079595611ac3611ad396369060040161037c565b9390926084359560a435976136e8565b6040519081529081906020820190565b9060806003198301126103a957600435916024359160443591606435906001600160401b0382116103a957611b1a9160040161037c565b9091565b346103a957611b2c36611ae3565b611b37949394614853565b611b3f6142c7565b611b47614909565b611b5084614317565b8415610aa857838591611b8a93611b668661432f565b611b71868585615455565b611b7c600c54610a03565b611b85816143a4565b61453a565b611b98610460600354610a03565b803b156103a957611bc493600080946040519687958694859363f2ebd41f60e01b85526004850161338c565b03925af1801561085057611be3575b611bdb614986565b6110ab614303565b806108156000611bf2936114f1565b38611bd3565b60005b838110611c0b5750506000910152565b8181015183820152602001611bfb565b90602091611c3481518092818552858086019101611bf8565b601f01601f1916010190565b602081016020825282518091526040820191602060408360051b8301019401926000915b838310611c7357505050505090565b9091929394602080611c91600193603f198682030187528951611c1b565b97019301930191939290611c64565b346103a95760003660031901126103a957610795611cbc6139a2565b611cc4613a94565b611ccd826139de565b52611cd7816139de565b50611ce0613abc565b611ce982613a01565b52611cf381613a01565b50611cfc613ae4565b611d0582613a11565b52611d0f81613a11565b50611d18613b09565b611d2182613a21565b52611d2b81613a21565b50611d34613b2e565b611d3d82613a31565b52611d4781613a31565b50611d50613b59565b611d5982613a41565b52611d6381613a41565b50611d6c613b7f565b611d7582613a51565b52611d7f81613a51565b50611d88613bb1565b611d9182613a61565b52611d9b81613a61565b50611da4613bda565b611dad82613a72565b52611db781613a72565b50611dc0613c04565b611dc982613a83565b52611dd381613a83565b5060405191829182611c40565b346103a95760603660031901126103a957611df9610999565b6044356024356001600160401b0382116103a957611e1d602092369060040161037c565b600c54604051636b80155f60e01b81529586946001600160a01b039092169385938493611e509391929160048601613c32565b03915afa80156108505761079591600091611e79575b5060405191829182901515815260200190565b611e92915060203d6020116109815761097381836114f1565b38611e66565b346103a95760003660031901126103a9576005546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a9576020604051600080516020615cbf8339815191528152f35b9080601f830112156103a957816020611f0593359101611554565b90565b64ffffffffff8116036103a957565b3590610a2b82611f08565b61ffff8116036103a957565b3590610a2b82611f22565b600811156103a957565b3590610a2b82611f39565b9094939260609260808301968352602083015260408201520152565b346103a95760803660031901126103a9576004356001600160401b0381116103a95761014060031982360301126103a957611fa3611519565b6004820135815260248201356020820152604482013560408201526064820135906001600160401b0382116103a95761205161012461079594611fef6120679560043691840101611eea565b606085015261200060848201610a20565b608085015261201160a48201611f17565b60a085015261202260c48201611f17565b60c085015261203360e48201611f2e565b60e08501526120456101048201611f17565b61010085015201611f43565b6101208201526024356044359060643592613c57565b9060409492945194859485611f4e565b346103a95760e03660031901126103a95760043561209481610a0f565b602435906120a182610a0f565b604435916120ae83610a0f565b6064356120ba81610a0f565b608435916120c783610a0f565b60a435916120d483610a0f565b60c435946120e186610a0f565b6120e9614792565b6120f28161572c565b6120fb8361572c565b6121048761572c565b61210d8261572c565b6121168561572c565b61211f8461572c565b6121288661572c565b612136610460600754610a03565b91823b156103a957604051638ffee9cd60e01b81526001600160a01b038381166004830152858116602483015289811660448301528281166064830152878116608483015286811660a4830152881660c482015295928660e4815a6000948591f191821561085057612220986121da612204966121cc6121e8946122129b6121f698612251575b506001600160a01b03166133a2565b6001600160a01b03166133c4565b6001600160a01b03166133e6565b6001600160a01b0316613408565b6001600160a01b031661342a565b6001600160a01b031661344c565b6001600160a01b031661346e565b6040516007815233907fc5ec6eb3c84a615de1792ae2858fe498e7c3c8e4986fef4ae3cbf1f8d2c68bca90602090a2005b806108156000612260936114f1565b386121bd565b346103a95760403660031901126103a957602060ff6122ab60243560043561228d82610a0f565b600052600080516020615c3f83398151915284526040600020613049565b54166040519015158152f35b346103a95760003660031901126103a95760206040517f75027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc8152f35b346103a95760003660031901126103a957602060405160008152f35b346103a9576101603660031901126103a957610795611ad361014435610124356101043560e43560c43560a435608435606435604435602435600435613d67565b6001600160a01b03909116815260200190565b346103a95760003660031901126103a957600b546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a9576020604051600080516020615b3f8339815191528152f35b906020611f05928181520190611c1b565b346103a95760003660031901126103a95761079560408051906123e881836114f1565b60058252640352e302e360dc1b602083015251918291602083526020830190611c1b565b346103a9576101603660031901126103a95760443561014435602435600435610124356101043560e43560c43560a4356084356064356001600160401b038a116103a9576107959a61246561141a9b369060040161037c565b9a9099613dca565b346103a95760403660031901126103a95760243560043561248d82611f39565b6001546124b1906124aa90610460906001600160a01b0316610a03565b3314613eed565b6124bc811515613f4c565b6124ca610460600054610a03565b91823b156103a9576124f69260009283604051809681958294637f15208d60e01b8452600484016136d2565b03925af180156108505761250657005b8061081560006110ab936114f1565b346103a9576101403660031901126103a9576110ab60043561253681610a0f565b60243561254281610a0f565b60443561254e81610a0f565b60643561255a81610a0f565b60843561256681610a0f565b60a4359061257382610a0f565b60c4359261258084610a0f565b60e4359461258d86610a0f565b610104359661259b88610a0f565b61012435986125a98a610a0f565b613f8e565b346103a95760203660031901126103a9576004356125ca614792565b6125d381614317565b806000526009602052604060002060ff19815416905533907f81a106317e7bcc4bb0d00469e38615879068b044d72620ca9aec13ad478ccb6c600080a3005b346103a95760403660031901126103a9576110ab60243560043561263582610a0f565b6126416110a1826134c7565b61509c565b346103a95760003660031901126103a9576008546040516001600160a01b039091168152602090f35b346103a9576126da6118fc602061268536611ae3565b93829481989392612694614792565b61269c6142c7565b6126a4614909565b6126ad83614317565b6126b68661432f565b6126c1868585615455565b6126cc600c54610a03565b6126d5816143a4565b614572565b6126e8610460600354610a03565b906000604051809681958294637236934f60e11b84528a6004850161338c565b346103a95761271636611ae3565b61272193929361429d565b6127296142c7565b61273285614317565b821561288c578484916127639361274a848785615455565b612755600c54610a03565b61275e816143a4565b6145aa565b612771610460600054610a03565b604051638d34875560e01b815260048101859052909290600081602481875afa90811561085057600091612871575b508051156128605761012001516127b681612910565b6127bf81612910565b61284f57823b156103a95760006040518094637f15208d60e01b82528183816127eb8a600483016136a4565b03925af1928315610850577f07783f66bb7a1367042849627a0e745b947e50de5c98cd9e436eaf66569f6d1a9361283a575b5061282f60405192839242918461338c565b0390a26110ab614303565b806108156000612849936114f1565b3861281d565b63e047416960e01b60005260046000fd5b637bb0b62160e01b60005260046000fd5b61288691503d806000833e61092981836114f1565b386127a0565b63fbd85bc360e01b60005260046000fd5b346103a95760003660031901126103a9576002546040516001600160a01b039091168152602090f35b346103a95760203660031901126103a9576004356128e381610a0f565b6128eb614792565b6001600160a01b03168015610aa857600c80546001600160a01b031916919091179055005b6008111561291a57565b634e487b7160e01b600052602160045260246000fd5b90600882101561291a5752565b610a2b909291926101008061012083019580518452602081015160208501526040810151604085015260018060a01b03606082015116606085015264ffffffffff60808201511660808501526129a160a082015160a086019064ffffffffff169052565b60c08181015161ffff169085015260e08181015164ffffffffff16908501520151910190612930565b346103a95760203660031901126103a957612a1960006004356129eb61423c565b506129f96104608354610a03565b6040518080958194638d34875560e01b8352600483019190602083019252565b03915afa90811561085057600091612b03575b5080519060208101519060408101516080820151612a4990610a03565b60a083015164ffffffffff1660c084015164ffffffffff169160e0850151612a729061ffff1690565b93610100860151612a879064ffffffffff1690565b95610120015196612a9788612910565b612a9f611529565b988952602089015260408801526001600160a01b0316606087015264ffffffffff16608086015264ffffffffff1660a085015261ffff1660c084015264ffffffffff1660e0830152612af5906101008301614291565b60405161079581928261293d565b612b16913d8091833e61092981836114f1565b38612a2c565b346103a95760203660031901126103a9576004356000526009602052602060ff604060002054166040519015158152f35b60609060031901126103a957600435906024359060443590565b346103a957612b7536612b4d565b919060018060a01b03612b8c610460600154610a03565b1680158015612e80575b8015612e76575b610aa8573303612e6557612bb5610460600054610a03565b92612bbf84610a03565b15610aa857604051638d34875560e01b815260048101849052600081602481885afa90811561085057600091612e4c575b50805115610905576001600160801b038311610f8e5764ffffffffff8211610f8e5760c081015164ffffffffff1694803b156103a9576000604051809263fa5fa16360e01b8252818381612c488a8c6004840161334b565b03925af1801561085057612e37575b508215801590612e2a575b612cfb575b50506000612c9c92612c7c6104608354610a03565b6040518080968194638d34875560e01b8352600483019190602083019252565b03915afa91821561085057600092612cde575b50604082015103610f8e5764ffffffffff612cd360c08293015164ffffffffff1690565b9216911610610f8e57005b612cf49192503d806000833e61092981836114f1565b9038612caf565b604081015115612dbf575b6101209150018051612d1781612910565b612d2081612910565b15908115612da1575b50612d36575b3880612c67565b612d44610460600054610a03565b91823b156103a95760006040518094637f15208d60e01b8252818381612d6d87600483016136bb565b03925af190811561085057612c9c93600092612d8d575b50925050612d2f565b8061081584612d9b936114f1565b38612d84565b6001915051612daf81612910565b612db881612910565b1438612d29565b612dcd610460600054610a03565b803b156103a9576040516390da939b60e01b8152926000918491829084908290612dfb908b6004840161334b565b03925af19182156108505761012092612e15575b50612d06565b806108156000612e24936114f1565b38612e0f565b5060408101511515612c62565b806108156000612e46936114f1565b38612c57565b612e5f913d8091833e61092981836114f1565b38612bf0565b63ea8e4eb560e01b60005260046000fd5b5080331415612b9d565b50612e92610460610460600054610a03565b15612b96565b346103a957612eda6020612eab36612b4d565b60085460405163e7f9caa560e01b81529586946001600160a01b0390921693859384939091906004850161338c565b03915afa90811561085057600091612efb575b506040519015158152602090f35b612f14915060203d6020116109815761097381836114f1565b38612eed565b346103a95760003660031901126103a9576020604051600080516020615c5f8339815191528152f35b346103a95760003660031901126103a9576003546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a9576000546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a9576007546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a957600c546040516001600160a01b039091168152602090f35b346103a95760003660031901126103a957610795604080519061300a81836114f1565b600682526518971817189960d11b602083015251918291602083526020830190611c1b565b6001600160a01b03166000908152600a6020526040902090565b9060018060a01b0316600052602052604060002090565b908160209103126103a9575180151581036103a95790565b6040513d6000823e3d90fd5b6000526009602052604060002090565b81601f820112156103a95780516130aa81611539565b926130b860405194856114f1565b818452602082840101116103a957611f059160208085019101611bf8565b5190610a2b82610a0f565b5190610a2b82611f08565b5190610a2b82611f22565b5190610a2b82611f39565b6020818303126103a9578051906001600160401b0382116103a95701610140818303126103a957613131611519565b9181518352602082015160208401526040820151604084015260608201519160018060401b0383116103a95761316f610120926131d1948301613094565b6060850152613180608082016130d6565b608085015261319160a082016130e1565b60a08501526131a260c082016130e1565b60c08501526131b360e082016130ec565b60e08501526131c561010082016130e1565b610100850152016130f7565b61012082015290565b91908260809103126103a9578151916020810151916060604083015192015190565b90926060929594936080835280516080840152602081015160a0840152604081015160c08401526132a96101206132438684015161014060e08801526101c0870190611c1b565b60808401516001600160a01b03166101008701529260a081015164ffffffffff168683015260c081015164ffffffffff1661014087015260e081015161ffff1661016087015261010081015164ffffffffff1661018087015201516101a0850190612930565b95602083015260408201520152565b60009060033d116132c557565b905060046000803e60005160e01c90565b600060443d10611f05576040513d600319016004823e8051916001600160401b0383113d602485011117613345578183018051909390916001600160401b03831161333d573d8401600319018584016020011161333d5750611f05929101602001906114f1565b949350505050565b92915050565b908152602081019190915260400190565b908160209103126103a95751611f0581610a0f565b6001600160a01b039091168152602081019190915260400190565b6040919493926060820195825260208201520152565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b908160209103126103a9575190565b634e487b7160e01b600052601160045260246000fd5b919082039182116134c257565b61349f565b600052600080516020615c3f83398151915260205260016040600020015490565b903590601e19813603018212156103a957018035906001600160401b0382116103a9576020019181360383136103a957565b9035601e19823603018112156103a9570160208101919035906001600160401b0382116103a95781360383136103a957565b908060209392818452848401376000828201840152601f01601f1916010190565b63ffffffff8116036103a957565b3590610a2b8261356d565b91611f0593919260408152833560408201526020840135606082015260408401356080820152606084013560a0820152608084013560c082015261365161364361016061363c6135ef6135dc60a08a018a61351a565b61018060e08901526101c088019161354c565b60c089013561010087015260e0890135610120870152610100890135610140870152610120890135838701526136296101408a018a61351a565b878303603f19016101808901529061354c565b960161357b565b63ffffffff166101a0830152565b602081850391015261354c565b9695949092608094926136889489526020890152604088015260a0606088015260a087019161354c565b930152565b908152604081019190610a2b906020016005612930565b908152604081019190610a2b906020016001612930565b908152604081019190610a2b906020016002612930565b908152604081019291610a2b9160200190612930565b959697949297939091936136fa6142c7565b61370261429d565b33600052600a6020526040600020544311156109885761373981613727368887611554565b61373236868e611554565b908a61546f565b80156109485761374d610460600454610a03565b604051634977ff8b60e11b81526004810183905290602090829060249082905afa908115610850576000916138ed575b501561094857613791610460600054610a03565b604051631e1778ad60e11b8152600481018990529096906020816024818b5afa908115610850576000916138ce575b506138bd576137d0600b54610a03565b6001600160a01b03811615610aa857868b868b6138158e8b8a6137f761046060209a610a03565b966040519a8b998a98899863728e8bbb60e01b8a5260048a0161390c565b03915afa9081156108505760009161389e575b5015610f8e57602097600094613857936040519b8c9a8b998a986306f4597160e21b8a52339260048b01613952565b03925af19081156108505760009161387f575b50436138753361302f565b5590610a2b614303565b613898915060203d602011610f0b57610efd81836114f1565b3861386a565b6138b7915060203d6020116109815761097381836114f1565b38613828565b630dd1bc8b60e31b60005260046000fd5b6138e7915060203d602011610f0b57610efd81836114f1565b386137c0565b613906915060203d6020116109815761097381836114f1565b3861377d565b969490611f059896926139449594613931928a5260a060208b015260a08a019161354c565b926040880152868303606088015261354c565b92608081850391015261354c565b99989793919461397a60a098966139949560c08e6136889b968152816020820152019161354c565b926001808a1b031660408c01528a830360608c015261354c565b91878303608089015261354c565b60405161016091906139b483826114f1565b600a815291601f19018260005b8281106139cd57505050565b8060606020809385010152016139c1565b8051156139eb5760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156139eb5760400190565b8051600210156139eb5760600190565b8051600310156139eb5760800190565b8051600410156139eb5760a00190565b8051600510156139eb5760c00190565b8051600610156139eb5760e00190565b8051600710156139eb576101000190565b8051600810156139eb576101200190565b8051600910156139eb576101400190565b60405190613aa36040836114f1565b600a8252691c1bdcda5d1a5bdb925960b21b6020830152565b60405190613acb6040836114f1565b600a8252691b5a5b9d105b5bdd5b9d60b21b6020830152565b60405190613af36040836114f1565b60078252666d696e7446656560c81b6020830152565b60405190613b186040836114f1565b60078252661b995dd119589d60ca1b6020830152565b60405190613b3d6040836114f1565b600d82526c1b995dd0dbdb1b185d195c985b609a1b6020830152565b60405190613b686040836114f1565b6008825267627463507269636560c01b6020830152565b60405190613b8e6040836114f1565b60148252730c2eae8d0dee4d2f4cac8a6e0cadcc8e690c2e6d60631b6020830152565b60405190613bc06040836114f1565b600b82526a0eac6c888cac4e890c2e6d60ab1b6020830152565b60405190613be96040836114f1565b600c82526b0c6dedce8e4c2c6e890c2e6d60a31b6020830152565b60405190613c136040836114f1565b601082526f07175616e74756d54696d657374616d760841b6020830152565b611f05949260609263ffffffff60e01b1682526020820152816040820152019161354c565b9192303303612e6557610120830160028151613c7281612910565b613c7b81612910565b14613d39575b600c8303613d2a576301e13380905b613caf82613caa61052461010089015164ffffffffff1690565b614704565b91613cc3613cbd42856134b5565b9161472b565b10613d195760039051613cd581612910565b613cde81612910565b14613d0c575b50613d0693613cf4600454610a03565b92613d00600154610a03565b94615562565b90919293565b421015613d195738613ce4565b6309116a8160e11b60005260046000fd5b613d3383614711565b90613c90565b613d4f61052461010086015164ffffffffff1690565b421115613c815763088502f160e21b60005260046000fd5b99979593919896949290986040519960208b019b8c5260408b015260608a0152608089015260a088015260c087015260e08601526101008501526101208401526101408301526101608201526101608152613dc4610180826114f1565b51902090565b949a999590969198929a979397613ddf61429d565b613de76142c7565b613def614909565b8315610f8e57613e3d848760209d8f9a613e248f8f9d8f9e60009f928893613ea09f8c908f8f613e1e8461432f565b8c61576b565b613e2f600c54610a03565b613e38816143a4565b6145e2565b613e4b610460600154610a03565b986040519c8d9b8c9a8b9963ee3448f960e01b8b5260048b0195926101009794919a9998959261012088019b8852602088015260408701526060860152608085015260a084015260c083015260e08201520152565b03925af190811561085057600091613ece575b5015610f8e57613ec1614986565b613ec9614303565b600190565b613ee7915060203d6020116109815761097381836114f1565b38613eb3565b15613ef457565b60405162461bcd60e51b815260206004820152602a60248201527f4f6e6c79206c6f616e206f7065726174696f6e73206d616e616765722063616e6044820152692063616c6c207468697360b01b6064820152608490fd5b15613f5357565b60405162461bcd60e51b8152602060048201526013602482015272125b9d985b1a59081c1bdcda5d1a5bdb881251606a1b6044820152606490fd5b97959391989694929098600080516020615cdf8339815191525499613fb960ff8c60401c1615151590565b9a6001600160401b0316801590816140a9575b600114908161409f575b159081614096575b5061408557600080516020615cdf83398151915280546001600160401b0319166001179055614011998b614060576140b1565b61401757565b600080516020615cdf833981519152805460ff60401b19169055604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1565b600080516020615cdf833981519152805460ff60401b1916600160401b1790556140b1565b63f92ee8a960e01b60005260046000fd5b90501538613fde565b303b159150613fd6565b8c9150613fcc565b989793929896919094966140c3615a16565b6140cb6157e7565b6140d3615a16565b6140db615a16565b6140e3615a44565b6001600160a01b0316948515610aa8576001600160a01b0316908115610aa8576001600160a01b0316988915610aa8576001600160a01b0316928315610aa8576001600160a01b0316968715610aa8576001600160a01b0316958615610aa8576001600160a01b0316918215610aa8576001600160a01b0316938415610aa8576001600160a01b0316958615610aa8576001600160a01b03891615610aa8576141be61420c986141b96141c8966141b46142399e6141af6141c3986141aa6141ea9e6133a2565b6133c4565b6133e6565b613408565b61342a565b61344c565b61346e565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b61421581614c89565b5061421f81614d22565b5061422981614ddf565b5061423381614e9c565b50614f59565b50565b6040519061012082016001600160401b03811183821017611514576040526000610100838281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201520152565b600882101561291a5752565b60ff600080516020615c7f83398151915254166142b657565b63d93c066560e01b60005260046000fd5b6002600080516020615c9f83398151915254146142f2576002600080516020615c9f83398151915255565b633ee5aeb560e01b60005260046000fd5b6001600080516020615c9f83398151915255565b1561431e57565b6379ec0ed760e11b60005260046000fd5b8015801561437c575b801561436d575b6143465750565b6382d6282f60e01b60005260045264e8d4a51000602452655af3107a400060445260646000fd5b50655af3107a4000811161433f565b5064e8d4a510008110614338565b9290611751613dc492604051948593602085019788611f4e565b6001600160a01b0316156143b457565b639cef199b60e01b60005260046000fd5b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd9263018af30960e01b60048601613c32565b0381875afa90811561085057600091614473575b501561446257823b156103a9576144429260009283604051809681958294630e62cc9360e21b84526004840161334b565b03925af18015610850576144535750565b806108156000610a2b936114f1565b636227817160e01b60005260046000fd5b61448c915060203d6020116109815761097381836114f1565b38614411565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd926304e9585760e11b60048601613c32565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd9263121f00ad60e21b60048601613c32565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd9263544ba5af60e01b60048601613c32565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd926318eea33b60e21b60048601613c32565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd92636b40812160e11b60048601613c32565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd92630d7d9f4b60e41b60048601613c32565b604051636b80155f60e01b81526001600160a01b0390911695939092602092849283926143fd92632c545d9960e21b60048601613c32565b604051634911e9cd60e01b8152600481019190915291926001600160a01b0316602083602481845afa928315610850576000936146dc575b50604051630180d64960e11b8152600481019290925260209082908180602481015b03915afa908115610850576000916146bd575b50808211156146b357614699916134b5565b905b036146a257565b63896492f560e01b60005260046000fd5b505060009061469b565b6146d6915060203d602011610f0b57610efd81836114f1565b38614687565b6020919350916146fb61467493833d8511610f0b57610efd81836114f1565b93915091614652565b919082018092116134c257565b9062278d0082029180830462278d0014901517156134c257565b908160011b91808304600214901517156134c257565b818102929181159184041417156134c257565b90600c81146147805762278d0081029080820462278d0014901517156134c25781018091116134c25790565b506301e1338081018091116134c25790565b600080516020615cbf833981519152600052600080516020615c3f83398151915260205260ff6147d033600080516020615b7f833981519152613049565b5416156147d957565b63e2517d3f60e01b60005233600452600080516020615cbf83398151915260245260446000fd5b60008052600080516020615c3f83398151915260205260ff61483033600080516020615bbf833981519152613049565b54161561483957565b63e2517d3f60e01b60005233600452600060245260446000fd5b600080516020615b1f833981519152600052600080516020615c3f83398151915260205260ff61489133600080516020615c1f833981519152613049565b54161561489a57565b63e2517d3f60e01b60005233600452600080516020615b1f83398151915260245260446000fd5b80600052600080516020615c3f83398151915260205260ff6148e7336040600020613049565b5416156148f15750565b63e2517d3f60e01b6000523360045260245260446000fd5b6002600080516020615b5f8339815191525414614934576002600080516020615b5f83398151915255565b60405162461bcd60e51b8152602060048201526024808201527f476c6f62616c5265656e7472616e637947756172643a207265656e7472616e746044820152640818d85b1b60da1b6064820152608490fd5b6001600080516020615b5f83398151915255565b91909115613f53578115614a43575115614a0457116149b557565b60405162461bcd60e51b815260206004820152602160248201527f5061796d656e7420616d6f756e74206578636565647320746f74616c206465626044820152601d60fa1b6064820152608490fd5b60405162461bcd60e51b8152602060048201526017602482015276141bdcda5d1a5bdb88191bd95cc81b9bdd08195e1a5cdd604a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152602860248201527f5061796d656e7420616d6f756e74206d7573742062652067726561746572207460448201526768616e207a65726f60c01b6064820152608490fd5b60008054604051638d34875560e01b815260048101849052929190839060249082906001600160a01b03165afa91821561085057600092614b0b575b5081511490811591614aec575b50610f8e57600190565b608001516001600160a01b039150614b0390610a03565b161538614ae2565b614b219192503d806000833e61092981836114f1565b9038614ad5565b614b3181612910565b60018114159081614bd9575b81614bc3575b81614bae575b50614b5057565b60405162461bcd60e51b815260206004820152603060248201527f506f736974696f6e20737461747573206e6f7420656c696769626c6520666f7260448201526f081c185c9d1a585b081c185e5b595b9d60821b6064820152608490fd5b60049150614bbb81612910565b141538614b49565b9050614bce81612910565b600381141590614b43565b9050614be481612910565b600281141590614b3d565b6040516323b872dd60e01b60208083019182526001600160a01b0394851660248401529490931660448201526064808201959095529384529260009190614c376084826114f1565b519082855af115613078576000513d614c8057506001600160a01b0381163b155b614c5f5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614c58565b60008052600080516020615c3f83398151915260205260ff614cb982600080516020615bbf833981519152613049565b5416614d1c5760008052600080516020615c3f833981519152602052614ced81600080516020615bbf833981519152613049565b805460ff1916600117905533906001600160a01b03166000600080516020615aff8339815191528180a4600190565b50600090565b600080516020615b1f833981519152600052600080516020615c3f83398151915260205260ff614d6082600080516020615c1f833981519152613049565b5416614d1c57600080516020615b1f833981519152600052600080516020615c3f833981519152602052614da281600080516020615c1f833981519152613049565b805460ff1916600117905533906001600160a01b0316600080516020615b1f833981519152600080516020615aff833981519152600080a4600190565b600080516020615cbf833981519152600052600080516020615c3f83398151915260205260ff614e1d82600080516020615b7f833981519152613049565b5416614d1c57600080516020615cbf833981519152600052600080516020615c3f833981519152602052614e5f81600080516020615b7f833981519152613049565b805460ff1916600117905533906001600160a01b0316600080516020615cbf833981519152600080516020615aff833981519152600080a4600190565b600080516020615c5f833981519152600052600080516020615c3f83398151915260205260ff614eda82600080516020615bff833981519152613049565b5416614d1c57600080516020615c5f833981519152600052600080516020615c3f833981519152602052614f1c81600080516020615bff833981519152613049565b805460ff1916600117905533906001600160a01b0316600080516020615c5f833981519152600080516020615aff833981519152600080a4600190565b600080516020615b3f833981519152600052600080516020615c3f83398151915260205260ff614f9782600080516020615b9f833981519152613049565b5416614d1c57600080516020615b3f833981519152600052600080516020615c3f833981519152602052614fd981600080516020615b9f833981519152613049565b805460ff1916600117905533906001600160a01b0316600080516020615b3f833981519152600080516020615aff833981519152600080a4600190565b80600052600080516020615c3f83398151915260205260ff61503c836040600020613049565b54166150955780600052600080516020615c3f833981519152602052615066826040600020613049565b805460ff1916600117905533916001600160a01b031690600080516020615aff833981519152600080a4600190565b5050600090565b80600052600080516020615c3f83398151915260205260ff6150c2836040600020613049565b5416156150955780600052600080516020615c3f8339815191526020526150ed826040600020613049565b805460ff1916905533916001600160a01b0316907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a4600190565b8051156151355750565b60405163df70480560e01b8152602060048201529081906116fd906024830190611c1b565b9c9798939d9e9d60a08e6151c99c976101609f9a949363ffffffff9f9a96976151a498610180968552602085015260408401526060830152608082015201526101808d019161354c565b9560c08b015260e08a015261010089015261012088015286830361014088015261354c565b9416910152565b803560208201359060408301359260608101359060808101359060a081016151f890826134e8565b60c083013560e0840135906101008501359261012086013594610140870161522090886134e8565b9890976101600135996152328b61356d565b6040519d8e9d60208f019d6152469e61515a565b03601f198101825261525890826114f1565b8051906020012090565b91909181156152955761527d92615278916157f7565b6158a6565b1061528457565b635e31938360e11b60005260046000fd5b50505050565b600881101561291a5780151590816152ec575b816152d6575b816152c1575b5061284f57565b600691506152ce81612910565b1415386152ba565b90506152e181612910565b6002811415906152b4565b90506152f781612910565b6001811415906152ae565b9061531560209282815194859201611bf8565b0190565b6040516352d1902d60e01b81529091906020816004816001600160a01b0387165afa60009181615434575b5061536757634c9c8ce360e01b6000526001600160a01b03831660045260246000fd5b600080516020615bdf83398151915281036154205750813b156153fe57600080516020615bdf83398151915280546001600160a01b0319166001600160a01b0384169081179091557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28051156153e45761423991615a5b565b5050346153ed57565b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60009081526001600160a01b0391909116600452602490fd5b632a87526960e21b60005260045260246000fd5b61544e91925060203d602011610f0b57610efd81836114f1565b9038615344565b9190613dc49061175160405193849260208401968761338c565b61547890614317565b8051156154f55760409051106154b9576154919061512b565b801561549a5750565b6304a45adb60e51b600052600452600160245260001960445260646000fd5b60405163df70480560e01b815260206004820152601360248201527214da59db985d1d5c99481d1bdbc81cda1bdc9d606a1b6044820152606490fd5b60405163df70480560e01b815260206004820152600f60248201526e456d707479207369676e617475726560881b6044820152606490fd5b51906001600160581b03821682036103a957565b91908260409103126103a957611f05602061555b8461552d565b930161552d565b604080516353f366c760e01b815260048101849052939794969195849060249082906001600160a01b03165afa928315610850576000936156f9575b5060408501805190936155db916155be916001600160581b031690615931565b976155ca8986516159a3565b976155d68983836159c8565b6157f7565b925160405163100c48d360e21b81526001600160a01b039092169190602082600481865afa9081156108505761561a926000926156d8575b50856159fa565b6156c75760206004916040519283809263100c48d360e21b82525afa801561085057615650916000916156a8575b5086846159fa565b61569757613caa61567360e06156698861567a966158a6565b96015161ffff1690565b61ffff1690565b9061ffff821161568657565b6319a4c60960e21b60005260046000fd5b631300e8bd60e21b60005260046000fd5b6156c1915060203d602011610f0b57610efd81836114f1565b38615648565b63e5cace4160e01b60005260046000fd5b6156f291925060203d602011610f0b57610efd81836114f1565b9038615613565b61571c91935060403d604011615725575b61571481836114f1565b810190615541565b9050913861559e565b503d61570a565b6001600160a01b03811690811561575a573b156157465750565b630fb15bad60e11b60005260045260246000fd5b63d92e233d60e01b60005260046000fd5b9896919497909392956040519860208a019a7ffa8f74e09e937f69ff6ed56ad5685b576507504860024ea40564c0432ff8034a8c5260408b015260608a0152608089015260a088015260c087015260e08601526101008501526101208401526101408301526101608201526101608152613dc4610180826114f1565b6157ef615a16565b614303615a16565b90660775f05a0740008211615895576a52b7d2dcc80cd2e4000000811161588457811580159081615858575b506158475761583191614741565b6064810290808204606414901517156134c25790565b63450d49cd60e01b60005260046000fd5b905061586e576064826000190404811138615823565b634e487b7160e01b600052601260045260246000fd5b63128df78360e01b60005260046000fd5b63e9ec682160e01b60005260046000fd5b81156159205768327cb2734119d3b7a9601e1b811161590f577e068db8bac710cb295e9e1b089a027525460aa64c2f837b4a2339c0ebedfa4381116158fe5761271081029080820461271014901517156134c2570490565b633da428df60e21b60005260046000fd5b638a94304d60e01b60005260046000fd5b6323d359a360e01b60005260046000fd5b68327cb2734119d3b7a9601e1b811161590f5761271082116159925780158015908161597f575b5061596e576127109161596a91614741565b0490565b6340c0d6e560e11b60005260046000fd5b905061586e578060001904821138615958565b637186728f60e11b60005260046000fd5b908101908181116134c25781106159b75790565b636be580af60e11b60005260046000fd5b660775f05a07400010615895576a52b7d2dcc80cd2e4000000106158845768327cb2734119d3b7a9601e1b1061590f57565b908015615a0e57615a0a916158a6565b1090565b505050600090565b60ff600080516020615cdf8339815191525460401c1615615a3357565b631afcd79f60e31b60005260046000fd5b600080516020615b5f833981519152541561498657565b600080611f0593602081519101845af43d15615a99573d91615a7c83611539565b92615a8a60405194856114f1565b83523d6000602085013e615a9d565b6060915b90615ac35750805115615ab257602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580615af5575b615ad4575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15615acc56fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5e17fc5225d4a099df75359ce1f405503ca79498a8dc46a7d583235a0ee45c16f4a222f146e17d7057e96450fc67f08ce8569fd5cf3b62a23983c4f4b9e497f35cd165352ca420415a2423a5a15f077145431fc21aec9b84cb1b8800541a5c26b16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c1b3eac282bb4080c159156c6faa9df237c5a80b4a568c4661ea2010de1eb2caeb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbccd6c996ba66d0dbb3c38dbaaac7d192f7d41593dd02b55a9147053192322b1d3b615dc3ea5d9654acb949989a0a9587a0da8cd03451c0368cc676ec7c08dd81402dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268004ad5455c7a5edb25c14b61cc4d6429153aab5507800334ac05d65e9828801bf3cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00aaae1071a267a66db1d9c0714498307791bc0f693f5b254c861d95ca60503b6da2646970667358221220bf923774eda538ae7e572ed34d44d75ffa44665884eb85128bc0d128090cf31a64736f6c634300081c0033";
38704
38776
  var isSuperArgs = (xs) => xs.length > 1;
38705
38777
  var PositionManager__factory = class extends ContractFactory2 {
38706
38778
  constructor(...args) {
@@ -39278,6 +39350,26 @@ var _abi3 = [
39278
39350
  internalType: "bytes32",
39279
39351
  name: "positionId",
39280
39352
  type: "bytes32"
39353
+ },
39354
+ {
39355
+ internalType: "uint256",
39356
+ name: "quantumTimestamp",
39357
+ type: "uint256"
39358
+ },
39359
+ {
39360
+ internalType: "uint256",
39361
+ name: "btcPrice",
39362
+ type: "uint256"
39363
+ },
39364
+ {
39365
+ internalType: "uint256",
39366
+ name: "btcAmountSats",
39367
+ type: "uint256"
39368
+ },
39369
+ {
39370
+ internalType: "bytes",
39371
+ name: "liquidationValidatorSignature",
39372
+ type: "bytes"
39281
39373
  }
39282
39374
  ],
39283
39375
  name: "calculateLiquidationBonus",
@@ -39288,7 +39380,7 @@ var _abi3 = [
39288
39380
  type: "uint256"
39289
39381
  }
39290
39382
  ],
39291
- stateMutability: "view",
39383
+ stateMutability: "nonpayable",
39292
39384
  type: "function"
39293
39385
  },
39294
39386
  {
@@ -39299,9 +39391,14 @@ var _abi3 = [
39299
39391
  type: "bytes32"
39300
39392
  },
39301
39393
  {
39302
- internalType: "bytes32",
39303
- name: "commitHash",
39304
- type: "bytes32"
39394
+ internalType: "uint256",
39395
+ name: "quantumTimestamp",
39396
+ type: "uint256"
39397
+ },
39398
+ {
39399
+ internalType: "uint256",
39400
+ name: "btcPrice",
39401
+ type: "uint256"
39305
39402
  }
39306
39403
  ],
39307
39404
  name: "commitLiquidation",
@@ -39315,6 +39412,21 @@ var _abi3 = [
39315
39412
  internalType: "bytes32",
39316
39413
  name: "positionId",
39317
39414
  type: "bytes32"
39415
+ },
39416
+ {
39417
+ internalType: "uint256",
39418
+ name: "btcPrice",
39419
+ type: "uint256"
39420
+ },
39421
+ {
39422
+ internalType: "uint256",
39423
+ name: "quantumTimestamp",
39424
+ type: "uint256"
39425
+ },
39426
+ {
39427
+ internalType: "bytes",
39428
+ name: "liquidationValidatorSignature",
39429
+ type: "bytes"
39318
39430
  }
39319
39431
  ],
39320
39432
  name: "isLiquidatable",
@@ -39325,7 +39437,7 @@ var _abi3 = [
39325
39437
  type: "bool"
39326
39438
  }
39327
39439
  ],
39328
- stateMutability: "view",
39440
+ stateMutability: "nonpayable",
39329
39441
  type: "function"
39330
39442
  },
39331
39443
  {
@@ -39334,6 +39446,16 @@ var _abi3 = [
39334
39446
  internalType: "bytes32",
39335
39447
  name: "positionId",
39336
39448
  type: "bytes32"
39449
+ },
39450
+ {
39451
+ internalType: "uint256",
39452
+ name: "btcPrice",
39453
+ type: "uint256"
39454
+ },
39455
+ {
39456
+ internalType: "uint256",
39457
+ name: "quantumTimestamp",
39458
+ type: "uint256"
39337
39459
  }
39338
39460
  ],
39339
39461
  name: "liquidatePosition",
@@ -39356,9 +39478,19 @@ var _abi3 = [
39356
39478
  },
39357
39479
  {
39358
39480
  internalType: "uint256",
39359
- name: "nonce",
39481
+ name: "quantumTimestamp",
39482
+ type: "uint256"
39483
+ },
39484
+ {
39485
+ internalType: "uint256",
39486
+ name: "btcPrice",
39360
39487
  type: "uint256"
39361
39488
  },
39489
+ {
39490
+ internalType: "bytes",
39491
+ name: "liquidationValidatorSignature",
39492
+ type: "bytes"
39493
+ },
39362
39494
  {
39363
39495
  internalType: "uint256",
39364
39496
  name: "deadline",
@@ -39542,6 +39674,11 @@ var _abi4 = [
39542
39674
  internalType: "bytes32",
39543
39675
  name: "positionId",
39544
39676
  type: "bytes32"
39677
+ },
39678
+ {
39679
+ internalType: "uint256",
39680
+ name: "btcPrice",
39681
+ type: "uint256"
39545
39682
  }
39546
39683
  ],
39547
39684
  name: "calculateCollateralRatio",
@@ -39557,7 +39694,7 @@ var _abi4 = [
39557
39694
  },
39558
39695
  {
39559
39696
  inputs: [],
39560
- name: "getCurrentBTCPrice",
39697
+ name: "getOriginationFeeBalance",
39561
39698
  outputs: [
39562
39699
  {
39563
39700
  internalType: "uint256",
@@ -39569,8 +39706,14 @@ var _abi4 = [
39569
39706
  type: "function"
39570
39707
  },
39571
39708
  {
39572
- inputs: [],
39573
- name: "getOriginationFeeBalance",
39709
+ inputs: [
39710
+ {
39711
+ internalType: "bytes32",
39712
+ name: "pkpId",
39713
+ type: "bytes32"
39714
+ }
39715
+ ],
39716
+ name: "getPKPActualCollateral",
39574
39717
  outputs: [
39575
39718
  {
39576
39719
  internalType: "uint256",
@@ -39585,11 +39728,11 @@ var _abi4 = [
39585
39728
  inputs: [
39586
39729
  {
39587
39730
  internalType: "bytes32",
39588
- name: "pkpId",
39731
+ name: "positionId",
39589
39732
  type: "bytes32"
39590
39733
  }
39591
39734
  ],
39592
- name: "getPKPActualCollateral",
39735
+ name: "getTotalAuthorizedSats",
39593
39736
  outputs: [
39594
39737
  {
39595
39738
  internalType: "uint256",
@@ -39702,15 +39845,15 @@ var _abi4 = [
39702
39845
  name: "authorizedSpendsHash",
39703
39846
  type: "bytes32"
39704
39847
  },
39848
+ {
39849
+ internalType: "bytes32",
39850
+ name: "ucdDebtHash",
39851
+ type: "bytes32"
39852
+ },
39705
39853
  {
39706
39854
  internalType: "uint256",
39707
39855
  name: "quantumTimestamp",
39708
39856
  type: "uint256"
39709
- },
39710
- {
39711
- internalType: "bytes",
39712
- name: "mintValidatorSignature",
39713
- type: "bytes"
39714
39857
  }
39715
39858
  ],
39716
39859
  name: "mintUCD",
@@ -39735,33 +39878,19 @@ var _abi4 = [
39735
39878
  internalType: "uint256",
39736
39879
  name: "paymentAmount",
39737
39880
  type: "uint256"
39738
- }
39739
- ],
39740
- name: "processPartialPayment",
39741
- outputs: [
39742
- {
39743
- internalType: "bool",
39744
- name: "",
39745
- type: "bool"
39746
- }
39747
- ],
39748
- stateMutability: "nonpayable",
39749
- type: "function"
39750
- },
39751
- {
39752
- inputs: [
39881
+ },
39753
39882
  {
39754
- internalType: "bytes32",
39755
- name: "positionId",
39756
- type: "bytes32"
39883
+ internalType: "uint256",
39884
+ name: "quantumTimestamp",
39885
+ type: "uint256"
39757
39886
  },
39758
39887
  {
39759
39888
  internalType: "uint256",
39760
- name: "repaymentAmount",
39889
+ name: "btcPrice",
39761
39890
  type: "uint256"
39762
39891
  }
39763
39892
  ],
39764
- name: "repayPosition",
39893
+ name: "processPayment",
39765
39894
  outputs: [
39766
39895
  {
39767
39896
  internalType: "bool",
@@ -39839,6 +39968,21 @@ var _abi4 = [
39839
39968
  internalType: "uint256",
39840
39969
  name: "newDebt",
39841
39970
  type: "uint256"
39971
+ },
39972
+ {
39973
+ internalType: "uint256",
39974
+ name: "quantumTimestamp",
39975
+ type: "uint256"
39976
+ },
39977
+ {
39978
+ internalType: "uint256",
39979
+ name: "btcPrice",
39980
+ type: "uint256"
39981
+ },
39982
+ {
39983
+ internalType: "bytes",
39984
+ name: "updateValidatorSignature",
39985
+ type: "bytes"
39842
39986
  }
39843
39987
  ],
39844
39988
  name: "updatePosition",
@@ -41895,6 +42039,46 @@ function convertEthereumSignatureToBitcoinDER(signature2) {
41895
42039
  return Buffer.from(bip66.encode(r2, s)).toString("hex");
41896
42040
  }
41897
42041
 
42042
+ // src/utils/signature-tempering.utils.ts
42043
+ function temperSignature(signature2) {
42044
+ if (!signature2 || signature2.length < 4) {
42045
+ throw new Error("Invalid signature format for tempering");
42046
+ }
42047
+ if (!signature2.startsWith("0x")) {
42048
+ throw new Error("Signature must start with 0x prefix");
42049
+ }
42050
+ const thirdCharIndex = 2;
42051
+ const originalChar = signature2[thirdCharIndex]?.toLowerCase();
42052
+ if (!originalChar) {
42053
+ throw new Error("Signature too short for tempering");
42054
+ }
42055
+ const hexChars = "0123456789abcdef".split("");
42056
+ const validReplacements = hexChars.filter(
42057
+ (char) => char !== originalChar
42058
+ );
42059
+ const randomIndex = Math.floor(Math.random() * validReplacements.length);
42060
+ const newChar = validReplacements[randomIndex];
42061
+ const tempered = signature2.slice(0, thirdCharIndex) + newChar + signature2.slice(thirdCharIndex + 1);
42062
+ return tempered;
42063
+ }
42064
+ function maybeTemperSignature(signature2, shouldTemper, operationName) {
42065
+ if (!shouldTemper) {
42066
+ return signature2;
42067
+ }
42068
+ const tempered = temperSignature(signature2);
42069
+ if (operationName) {
42070
+ console.warn(
42071
+ `\u26A0\uFE0F [SIGNATURE TEMPERING TEST] ${operationName}: Modified signature character at position 3`
42072
+ );
42073
+ console.warn(` Original (first 20 chars): ${signature2.slice(0, 20)}...`);
42074
+ console.warn(` Tempered (first 20 chars): ${tempered.slice(0, 20)}...`);
42075
+ console.warn(
42076
+ ` \u26A0\uFE0F This transaction WILL FAIL - testing signature validation`
42077
+ );
42078
+ }
42079
+ return tempered;
42080
+ }
42081
+
41898
42082
  // src/modules/contract/contract-manager.module.ts
41899
42083
  var ContractManager = class {
41900
42084
  config;
@@ -42019,7 +42203,6 @@ var ContractManager = class {
42019
42203
  const requiredAddresses = [
42020
42204
  "positionManager",
42021
42205
  "ucdToken",
42022
- "btcProofValidator",
42023
42206
  "priceFeedConsumer"
42024
42207
  ];
42025
42208
  const optionalAddresses = [
@@ -42972,6 +43155,7 @@ function createPKPManager(config) {
42972
43155
  var LoanCreator = class {
42973
43156
  config;
42974
43157
  transactionTimeoutMs;
43158
+ pkpValidationRegistryAddressCache;
42975
43159
  constructor(config) {
42976
43160
  this.config = config;
42977
43161
  this.transactionTimeoutMs = config.transactionTimeoutMs || 3e5;
@@ -43001,7 +43185,54 @@ var LoanCreator = class {
43001
43185
  if (this.config.debug) {
43002
43186
  log.info("\u{1F4DD} Step 1: Creating PKP via LitOps");
43003
43187
  }
43188
+ let pkpValidationRegistryAddress;
43189
+ if (this.pkpValidationRegistryAddressCache) {
43190
+ pkpValidationRegistryAddress = this.pkpValidationRegistryAddressCache;
43191
+ } else {
43192
+ const positionManagerResult = this.config.contractManager.getPositionManager();
43193
+ if (!positionManagerResult.success || !positionManagerResult.value) {
43194
+ return failure(
43195
+ new SDKError({
43196
+ message: "Failed to get PositionManager contract",
43197
+ category: "CONTRACT" /* CONTRACT */,
43198
+ severity: "HIGH" /* HIGH */
43199
+ })
43200
+ );
43201
+ }
43202
+ pkpValidationRegistryAddress = await positionManagerResult.value.pkpValidationRegistry();
43203
+ if (!pkpValidationRegistryAddress || pkpValidationRegistryAddress === "0x0000000000000000000000000000000000000000") {
43204
+ return failure(
43205
+ new SDKError({
43206
+ message: "PKPValidationRegistry address not set in PositionManager contract",
43207
+ category: "CONTRACT" /* CONTRACT */,
43208
+ severity: "HIGH" /* HIGH */
43209
+ })
43210
+ );
43211
+ }
43212
+ this.pkpValidationRegistryAddressCache = pkpValidationRegistryAddress;
43213
+ if (this.config.debug) {
43214
+ log.info(`\u2705 Retrieved PKPValidationRegistry from PositionManager: ${pkpValidationRegistryAddress}`);
43215
+ }
43216
+ }
43004
43217
  const isServiceMode = this.config.mode === "service";
43218
+ if (isServiceMode && typeof this.config.litOps.updatePkpValidationRegistry === "function") {
43219
+ this.config.litOps.updatePkpValidationRegistry(pkpValidationRegistryAddress);
43220
+ }
43221
+ const { DH_LIT_ACTIONS_DATIL } = await import("@gvnrdao/dh-lit-actions");
43222
+ const certificationCid = DH_LIT_ACTIONS_DATIL.pkpValidator.authorizedCidHex.toLowerCase();
43223
+ if (this.config.debug) {
43224
+ log.info(`\u2705 Using pkpValidator CID for certification: ${certificationCid}`);
43225
+ }
43226
+ if (certificationCid && isServiceMode) {
43227
+ if (typeof this.config.litOps.updateCertificationCid === "function") {
43228
+ this.config.litOps.updateCertificationCid(certificationCid);
43229
+ if (this.config.debug) {
43230
+ log.info(`\u2705 Stored certificationCid in LitOps for validation: ${certificationCid}`);
43231
+ }
43232
+ } else if (this.config.debug) {
43233
+ log.info(`\u26A0\uFE0F LitOps.updateCertificationCid not available (using older lit-ops version)`);
43234
+ }
43235
+ }
43005
43236
  if (!isServiceMode && !this.config.litOpsSigner) {
43006
43237
  return failure(
43007
43238
  new SDKError({
@@ -43212,10 +43443,15 @@ var LoanCreator = class {
43212
43443
  BigInt(pkpIdBytes32).toString()
43213
43444
  );
43214
43445
  console.log("==========================================\n");
43215
- const validatorVersion = this.config.validatorVersion || 1;
43446
+ const validatorVersion = this.config.loanCreationValidatorVersion || 1;
43447
+ const validatorSignature = maybeTemperSignature(
43448
+ pkpData.validatorSignature,
43449
+ this.config.temperSignaturesTest,
43450
+ "createPosition"
43451
+ );
43216
43452
  const tx = await positionManager.createPosition(
43217
43453
  pkpIdBytes32,
43218
- pkpData.validatorSignature,
43454
+ validatorSignature,
43219
43455
  mainnetVaultAddress,
43220
43456
  regtestVaultAddress,
43221
43457
  request.selectedTerm,
@@ -43530,7 +43766,9 @@ var LoanQuery = class {
43530
43766
  // Will be enriched below
43531
43767
  }
43532
43768
  };
43533
- const enrichedLoans = await this.enrichLoansWithVaultAddresses([loanData]);
43769
+ const enrichedLoans = await this.enrichLoansWithVaultAddresses([
43770
+ loanData
43771
+ ]);
43534
43772
  const enrichedLoan = enrichedLoans[0] || loanData;
43535
43773
  if (enrichBalance) {
43536
43774
  await this.enrichLoanWithBalance(enrichedLoan);
@@ -43568,9 +43806,7 @@ var LoanQuery = class {
43568
43806
  }
43569
43807
  return tryCatchAsync(
43570
43808
  async () => {
43571
- const rawLoan = await this.config.graphClient.getDetailedPositionByPkpId(
43572
- pkpId
43573
- );
43809
+ const rawLoan = await this.config.graphClient.getDetailedPositionByPkpId(pkpId);
43574
43810
  if (!rawLoan) {
43575
43811
  return null;
43576
43812
  }
@@ -43598,7 +43834,9 @@ var LoanQuery = class {
43598
43834
  // Will be enriched below
43599
43835
  }
43600
43836
  };
43601
- const enrichedLoans = await this.enrichLoansWithVaultAddresses([loanData]);
43837
+ const enrichedLoans = await this.enrichLoansWithVaultAddresses([
43838
+ loanData
43839
+ ]);
43602
43840
  const enrichedLoan = enrichedLoans[0] || loanData;
43603
43841
  if (enrichBalance) {
43604
43842
  await this.enrichLoanWithBalance(enrichedLoan);
@@ -43659,7 +43897,9 @@ var LoanQuery = class {
43659
43897
  skip
43660
43898
  );
43661
43899
  }
43662
- const enrichedLoans = await this.enrichLoansWithVaultAddresses(result.positions);
43900
+ const enrichedLoans = await this.enrichLoansWithVaultAddresses(
43901
+ result.positions
43902
+ );
43663
43903
  return {
43664
43904
  loans: enrichedLoans,
43665
43905
  page,
@@ -43678,7 +43918,7 @@ var LoanQuery = class {
43678
43918
  }
43679
43919
  /**
43680
43920
  * Get loans with BTC balance data from Bitcoin network
43681
- *
43921
+ *
43682
43922
  * Same as getLoans but includes actual Bitcoin balance for each position's vault.
43683
43923
  * Queries BTC balances in parallel for performance.
43684
43924
  *
@@ -43692,12 +43932,19 @@ var LoanQuery = class {
43692
43932
  const skip = page * pageSize;
43693
43933
  if (!filters.borrower) {
43694
43934
  if (this.config.debug) {
43695
- log.info("\u26A0\uFE0F getLoansWithBtc only supports borrower filter, falling back to getLoans");
43935
+ log.info(
43936
+ "\u26A0\uFE0F getLoansWithBtc only supports borrower filter, falling back to getLoans"
43937
+ );
43696
43938
  }
43697
43939
  return this.getLoans(filters, pagination);
43698
43940
  }
43699
43941
  if (this.config.debug) {
43700
- log.info("\u{1F50D} Querying loans with BTC balance data", { filters, page, pageSize, skip });
43942
+ log.info("\u{1F50D} Querying loans with BTC balance data", {
43943
+ filters,
43944
+ page,
43945
+ pageSize,
43946
+ skip
43947
+ });
43701
43948
  }
43702
43949
  return tryCatchAsync(
43703
43950
  async () => {
@@ -43708,7 +43955,9 @@ var LoanQuery = class {
43708
43955
  filters.orderBy || "createdAt",
43709
43956
  filters.orderDirection || "desc"
43710
43957
  );
43711
- const enrichedLoans = await this.enrichLoansWithVaultAddresses(result.positions);
43958
+ const enrichedLoans = await this.enrichLoansWithVaultAddresses(
43959
+ result.positions
43960
+ );
43712
43961
  return {
43713
43962
  loans: enrichedLoans,
43714
43963
  page,
@@ -43748,9 +43997,7 @@ var LoanQuery = class {
43748
43997
  loan.pkpId,
43749
43998
  this.config.provider
43750
43999
  );
43751
- const addressesResult = await this.config.bitcoinOperations.deriveAddresses(
43752
- pkpPublicKey
43753
- );
44000
+ const addressesResult = await this.config.bitcoinOperations.deriveAddresses(pkpPublicKey);
43754
44001
  if (addressesResult.success) {
43755
44002
  loan.collateral.vaultAddress = addressesResult.value;
43756
44003
  if (this.config.debug) {
@@ -43762,23 +44009,31 @@ var LoanQuery = class {
43762
44009
  }
43763
44010
  } else {
43764
44011
  if (this.config.debug) {
43765
- log.warn(`\u26A0\uFE0F Failed to derive vault addresses for loan ${loan.id}`, {
43766
- error: addressesResult.error.message
43767
- });
44012
+ log.warn(
44013
+ `\u26A0\uFE0F Failed to derive vault addresses for loan ${loan.id}`,
44014
+ {
44015
+ error: addressesResult.error.message
44016
+ }
44017
+ );
43768
44018
  }
43769
44019
  }
43770
44020
  } catch (error) {
43771
44021
  if (this.config.debug) {
43772
- log.warn(`\u26A0\uFE0F Vault address derivation error for loan ${loan.id}`, {
43773
- error: error instanceof Error ? error.message : String(error)
43774
- });
44022
+ log.warn(
44023
+ `\u26A0\uFE0F Vault address derivation error for loan ${loan.id}`,
44024
+ {
44025
+ error: error instanceof Error ? error.message : String(error)
44026
+ }
44027
+ );
43775
44028
  }
43776
44029
  }
43777
44030
  })
43778
44031
  );
43779
44032
  }
43780
44033
  if (this.config.debug) {
43781
- log.info(`\u2705 Completed vault address enrichment for ${loans.length} loans`);
44034
+ log.info(
44035
+ `\u2705 Completed vault address enrichment for ${loans.length} loans`
44036
+ );
43782
44037
  }
43783
44038
  return loans;
43784
44039
  }
@@ -43801,12 +44056,12 @@ var LoanQuery = class {
43801
44056
  */
43802
44057
  mapStringToStatus(statusString) {
43803
44058
  const statusMap = {
43804
- "PENDING_DEPOSIT": 0,
43805
- "ACTIVE": 1,
43806
- "EXPIRED": 2,
43807
- "REPAID": 3,
43808
- "LIQUIDATED": 4,
43809
- "EXTENDED": 5
44059
+ PENDING_DEPOSIT: 0,
44060
+ ACTIVE: 1,
44061
+ EXPIRED: 2,
44062
+ REPAID: 3,
44063
+ LIQUIDATED: 4,
44064
+ EXTENDED: 5
43810
44065
  };
43811
44066
  return statusMap[statusString.toUpperCase()] ?? null;
43812
44067
  }
@@ -43814,7 +44069,15 @@ var LoanQuery = class {
43814
44069
  * Validate if a string is a valid loan status
43815
44070
  */
43816
44071
  isValidStatus(statusString) {
43817
- const validStatuses = ["PENDING_DEPOSIT", "ACTIVE", "EXPIRED", "REPAID", "LIQUIDATED", "EXTENDED", "CLOSED"];
44072
+ const validStatuses = [
44073
+ "PENDING_DEPOSIT",
44074
+ "ACTIVE",
44075
+ "EXPIRED",
44076
+ "REPAID",
44077
+ "LIQUIDATED",
44078
+ "EXTENDED",
44079
+ "CLOSED"
44080
+ ];
43818
44081
  return validStatuses.includes(statusString.toUpperCase());
43819
44082
  }
43820
44083
  /**
@@ -44310,9 +44573,9 @@ async function getBitcoinAddressesFromPkp(pkpPublicKey) {
44310
44573
  var BitcoinUtils = class {
44311
44574
  static validateAddress(address) {
44312
44575
  const base58Pattern = /^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
44576
+ const bech32Pattern = /^(bc1|tb1|bcrt1)[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{11,87}$/;
44313
44577
  const isBase58 = base58Pattern.test(address) && address.length >= 26 && address.length <= 35;
44314
- const bech32Pattern = /^(bc1|tb1|bcrt1)[a-z0-9]{39,87}$/;
44315
- const isBech32 = bech32Pattern.test(address);
44578
+ const isBech32 = bech32Pattern.test(address.toLowerCase());
44316
44579
  return isBase58 || isBech32;
44317
44580
  }
44318
44581
  static formatTransaction(hash3, amount, recipient) {
@@ -44350,33 +44613,212 @@ var BitcoinUtils = class {
44350
44613
  // src/utils/bitcoin-provider.utils.ts
44351
44614
  import axios from "axios";
44352
44615
 
44616
+ // ../lit-actions/src/modules/lit-action-logger.module.ts
44617
+ var NoOpLogger = class {
44618
+ stepStart(_stepId, _description) {
44619
+ }
44620
+ stepEnd(_stepId, _warnThresholdMs) {
44621
+ }
44622
+ log(_stepId, _message) {
44623
+ }
44624
+ warn(_stepId, _message) {
44625
+ }
44626
+ error(_stepId, _message) {
44627
+ }
44628
+ getElapsed() {
44629
+ return 0;
44630
+ }
44631
+ getRemaining() {
44632
+ return 3e4;
44633
+ }
44634
+ summary() {
44635
+ }
44636
+ getExecutionId() {
44637
+ return "";
44638
+ }
44639
+ isDebugEnabled() {
44640
+ return false;
44641
+ }
44642
+ };
44643
+ var DebugLogger = class {
44644
+ executionId;
44645
+ executionStartTime;
44646
+ stepStartTimes = /* @__PURE__ */ new Map();
44647
+ stepDurations = /* @__PURE__ */ new Map();
44648
+ TIMEOUT_MS = 3e4;
44649
+ // 30 seconds LIT Action timeout
44650
+ actionName;
44651
+ constructor(actionName) {
44652
+ this.actionName = actionName;
44653
+ this.executionStartTime = Date.now();
44654
+ const timestamp = Date.now();
44655
+ const random = Math.random().toString(36).substring(2, 9);
44656
+ this.executionId = `exec_${timestamp}_${random}`;
44657
+ this.logHeader();
44658
+ }
44659
+ /**
44660
+ * Log action header with execution context
44661
+ */
44662
+ logHeader() {
44663
+ console.log(
44664
+ `[${this.actionName}] ========================================`
44665
+ );
44666
+ console.log(`[${this.actionName}] Execution started`);
44667
+ console.log(`[${this.actionName}] Execution ID: ${this.executionId}`);
44668
+ const isLitNode = typeof globalThis.litNodeContext !== "undefined";
44669
+ if (isLitNode) {
44670
+ console.log(`[${this.actionName}] Context: LIT Node`);
44671
+ console.log(
44672
+ `[${this.actionName}] Node: ${globalThis.litNodeContext?.nodeAddress || "unknown"}`
44673
+ );
44674
+ } else {
44675
+ console.log(`[${this.actionName}] Context: Browser/Test`);
44676
+ }
44677
+ console.log(
44678
+ `[${this.actionName}] ========================================`
44679
+ );
44680
+ }
44681
+ stepStart(stepId, description) {
44682
+ this.stepStartTimes.set(stepId, Date.now());
44683
+ const elapsed = Date.now() - this.executionStartTime;
44684
+ const remaining = this.TIMEOUT_MS - elapsed;
44685
+ console.log(`[Step ${stepId}] ${description}...`);
44686
+ console.log(
44687
+ `[Step ${stepId}] Elapsed: ${elapsed}ms | Remaining: ${remaining}ms`
44688
+ );
44689
+ }
44690
+ stepEnd(stepId, warnThresholdMs = 5e3) {
44691
+ const startTime = this.stepStartTimes.get(stepId);
44692
+ if (!startTime) {
44693
+ console.warn(
44694
+ `[Step ${stepId}] \u26A0\uFE0F stepEnd called without matching stepStart`
44695
+ );
44696
+ return;
44697
+ }
44698
+ const duration = Date.now() - startTime;
44699
+ this.stepDurations.set(stepId, duration);
44700
+ console.log(`[Step ${stepId}] Duration: ${duration}ms`);
44701
+ if (duration > warnThresholdMs) {
44702
+ console.warn(
44703
+ `\u26A0\uFE0F [Step ${stepId}] Took ${duration}ms (> ${warnThresholdMs}ms threshold)`
44704
+ );
44705
+ }
44706
+ const elapsed = Date.now() - this.executionStartTime;
44707
+ const remaining = this.TIMEOUT_MS - elapsed;
44708
+ if (remaining < 5e3) {
44709
+ console.warn(
44710
+ `\u26A0\uFE0F [Step ${stepId}] Time remaining: ${remaining}ms (approaching timeout)`
44711
+ );
44712
+ }
44713
+ }
44714
+ log(stepId, message) {
44715
+ console.log(`[Step ${stepId}] ${message}`);
44716
+ }
44717
+ warn(stepId, message) {
44718
+ console.warn(`\u26A0\uFE0F [Step ${stepId}] ${message}`);
44719
+ }
44720
+ error(stepId, message) {
44721
+ console.error(`\u274C [Step ${stepId}] ${message}`);
44722
+ }
44723
+ getElapsed() {
44724
+ return Date.now() - this.executionStartTime;
44725
+ }
44726
+ getRemaining() {
44727
+ return this.TIMEOUT_MS - this.getElapsed();
44728
+ }
44729
+ summary() {
44730
+ const totalDuration = Date.now() - this.executionStartTime;
44731
+ const remaining = this.TIMEOUT_MS - totalDuration;
44732
+ console.log(
44733
+ `[${this.actionName}] ========================================`
44734
+ );
44735
+ console.log(`[${this.actionName}] Execution Summary`);
44736
+ console.log(`[${this.actionName}] Execution ID: ${this.executionId}`);
44737
+ console.log(
44738
+ `[${this.actionName}] Total time: ${(totalDuration / 1e3).toFixed(2)}s`
44739
+ );
44740
+ console.log(`[${this.actionName}] Time remaining: ${remaining}ms`);
44741
+ if (this.stepDurations.size > 0) {
44742
+ console.log(`[${this.actionName}] Step breakdown:`);
44743
+ for (const [stepId, duration] of this.stepDurations.entries()) {
44744
+ const percent = (duration / totalDuration * 100).toFixed(1);
44745
+ console.log(
44746
+ `[${this.actionName}] Step ${stepId}: ${duration}ms (${percent}%)`
44747
+ );
44748
+ }
44749
+ }
44750
+ if (totalDuration > 2e4) {
44751
+ console.warn(
44752
+ `\u26A0\uFE0F [${this.actionName}] Slow execution: ${(totalDuration / 1e3).toFixed(2)}s (${remaining}ms remaining)`
44753
+ );
44754
+ }
44755
+ if (remaining < 5e3) {
44756
+ console.warn(
44757
+ `\u26A0\uFE0F [${this.actionName}] CRITICAL: Only ${remaining}ms remaining before timeout!`
44758
+ );
44759
+ }
44760
+ console.log(
44761
+ `[${this.actionName}] ========================================`
44762
+ );
44763
+ }
44764
+ getExecutionId() {
44765
+ return this.executionId;
44766
+ }
44767
+ isDebugEnabled() {
44768
+ return true;
44769
+ }
44770
+ };
44771
+ var LitActionLogger = class {
44772
+ /**
44773
+ * Create logger instance
44774
+ * Returns NoOpLogger when disabled (99% case), DebugLogger when enabled
44775
+ * @param actionName - Name of the LIT Action (for logging context)
44776
+ * @param debugAction - Optional override for globalThis.debugAction
44777
+ */
44778
+ static create(actionName = "LIT Action", debugAction) {
44779
+ const debugEnabled = debugAction ?? globalThis.debugAction ?? false;
44780
+ if (debugEnabled) {
44781
+ return new DebugLogger(actionName);
44782
+ } else {
44783
+ return new NoOpLogger();
44784
+ }
44785
+ }
44786
+ };
44787
+
44353
44788
  // ../lit-actions/src/modules/bitcoin-data-provider.module.ts
44354
44789
  var BitcoinDataProvider = class {
44355
44790
  config;
44356
44791
  timeout;
44792
+ logger;
44357
44793
  constructor(config) {
44358
44794
  this.config = config;
44359
- this.timeout = config.timeout || 1e4;
44795
+ this.timeout = config.timeout || 15e3;
44796
+ this.logger = LitActionLogger.create("BitcoinDataProvider");
44360
44797
  }
44361
44798
  /**
44362
44799
  * Get current Bitcoin block height from provider
44363
44800
  */
44364
44801
  async getCurrentBlockHeight() {
44802
+ this.logger.stepStart("0", "getCurrentBlockHeight");
44365
44803
  if (this.config.rpcHelper) {
44366
44804
  const blockCount = await this.config.rpcHelper.getBlockCount();
44805
+ this.logger.stepEnd("0");
44367
44806
  return blockCount;
44368
44807
  }
44369
44808
  const controller = new AbortController();
44370
44809
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
44371
44810
  try {
44372
- const response = await fetch(`${this.config.providerUrl}/blocks/tip/height`, {
44373
- signal: controller.signal,
44374
- headers: {
44375
- Accept: "text/plain",
44376
- "User-Agent": "Mozilla/5.0 (compatible; DiamondHandsValidator/1.0)",
44377
- "ngrok-skip-browser-warning": "true"
44811
+ const response = await fetch(
44812
+ `${this.config.providerUrl}/blocks/tip/height`,
44813
+ {
44814
+ signal: controller.signal,
44815
+ headers: {
44816
+ Accept: "text/plain",
44817
+ "User-Agent": "Mozilla/5.0 (compatible; DiamondHandsValidator/1.0)",
44818
+ "ngrok-skip-browser-warning": "true"
44819
+ }
44378
44820
  }
44379
- });
44821
+ );
44380
44822
  clearTimeout(timeoutId);
44381
44823
  if (!response.ok) {
44382
44824
  throw new Error(
@@ -44388,9 +44830,11 @@ var BitcoinDataProvider = class {
44388
44830
  if (isNaN(height)) {
44389
44831
  throw new Error(`Invalid block height response: ${heightText}`);
44390
44832
  }
44833
+ this.logger.stepEnd("0");
44391
44834
  return height;
44392
44835
  } catch (error) {
44393
44836
  clearTimeout(timeoutId);
44837
+ this.logger.stepEnd("0");
44394
44838
  if (error.name === "AbortError") {
44395
44839
  throw new Error(`Request timeout after ${this.timeout}ms`);
44396
44840
  }
@@ -44404,9 +44848,9 @@ var BitcoinDataProvider = class {
44404
44848
  * @returns Array of UTXOs
44405
44849
  */
44406
44850
  async getUTXOs(address) {
44407
- console.log(`[Bitcoin Data] Original address: "${address}"`);
44851
+ this.logger.log("0", `Original address: "${address}"`);
44408
44852
  const cleanAddress = this.stripNetworkPrefix(address);
44409
- console.log(`[Bitcoin Data] Cleaned address: "${cleanAddress}"`);
44853
+ this.logger.log("0", `Cleaned address: "${cleanAddress}"`);
44410
44854
  if (this.config.rpcHelper) {
44411
44855
  return await this.fetchUTXOsFromRPC(cleanAddress);
44412
44856
  }
@@ -44416,23 +44860,25 @@ var BitcoinDataProvider = class {
44416
44860
  cleanAddress
44417
44861
  );
44418
44862
  } catch (error) {
44419
- console.warn(`[Bitcoin Data] Primary provider failed: ${error.message}`);
44863
+ this.logger.warn("0", `Primary provider failed: ${error.message}`);
44420
44864
  if (this.config.fallbackProviders && this.config.fallbackProviders.length > 0) {
44421
44865
  const sortedFallbacks = [...this.config.fallbackProviders].sort(
44422
44866
  (a, b2) => a.priority - b2.priority
44423
44867
  );
44424
44868
  for (const fallback of sortedFallbacks) {
44425
44869
  try {
44426
- console.log(
44427
- `[Bitcoin Data] Trying fallback: ${fallback.name} (${fallback.url})`
44870
+ this.logger.log(
44871
+ "0",
44872
+ `Trying fallback: ${fallback.name} (${fallback.url})`
44428
44873
  );
44429
44874
  return await this.fetchUTXOsFromProvider(
44430
44875
  fallback.url,
44431
44876
  cleanAddress
44432
44877
  );
44433
44878
  } catch (fallbackError) {
44434
- console.warn(
44435
- `[Bitcoin Data] Fallback ${fallback.name} failed: ${fallbackError.message}`
44879
+ this.logger.warn(
44880
+ "0",
44881
+ `Fallback ${fallback.name} failed: ${fallbackError.message}`
44436
44882
  );
44437
44883
  continue;
44438
44884
  }
@@ -44520,10 +44966,11 @@ var BitcoinDataProvider = class {
44520
44966
  * - providerUrl must include full base path (e.g., "http://localhost:3002/api/esplora")
44521
44967
  */
44522
44968
  async fetchUTXOsFromProvider(providerUrl, address) {
44969
+ this.logger.stepStart("1", "fetchUTXOsFromProvider");
44523
44970
  const endpoint = `${providerUrl}/address/${address}/utxos`;
44524
- console.log(`Fetching UTXOs from ${endpoint}`);
44971
+ this.logger.log("1", `Fetching UTXOs from ${endpoint}`);
44525
44972
  const currentBlockHeight = await this.getCurrentBlockHeight();
44526
- console.log(`[Bitcoin Data] Current block height: ${currentBlockHeight}`);
44973
+ this.logger.log("1", `Current block height: ${currentBlockHeight}`);
44527
44974
  const controller = new AbortController();
44528
44975
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
44529
44976
  try {
@@ -44544,13 +44991,16 @@ var BitcoinDataProvider = class {
44544
44991
  );
44545
44992
  }
44546
44993
  const data = await response.json();
44547
- console.log(
44548
- `[Bitcoin Data] Raw API Response:`,
44549
- JSON.stringify(data, null, 2)
44994
+ this.logger.log(
44995
+ "1",
44996
+ `Raw API Response: ${JSON.stringify(data, null, 2)}`
44550
44997
  );
44551
- return this.parseBlockstreamUTXOs(data, currentBlockHeight);
44998
+ const utxos = this.parseBlockstreamUTXOs(data, currentBlockHeight);
44999
+ this.logger.stepEnd("1");
45000
+ return utxos;
44552
45001
  } catch (error) {
44553
45002
  clearTimeout(timeoutId);
45003
+ this.logger.stepEnd("1");
44554
45004
  if (error.name === "AbortError") {
44555
45005
  throw new Error(`Request timeout after ${this.timeout}ms`);
44556
45006
  }
@@ -44574,22 +45024,27 @@ var BitcoinDataProvider = class {
44574
45024
  const retryDelay = 500;
44575
45025
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
44576
45026
  try {
44577
- console.log(`[Bitcoin Data] UTXO query attempt ${attempt}/${maxRetries}...`);
45027
+ this.logger.log("2", `UTXO query attempt ${attempt}/${maxRetries}...`);
44578
45028
  utxos = await this.getUTXOs(address);
44579
- console.log(`[Bitcoin Data] UTXO query succeeded on attempt ${attempt}`);
45029
+ this.logger.log("2", `UTXO query succeeded on attempt ${attempt}`);
44580
45030
  lastError = null;
44581
45031
  break;
44582
45032
  } catch (error) {
44583
45033
  lastError = error;
44584
- console.error(`[Bitcoin Data] UTXO query failed on attempt ${attempt}:`, error.message);
45034
+ this.logger.error(
45035
+ "2",
45036
+ `UTXO query failed on attempt ${attempt}: ${error.message}`
45037
+ );
44585
45038
  if (attempt < maxRetries) {
44586
- console.log(`[Bitcoin Data] Waiting ${retryDelay}ms before retry...`);
45039
+ this.logger.log("2", `Waiting ${retryDelay}ms before retry...`);
44587
45040
  await new Promise((resolve) => setTimeout(resolve, retryDelay));
44588
45041
  }
44589
45042
  }
44590
45043
  }
44591
45044
  if (lastError) {
44592
- throw new Error(`Failed to query UTXOs after ${maxRetries} attempts: ${lastError.message}`);
45045
+ throw new Error(
45046
+ `Failed to query UTXOs after ${maxRetries} attempts: ${lastError.message}`
45047
+ );
44593
45048
  }
44594
45049
  const totalBalance = utxos.reduce((sum, utxo) => sum + utxo.satoshis, 0n);
44595
45050
  const confirmedBalance = utxos.filter((utxo) => utxo.confirmations >= minConfirmations).reduce((sum, utxo) => sum + utxo.satoshis, 0n);
@@ -44602,6 +45057,72 @@ var BitcoinDataProvider = class {
44602
45057
  unconfirmedBalance
44603
45058
  };
44604
45059
  }
45060
+ /**
45061
+ * Get balance for a Bitcoin address (fast, no UTXO details)
45062
+ *
45063
+ * WARNING: This method does NOT validate individual UTXOs.
45064
+ * Use ONLY for non-critical balance display, never for authorization validation.
45065
+ * For authorization/security: ALWAYS use getUTXOSet() with full UTXO validation.
45066
+ *
45067
+ * Uses Esplora /address/:address endpoint to get confirmed balance from chain_stats.
45068
+ *
45069
+ * @param address - Bitcoin address
45070
+ * @returns Balance in satoshis (confirmed balance only)
45071
+ * @throws Error if the request fails or response is invalid
45072
+ */
45073
+ async getBalance(address) {
45074
+ const cleanAddress = this.stripNetworkPrefix(address);
45075
+ const endpoint = `${this.config.providerUrl}/address/${cleanAddress}`;
45076
+ this.logger.log("3", `Fetching balance from ${endpoint}`);
45077
+ const controller = new AbortController();
45078
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
45079
+ try {
45080
+ const response = await fetch(endpoint, {
45081
+ signal: controller.signal,
45082
+ headers: {
45083
+ Accept: "application/json",
45084
+ "Content-Type": "application/json",
45085
+ "User-Agent": "Mozilla/5.0 (compatible; DiamondHandsValidator/1.0)",
45086
+ "ngrok-skip-browser-warning": "true"
45087
+ }
45088
+ });
45089
+ clearTimeout(timeoutId);
45090
+ if (!response.ok) {
45091
+ throw new Error(
45092
+ `Bitcoin provider error: ${response.status} ${response.statusText}`
45093
+ );
45094
+ }
45095
+ const data = await response.json();
45096
+ if (!data.chain_stats) {
45097
+ throw new Error("Invalid response: missing chain_stats");
45098
+ }
45099
+ const fundedTxoSum = data.chain_stats.funded_txo_sum;
45100
+ const spentTxoSum = data.chain_stats.spent_txo_sum;
45101
+ if (fundedTxoSum === void 0 || spentTxoSum === void 0) {
45102
+ throw new Error(
45103
+ `Invalid response: missing required fields. funded_txo_sum: ${fundedTxoSum}, spent_txo_sum: ${spentTxoSum}`
45104
+ );
45105
+ }
45106
+ const confirmedBalance = fundedTxoSum - spentTxoSum;
45107
+ const balance = BigInt(confirmedBalance);
45108
+ this.logger.log("3", `Balance: ${balance.toString()} sats`);
45109
+ this.logger.log(
45110
+ "3",
45111
+ ` - Funded: ${fundedTxoSum} sats, Spent: ${spentTxoSum} sats`
45112
+ );
45113
+ return balance;
45114
+ } catch (error) {
45115
+ clearTimeout(timeoutId);
45116
+ if (error.name === "AbortError") {
45117
+ throw new Error(`Request timeout after ${this.timeout}ms`);
45118
+ }
45119
+ const errorMessage = error.message || "Unknown error";
45120
+ this.logger.log("3", `Balance fetch failed: ${errorMessage}`);
45121
+ throw new Error(
45122
+ `Failed to fetch Bitcoin balance for address ${cleanAddress}: ${errorMessage}`
45123
+ );
45124
+ }
45125
+ }
44605
45126
  /**
44606
45127
  * Get transaction with confirmation count
44607
45128
  *
@@ -44630,12 +45151,9 @@ var BitcoinDataProvider = class {
44630
45151
  const controller = new AbortController();
44631
45152
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
44632
45153
  try {
44633
- const response = await fetch(
44634
- `${this.config.providerUrl}/api/tx/${txid}`,
44635
- {
44636
- signal: controller.signal
44637
- }
44638
- );
45154
+ const response = await fetch(`${this.config.providerUrl}/tx/${txid}`, {
45155
+ signal: controller.signal
45156
+ });
44639
45157
  clearTimeout(timeoutId);
44640
45158
  if (!response.ok) {
44641
45159
  if (response.status === 404) {
@@ -45524,9 +46042,15 @@ function loadSDKConfig() {
45524
46042
  const debugMode = getEnv("DEBUG_SDK") === "true" || environment === "datil";
45525
46043
  const runRealIntegrationTests = getEnv("RUN_REAL_INTEGRATION_TESTS") === "true";
45526
46044
  const litRelayUrl = getEnv("LIT_RELAY_URL");
45527
- const ethRpcUrl = getEnv("ETH_RPC_URL") || "https://rpc.ankr.com/eth";
45528
- const polygonRpcUrl = getEnv("POLYGON_RPC_URL") || "https://rpc.ankr.com/polygon";
46045
+ const ethRpcUrl = getEnv("ETH_RPC_URL");
46046
+ const polygonRpcUrl = getEnv("POLYGON_RPC_URL");
45529
46047
  const pkpMintPrivateKey = getEnv("PKP_MINT_PRIVATE_KEY");
46048
+ if (!ethRpcUrl) {
46049
+ throw new Error("ETH_RPC_URL environment variable is required");
46050
+ }
46051
+ if (!polygonRpcUrl) {
46052
+ throw new Error("POLYGON_RPC_URL environment variable is required");
46053
+ }
45530
46054
  const validNetworks = ["datil"];
45531
46055
  if (!validNetworks.includes(litNetwork)) {
45532
46056
  throw new Error(
@@ -45580,7 +46104,7 @@ var POSITION_MANAGER_ABI = [
45580
46104
  // Core position management
45581
46105
  "function createPosition(bytes32 pkpId, bytes calldata validatorSignature, address borrower, string calldata vaultAddress, uint256 selectedTermMonths) external returns (bool)",
45582
46106
  "function deletePosition(bytes32 positionId) external",
45583
- "function getPositionDetails(bytes32 positionId) external view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status))",
46107
+ "function getPositionById(bytes32 positionId) external view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status))",
45584
46108
  "function getUserPositions(address user) external view returns (bytes32[] memory)",
45585
46109
  "function calculateCollateralRatio(bytes32 positionId) external view returns (uint256)",
45586
46110
  // Access control
@@ -45588,9 +46112,10 @@ var POSITION_MANAGER_ABI = [
45588
46112
  "function ADMIN_ROLE() external view returns (bytes32)",
45589
46113
  "function paused() external view returns (bool)",
45590
46114
  // Core flow transactions
45591
- "function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)",
46115
+ "function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)",
46116
+ // PositionManager.mintUCD()
45592
46117
  "function repayPosition(bytes32 positionId, uint256 repaymentAmount) external returns (bool)",
45593
- "function makePartialPayment(bytes32 positionId, uint256 paymentAmount) external returns (bool)",
46118
+ "function makePayment(bytes32 positionId, uint256 paymentAmount, uint256 quantumTimestamp, uint256 btcPrice, bytes calldata paymentValidatorSignature) external returns (bool)",
45594
46119
  // addCollateral removed - BTC balance is now queried on-chain via lit-actions with signature validation
45595
46120
  "function withdrawBTC(bytes32 positionId, string withdrawalAddress, uint256 networkFee) external returns (bool)",
45596
46121
  "function extendPosition(bytes32 positionId, uint256 selectedTerm) external returns (bool)",
@@ -45711,6 +46236,7 @@ var DiamondHandsGraph = class {
45711
46236
  * Converts flat graph structure to nested LoanData structure
45712
46237
  */
45713
46238
  transformGraphPositionToLoanData(graphPosition) {
46239
+ const ucdDebt = graphPosition.ucdDebt ? Number(graphPosition.ucdDebt) : 0;
45714
46240
  return {
45715
46241
  id: graphPosition.id,
45716
46242
  pkpId: graphPosition.pkpId,
@@ -45723,14 +46249,16 @@ var DiamondHandsGraph = class {
45723
46249
  loan: {
45724
46250
  ucdMinted: graphPosition.ucdMinted ? Number(graphPosition.ucdMinted) : 0,
45725
46251
  ucdPaid: graphPosition.ucdPaid ? Number(graphPosition.ucdPaid) : 0,
45726
- ucdDebt: graphPosition.ucdDebt ? Number(graphPosition.ucdDebt) : 0,
46252
+ ucdDebt,
45727
46253
  selectedTerm: graphPosition.selectedTerm ? Number(graphPosition.selectedTerm) : 0,
45728
46254
  status: graphPosition.status,
45729
46255
  expiryAt: graphPosition.expiryAt ? Number(graphPosition.expiryAt) : 0
45730
46256
  },
45731
46257
  collateral: {
45732
46258
  vaultAddress: graphPosition.vaultAddress || ""
45733
- }
46259
+ },
46260
+ // Backwards compatibility: provide ucdDebt at top level for components expecting flat structure
46261
+ ucdDebt
45734
46262
  };
45735
46263
  }
45736
46264
  /**
@@ -46547,7 +47075,7 @@ var DiamondHandsGraph = class {
46547
47075
  first = this.defaultPageSize,
46548
47076
  skip = 0
46549
47077
  } = filters || {};
46550
- let whereConditions = [];
47078
+ const whereConditions = [];
46551
47079
  if (user)
46552
47080
  whereConditions.push(`user: "${user.toLowerCase()}"`);
46553
47081
  if (stablecoin)
@@ -46584,7 +47112,7 @@ var DiamondHandsGraph = class {
46584
47112
  * Get PSM analytics for a date range
46585
47113
  */
46586
47114
  async getPSMDailyMetrics(startDate, endDate, first = 30) {
46587
- let whereConditions = [];
47115
+ const whereConditions = [];
46588
47116
  if (startDate)
46589
47117
  whereConditions.push(`date_gte: "${startDate}"`);
46590
47118
  if (endDate)
@@ -46961,6 +47489,13 @@ import { LitOps } from "@gvnrdao/dh-lit-ops";
46961
47489
 
46962
47490
  // src/utils/telegram-messaging.utils.ts
46963
47491
  var TelegramBot = null;
47492
+ try {
47493
+ if (typeof window === "undefined" && typeof global !== "undefined") {
47494
+ TelegramBot = __require("node-telegram-bot-api");
47495
+ }
47496
+ } catch (error) {
47497
+ console.warn("Telegram bot API not available:", error instanceof Error ? error.message : String(error));
47498
+ }
46964
47499
  async function sendTelegramMessage(chatId, chatToken, message, threadId) {
46965
47500
  try {
46966
47501
  const bot = new TelegramBot(chatToken, { polling: false });
@@ -46985,7 +47520,7 @@ async function sendTelegramMessage(chatId, chatToken, message, threadId) {
46985
47520
  }
46986
47521
  }
46987
47522
  function formatMintMessage(mintAmount, loanId, txHash) {
46988
- return `${mintAmount} UCD was minted for loan id: ${loanId} ${txHash}`;
47523
+ return `${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
46989
47524
  }
46990
47525
 
46991
47526
  // src/modules/diamond-hands-sdk.ts
@@ -47048,7 +47583,12 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47048
47583
  network: config.litNetwork || "datil",
47049
47584
  signer: config.mode === "standalone" ? config.litOpsSigner : void 0,
47050
47585
  serviceEndpoint: isServiceModeConfig(config) ? config.serviceEndpoint : void 0,
47051
- debug: config.debug
47586
+ debug: config.debug,
47587
+ holderCapacityCreditsLitPrivateKey: config.holderCapacityCreditsLitPrivateKey
47588
+ // TODO Round 2: Add litActionExecution config when added to config.i.ts interface
47589
+ // ...((config as any).litActionExecution ? {
47590
+ // litActionExecution: (config as any).litActionExecution,
47591
+ // } : {}),
47052
47592
  });
47053
47593
  if (config.debug) {
47054
47594
  log.info("\u2705 LitOps initialized", {
@@ -47140,7 +47680,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47140
47680
  litActionCid: config.litActionCid || "",
47141
47681
  userId: config.contractSigner.address,
47142
47682
  debug: config.debug,
47143
- validatorVersion: config.validatorVersion
47683
+ loanCreationValidatorVersion: config.validators.loanCreation,
47684
+ temperSignaturesTest: config.temperSignaturesTest
47144
47685
  });
47145
47686
  if (!loanCreatorResult.success) {
47146
47687
  throw new Error(
@@ -47369,6 +47910,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47369
47910
  "[DEBUG] enrichConfigWithNetworkDefaults - output config.serviceEndpoint:",
47370
47911
  enrichedConfig.serviceEndpoint
47371
47912
  );
47913
+ if (!enrichedConfig.validators) {
47914
+ enrichedConfig.validators = {
47915
+ loanCreation: 1,
47916
+ // Default PKP security validation version
47917
+ minting: 4,
47918
+ // Default business rules validation version
47919
+ payment: 1,
47920
+ // Default payment validation version
47921
+ extension: 4
47922
+ // Default extension validation version
47923
+ };
47924
+ if (config.debug) {
47925
+ log.info("\u2705 Using default validator versions");
47926
+ }
47927
+ }
47372
47928
  return enrichedConfig;
47373
47929
  }
47374
47930
  /**
@@ -47622,15 +48178,15 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47622
48178
  log.info("\u{1F510} Performing LIT Action validation...", {});
47623
48179
  }
47624
48180
  try {
47625
- const position = await this.getPosition(request.positionId);
47626
- if (!position) {
48181
+ const position2 = await this.getPosition(request.positionId);
48182
+ if (!position2) {
47627
48183
  return {
47628
48184
  success: false,
47629
48185
  error: `Position ${request.positionId} not found in PositionManager. Please verify the position ID is correct.`
47630
48186
  };
47631
48187
  }
47632
48188
  if (this.config.debug) {
47633
- log.info(` Position PKP ID: ${position.pkpId}`);
48189
+ log.info(` Position PKP ID: ${position2.pkpId}`);
47634
48190
  }
47635
48191
  let pkpPublicKey;
47636
48192
  let pkpEthAddress;
@@ -47653,14 +48209,14 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47653
48209
  } else {
47654
48210
  try {
47655
48211
  pkpPublicKey = await getPKPPublicKeyFromTokenId(
47656
- position.pkpId,
48212
+ position2.pkpId,
47657
48213
  this.getProviderOrThrow()
47658
48214
  );
47659
48215
  pkpEthAddress = ethers_exports.utils.computeAddress(pkpPublicKey);
47660
48216
  pkpCache.set(request.positionId, {
47661
48217
  publicKey: pkpPublicKey,
47662
48218
  ethAddress: pkpEthAddress,
47663
- tokenId: position.pkpId
48219
+ tokenId: position2.pkpId
47664
48220
  });
47665
48221
  if (this.config.debug) {
47666
48222
  log.info("\u2705 Retrieved PKP data from contract and cached", {
@@ -47670,11 +48226,11 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47670
48226
  });
47671
48227
  }
47672
48228
  } catch (error) {
47673
- const errorMsg = `Failed to retrieve PKP public key for position ${request.positionId}. PKP Token ID: ${position.pkpId}. Error: ${error instanceof Error ? error.message : String(error)}`;
48229
+ const errorMsg = `Failed to retrieve PKP public key for position ${request.positionId}. PKP Token ID: ${position2.pkpId}. Error: ${error instanceof Error ? error.message : String(error)}`;
47674
48230
  if (this.config.debug) {
47675
48231
  log.error("\u274C PKP public key retrieval failed", {
47676
48232
  positionId: request.positionId,
47677
- pkpId: position.pkpId,
48233
+ pkpId: position2.pkpId,
47678
48234
  error: error instanceof Error ? error.message : String(error)
47679
48235
  });
47680
48236
  }
@@ -47759,7 +48315,7 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47759
48315
  litActionResult = await this.litOps.requestMintAuthorization({
47760
48316
  authMessage: {
47761
48317
  ...auth,
47762
- ...mode === "dev" && contracts && { contracts }
48318
+ ...mode === "dev" && contracts && { contractAddresses: contracts }
47763
48319
  },
47764
48320
  userSignature: auth.signature,
47765
48321
  ...request.customRpcUrl && { customRpcUrl: request.customRpcUrl },
@@ -47899,6 +48455,11 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47899
48455
  if (!signatureBytes.startsWith("0x")) {
47900
48456
  signatureBytes = "0x" + signatureBytes;
47901
48457
  }
48458
+ const finalSignature = maybeTemperSignature(
48459
+ signatureBytes,
48460
+ this.config.temperSignaturesTest,
48461
+ "requestMintUCD"
48462
+ );
47902
48463
  if (this.config.debug) {
47903
48464
  log.info(" Calling contract with LIT Action validated parameters:", {
47904
48465
  mintAmount: validationResponse.mintAmount,
@@ -47908,23 +48469,42 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47908
48469
  btcPrice: validationResponse.btcPrice,
47909
48470
  authorizedSpendsHash: validationResponse.authorizedSpendsHash,
47910
48471
  timestamp: validationResponse.timestamp,
47911
- signatureLength: signatureBytes.length
48472
+ signatureLength: finalSignature.length
47912
48473
  });
47913
48474
  }
47914
- const loanOpsAddress = this.getContractAddressesOrThrow().loanOperationsManager;
47915
- if (!loanOpsAddress) {
47916
- throw new Error("LoanOperationsManager address not configured");
48475
+ const positionManagerAddress = this.getContractAddressesOrThrow().positionManager;
48476
+ if (!positionManagerAddress) {
48477
+ throw new Error("PositionManager address not configured");
47917
48478
  }
47918
- const loanOpsAbi = [
47919
- "function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)"
48479
+ const positionManagerAbi = [
48480
+ "function mintUCD(bytes32 positionId, uint256 mintAmount, uint256 mintFee, uint256 newDebt, uint256 newCollateral, uint256 btcPrice, bytes32 authorizedSpendsHash, bytes32 ucdDebtHash, bytes32 contractHash, uint256 quantumTimestamp, bytes calldata mintValidatorSignature) external returns (bool)"
47920
48481
  ];
47921
- const loanOpsContract = new ethers_exports.Contract(
47922
- loanOpsAddress,
47923
- loanOpsAbi,
48482
+ const positionManager = new ethers_exports.Contract(
48483
+ positionManagerAddress,
48484
+ positionManagerAbi,
47924
48485
  this.getSignerOrThrow()
47925
48486
  );
47926
48487
  const positionIdBytes32 = this.toBytes32(request.positionId);
47927
- const tx = await loanOpsContract.mintUCD(
48488
+ const position = await this.getPosition(request.positionId);
48489
+ if (!position) {
48490
+ throw new Error(`Position not found: ${request.positionId}`);
48491
+ }
48492
+ const currentDebt = position.ucdDebt.toString();
48493
+ const ucdDebtHash = ethers_exports.utils.keccak256(
48494
+ ethers_exports.utils.defaultAbiCoder.encode(["uint256"], [currentDebt])
48495
+ );
48496
+ const contractHash = ethers_exports.utils.keccak256(
48497
+ ethers_exports.utils.defaultAbiCoder.encode(
48498
+ ["address", "address", "address", "address"],
48499
+ [
48500
+ positionManagerAddress,
48501
+ this.getContractAddressesOrThrow().loanOperationsManager,
48502
+ this.getContractAddressesOrThrow().termManager,
48503
+ this.getContractAddressesOrThrow().ucdController
48504
+ ]
48505
+ )
48506
+ );
48507
+ const tx = await positionManager.mintUCD(
47928
48508
  positionIdBytes32,
47929
48509
  validationResponse.mintAmount,
47930
48510
  validationResponse.mintFee,
@@ -47932,10 +48512,12 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
47932
48512
  validationResponse.newCollateral,
47933
48513
  validationResponse.btcPrice,
47934
48514
  validationResponse.authorizedSpendsHash,
48515
+ ucdDebtHash,
48516
+ contractHash,
47935
48517
  validationResponse.timestamp,
47936
- signatureBytes
48518
+ finalSignature
47937
48519
  );
47938
- const receipt = await tx.wait();
48520
+ const receipt = await tx.wait(1, 3e5);
47939
48521
  let amountMinted;
47940
48522
  let positionId;
47941
48523
  if (receipt && receipt.logs && receipt.logs.length > 0) {
@@ -48008,326 +48590,145 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
48008
48590
  /**
48009
48591
  * Extend position term
48010
48592
  *
48011
- * @param positionId - Position identifier
48012
- * @param selectedTerm - Extension term in months
48593
+ * Follows main's security pattern: authorization → LIT validation → contract execution
48594
+ *
48595
+ * @param _positionId - Position identifier
48596
+ * @param _selectedTerm - Extension term in months
48013
48597
  * @returns Transaction receipt
48014
48598
  */
48015
- /* INCOMPLETE - authorizeExtendPosition not implemented
48016
- async extendPosition(
48017
- positionId: string,
48018
- selectedTerm: number
48019
- ): Promise<ethers5.providers.TransactionReceipt> {
48599
+ async extendPosition(_positionId, _selectedTerm) {
48600
+ throw new Error("extendPosition not yet implemented - requires requestExtendAuthorization in lit-ops");
48601
+ }
48602
+ /**
48603
+ * Make a payment on a loan position
48604
+ *
48605
+ * Follows main's security pattern: authorization → LIT validation → contract execution
48606
+ *
48607
+ * @param request - Payment request with position ID and amount
48608
+ * @returns Payment result with transaction details
48609
+ */
48610
+ async makePayment(request) {
48611
+ this.ensureInitialized();
48612
+ try {
48020
48613
  if (this.config.debug) {
48021
- log.info("🔍 Extending position...", { positionId, selectedTerm });
48022
- }
48023
-
48024
- // Validate input parameters
48025
- if (!positionId || positionId === "0") {
48026
- throw new Error("positionId is required and must be non-zero");
48027
- }
48028
-
48029
- if (selectedTerm <= 0 || selectedTerm > 12) {
48030
- throw new Error("selectedTerm must be between 1 and 12 months");
48614
+ log.info(`\u{1F4B3} Making payment...`, {});
48615
+ log.info(` Amount: ${request.paymentAmount} UCD`);
48616
+ log.info(` positionId: ${request.positionId}`);
48031
48617
  }
48032
-
48033
- // Get position to retrieve PKP ID
48034
- const position = await this.getPosition(positionId);
48035
- if (!position) {
48036
- throw new Error(`Position ${positionId} not found`);
48618
+ if (!request.positionId || request.positionId === "0") {
48619
+ return {
48620
+ success: false,
48621
+ error: "positionId is required and must be non-zero"
48622
+ };
48037
48623
  }
48038
-
48039
- // Get PKP information
48040
- const pkpPublicKey = position.pkpId;
48041
- if (!pkpPublicKey) {
48042
- throw new Error(`PKP public key not found for position ${positionId}`);
48624
+ if (request.paymentAmount <= 0) {
48625
+ return {
48626
+ success: false,
48627
+ error: "Payment amount must be greater than zero"
48628
+ };
48043
48629
  }
48044
-
48045
- // Get PKP token ID and ETH address (if available)
48046
- const pkpTokenId = (position as any).pkpTokenId;
48047
- const pkpEthAddress = (position as any).pkpEthAddress;
48048
-
48049
- // Generate owner authorization
48050
- const network = await this.config.provider!.getNetwork();
48630
+ const network = await this.getProviderOrThrow().getNetwork();
48051
48631
  const chainId = Number(network.chainId);
48052
- const mode = this.config.litNetwork === "datil" ? "prod" : "dev";
48053
- const signer = this.config.contractSigner as Wallet;
48054
-
48055
- const ownerAuth = await generateExtendAuthorization(
48056
- positionId,
48057
- selectedTerm,
48058
- chainId,
48059
- mode,
48060
- signer
48061
- );
48062
-
48063
- // Call authorizeExtendPosition to get signed authorization
48064
- const authResult = await this.litOps.authorizeExtendPosition(
48065
- {
48066
- type: "extend",
48067
- positionId,
48068
- newTerm: selectedTerm,
48069
- chainId,
48070
- timestamp: ownerAuth.timestamp,
48071
- extensionFee: 0n, // Will be calculated by Lit Action
48072
- },
48073
- pkpPublicKey,
48074
- ownerAuth,
48075
- pkpTokenId,
48076
- pkpEthAddress
48632
+ const mode = chainId === 1 || chainId === 137 ? "prod" : "dev";
48633
+ const paymentAmountWei = ethers_exports.utils.parseEther(
48634
+ request.paymentAmount.toString()
48077
48635
  );
48078
-
48079
- if (!authResult.success) {
48080
- throw new Error(
48081
- `Authorization failed: ${authResult.error.message}`
48636
+ const contracts = mode === "dev" ? {
48637
+ PositionManager: this.config.contractAddresses?.positionManager || "",
48638
+ LoanOperationsManagerModule: this.config.contractAddresses?.loanOperationsManager || "",
48639
+ TermManagerModule: this.config.contractAddresses?.termManager || "",
48640
+ UCDController: this.config.contractAddresses?.ucdController || ""
48641
+ } : void 0;
48642
+ if (this.config.debug && mode === "dev") {
48643
+ log.info(" Contract addresses for dev mode:", {});
48644
+ log.info(
48645
+ ` PositionManager: ${contracts?.PositionManager || "MISSING"}`
48082
48646
  );
48083
- }
48084
-
48085
- const authResponse = authResult.value;
48086
-
48087
- if (!authResponse.approved) {
48088
- throw new Error(
48089
- `Extension not approved: ${authResponse.reason || "Unknown reason"}`
48647
+ log.info(
48648
+ ` LoanOpsManager: ${contracts?.LoanOperationsManagerModule || "MISSING"}`
48090
48649
  );
48091
- }
48092
-
48093
- if (!authResponse.signature) {
48094
- throw new Error("Authorization signature not provided");
48095
- }
48096
-
48097
- if (!authResponse.btcPrice) {
48098
- throw new Error("BTC price not provided in authorization response");
48099
- }
48100
-
48101
- if (!authResponse.quantumTimestamp) {
48102
- throw new Error("Quantum timestamp not provided in authorization response");
48103
- }
48104
-
48105
- // Call contract extendPosition
48106
- const contractManager = this.getContractManager();
48107
- const positionManagerResult = contractManager.getPositionManager();
48108
- if (!positionManagerResult.success) {
48109
- throw new Error(
48110
- `Failed to get PositionManager: ${positionManagerResult.error.message}`
48650
+ log.info(
48651
+ ` TermManager: ${contracts?.TermManagerModule || "MISSING"}`
48652
+ );
48653
+ log.info(
48654
+ ` UCDController: ${contracts?.UCDController || "MISSING"}`
48111
48655
  );
48112
48656
  }
48113
- const positionManager = positionManagerResult.value;
48114
- const btcPrice = BigInt(authResponse.btcPrice);
48115
- const quantumTimestamp = BigInt(authResponse.quantumTimestamp);
48116
-
48117
- if (this.config.debug) {
48118
- log.info("📝 Calling contract extendPosition", {
48119
- positionId,
48120
- selectedTerm,
48121
- btcPrice: btcPrice.toString(),
48122
- quantumTimestamp: quantumTimestamp.toString(),
48123
- hasSignature: !!authResponse.signature,
48124
- });
48657
+ if (mode === "dev" && contracts) {
48658
+ if (!contracts.PositionManager) {
48659
+ throw new Error("PositionManager address is required for dev mode");
48660
+ }
48661
+ if (!contracts.LoanOperationsManagerModule) {
48662
+ throw new Error(
48663
+ "LoanOperationsManagerModule address is required for dev mode"
48664
+ );
48665
+ }
48125
48666
  }
48126
-
48127
- const tx = await positionManager.extendPosition(
48128
- positionId,
48129
- selectedTerm,
48130
- quantumTimestamp,
48131
- btcPrice,
48132
- authResponse.signature
48667
+ let bitcoinProviderUrl;
48668
+ if (!bitcoinProviderUrl) {
48669
+ if (this.config.bitcoinProviders && this.config.bitcoinProviders.length > 0) {
48670
+ const firstProvider = this.config.bitcoinProviders[0];
48671
+ if (firstProvider && firstProvider.url) {
48672
+ bitcoinProviderUrl = firstProvider.url;
48673
+ }
48674
+ } else if (this.config.bitcoinRpcUrl) {
48675
+ bitcoinProviderUrl = this.config.bitcoinRpcUrl;
48676
+ }
48677
+ }
48678
+ const signer = this.getSignerOrThrow();
48679
+ const auth = await generatePaymentAuthorization(
48680
+ request.positionId,
48681
+ BigInt(paymentAmountWei.toString()),
48682
+ chainId,
48683
+ mode,
48684
+ signer
48133
48685
  );
48134
-
48135
48686
  if (this.config.debug) {
48136
- log.info(" Waiting for transaction confirmation...", {
48137
- txHash: tx.hash,
48138
- });
48687
+ log.info(" Payment authorization generated", {});
48688
+ log.info(` Timestamp: ${auth.timestamp}`);
48689
+ log.info(` ChainId: ${auth.chainId}`);
48690
+ log.info(` Mode: ${auth.mode}`);
48691
+ log.info(` Signature: ${auth.signature.substring(0, 20)}...`);
48692
+ }
48693
+ await waitUntilTimestamp(auth.timestamp);
48694
+ validateQuantumTiming(auth.timestamp, 30);
48695
+ return {
48696
+ success: false,
48697
+ error: "makePayment not yet implemented - requires requestPaymentAuthorization in lit-ops"
48698
+ };
48699
+ } catch (error) {
48700
+ let transactionHash;
48701
+ let receipt;
48702
+ if (error?.transaction?.hash) {
48703
+ transactionHash = error.transaction.hash;
48704
+ } else if (error?.transactionHash) {
48705
+ transactionHash = error.transactionHash;
48706
+ } else if (error?.receipt?.transactionHash) {
48707
+ transactionHash = error.receipt.transactionHash;
48708
+ receipt = error.receipt;
48139
48709
  }
48140
-
48141
- const receipt = await tx.wait();
48142
-
48710
+ const errorMsg = error instanceof Error ? error.message : String(error);
48143
48711
  if (this.config.debug) {
48144
- log.info(" Position extended successfully", {
48145
- txHash: receipt.transactionHash,
48146
- blockNumber: receipt.blockNumber,
48712
+ log.error("\u274C Payment failed", {
48713
+ transactionHash: transactionHash || "not available",
48714
+ error: errorMsg
48147
48715
  });
48148
48716
  }
48149
-
48150
- return receipt;
48151
- }
48152
- END INCOMPLETE extendPosition */
48153
- /**
48154
- * Make a partial payment on a loan
48155
- *
48156
- * @param request - Partial payment request with position ID and amount
48157
- * @returns Partial payment result with transaction details
48158
- */
48159
- /* INCOMPLETE - needs proper implementation
48160
- async partPayment(
48161
- request: PartialPaymentRequest
48162
- ): Promise<PartialPaymentResult> {
48163
- this.ensureInitialized();
48164
-
48165
- try {
48166
- if (this.config.debug) {
48167
- log.info(`💳 Making partial payment...`, {});
48168
- log.info(` Amount: ${request.paymentAmount} UCD`);
48169
- log.info(` positionId: ${request.positionId}`);
48170
- }
48171
-
48172
- // Get contract addresses
48173
- const contractAddresses = this.getContractAddressesOrThrow();
48174
- if (!contractAddresses.positionManager) {
48175
- return {
48176
- success: false,
48177
- error: "PositionManager address not configured",
48178
- };
48179
- }
48180
-
48181
- // Get PositionManager contract
48182
- const contractManager = this.getContractManager();
48183
- const positionManagerResult = contractManager.getPositionManager();
48184
- if (!positionManagerResult.success) {
48185
- return {
48186
- success: false,
48187
- error: `Failed to get PositionManager: ${positionManagerResult.error.message}`,
48188
- };
48189
- }
48190
- const positionManager = positionManagerResult.value;
48191
-
48192
- // Convert position ID to bytes32 format
48193
- const positionIdBytes32 = this.toBytes32(request.positionId);
48194
-
48195
- // Convert payment amount to wei
48196
- const paymentAmountWei = ethers5.utils.parseEther(
48197
- request.paymentAmount.toString()
48198
- );
48199
-
48200
- if (this.config.debug) {
48201
- log.info("📝 Calling makePartialPayment contract method...");
48202
- }
48203
-
48204
- // Call makePartialPayment - convert BigNumber to string for contract call
48205
- const tx = await positionManager.makePartialPayment(
48206
- positionIdBytes32,
48207
- paymentAmountWei.toString()
48208
- );
48209
-
48210
- if (this.config.debug) {
48211
- log.info(`📤 Transaction sent: ${tx.hash}`);
48212
- log.info("⏳ Waiting for transaction confirmation...");
48213
- }
48214
-
48215
- // Wait for transaction receipt using provider (more reliable than tx.wait())
48216
- const provider = contractManager.getProvider();
48217
- const timeoutMs = this.config.transactionTimeoutMs || 300000; // Default 5 minutes
48218
-
48219
- const receipt = await Promise.race([
48220
- provider.waitForTransaction(tx.hash, 1), // Wait for 1 confirmation
48221
- new Promise<never>((_, reject) =>
48222
- setTimeout(
48223
- () =>
48224
- reject(
48225
- new Error(
48226
- `Transaction timeout after ${timeoutMs}ms. Transaction hash: ${tx.hash}`
48227
- )
48228
- ),
48229
- timeoutMs
48230
- )
48231
- ),
48232
- ]);
48233
-
48234
- if (!receipt) {
48235
- return {
48236
- success: false,
48237
- error: `Transaction receipt not found for hash: ${tx.hash}`,
48238
- transactionHash: tx.hash,
48239
- };
48240
- }
48241
-
48242
- if (receipt.status === 0) {
48243
- return {
48244
- success: false,
48245
- error: "Transaction reverted",
48246
- transactionHash: tx.hash,
48247
- blockNumber: receipt.blockNumber,
48248
- };
48249
- }
48250
-
48251
- if (this.config.debug) {
48252
- log.info(`✅ Transaction confirmed in block ${receipt.blockNumber}`);
48253
- }
48254
-
48255
- // Return result
48256
- const result: PartialPaymentResult = {
48257
- success: true,
48258
- transactionHash:
48259
- (receipt as any).transactionHash || (receipt as any).hash,
48260
- blockNumber: receipt?.blockNumber,
48261
- blockHash: (receipt as any).blockHash,
48262
- gasUsed: receipt?.gasUsed?.toString(),
48263
- effectiveGasPrice:
48264
- (receipt as any).effectiveGasPrice?.toString() ||
48265
- (receipt as any).gasPrice?.toString(),
48266
- positionId: request.positionId,
48267
- paymentAmountUCD: request.paymentAmount,
48268
- };
48269
-
48270
- // Send Telegram notification if configured
48271
- if (this.config.telegram && result.transactionHash) {
48272
- const paymentAmount = result.paymentAmountUCD || request.paymentAmount;
48273
- const loanId = result.positionId || request.positionId;
48274
- const message = formatPartialPaymentMessage(
48275
- paymentAmount,
48276
- loanId,
48277
- result.transactionHash
48278
- );
48279
- await sendTelegramMessage(
48280
- this.config.telegram.chatId,
48281
- this.config.telegram.chatToken,
48282
- message,
48283
- this.config.telegram.threadId
48284
- );
48285
- }
48286
-
48287
- return result;
48288
- } catch (error: any) {
48289
- // Capture transaction hash if available
48290
- let transactionHash: string | undefined;
48291
- let receipt: any;
48292
-
48293
- if ((error as any)?.transaction?.hash) {
48294
- transactionHash = (error as any).transaction.hash;
48295
- } else if ((error as any)?.transactionHash) {
48296
- transactionHash = (error as any).transactionHash;
48297
- } else if ((error as any)?.receipt?.transactionHash) {
48298
- transactionHash = (error as any).receipt.transactionHash;
48299
- receipt = (error as any).receipt;
48300
- }
48301
-
48302
- const errorMsg = error instanceof Error ? error.message : String(error);
48303
-
48304
- if (this.config.debug) {
48305
- log.error("❌ Partial payment failed", {
48306
- transactionHash: transactionHash || "not available",
48307
- error: errorMsg,
48308
- });
48309
- }
48310
-
48311
- const result: PartialPaymentResult = {
48312
- success: false,
48313
- error: `Partial payment failed: ${errorMsg}`,
48314
- };
48315
-
48316
- if (transactionHash) {
48317
- result.transactionHash = transactionHash;
48318
- }
48319
-
48320
- if (receipt) {
48321
- result.blockNumber = receipt.blockNumber;
48322
- result.gasUsed = receipt.gasUsed?.toString();
48323
- result.effectiveGasPrice =
48324
- receipt.effectiveGasPrice?.toString() || receipt.gasPrice?.toString();
48325
- }
48326
-
48327
- return result;
48717
+ const result = {
48718
+ success: false,
48719
+ error: `Payment failed: ${errorMsg}`
48720
+ };
48721
+ if (transactionHash) {
48722
+ result.transactionHash = transactionHash;
48723
+ }
48724
+ if (receipt) {
48725
+ result.blockNumber = receipt.blockNumber;
48726
+ result.gasUsed = receipt.gasUsed?.toString();
48727
+ result.effectiveGasPrice = receipt.effectiveGasPrice?.toString() || receipt.gasPrice?.toString();
48328
48728
  }
48729
+ return result;
48329
48730
  }
48330
- */
48731
+ }
48331
48732
  /**
48332
48733
  * Withdraw Bitcoin from a position
48333
48734
  *
@@ -48535,8 +48936,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
48535
48936
  withdrawalAddress,
48536
48937
  // SDK interface uses withdrawalAddress
48537
48938
  amount: withdrawalAmount.toString(),
48538
- contracts
48539
- // Pass contracts object (undefined in prod mode)
48939
+ contractAddresses: contracts
48940
+ // Match lit-ops interface (contracts contractAddresses)
48540
48941
  },
48541
48942
  userSignature: auth.signature,
48542
48943
  customRpcUrl,
@@ -49017,7 +49418,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
49017
49418
  // Hardhat URL for EVM contract queries
49018
49419
  customBitcoinRpcUrl: request.customBitcoinRpcUrl,
49019
49420
  // Bitcoin URL for UTXO queries
49020
- contracts: contractsParam
49421
+ contractAddresses: contractsParam
49422
+ // Match lit-ops interface (contracts → contractAddresses)
49021
49423
  });
49022
49424
  if (!signResult.success) {
49023
49425
  return {
@@ -49702,6 +50104,73 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
49702
50104
  return "regtest";
49703
50105
  }
49704
50106
  }
50107
+ /**
50108
+ * Extract error message from LIT Action response
50109
+ * Checks both `error` and `reason` fields and parses nested error structures
50110
+ *
50111
+ * @private
50112
+ * @remarks Production-ready error parser for LIT Protocol responses
50113
+ * Will be integrated into core methods in Round 2
50114
+ */
50115
+ // @ts-ignore - Method will be used in Round 2 when integrated into core methods
50116
+ extractLitActionError(response) {
50117
+ if (response.error) {
50118
+ try {
50119
+ if (response.error.includes("Response from the nodes:")) {
50120
+ const jsonStart = response.error.indexOf("{");
50121
+ if (jsonStart !== -1) {
50122
+ const jsonStr = response.error.substring(jsonStart);
50123
+ const parsed = JSON.parse(jsonStr);
50124
+ if (parsed.error) {
50125
+ const errorObj = parsed.error;
50126
+ const errorKind = errorObj.errorKind || "";
50127
+ const errorCode = errorObj.errorCode || "";
50128
+ const message = errorObj.message || "";
50129
+ const details = errorObj.details || [];
50130
+ let errorMsg = message;
50131
+ if (errorKind) {
50132
+ errorMsg = `${errorKind}: ${errorMsg}`;
50133
+ }
50134
+ if (errorCode && errorCode !== errorKind) {
50135
+ errorMsg += ` (${errorCode})`;
50136
+ }
50137
+ if (details.length > 0) {
50138
+ errorMsg += ` - ${details.join(", ")}`;
50139
+ }
50140
+ if (response.failedStep) {
50141
+ errorMsg += ` (Failed at step: ${response.failedStep})`;
50142
+ }
50143
+ return errorMsg;
50144
+ }
50145
+ }
50146
+ }
50147
+ if (response.error.includes("timeout") || response.error.includes("Timeout")) {
50148
+ let timeoutMsg = "LIT Action execution timed out";
50149
+ if (response.error.includes("didn't respond within")) {
50150
+ const match2 = response.error.match(/didn't respond within (\d+s?)/);
50151
+ if (match2) {
50152
+ timeoutMsg += ` (timeout after ${match2[1]})`;
50153
+ }
50154
+ }
50155
+ if (response.failedStep) {
50156
+ timeoutMsg += ` at step ${response.failedStep}`;
50157
+ }
50158
+ return timeoutMsg;
50159
+ }
50160
+ if (response.error.length > 0 && response.error !== "undefined") {
50161
+ return response.error;
50162
+ }
50163
+ } catch (parseError) {
50164
+ if (response.error.length > 0) {
50165
+ return response.error;
50166
+ }
50167
+ }
50168
+ }
50169
+ if (response.reason) {
50170
+ return response.reason;
50171
+ }
50172
+ return "Unknown reason";
50173
+ }
49705
50174
  // ============================================================================
49706
50175
  // PRIVATE HELPER METHODS
49707
50176
  // ============================================================================
@@ -50042,9 +50511,10 @@ var AuthParamsValidation;
50042
50511
  return validateExtendTerm(params);
50043
50512
  case "close":
50044
50513
  return validateClosePosition(params);
50045
- default:
50514
+ default: {
50046
50515
  const _exhaustive = params;
50047
50516
  return [`Unknown authorization type: ${_exhaustive.type}`];
50517
+ }
50048
50518
  }
50049
50519
  }
50050
50520
  AuthParamsValidation2.validate = validate5;