-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dynamic custodians & bnpl /w match testing
- buy now pay later tests added using native seaport matchOrders - custodians are now entirely customizable
- Loading branch information
1 parent
fe5bd1f
commit cf589ce
Showing
6 changed files
with
1,171 additions
and
714 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pragma solidity =0.8.17; | ||
|
||
import {ERC20} from "solady/src/tokens/ERC20.sol"; | ||
import "../Custodian.sol"; | ||
|
||
interface IPool { | ||
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external; | ||
|
||
function withdraw(address asset, uint256 amount, address to) external returns (uint256); | ||
} | ||
|
||
contract AAVEPoolCustodian is Custodian { | ||
IPool public pool; | ||
|
||
constructor(LoanManager LM_, address seaport_, address pool_) Custodian(LM_, seaport_) { | ||
pool = IPool(pool_); | ||
} | ||
|
||
//gets full seaport context | ||
function custody( | ||
ReceivedItem[] calldata consideration, | ||
bytes32[] calldata orderHashes, | ||
uint256 contractNonce, | ||
bytes calldata context | ||
) external override returns (bytes4 selector) { | ||
_enter(consideration[0].token, consideration[0].amount); | ||
selector = AAVEPoolCustodian.custody.selector; | ||
} | ||
|
||
function _beforeApprovalsSetHook(address fulfiller, SpentItem[] calldata maximumSpent, bytes calldata context) | ||
internal | ||
virtual | ||
override | ||
{ | ||
_exit(maximumSpent[0].token, maximumSpent[0].amount); | ||
} | ||
|
||
function _enter(address token, uint256 amount) internal { | ||
ERC20(token).approve(address(pool), amount); | ||
pool.supply(token, amount, address(this), 0); | ||
} | ||
|
||
function _exit(address token, uint256 amount) internal { | ||
pool.withdraw(token, amount, address(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.