Skip to content

Commit efdf97a

Browse files
committed
chore: update README
1 parent 171234e commit efdf97a

1 file changed

Lines changed: 48 additions & 13 deletions

File tree

‎README.md‎

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The `Request` contract is the core contract managing funding requests with dual-
6767

6868
- **OfferReceiver**: Validates and processes signed offers using EIP-712 signatures
6969
- **VaultController**: Manages PT/YT tokens with ERC4626-style redemptions
70-
- **Ownable**: Restricts admin functions to the contract owner
70+
- **OwnableRoles**: Restricts admin functions to the contract owner and allows for the "puller" role to pull funds from the contract
7171

7272
### Request Lifecycle
7373

@@ -78,7 +78,7 @@ The `Request` contract is the core contract managing funding requests with dual-
7878
7979
1. DEPLOYMENT
8080
└─> Factory creates Request + PT Vault + YT Vault (beacon proxies)
81-
└─> Owner is set, contract initialized
81+
└─> Owner and puller role are set, contract initialized
8282
8383
2. FUNDING PHASE (canWithdraw = false)
8484
├─> Method A: consume() - Process signed offers from prime brokers
@@ -87,10 +87,12 @@ The `Request` contract is the core contract managing funding requests with dual-
8787
└─> Owner authorizes → Prime broker calls mint() → PT/YT minted
8888
8989
3. FUND UTILIZATION
90-
└─> Owner calls pullFunds() to transfer assets to borrower
90+
└─> Puller calls pullFunds(amount, data) to transfer assets to themselves
91+
└─> If data is provided, onPullFunds() callback is invoked on the puller
9192
9293
4. REPAYMENT
93-
└─> Borrower transfers assets back to Request contract
94+
└─> Puller (or borrower) transfers assets back to Request contract
95+
└─> Optional: Use repay(amount) helper function
9496
9597
5. REDEMPTION PHASE (canWithdraw = true)
9698
└─> Owner calls setRepaid()
@@ -110,7 +112,7 @@ The owner broadcasts a signed EIP-712 offer to the contract. This method is idea
110112
2. Owner calls `consume(offer, signature, ptAmount)`
111113
3. Contract validates the signature and offer parameters
112114
4. Contract calls `onRequestConsumed()` callback on the maker's contract
113-
5. Contract pulls `ptAmount` of underlying asset from the owner (msg.sender)
115+
5. Contract pulls `ptAmount` of underlying asset from the maker (offer.maker)
114116
6. PT and YT tokens are minted to the maker
115117
7. The maker's offer nonce is updated
116118

@@ -176,20 +178,52 @@ request.mint(); // Receives 1M PT + 100k YT
176178

177179
After offers are consumed or minting is complete:
178180

179-
1. **Pull Funds**: Owner calls `pullFunds(receiver, amount)` to transfer collected assets to the borrower
180-
2. **Borrower Utilizes Funds**: The borrower uses the funds for their intended purpose
181-
3. **Repayment**: Borrower transfers assets back to the Request contract
182-
4. **Enable Redemptions**: Owner calls `setRepaid()` to unlock withdrawals
181+
1. **Pull Funds**: Address with puller role calls `pullFunds(amount, data)` to transfer collected assets to themselves
182+
2. **Callback Invocation**: If `data.length > 0`, the contract calls `onPullFunds(amount, data)` on the puller address
183+
3. **Fund Utilization**: The puller uses the funds for their intended purpose
184+
4. **Repayment**: Puller (or borrower) transfers assets back to the Request contract
185+
5. **Enable Redemptions**: Owner calls `setRepaid()` to unlock withdrawals
183186

184187
```solidity
185-
// After funding phase
186-
request.pullFunds(borrowerAddress, totalFunded);
188+
// After funding phase - puller pulls funds
189+
// Funds are transferred to msg.sender (the puller)
190+
request.pullFunds(totalFunded, ""); // No callback
187191
188-
// After borrower repays
192+
// With callback data - useful for automated position management
193+
bytes memory positionData = abi.encode(positionId, strategy);
194+
request.pullFunds(totalFunded, positionData); // Calls onPullFunds() on puller
195+
196+
// After repayment (optional helper function)
197+
request.repay(repaymentAmount);
198+
// Or direct transfer:
199+
asset.transfer(address(request), repaymentAmount);
200+
201+
// Enable redemptions
189202
request.setRepaid(); // Enables PT/YT holders to redeem
190203
```
191204

192-
The `pullFunds()` function can be called multiple times by the owner during the funding phase. The `setRepaid()` function toggles the withdrawal lock, enabling PT/YT holders to redeem their tokens for the underlying assets held by the contract.
205+
**Puller Role:**
206+
- The puller role is set during contract initialization via the factory
207+
- Only addresses with the puller role can call `pullFunds()`
208+
- Funds are always transferred to `msg.sender` (the puller), not a separate recipient
209+
- The puller can be a smart contract implementing `IPositionManagerRequestCallback` for automated fund management
210+
211+
**Callback Interface:**
212+
213+
Position managers implementing automated strategies can implement `IPositionManagerRequestCallback`:
214+
215+
```solidity
216+
interface IPositionManagerRequestCallback {
217+
function onPullFunds(uint256 amount, bytes calldata data) external;
218+
}
219+
```
220+
221+
The callback is invoked **after** funds are transferred, allowing the position manager to:
222+
- Open positions in DeFi protocols
223+
- Update internal accounting
224+
- Execute automated strategies based on the provided data
225+
226+
The `pullFunds()` function can be called multiple times by the puller during the funding phase. The `setRepaid()` function toggles the withdrawal lock, enabling PT/YT holders to redeem their tokens for the underlying assets held by the contract.
193227

194228
## RequestFactory
195229

@@ -231,6 +265,7 @@ RequestFactory factory = new RequestFactory(beaconOwner);
231265
// Create a new request with PT/YT vaults
232266
(address request, address ptVault, address ytVault) = factory.createRequest(
233267
owner, // Request owner (admin)
268+
puller, // Address with puller role (can call pullFunds)
234269
address(usdc), // Underlying asset
235270
"USDC Request", // Base name (becomes "PT-USDC Request" / "YT-USDC Request")
236271
"USDC-REQ" // Base symbol (becomes "PT-USDC-REQ" / "YT-USDC-REQ")

0 commit comments

Comments
 (0)