Skip to content

Commit

Permalink
deploy: 5c7e162
Browse files Browse the repository at this point in the history
  • Loading branch information
EridianAlpha committed Apr 24, 2024
1 parent 39bff02 commit a5b442e
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 28 deletions.
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ <h1 id="aavepm---aave-position-manager"><a class="header" href="#aavepm---aave-p
<li><a href="#74-update-health-factor-target">7.4. Update Health Factor Target</a></li>
<li><a href="#75-aave-supply-wsteth">7.5. Aave Supply wstETH</a></li>
<li><a href="#76-aave-borrow-usdc">7.6. Aave Borrow USDC</a></li>
<li><a href="#77-rebalance">7.7. Rebalance</a></li>
</ul>
</li>
<li><a href="#8-build-and-deploy-documentation">8. Build and Deploy Documentation</a></li>
Expand Down Expand Up @@ -316,6 +317,12 @@ <h3 id="76-aave-borrow-usdc"><a class="header" href="#76-aave-borrow-usdc">7.6.
<tr><td>Anvil</td><td><code>make aave-borrow-USDC-anvil</code></td></tr>
</tbody></table>
</div>
<h3 id="77-rebalance"><a class="header" href="#77-rebalance">7.7. Rebalance</a></h3>
<p>Rebalances the Aave position to maintain the desired Health Factor.</p>
<div class="table-wrapper"><table><thead><tr><th>Chain</th><th>Command</th></tr></thead><tbody>
<tr><td>Anvil</td><td><code>make rebalance-anvil</code></td></tr>
</tbody></table>
</div>
<h2 id="8-build-and-deploy-documentation"><a class="header" href="#8-build-and-deploy-documentation">8. Build and Deploy Documentation</a></h2>
<p>Instructions on how to build and deploy the documentation book are detailed here: <a href="https://docs.eridianalpha.com/ethereum-dev/foundry-notes/docs-and-github-pages">https://docs.eridianalpha.com/ethereum-dev/foundry-notes/docs-and-github-pages</a></p>
<h2 id="9-license"><a class="header" href="#9-license">9. License</a></h2>
Expand Down
88 changes: 75 additions & 13 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ <h1 id="aavepm---aave-position-manager"><a class="header" href="#aavepm---aave-p
<li><a href="index.html#74-update-health-factor-target">7.4. Update Health Factor Target</a></li>
<li><a href="index.html#75-aave-supply-wsteth">7.5. Aave Supply wstETH</a></li>
<li><a href="index.html#76-aave-borrow-usdc">7.6. Aave Borrow USDC</a></li>
<li><a href="index.html#77-rebalance">7.7. Rebalance</a></li>
</ul>
</li>
<li><a href="index.html#8-build-and-deploy-documentation">8. Build and Deploy Documentation</a></li>
Expand Down Expand Up @@ -317,6 +318,12 @@ <h3 id="76-aave-borrow-usdc"><a class="header" href="#76-aave-borrow-usdc">7.6.
<tr><td>Anvil</td><td><code>make aave-borrow-USDC-anvil</code></td></tr>
</tbody></table>
</div>
<h3 id="77-rebalance"><a class="header" href="#77-rebalance">7.7. Rebalance</a></h3>
<p>Rebalances the Aave position to maintain the desired Health Factor.</p>
<div class="table-wrapper"><table><thead><tr><th>Chain</th><th>Command</th></tr></thead><tbody>
<tr><td>Anvil</td><td><code>make rebalance-anvil</code></td></tr>
</tbody></table>
</div>
<h2 id="8-build-and-deploy-documentation"><a class="header" href="#8-build-and-deploy-documentation">8. Build and Deploy Documentation</a></h2>
<p>Instructions on how to build and deploy the documentation book are detailed here: <a href="https://docs.eridianalpha.com/ethereum-dev/foundry-notes/docs-and-github-pages">https://docs.eridianalpha.com/ethereum-dev/foundry-notes/docs-and-github-pages</a></p>
<h2 id="9-license"><a class="header" href="#9-license">9. License</a></h2>
Expand All @@ -328,7 +335,7 @@ <h2 id="9-license"><a class="header" href="#9-license">9. License</a></h2>
<li><a href="src/interfaces/IWETH9.sol/interface.IWETH9.html">IWETH9</a></li>
</ul>
<div style="break-before: page; page-break-before: always;"></div><h1 id="iaavepm"><a class="header" href="#iaavepm">IAavePM</a></h1>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/e5ff4c818eb9da738a1e141f46b81e54b56dd392/src/interfaces/IAavePM.sol">Git Source</a></p>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/5c7e16284333d5d63e73537e5550f796a2833903/src/interfaces/IAavePM.sol">Git Source</a></p>
<p>This interface defines the essential structures and functions for the AavePM contract.</p>
<h2 id="functions"><a class="header" href="#functions">Functions</a></h2>
<h3 id="initialize"><a class="header" href="#initialize">initialize</a></h3>
Expand Down Expand Up @@ -369,11 +376,16 @@ <h3 id="aavesupplywsteth"><a class="header" href="#aavesupplywsteth">aaveSupplyW
<h3 id="aaveborrowusdc"><a class="header" href="#aaveborrowusdc">aaveBorrowUSDC</a></h3>
<pre><code class="language-solidity">function aaveBorrowUSDC(uint256 borrowAmount) external;
</code></pre>
<h3 id="aaverepay"><a class="header" href="#aaverepay">aaveRepay</a></h3>
<pre><code class="language-solidity">function aaveRepay() external;
<h3 id="aaverepaydebtusdc"><a class="header" href="#aaverepaydebtusdc">aaveRepayDebtUSDC</a></h3>
<pre><code class="language-solidity">function aaveRepayDebtUSDC(uint256 repayAmount) external;
</code></pre>
<h3 id="aavewithdraw"><a class="header" href="#aavewithdraw">aaveWithdraw</a></h3>
<pre><code class="language-solidity">function aaveWithdraw() external;
<pre><code class="language-solidity">function aaveWithdraw(uint256 withdrawAmount) external;
</code></pre>
<h3 id="executeoperation"><a class="header" href="#executeoperation">executeOperation</a></h3>
<pre><code class="language-solidity">function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes calldata)
external
returns (bool);
</code></pre>
<h3 id="swaptokens"><a class="header" href="#swaptokens">swapTokens</a></h3>
<pre><code class="language-solidity">function swapTokens(
Expand Down Expand Up @@ -477,6 +489,9 @@ <h3 id="aavepm__healthfactorbelowminimum"><a class="header" href="#aavepm__healt
<h3 id="aavepm__notenoughtokensforswap"><a class="header" href="#aavepm__notenoughtokensforswap">AavePM__NotEnoughTokensForSwap</a></h3>
<pre><code class="language-solidity">error AavePM__NotEnoughTokensForSwap(string tokenInIdentifier);
</code></pre>
<h3 id="aavepm__flashloaninitiatorunauthorized"><a class="header" href="#aavepm__flashloaninitiatorunauthorized">AavePM__FlashLoanInitiatorUnauthorized</a></h3>
<pre><code class="language-solidity">error AavePM__FlashLoanInitiatorUnauthorized();
</code></pre>
<h2 id="structs"><a class="header" href="#structs">Structs</a></h2>
<h3 id="contractaddress"><a class="header" href="#contractaddress">ContractAddress</a></h3>
<pre><code class="language-solidity">struct ContractAddress {
Expand All @@ -498,7 +513,7 @@ <h3 id="uniswapv3pool"><a class="header" href="#uniswapv3pool">UniswapV3Pool</a>
}
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="ierc20extended"><a class="header" href="#ierc20extended">IERC20Extended</a></h1>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/e5ff4c818eb9da738a1e141f46b81e54b56dd392/src/interfaces/IERC20Extended.sol">Git Source</a></p>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/5c7e16284333d5d63e73537e5550f796a2833903/src/interfaces/IERC20Extended.sol">Git Source</a></p>
<p><strong>Inherits:</strong>
IERC20</p>
<p>This interface extends the ERC20 interface with the decimals function.</p>
Expand All @@ -507,7 +522,7 @@ <h3 id="decimals"><a class="header" href="#decimals">decimals</a></h3>
<pre><code class="language-solidity">function decimals() external view returns (uint8);
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="iweth9"><a class="header" href="#iweth9">IWETH9</a></h1>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/e5ff4c818eb9da738a1e141f46b81e54b56dd392/src/interfaces/IWETH9.sol">Git Source</a></p>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/5c7e16284333d5d63e73537e5550f796a2833903/src/interfaces/IWETH9.sol">Git Source</a></p>
<p>This interface enables the wrapping and unwrapping of ETH to WETH.</p>
<h2 id="functions-2"><a class="header" href="#functions-2">Functions</a></h2>
<h3 id="deposit"><a class="header" href="#deposit">deposit</a></h3>
Expand All @@ -517,7 +532,7 @@ <h3 id="withdraw"><a class="header" href="#withdraw">withdraw</a></h3>
<pre><code class="language-solidity">function withdraw(uint256 wad) external;
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="aavepm"><a class="header" href="#aavepm">AavePM</a></h1>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/e5ff4c818eb9da738a1e141f46b81e54b56dd392/src/AavePM.sol">Git Source</a></p>
<p><a href="https://github.com/EridianAlpha/aave-position-manager/blob/5c7e16284333d5d63e73537e5550f796a2833903/src/AavePM.sol">Git Source</a></p>
<p><strong>Inherits:</strong>
<a href="src/AavePM.sol//src/interfaces/IAavePM.sol/interface.IAavePM.html">IAavePM</a>, Initializable, AccessControlUpgradeable, UUPSUpgradeable</p>
<p><strong>Author:</strong>
Expand Down Expand Up @@ -562,6 +577,12 @@ <h3 id="health_factor_target_minimum"><a class="header" href="#health_factor_tar
A contract upgrade is required to change this value.</em></p>
<pre><code class="language-solidity">uint16 private constant HEALTH_FACTOR_TARGET_MINIMUM = 200;
</code></pre>
<h3 id="aave_health_factor_divisor"><a class="header" href="#aave_health_factor_divisor">AAVE_HEALTH_FACTOR_DIVISOR</a></h3>
<p>The divisor for the Aave Health Factor.</p>
<p><em>The Aave Health Factor is a value with 18 decimal places.
This divisor is used to scale the Health Factor to 2 decimal places.</em></p>
<pre><code class="language-solidity">uint256 constant AAVE_HEALTH_FACTOR_DIVISOR = 1e16;
</code></pre>
<h2 id="functions-3"><a class="header" href="#functions-3">Functions</a></h2>
<h3 id="constructor"><a class="header" href="#constructor">constructor</a></h3>
<p>Constructor implemented but unused.</p>
Expand Down Expand Up @@ -689,18 +710,45 @@ <h3 id="aaveborrowusdc-1"><a class="header" href="#aaveborrowusdc-1">aaveBorrowU
<tr><td><code>borrowAmount</code></td><td><code>uint256</code></td><td>The amount of USDC to borrow. 8 decimal places to the dollar. e.g. 100000000 = $1.00.</td></tr>
</tbody></table>
</div>
<h3 id="aaverepay-1"><a class="header" href="#aaverepay-1">aaveRepay</a></h3>
<p>Repay Aave debt.</p>
<p><em>Caller must have <code>MANAGER_ROLE</code>.
TODO: Implement function.</em></p>
<pre><code class="language-solidity">function aaveRepay() public onlyRole(MANAGER_ROLE);
<h3 id="aaverepaydebtusdc-1"><a class="header" href="#aaverepaydebtusdc-1">aaveRepayDebtUSDC</a></h3>
<p>Repay USDC debt to Aave.</p>
<p><em>Caller must have <code>MANAGER_ROLE</code>.</em></p>
<pre><code class="language-solidity">function aaveRepayDebtUSDC(uint256 repayAmount) public onlyRole(MANAGER_ROLE);
</code></pre>
<p><strong>Parameters</strong></p>
<div class="table-wrapper"><table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody>
<tr><td><code>repayAmount</code></td><td><code>uint256</code></td><td>The amount of USDC to repay. 8 decimal places to the dollar. e.g. 100000000 = $1.00.</td></tr>
</tbody></table>
</div>
<h3 id="aavewithdraw-1"><a class="header" href="#aavewithdraw-1">aaveWithdraw</a></h3>
<p>Withdraw all wstETH from Aave.</p>
<p><em>Caller must have <code>MANAGER_ROLE</code>.
TODO: Implement function.</em></p>
<pre><code class="language-solidity">function aaveWithdraw() public onlyRole(MANAGER_ROLE);
<pre><code class="language-solidity">function aaveWithdraw(uint256 withdrawAmount) public onlyRole(MANAGER_ROLE);
</code></pre>
<h3 id="executeoperation-1"><a class="header" href="#executeoperation-1">executeOperation</a></h3>
<p>Flash loan callback function.</p>
<p><em>This function is called by the Aave pool contract after the flash loan is executed.
It is used to repay the flash loan and execute the operation.
The function is called by the Aave pool contract and is not intended to be called directly.</em></p>
<pre><code class="language-solidity">function executeOperation(address asset, uint256 amount, uint256 premium, address initiator, bytes calldata)
external
returns (bool);
</code></pre>
<p><strong>Parameters</strong></p>
<div class="table-wrapper"><table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody>
<tr><td><code>asset</code></td><td><code>address</code></td><td>The address of the asset being flash loaned.</td></tr>
<tr><td><code>amount</code></td><td><code>uint256</code></td><td>The amount of the asset being flash loaned.</td></tr>
<tr><td><code>premium</code></td><td><code>uint256</code></td><td>The fee charged for the flash loan.</td></tr>
<tr><td><code>initiator</code></td><td><code>address</code></td><td>The address of the contract that initiated the flash loan.</td></tr>
<tr><td><code>&lt;none&gt;</code></td><td><code>bytes</code></td><td></td></tr>
</tbody></table>
</div>
<p><strong>Returns</strong></p>
<div class="table-wrapper"><table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody>
<tr><td><code>&lt;none&gt;</code></td><td><code>bool</code></td><td>bool True if the operation was successful.</td></tr>
</tbody></table>
</div>
<h3 id="swaptokens-1"><a class="header" href="#swaptokens-1">swapTokens</a></h3>
<p>Swaps the contract's entire specified token balance using a UniswapV3 pool.</p>
<p><em>Caller must have <code>MANAGER_ROLE</code>.
Expand Down Expand Up @@ -738,7 +786,21 @@ <h3 id="renameidentifierfromethtowethifneeded"><a class="header" href="#renameid
<p>// TODO: Add comment</p>
<pre><code class="language-solidity">function renameIdentifierFromETHToWETHIfNeeded(string memory tokenIdentifier) private pure returns (string memory);
</code></pre>
<h3 id="calculatemaxborrowusdc"><a class="header" href="#calculatemaxborrowusdc">calculateMaxBorrowUSDC</a></h3>
<pre><code class="language-solidity">function calculateMaxBorrowUSDC(
uint256 totalCollateralBase,
uint256 totalDebtBase,
uint256 currentLiquidationThreshold,
uint16 healthFactorTarget
) private pure returns (uint256 maxBorrowUSDC);
</code></pre>
<h3 id="rebalance-1"><a class="header" href="#rebalance-1">rebalance</a></h3>
<p>Rebalance the Aave position.</p>
<p><em>Caller must have <code>MANAGER_ROLE</code>.
The function rebalances the Aave position by converting any ETH to WETH, then WETH to wstETH.
It then deposits the wstETH into Aave.
If the health factor is below the target, it repays debt to increase the health factor.
If the health factor is above the target, it borrows more USDC and reinvests.</em></p>
<pre><code class="language-solidity">function rebalance() public onlyRole(MANAGER_ROLE);
</code></pre>
<h3 id="getcreator-1"><a class="header" href="#getcreator-1">getCreator</a></h3>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

Loading

0 comments on commit a5b442e

Please sign in to comment.