Skip to content

Commit

Permalink
feat: add gateway strategy plus test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Jan 10, 2025
1 parent 1089f49 commit a278043
Show file tree
Hide file tree
Showing 46 changed files with 2,588 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
forge build --sizes --deny-warnings
id: build
- name: Run forge tests
# Currently forked tests are disabled to increase reliability of CI builds
run: |
forge test -vvv --deny-warnings
forge test --no-match-contract Forked -vvv --deny-warnings
id: test
- name: Run forge docs
run: |
Expand Down
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;
}
```

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;
```

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);
```

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.|


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.|


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.|


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.|


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);
```

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.|


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);
```

Loading

0 comments on commit a278043

Please sign in to comment.