@pendle/core-v2 6.4.2-swaphubtest → 6.4.2-swaphubtest2

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.
Files changed (131) hide show
  1. package/build/artifacts/contracts/LiquidityMining/PendleMerkleDistributor.sol/PendleMerkleDistributor.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/PendleMerkleDistributor.sol/PendleMerkleDistributor.json +2 -2
  3. package/build/artifacts/contracts/LiquidityMining/PendleMultiTokenMerkleDistributor.sol/PendleMultiTokenMerkleDistributor.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/PendleMultiTokenMerkleDistributor.sol/PendleMultiTokenMerkleDistributor.json +2 -2
  5. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  6. package/build/artifacts/contracts/core/Market/PendleMarketV6.sol/PendleMarketV6.dbg.json +1 -1
  7. package/build/artifacts/contracts/core/Market/PendleMarketV6.sol/PendleMarketV6.json +2 -2
  8. package/build/artifacts/contracts/core/RewardManager/RewardManager.sol/RewardManager.dbg.json +1 -1
  9. package/build/artifacts/contracts/core/RewardManager/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
  10. package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
  11. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactoryUpg.sol/PendleYieldContractFactoryUpg.dbg.json +1 -1
  12. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactoryUpg.sol/PendleYieldContractFactoryUpg.json +2 -2
  13. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  14. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
  15. package/build/artifacts/contracts/core/libraries/TokenHelper.sol/TokenHelper.dbg.json +1 -1
  16. package/build/artifacts/contracts/cross-chain/FixedPricePTAMM.sol/FixedPricePTAMM.dbg.json +1 -1
  17. package/build/artifacts/contracts/cross-chain/FixedPricePTAMM.sol/FixedPricePTAMM.json +2 -2
  18. package/build/artifacts/contracts/cross-chain/deposit-box/DepositBox.sol/DepositBox.dbg.json +4 -0
  19. package/build/artifacts/contracts/cross-chain/deposit-box/DepositBox.sol/DepositBox.json +170 -0
  20. package/build/artifacts/contracts/cross-chain/deposit-box/DepositBoxFactory.sol/DepositBoxFactory.dbg.json +4 -0
  21. package/build/artifacts/contracts/cross-chain/deposit-box/DepositBoxFactory.sol/DepositBoxFactory.json +124 -0
  22. package/build/artifacts/contracts/cross-chain/swap-hub/PendleCrossChainSwapHub.sol/PendleCrossChainSwapHub.dbg.json +1 -1
  23. package/build/artifacts/contracts/cross-chain/swap-hub/PendleCrossChainSwapHub.sol/PendleCrossChainSwapHub.json +200 -433
  24. package/build/artifacts/contracts/cross-chain/swap-hub/SwapHubBase.sol/SwapHubBase.dbg.json +1 -1
  25. package/build/artifacts/contracts/cross-chain/swap-hub/SwapHubBase.sol/SwapHubBase.json +199 -423
  26. package/build/artifacts/contracts/deprecated/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.dbg.json +1 -1
  27. package/build/artifacts/contracts/deprecated/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.json +2 -2
  28. package/build/artifacts/contracts/interfaces/IPCrossChainSwapHub.sol/IPCrossChainSwapHub.dbg.json +1 -1
  29. package/build/artifacts/contracts/interfaces/IPCrossChainSwapHub.sol/IPCrossChainSwapHub.json +161 -398
  30. package/build/artifacts/contracts/interfaces/IPDepositBoxFactory.sol/IPDepositBoxFactory.dbg.json +4 -0
  31. package/build/artifacts/contracts/interfaces/IPDepositBoxFactory.sol/IPDepositBoxFactory.json +108 -0
  32. package/build/artifacts/contracts/limit/LimitRouterBase.sol/LimitRouterBase.dbg.json +1 -1
  33. package/build/artifacts/contracts/limit/PendleLimitRouter.sol/PendleLimitRouter.dbg.json +1 -1
  34. package/build/artifacts/contracts/limit/PendleLimitRouter.sol/PendleLimitRouter.json +2 -2
  35. package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.dbg.json +1 -1
  36. package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.json +2 -2
  37. package/build/artifacts/contracts/offchain-helpers/ExpiredLpPtRedeemer.sol/ExpiredLpPtRedeemer.dbg.json +1 -1
  38. package/build/artifacts/contracts/offchain-helpers/ExpiredLpPtRedeemer.sol/ExpiredLpPtRedeemer.json +2 -2
  39. package/build/artifacts/contracts/offchain-helpers/LimitBackendHelperV2.sol/LimitBackendHelperV2.dbg.json +1 -1
  40. package/build/artifacts/contracts/offchain-helpers/LimitBackendHelperV2.sol/LimitBackendHelperV2.json +2 -2
  41. package/build/artifacts/contracts/offchain-helpers/MarketSweed.sol/MarketSweed.dbg.json +1 -1
  42. package/build/artifacts/contracts/offchain-helpers/MarketSweed.sol/MarketSweed.json +2 -2
  43. package/build/artifacts/contracts/offchain-helpers/PendleAPIFeeDepositor.sol/PendleAPIFeeDepositor.dbg.json +1 -1
  44. package/build/artifacts/contracts/offchain-helpers/PendleAPIFeeDepositor.sol/PendleAPIFeeDepositor.json +2 -2
  45. package/build/artifacts/contracts/offchain-helpers/PendleLPWrapper.sol/PendleLPWrapper.dbg.json +1 -1
  46. package/build/artifacts/contracts/offchain-helpers/PendleLPWrapper.sol/PendleLPWrapper.json +2 -2
  47. package/build/artifacts/contracts/offchain-helpers/PendleLPWrapperFactory.sol/PendleLPWrapperFactory.dbg.json +1 -1
  48. package/build/artifacts/contracts/offchain-helpers/PendleLPWrapperFactory.sol/PendleLPWrapperFactory.json +2 -2
  49. package/build/artifacts/contracts/offchain-helpers/deploy/PendleCommonPoolDeployHelperV2.sol/PendleCommonPoolDeployHelperV2.dbg.json +1 -1
  50. package/build/artifacts/contracts/offchain-helpers/deploy/PendleCommonPoolDeployHelperV2.sol/PendleCommonPoolDeployHelperV2.json +2 -2
  51. package/build/artifacts/contracts/offchain-helpers/deploy/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
  52. package/build/artifacts/contracts/offchain-helpers/deploy/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +2 -2
  53. package/build/artifacts/contracts/offchain-helpers/deploy/PendlePoolDeployHelperV2.sol/PendlePoolDeployHelperV2.dbg.json +1 -1
  54. package/build/artifacts/contracts/offchain-helpers/deploy/PendlePoolDeployHelperV2.sol/PendlePoolDeployHelperV2.json +2 -2
  55. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.dbg.json +1 -1
  56. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.json +2 -2
  57. package/build/artifacts/contracts/router/ActionCallbackV3.sol/ActionCallbackV3.dbg.json +1 -1
  58. package/build/artifacts/contracts/router/ActionCallbackV3.sol/ActionCallbackV3.json +2 -2
  59. package/build/artifacts/contracts/router/ActionCrossChain.sol/ActionCrossChain.dbg.json +1 -1
  60. package/build/artifacts/contracts/router/ActionCrossChain.sol/ActionCrossChain.json +2 -2
  61. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
  62. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +2 -2
  63. package/build/artifacts/contracts/router/ActionSimple.sol/ActionSimple.dbg.json +1 -1
  64. package/build/artifacts/contracts/router/ActionSimple.sol/ActionSimple.json +2 -2
  65. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.dbg.json +1 -1
  66. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.json +2 -2
  67. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.dbg.json +1 -1
  68. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.json +2 -2
  69. package/build/artifacts/contracts/router/Reflector.sol/Reflector.dbg.json +1 -1
  70. package/build/artifacts/contracts/router/Reflector.sol/Reflector.json +2 -2
  71. package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
  72. package/build/artifacts/contracts/router/base/ActionDelegateBase.sol/ActionDelegateBase.dbg.json +1 -1
  73. package/build/artifacts/contracts/router/base/ActionDelegateBase.sol/ActionDelegateBase.json +2 -2
  74. package/build/artifacts/contracts/router/swap-aggregator/OKXScaleHelper.sol/IOKXDexRouter.dbg.json +1 -1
  75. package/build/artifacts/contracts/router/swap-aggregator/OKXScaleHelper.sol/OKXScaleHelper.dbg.json +1 -1
  76. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/IKyberScalingHelper.dbg.json +1 -1
  77. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/IOdosRouterV2.dbg.json +1 -1
  78. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.dbg.json +1 -1
  79. package/build/artifacts/contracts/router/swap-aggregator/PendleSwap.sol/PendleSwap.json +2 -2
  80. package/contracts/core/libraries/TokenHelper.sol +5 -1
  81. package/contracts/cross-chain/deposit-box/DepositBoxFactory.sol +44 -0
  82. package/contracts/cross-chain/swap-hub/PendleCrossChainSwapHub.sol +14 -102
  83. package/contracts/cross-chain/swap-hub/SwapHubBase.sol +73 -150
  84. package/contracts/interfaces/IPCrossChainSwapHub.sol +35 -66
  85. package/contracts/interfaces/IPDepositBoxFactory.sol +19 -0
  86. package/deployments/130-core.json +2 -1
  87. package/deployments/9745-core.json +3 -2
  88. package/package.json +1 -1
  89. package/typechain-types/DepositBoxFactory.ts +226 -0
  90. package/typechain-types/IPCrossChainSwapHub.ts +192 -383
  91. package/typechain-types/IPDepositBoxFactory.ts +226 -0
  92. package/typechain-types/PendleCrossChainSwapHub.ts +217 -390
  93. package/typechain-types/SwapHubBase.ts +216 -389
  94. package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
  95. package/typechain-types/factories/ActionCallbackV3__factory.ts +1 -1
  96. package/typechain-types/factories/ActionCrossChain__factory.ts +1 -1
  97. package/typechain-types/factories/ActionMiscV3__factory.ts +1 -1
  98. package/typechain-types/factories/ActionSimple__factory.ts +1 -1
  99. package/typechain-types/factories/ActionSwapPTV3__factory.ts +1 -1
  100. package/typechain-types/factories/ActionSwapYTV3__factory.ts +1 -1
  101. package/typechain-types/factories/Broadcaster__factory.ts +1 -1
  102. package/typechain-types/factories/DepositBoxFactory__factory.ts +189 -0
  103. package/typechain-types/factories/DepositBox__factory.ts +1 -1
  104. package/typechain-types/factories/ExpiredLpPtRedeemer__factory.ts +1 -1
  105. package/typechain-types/factories/FixedPricePTAMM__factory.ts +1 -1
  106. package/typechain-types/factories/IPCrossChainSwapHub__factory.ts +161 -398
  107. package/typechain-types/factories/IPDepositBoxFactory__factory.ts +123 -0
  108. package/typechain-types/factories/LimitBackendHelperV2__factory.ts +1 -1
  109. package/typechain-types/factories/MarketSweed__factory.ts +1 -1
  110. package/typechain-types/factories/PendleAPIFeeDepositor__factory.ts +1 -1
  111. package/typechain-types/factories/PendleCommonPoolDeployHelperV2__factory.ts +1 -1
  112. package/typechain-types/factories/PendleCrossChainSwapHub__factory.ts +203 -440
  113. package/typechain-types/factories/PendleFeeDistributorV2__factory.ts +1 -1
  114. package/typechain-types/factories/PendleLPWrapperFactory__factory.ts +1 -1
  115. package/typechain-types/factories/PendleLPWrapper__factory.ts +1 -1
  116. package/typechain-types/factories/PendleLimitRouter__factory.ts +1 -1
  117. package/typechain-types/factories/PendleMarketV6__factory.ts +1 -1
  118. package/typechain-types/factories/PendleMerkleDistributor__factory.ts +1 -1
  119. package/typechain-types/factories/PendleMultiTokenMerkleDistributor__factory.ts +1 -1
  120. package/typechain-types/factories/PendlePoolDeployHelperV2__factory.ts +1 -1
  121. package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
  122. package/typechain-types/factories/PendleSwap__factory.ts +1 -1
  123. package/typechain-types/factories/PendleYieldContractFactoryUpg__factory.ts +1 -1
  124. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  125. package/typechain-types/factories/Reflector__factory.ts +1 -1
  126. package/typechain-types/factories/SwapHubBase__factory.ts +199 -423
  127. package/typechain-types/hardhat.d.ts +27 -9
  128. package/typechain-types/index.ts +6 -2
  129. package/build/artifacts/contracts/cross-chain/swap-hub/DepositBox.sol/DepositBox.dbg.json +0 -4
  130. package/build/artifacts/contracts/cross-chain/swap-hub/DepositBox.sol/DepositBox.json +0 -170
  131. /package/contracts/cross-chain/{swap-hub → deposit-box}/DepositBox.sol +0 -0
@@ -1,24 +1,25 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-or-later
2
2
  pragma solidity ^0.8.30;
3
3
 
4
- import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
5
4
  import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
6
5
  import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
7
6
  import {BoringOwnableUpgradeableV2} from "../../core/libraries/BoringOwnableUpgradeableV2.sol";
8
7
  import {TokenHelper} from "../../core/libraries/TokenHelper.sol";
9
8
  import {IPCrossChainSwapHub} from "../../interfaces/IPCrossChainSwapHub.sol";
10
9
  import {ApprovedCall, IPDepositBox} from "../../interfaces/IPDepositBox.sol";
11
- import {DepositBox} from "./DepositBox.sol";
10
+ import {IPDepositBoxFactory} from "../../interfaces/IPDepositBoxFactory.sol";
12
11
 
13
12
  abstract contract SwapHubBase is IPCrossChainSwapHub, EIP712Upgradeable, BoringOwnableUpgradeableV2, TokenHelper {
14
13
  // forgefmt: disable-next-item
15
14
  bytes32 internal constant WITHDRAW_TOKEN_MESSAGE_TYPEHASH = keccak256(
16
15
  "WithdrawTokenMessage("
17
- "address owner,"
18
- "uint32 boxId,"
16
+ "address proposer,"
19
17
  "uint256 expiry,"
18
+ "uint256 requestId,"
20
19
  "uint256 nonce,"
21
20
  //
21
+ "address owner,"
22
+ "uint32 boxId,"
22
23
  "address token,"
23
24
  "uint256 amountWithdraw,"
24
25
  "uint256 amountFee"
@@ -28,15 +29,16 @@ abstract contract SwapHubBase is IPCrossChainSwapHub, EIP712Upgradeable, BoringO
28
29
  // forgefmt: disable-next-item
29
30
  bytes32 internal constant BRIDGE_TOKEN_MESSAGE_TYPEHASH = keccak256(
30
31
  "BridgeTokenMessage("
31
- "address owner,"
32
- "uint32 boxId,"
32
+ "address proposer,"
33
33
  "uint256 expiry,"
34
+ "uint256 requestId,"
34
35
  "uint256 nonce,"
35
36
  //
37
+ "address owner,"
38
+ "uint32 boxId,"
36
39
  "address token,"
37
40
  "uint256 amountBridge,"
38
41
  "uint256 amountFee,"
39
- "bool pullFromOwner,"
40
42
  //
41
43
  "address bridgeExtRouter,"
42
44
  "address bridgeApprove,"
@@ -47,41 +49,17 @@ abstract contract SwapHubBase is IPCrossChainSwapHub, EIP712Upgradeable, BoringO
47
49
  // forgefmt: disable-next-item
48
50
  bytes32 internal constant SWAP_TOKEN_MESSAGE_TYPEHASH = keccak256(
49
51
  "SwapTokenMessage("
50
- "address owner,"
51
- "uint32 boxId,"
52
+ "address proposer,"
52
53
  "uint256 expiry,"
54
+ "uint256 requestId,"
53
55
  "uint256 nonce,"
54
56
  //
55
- "address tokenSpent,"
56
- "uint256 amountSpent,"
57
- "uint256 amountFee,"
58
- "address tokenReceived,"
59
- "uint256 minReceived,"
60
- "bool pullFromOwner,"
61
- "bool sendToOwner,"
62
- //
63
- "address swapExtRouter,"
64
- "address swapApprove,"
65
- "bytes swapCalldata"
66
- ")"
67
- );
68
-
69
- // forgefmt: disable-next-item
70
- bytes32 internal constant BUY_CROSS_CHAIN_PT_MESSAGE_TYPEHASH = keccak256(
71
- "BuyCrossChainPtMessage("
72
57
  "address owner,"
73
58
  "uint32 boxId,"
74
- "uint256 expiry,"
75
- "uint256 nonce,"
76
- //
77
59
  "address tokenSpent,"
78
60
  "uint256 amountSpent,"
79
- "uint256 amountFee,"
80
- "address ptAdapter,"
81
- "uint256 minPtReceived,"
82
- "uint32 dstEid,"
83
- "bytes32 receiver,"
84
- "bool pullFromOwner,"
61
+ "address tokenReceived,"
62
+ "uint256 minReceived,"
85
63
  //
86
64
  "address swapExtRouter,"
87
65
  "address swapApprove,"
@@ -90,21 +68,15 @@ abstract contract SwapHubBase is IPCrossChainSwapHub, EIP712Upgradeable, BoringO
90
68
  );
91
69
 
92
70
  address public immutable TREASURY;
71
+ IPDepositBoxFactory public immutable DEPOSIT_BOX_FACTORY;
93
72
 
94
- /// @dev creation code of OpenZeppelin's BeaconProxy
95
- address public immutable BEACON_PROXY_CODE_CONTRACT;
96
- address public immutable DEPOSIT_BOX_BEACON;
97
- bytes32 public immutable DEPOSIT_BOX_CODE_HASH;
98
-
99
- mapping(address owner => uint256 nonce) public ownerNonce;
100
73
  mapping(address executor => bool) public isExecutor;
74
+ mapping(address proposer => bool) public isProposer;
75
+ mapping(uint256 requestId => uint256 nonce) public requestNonce;
101
76
 
102
- constructor(address treasury_, address beaconProxyCodeContract_, address depositBoxBeacon_) {
77
+ constructor(address treasury_, address depositBoxFactory_) {
103
78
  TREASURY = treasury_;
104
- BEACON_PROXY_CODE_CONTRACT = beaconProxyCodeContract_;
105
- DEPOSIT_BOX_BEACON = depositBoxBeacon_;
106
- DEPOSIT_BOX_CODE_HASH =
107
- keccak256(abi.encodePacked(beaconProxyCodeContract_.code, abi.encode(depositBoxBeacon_, "")));
79
+ DEPOSIT_BOX_FACTORY = IPDepositBoxFactory(depositBoxFactory_);
108
80
  }
109
81
 
110
82
  modifier onlyExecutor() {
@@ -117,129 +89,92 @@ abstract contract SwapHubBase is IPCrossChainSwapHub, EIP712Upgradeable, BoringO
117
89
  emit SetExecutor(executor, isExecutor_);
118
90
  }
119
91
 
120
- function computeDepositBox(address owner, uint32 boxId)
121
- public
122
- view
123
- returns (address box, bytes32 salt, bool deployed)
124
- {
125
- salt = keccak256(abi.encode(owner, boxId));
126
- box = Create2.computeAddress(salt, DEPOSIT_BOX_CODE_HASH);
127
- deployed = box.code.length > 0;
128
- }
129
-
130
- function _checkAndDeployBox(address owner, uint32 boxId) internal returns (IPDepositBox) {
131
- (address box, bytes32 salt, bool deployed) = computeDepositBox(owner, boxId);
132
- if (deployed) {
133
- return IPDepositBox(box);
134
- }
135
-
136
- bytes memory bytecode = abi.encodePacked(BEACON_PROXY_CODE_CONTRACT.code, abi.encode(DEPOSIT_BOX_BEACON, ""));
137
- assert(Create2.deploy(0, salt, bytecode) == box);
138
- DepositBox(payable(box)).initialize(owner, boxId);
139
- return IPDepositBox(box);
92
+ function setProposer(address proposer, bool isProposer_) external onlyOwner {
93
+ isProposer[proposer] = isProposer_;
94
+ emit SetProposer(proposer, isProposer_);
140
95
  }
141
96
 
142
- function hashTypedData(WithdrawTokenMessage memory message) public view returns (bytes32) {
97
+ function hashTypedData(WithdrawTokenMessage memory ms) public view returns (bytes32) {
143
98
  return _hashTypedDataV4(
144
99
  keccak256(
145
100
  abi.encode(
146
101
  WITHDRAW_TOKEN_MESSAGE_TYPEHASH,
147
- message.owner,
148
- message.boxId,
149
- message.expiry,
150
- message.nonce,
102
+ ms.proposer,
103
+ ms.expiry,
104
+ ms.requestId,
105
+ ms.nonce,
151
106
  //
152
- message.token,
153
- message.amountWithdraw,
154
- message.amountFee
107
+ ms.owner,
108
+ ms.boxId,
109
+ ms.token,
110
+ ms.amountWithdraw,
111
+ ms.amountFee
155
112
  )
156
113
  )
157
114
  );
158
115
  }
159
116
 
160
- function hashTypedData(BridgeTokenMessage memory message) public view returns (bytes32) {
117
+ function hashTypedData(BridgeTokenMessage memory ms) public view returns (bytes32) {
161
118
  return _hashTypedDataV4(
162
119
  keccak256(
163
120
  abi.encode(
164
121
  BRIDGE_TOKEN_MESSAGE_TYPEHASH,
165
- message.owner,
166
- message.boxId,
167
- message.expiry,
168
- message.nonce,
122
+ ms.proposer,
123
+ ms.expiry,
124
+ ms.requestId,
125
+ ms.nonce,
169
126
  //
170
- message.token,
171
- message.amountBridge,
172
- message.amountFee,
173
- message.pullFromOwner,
127
+ ms.owner,
128
+ ms.boxId,
129
+ ms.token,
130
+ ms.amountBridge,
131
+ ms.amountFee,
174
132
  //
175
- message.bridgeExtRouter,
176
- message.bridgeApprove,
177
- keccak256(message.bridgeCalldata)
133
+ ms.bridgeExtRouter,
134
+ ms.bridgeApprove,
135
+ keccak256(ms.bridgeCalldata)
178
136
  )
179
137
  )
180
138
  );
181
139
  }
182
140
 
183
- function hashTypedData(SwapTokenMessage memory message) public view returns (bytes32) {
141
+ function hashTypedData(SwapTokenMessage memory ms) public view returns (bytes32) {
184
142
  return _hashTypedDataV4(
185
143
  keccak256(
186
144
  abi.encode(
187
145
  SWAP_TOKEN_MESSAGE_TYPEHASH,
188
- message.owner,
189
- message.boxId,
190
- message.expiry,
191
- message.nonce,
146
+ ms.proposer,
147
+ ms.expiry,
148
+ ms.requestId,
149
+ ms.nonce,
192
150
  //
193
- message.tokenSpent,
194
- message.amountSpent,
195
- message.amountFee,
196
- message.tokenReceived,
197
- message.minReceived,
198
- message.pullFromOwner,
199
- message.sendToOwner,
151
+ ms.owner,
152
+ ms.boxId,
153
+ ms.tokenSpent,
154
+ ms.amountSpent,
155
+ ms.tokenReceived,
156
+ ms.minReceived,
200
157
  //
201
- message.swapExtRouter,
202
- message.swapApprove,
203
- keccak256(message.swapCalldata)
158
+ ms.swapExtRouter,
159
+ ms.swapApprove,
160
+ keccak256(ms.swapCalldata)
204
161
  )
205
162
  )
206
163
  );
207
164
  }
208
165
 
209
- function hashTypedData(BuyCrossChainPtMessage memory message) public view returns (bytes32) {
210
- return _hashTypedDataV4(
211
- keccak256(
212
- abi.encode(
213
- BUY_CROSS_CHAIN_PT_MESSAGE_TYPEHASH,
214
- message.owner,
215
- message.boxId,
216
- message.expiry,
217
- message.nonce,
218
- //
219
- message.tokenSpent,
220
- message.amountSpent,
221
- message.amountFee,
222
- message.ptAdapter,
223
- message.minPtReceived,
224
- message.dstEid,
225
- message.receiver,
226
- message.pullFromOwner,
227
- //
228
- message.swapExtRouter,
229
- message.swapApprove,
230
- keccak256(message.swapCalldata)
231
- )
232
- )
233
- );
234
- }
235
-
236
- function _verifyOwnerSig(address owner, uint256 expiry, uint256 nonce, bytes32 messageHash, bytes memory signature)
237
- internal
238
- {
239
- require(SignatureChecker.isValidSignatureNow(owner, messageHash, signature), InvalidSignature());
166
+ function _verifyProposerSig(
167
+ address proposer,
168
+ uint256 expiry,
169
+ uint256 requestId,
170
+ uint256 nonce,
171
+ bytes32 messageHash,
172
+ bytes memory signature
173
+ ) internal {
174
+ require(SignatureChecker.isValidSignatureNow(proposer, messageHash, signature), InvalidSignature());
240
175
  require(expiry > block.timestamp, MessageExpired());
241
- require(ownerNonce[owner] < nonce, InvalidNonce());
242
- ownerNonce[owner] = nonce;
176
+ require(requestNonce[requestId] + 1 == nonce, InvalidNonce());
177
+ requestNonce[requestId] = nonce;
243
178
  }
244
179
 
245
180
  function _swapFromBox(
@@ -249,26 +184,14 @@ abstract contract SwapHubBase is IPCrossChainSwapHub, EIP712Upgradeable, BoringO
249
184
  address tokenReceived,
250
185
  address swapExtRouter,
251
186
  address swapApprove,
252
- bytes memory swapCalldata,
253
- address receiver
187
+ bytes memory swapCalldata
254
188
  ) internal returns (uint256 rawTokenReceived) {
255
- // forgefmt: disable-next-item
256
189
  ApprovedCall memory call = ApprovedCall({
257
- token: tokenSpent,
258
- amount: amountSpent,
259
- approveTo: swapApprove,
260
- callTo: swapExtRouter,
261
- data: swapCalldata
190
+ token: tokenSpent, amount: amountSpent, approveTo: swapApprove, callTo: swapExtRouter, data: swapCalldata
262
191
  });
263
192
 
264
- uint256 preBalance = _selfBalance(tokenReceived);
193
+ uint256 preBalance = _balanceOf(address(box), tokenReceived);
265
194
  box.approveAndCall(call, address(box));
266
- rawTokenReceived = _selfBalance(tokenReceived) - preBalance;
267
-
268
- _transferOut(tokenReceived, receiver, rawTokenReceived);
269
- }
270
-
271
- function _addressToBytes32(address addr) internal pure returns (bytes32) {
272
- return bytes32(uint256(uint160(addr)));
195
+ rawTokenReceived = _balanceOf(address(box), tokenReceived) - preBalance;
273
196
  }
274
197
  }
@@ -9,26 +9,29 @@ interface IPCrossChainSwapHub {
9
9
  error MessageExpired();
10
10
 
11
11
  struct WithdrawTokenMessage {
12
- address owner;
13
- uint32 boxId;
12
+ address proposer;
14
13
  uint256 expiry;
14
+ uint256 requestId;
15
15
  uint256 nonce;
16
16
  //
17
+ address owner;
18
+ uint32 boxId;
17
19
  address token;
18
20
  uint256 amountWithdraw;
19
21
  uint256 amountFee;
20
22
  }
21
23
 
22
24
  struct BridgeTokenMessage {
23
- address owner;
24
- uint32 boxId;
25
+ address proposer;
25
26
  uint256 expiry;
27
+ uint256 requestId;
26
28
  uint256 nonce;
27
29
  //
30
+ address owner;
31
+ uint32 boxId;
28
32
  address token;
29
33
  uint256 amountBridge;
30
34
  uint256 amountFee;
31
- bool pullFromOwner;
32
35
  //
33
36
  address bridgeExtRouter;
34
37
  address bridgeApprove;
@@ -36,96 +39,64 @@ interface IPCrossChainSwapHub {
36
39
  }
37
40
 
38
41
  struct SwapTokenMessage {
39
- address owner;
40
- uint32 boxId;
42
+ address proposer;
41
43
  uint256 expiry;
44
+ uint256 requestId;
42
45
  uint256 nonce;
43
46
  //
44
- address tokenSpent;
45
- uint256 amountSpent;
46
- uint256 amountFee;
47
- address tokenReceived;
48
- uint256 minReceived;
49
- bool pullFromOwner;
50
- bool sendToOwner;
51
- //
52
- address swapExtRouter;
53
- address swapApprove;
54
- bytes swapCalldata;
55
- }
56
-
57
- struct BuyCrossChainPtMessage {
58
47
  address owner;
59
48
  uint32 boxId;
60
- uint256 expiry;
61
- uint256 nonce;
62
- //
63
49
  address tokenSpent;
64
50
  uint256 amountSpent;
65
- uint256 amountFee;
66
- address ptAdapter;
67
- uint256 minPtReceived;
68
- uint32 dstEid;
69
- bytes32 receiver;
70
- bool pullFromOwner;
51
+ address tokenReceived;
52
+ uint256 minReceived;
71
53
  //
72
54
  address swapExtRouter;
73
55
  address swapApprove;
74
56
  bytes swapCalldata;
75
57
  }
76
58
 
77
- event WithdrawToken(address indexed owner, uint32 boxId, address token, uint256 amountWithdraw, uint256 amountFee);
59
+ event WithdrawToken(
60
+ uint256 requestId,
61
+ uint256 nonce,
62
+ address owner,
63
+ uint32 boxId,
64
+ address token,
65
+ uint256 amountWithdraw,
66
+ uint256 amountFee
67
+ );
78
68
 
79
69
  event BridgeToken(
80
- address indexed owner,
70
+ uint256 requestId,
71
+ uint256 nonce,
72
+ address owner,
81
73
  uint32 boxId,
82
74
  address bridgeExtRouter,
83
75
  address token,
84
76
  uint256 amountBridge,
85
- uint256 amountFee,
86
- bool pullFromOwner
77
+ uint256 amountFee
87
78
  );
88
79
 
89
80
  event SwapToken(
90
- address indexed owner,
81
+ uint256 requestId,
82
+ uint256 nonce,
83
+ address owner,
91
84
  uint32 boxId,
92
85
  address tokenSpent,
93
86
  uint256 amountSpent,
94
- uint256 amountFee,
95
87
  address tokenReceived,
96
- uint256 netTokenReceived,
97
- bool pullFromOwner,
98
- bool sendToOwner
99
- );
100
-
101
- event BuyCrossChainPt(
102
- address indexed owner,
103
- uint32 boxId,
104
- address tokenSpent,
105
- uint256 amountSpent,
106
- uint256 amountFee,
107
- address ptAdapter,
108
- address pt,
109
- uint256 netPtReceived,
110
- bool pullFromOwner
88
+ uint256 netTokenReceived
111
89
  );
112
90
 
113
91
  event SetExecutor(address indexed executor, bool isExecutor);
114
92
 
115
- function BEACON_PROXY_CODE_CONTRACT() external view returns (address);
116
-
117
- function DEPOSIT_BOX_BEACON() external view returns (address);
118
-
119
- function DEPOSIT_BOX_CODE_HASH() external view returns (bytes32);
120
-
121
- function ownerNonce(address owner) external view returns (uint256);
93
+ event SetProposer(address indexed proposer, bool isProposer);
122
94
 
123
95
  function isExecutor(address executor) external view returns (bool);
124
96
 
125
- function computeDepositBox(address owner, uint32 boxId)
126
- external
127
- view
128
- returns (address box, bytes32 salt, bool deployed);
97
+ function isProposer(address proposer) external view returns (bool);
98
+
99
+ function requestNonce(uint256 requestId) external view returns (uint256);
129
100
 
130
101
  function hashTypedData(WithdrawTokenMessage memory message) external view returns (bytes32);
131
102
 
@@ -133,15 +104,13 @@ interface IPCrossChainSwapHub {
133
104
 
134
105
  function hashTypedData(SwapTokenMessage memory message) external view returns (bytes32);
135
106
 
136
- function hashTypedData(BuyCrossChainPtMessage memory message) external view returns (bytes32);
137
-
138
107
  function withdrawToken(WithdrawTokenMessage memory message, bytes memory signature) external;
139
108
 
140
109
  function bridgeToken(BridgeTokenMessage memory message, bytes memory signature) external payable;
141
110
 
142
111
  function swapToken(SwapTokenMessage memory message, bytes memory signature) external;
143
112
 
144
- function buyCrossChainPt(BuyCrossChainPtMessage memory message, bytes memory signature) external payable;
145
-
146
113
  function setExecutor(address executor, bool isExecutor) external;
114
+
115
+ function setProposer(address proposer, bool isProposer) external;
147
116
  }
@@ -0,0 +1,19 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import {IPDepositBox} from "./IPDepositBox.sol";
5
+
6
+ interface IPDepositBoxFactory {
7
+ function computeDepositBox(address owner, uint32 boxId)
8
+ external
9
+ view
10
+ returns (address box, bytes32 salt, bool deployed);
11
+
12
+ function deployDepositBox(address owner, uint32 boxId) external returns (IPDepositBox box);
13
+
14
+ function BEACON_PROXY_CODE_CONTRACT() external view returns (address);
15
+
16
+ function DEPOSIT_BOX_BEACON() external view returns (address);
17
+
18
+ function DEPOSIT_BOX_CODE_HASH() external view returns (bytes32);
19
+ }
@@ -2,7 +2,8 @@
2
2
  "deployer": "0x1FcCC097db89A86Bfc474A1028F93958295b1Fb7",
3
3
  "network": {
4
4
  "chainId": 130,
5
- "wrappedNative": "0x4200000000000000000000000000000000000006"
5
+ "wrappedNative": "0x4200000000000000000000000000000000000006",
6
+ "governance": "0x7877AdFaDEd756f3248a0EBfe8Ac2E2eF87b75Ac"
6
7
  },
7
8
  "router": "0x888888888889758F76e7103c6CbF23ABbF58F946",
8
9
  "routerFacets": {
@@ -55,7 +55,8 @@
55
55
  "decimalsFactory": "0x992EC6A490A4B7f256bd59E63746951D98B29Be9",
56
56
  "lpLinearDiscountOracleFactory": "0x44fb16d078e9c39b65d6c15e78ede9736a9f2df5",
57
57
  "cross-chain": {
58
- "exchangeRateOracle": "0xA914c44E960cC95D996969BDf0ab5D6f4f2B5870"
58
+ "exchangeRateOracle": "0xA914c44E960cC95D996969BDf0ab5D6f4f2B5870",
59
+ "ptOftAdapterFactory": "0x41FAD93F225b5C1C95f2445A5d7fcB85bA46713f"
59
60
  },
60
61
  "merkleDistributor": "0x3dAe3d1734cA3C7B3089D4DD03C9876e0A0102b4"
61
- }
62
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pendle/core-v2",
3
3
  "description": "Core smart contracts of Pendle Protocol.",
4
4
  "license": "BUSL-1.1",
5
- "version": "6.4.2-swaphubtest",
5
+ "version": "6.4.2-swaphubtest2",
6
6
  "homepage": "https://pendle.finance",
7
7
  "keywords": [
8
8
  "pendle",