-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gateway strategy plus test cases
- Loading branch information
Showing
46 changed files
with
2,588 additions
and
3 deletions.
There are no files selected for viewing
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
10 changes: 10 additions & 0 deletions
10
...docs/contracts/src/src/gateway/CommonStructs.sol/struct.StrategySlippageArgs.md
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,10 @@ | ||
# StrategySlippageArgs | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/CommonStructs.sol) | ||
|
||
|
||
```solidity | ||
struct StrategySlippageArgs { | ||
uint256 amountOutMin; | ||
} | ||
``` | ||
|
27 changes: 27 additions & 0 deletions
27
...s/contracts/src/src/gateway/IStrategy.sol/abstract.IStrategyWithSlippageArgs.md
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,27 @@ | ||
# IStrategyWithSlippageArgs | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/IStrategy.sol) | ||
|
||
**Inherits:** | ||
[IStrategy](../../gateway/IStrategy.sol/interface.IStrategy.md) | ||
|
||
|
||
## Functions | ||
### handleGatewayMessageWithSlippageArgs | ||
|
||
|
||
```solidity | ||
function handleGatewayMessageWithSlippageArgs( | ||
IERC20 tokenSent, | ||
uint256 amountIn, | ||
address recipient, | ||
StrategySlippageArgs memory args | ||
) public virtual; | ||
``` | ||
|
||
### handleGatewayMessage | ||
|
||
|
||
```solidity | ||
function handleGatewayMessage(IERC20 tokenSent, uint256 amountIn, address recipient, bytes memory message) external; | ||
``` | ||
|
19 changes: 19 additions & 0 deletions
19
docs/docs/contracts/src/src/gateway/IStrategy.sol/interface.IStrategy.md
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,19 @@ | ||
# IStrategy | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/IStrategy.sol) | ||
|
||
|
||
## Functions | ||
### handleGatewayMessage | ||
|
||
|
||
```solidity | ||
function handleGatewayMessage(IERC20 tokenSent, uint256 amountIn, address recipient, bytes memory message) external; | ||
``` | ||
|
||
## Events | ||
### TokenOutput | ||
|
||
```solidity | ||
event TokenOutput(address tokenReceived, uint256 amountOut); | ||
``` | ||
|
55 changes: 55 additions & 0 deletions
55
...s/src/src/gateway/strategy/AvalonStrategy.sol/contract.AvalonLendingStrategy.md
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,55 @@ | ||
# AvalonLendingStrategy | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/AvalonStrategy.sol) | ||
|
||
**Inherits:** | ||
[IStrategyWithSlippageArgs](../../gateway/IStrategy.sol/abstract.IStrategyWithSlippageArgs.md), Context | ||
|
||
|
||
## State Variables | ||
### avBep20 | ||
|
||
```solidity | ||
IERC20 public immutable avBep20; | ||
``` | ||
|
||
|
||
### pool | ||
|
||
```solidity | ||
IAvalonIPool public immutable pool; | ||
``` | ||
|
||
|
||
## Functions | ||
### constructor | ||
|
||
|
||
```solidity | ||
constructor(IERC20 _avBep20, IAvalonIPool _pool); | ||
``` | ||
|
||
### handleGatewayMessageWithSlippageArgs | ||
|
||
Mints lending tokens to the recipient. | ||
|
||
*Requires that the strategy is approved to spend the incoming tokens.* | ||
|
||
|
||
```solidity | ||
function handleGatewayMessageWithSlippageArgs( | ||
IERC20 tokenSent, | ||
uint256 amountIn, | ||
address recipient, | ||
StrategySlippageArgs memory args | ||
) public override; | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`tokenSent`|`IERC20`|The ERC20 token to deposit.| | ||
|`amountIn`|`uint256`|The amount to be deposited.| | ||
|`recipient`|`address`|The address to receive the lending tokens.| | ||
|`args`|`StrategySlippageArgs`|Additional args for slippage protection.| | ||
|
||
|
55 changes: 55 additions & 0 deletions
55
...racts/src/src/gateway/strategy/AvalonStrategy.sol/contract.AvalonLstStrategy.md
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,55 @@ | ||
# AvalonLstStrategy | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/AvalonStrategy.sol) | ||
|
||
**Inherits:** | ||
[IStrategyWithSlippageArgs](../../gateway/IStrategy.sol/abstract.IStrategyWithSlippageArgs.md), Context | ||
|
||
|
||
## State Variables | ||
### solvLSTStrategy | ||
|
||
```solidity | ||
SolvLSTStrategy public immutable solvLSTStrategy; | ||
``` | ||
|
||
|
||
### avalonLendingStrategy | ||
|
||
```solidity | ||
AvalonLendingStrategy public immutable avalonLendingStrategy; | ||
``` | ||
|
||
|
||
## Functions | ||
### constructor | ||
|
||
|
||
```solidity | ||
constructor(SolvLSTStrategy _solvLSTStrategy, AvalonLendingStrategy _avalonLendingStrategy); | ||
``` | ||
|
||
### handleGatewayMessageWithSlippageArgs | ||
|
||
Mints lending tokens to the recipient. | ||
|
||
*Requires that the strategy is approved to spend the incoming tokens.* | ||
|
||
|
||
```solidity | ||
function handleGatewayMessageWithSlippageArgs( | ||
IERC20 tokenSent, | ||
uint256 amountIn, | ||
address recipient, | ||
StrategySlippageArgs memory args | ||
) public override; | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`tokenSent`|`IERC20`|The ERC20 token to deposit.| | ||
|`amountIn`|`uint256`|The amount to be deposited.| | ||
|`recipient`|`address`|The address to receive the lending tokens.| | ||
|`args`|`StrategySlippageArgs`|Additional args for slippage protection.| | ||
|
||
|
46 changes: 46 additions & 0 deletions
46
...contracts/src/src/gateway/strategy/AvalonStrategy.sol/interface.IAvalonIPool.md
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 @@ | ||
# IAvalonIPool | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/AvalonStrategy.sol) | ||
|
||
|
||
## Functions | ||
### supply | ||
|
||
Mints pool tokens to the recipient. | ||
|
||
|
||
```solidity | ||
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external; | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`asset`|`address`|The address of the ERC20 token to supply to the pool.| | ||
|`amount`|`uint256`|The amount of the asset to supply.| | ||
|`onBehalfOf`|`address`|The address that will receive the supplied amount.| | ||
|`referralCode`|`uint16`|Optional referral code to track the origin of the supply.| | ||
|
||
|
||
### withdraw | ||
|
||
Withdraws asset from the pool. | ||
|
||
|
||
```solidity | ||
function withdraw(address asset, uint256 amount, address to) external returns (uint256); | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`asset`|`address`|The address of the ERC20 token to withdraw from the pool.| | ||
|`amount`|`uint256`|The amount of the asset to withdraw.| | ||
|`to`|`address`|The address that will receive the withdrawn amount.| | ||
|
||
**Returns** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`<none>`|`uint256`|The actual amount withdrawn.| | ||
|
||
|
48 changes: 48 additions & 0 deletions
48
...tracts/src/src/gateway/strategy/BedrockStrategy.sol/contract.BedrockStrategy.md
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,48 @@ | ||
# BedrockStrategy | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/BedrockStrategy.sol) | ||
|
||
**Inherits:** | ||
[IStrategyWithSlippageArgs](../../gateway/IStrategy.sol/abstract.IStrategyWithSlippageArgs.md), Context | ||
|
||
|
||
## State Variables | ||
### vault | ||
|
||
```solidity | ||
IBedrockVault public immutable vault; | ||
``` | ||
|
||
|
||
## Functions | ||
### constructor | ||
|
||
|
||
```solidity | ||
constructor(IBedrockVault _vault); | ||
``` | ||
|
||
### handleGatewayMessageWithSlippageArgs | ||
|
||
Deposits tokens into Bedrock to mint uniBTC. | ||
|
||
*Requires that the strategy is approved to spend the incoming tokens.* | ||
|
||
|
||
```solidity | ||
function handleGatewayMessageWithSlippageArgs( | ||
IERC20 tokenSent, | ||
uint256 amountIn, | ||
address recipient, | ||
StrategySlippageArgs memory args | ||
) public override; | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`tokenSent`|`IERC20`|The ERC20 token to deposit.| | ||
|`amountIn`|`uint256`|The amount to be deposited.| | ||
|`recipient`|`address`|The address to receive uniBTC.| | ||
|`args`|`StrategySlippageArgs`|Additional args for slippage protection.| | ||
|
||
|
28 changes: 28 additions & 0 deletions
28
...ntracts/src/src/gateway/strategy/BedrockStrategy.sol/interface.IBedrockVault.md
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,28 @@ | ||
# IBedrockVault | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/BedrockStrategy.sol) | ||
|
||
*Bedrock ABI for their Vault.* | ||
|
||
|
||
## Functions | ||
### mint | ||
|
||
|
||
```solidity | ||
function mint(address _token, uint256 _amount) external; | ||
``` | ||
|
||
### redeem | ||
|
||
|
||
```solidity | ||
function redeem(address _token, uint256 _amount) external; | ||
``` | ||
|
||
### uniBTC | ||
|
||
|
||
```solidity | ||
function uniBTC() external view returns (address); | ||
``` | ||
|
64 changes: 64 additions & 0 deletions
64
.../contracts/src/src/gateway/strategy/IonicStrategy.sol/contract.IonicStrategy.md
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,64 @@ | ||
# IonicStrategy | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/IonicStrategy.sol) | ||
|
||
**Inherits:** | ||
[IStrategyWithSlippageArgs](../../gateway/IStrategy.sol/abstract.IStrategyWithSlippageArgs.md), Context | ||
|
||
*Implements IStrategyWithSlippageArgs and allows the contract to handle tokens with slippage arguments.* | ||
|
||
|
||
## State Variables | ||
### ioErc20 | ||
|
||
```solidity | ||
IIonicToken public immutable ioErc20; | ||
``` | ||
|
||
|
||
### pool | ||
|
||
```solidity | ||
IPool public immutable pool; | ||
``` | ||
|
||
|
||
## Functions | ||
### constructor | ||
|
||
*Constructor to initialize the Ionic token and pool interfaces.* | ||
|
||
|
||
```solidity | ||
constructor(IIonicToken _ioErc20, IPool _pool); | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`_ioErc20`|`IIonicToken`|Address of the Ionic token.| | ||
|`_pool`|`IPool`|Address of the Ionic pool.| | ||
|
||
|
||
### handleGatewayMessageWithSlippageArgs | ||
|
||
*Handles the transfer and minting of tokens with slippage control.* | ||
|
||
|
||
```solidity | ||
function handleGatewayMessageWithSlippageArgs( | ||
IERC20 tokenSent, | ||
uint256 amountIn, | ||
address recipient, | ||
StrategySlippageArgs memory args | ||
) public override; | ||
``` | ||
**Parameters** | ||
|
||
|Name|Type|Description| | ||
|----|----|-----------| | ||
|`tokenSent`|`IERC20`|The token to be transferred.| | ||
|`amountIn`|`uint256`|The amount of tokens to be transferred.| | ||
|`recipient`|`address`|The recipient address.| | ||
|`args`|`StrategySlippageArgs`|Slippage arguments, including minimum acceptable output amount.| | ||
|
||
|
22 changes: 22 additions & 0 deletions
22
...s/contracts/src/src/gateway/strategy/IonicStrategy.sol/interface.IIonicToken.md
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,22 @@ | ||
# IIonicToken | ||
[Git Source](https://github.com/bob-collective/bob/blob/master/src/gateway/strategy/IonicStrategy.sol) | ||
|
||
*Interface for the Ionic Finance token, providing minting, redeeming, | ||
and balance query functions.* | ||
|
||
|
||
## Functions | ||
### mint | ||
|
||
|
||
```solidity | ||
function mint(uint256 mintAmount) external returns (uint256); | ||
``` | ||
|
||
### redeem | ||
|
||
|
||
```solidity | ||
function redeem(uint256 redeemTokens) external returns (uint256); | ||
``` | ||
|
Oops, something went wrong.