Skip to content

Commit 6fd7656

Browse files
authored
fix: alice v2 callback (#1411)
fix: alic v2 callback
1 parent a33037a commit 6fd7656

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

contracts/release/extensions/external-position-manager/external-positions/alice-v2/AliceV2PositionLib.sol

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ contract AliceV2PositionLib is IAliceV2Position, AliceV2PositionLibBase1, AssetH
7373
// EXTERNAL FUNCTIONS //
7474
////////////////////////
7575

76-
function notifySettle(address _token, uint256, bytes32 _referenceId) external override {
76+
function notifySettle(address, uint256, bytes32 _referenceId) external override {
7777
if (msg.sender != address(ALICE_INSTANT_ORDER_V2)) {
7878
revert InvalidSender();
7979
}
@@ -91,15 +91,23 @@ contract AliceV2PositionLib is IAliceV2Position, AliceV2PositionLibBase1, AssetH
9191
revert OrderNotSettledOrCancelled();
9292
}
9393

94+
// Find the stored order details
95+
OrderDetails memory orderDetails = getOrderDetails({_orderId: orderId});
96+
9497
// Remove the order from storage
9598
__removeOrder({_orderId: orderId});
9699

97100
// Remove the reference ID from storage
98101
__removeReferenceId({_referenceId: _referenceId});
99102

100-
// Push the assets back to the vault
103+
// Push the assets back to the vault. Sweeping both assets in case Alice offchain logic fails.
104+
__retrieveAssetBalance({
105+
_asset: IERC20(orderDetails.outgoingAssetAddress),
106+
_receiver: IExternalPositionProxy(address(this)).getVaultProxy()
107+
});
108+
101109
__retrieveAssetBalance({
102-
_asset: IERC20(_token),
110+
_asset: IERC20(orderDetails.incomingAssetAddress),
103111
_receiver: IExternalPositionProxy(address(this)).getVaultProxy()
104112
});
105113
}
@@ -131,11 +139,16 @@ contract AliceV2PositionLib is IAliceV2Position, AliceV2PositionLibBase1, AssetH
131139
// Remove the reference ID from storage
132140
__removeReferenceId({_referenceId: _referenceId});
133141

134-
// Push the refunded sell asset back to the vault
142+
// Push the assets back to the vault. Sweeping both assets in case Alice offchain logic fails.
135143
__retrieveAssetBalance({
136144
_asset: IERC20(orderDetails.outgoingAssetAddress),
137145
_receiver: IExternalPositionProxy(address(this)).getVaultProxy()
138146
});
147+
148+
__retrieveAssetBalance({
149+
_asset: IERC20(orderDetails.incomingAssetAddress),
150+
_receiver: IExternalPositionProxy(address(this)).getVaultProxy()
151+
});
139152
}
140153

141154
////////////////////

0 commit comments

Comments
 (0)