Skip to content

Commit

Permalink
Add specifying osToken amount to batch deposit/mint calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Jul 1, 2024
1 parent a2114e8 commit 53b48bd
Show file tree
Hide file tree
Showing 37 changed files with 301 additions and 131 deletions.
14 changes: 12 additions & 2 deletions abi/IEthBlocklistErc20Vault.json
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -876,7 +881,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1570,6 +1575,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1607,7 +1617,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 12 additions & 2 deletions abi/IEthBlocklistVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -733,7 +738,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1273,6 +1278,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1310,7 +1320,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 12 additions & 2 deletions abi/IEthErc20Vault.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -800,7 +805,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1463,6 +1468,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1500,7 +1510,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 12 additions & 2 deletions abi/IEthGenesisVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -720,7 +725,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1253,6 +1258,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1290,7 +1300,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 12 additions & 2 deletions abi/IEthPrivErc20Vault.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -844,7 +849,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1520,6 +1525,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1557,7 +1567,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 12 additions & 2 deletions abi/IEthPrivVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -701,7 +706,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1223,6 +1228,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1260,7 +1270,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 12 additions & 2 deletions abi/IEthVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand All @@ -657,7 +662,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down Expand Up @@ -1166,6 +1171,11 @@
"name": "receiver",
"type": "address"
},
{
"internalType": "uint256",
"name": "osTokenShares",
"type": "uint256"
},
{
"internalType": "address",
"name": "referrer",
Expand Down Expand Up @@ -1203,7 +1213,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "osTokenShares",
"name": "",
"type": "uint256"
}
],
Expand Down
14 changes: 10 additions & 4 deletions contracts/interfaces/IEthErc20Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,30 @@ interface IEthErc20Vault is
/**
* @notice Deposits assets to the vault and mints OsToken shares to the receiver
* @param receiver The address to receive the OsToken
* @param osTokenShares The amount of OsToken shares to mint.
* If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount.
* @param referrer The address of the referrer
* @return osTokenShares The amount of OsToken shares minted
* @return The amount of OsToken shares minted
*/
function depositAndMintOsToken(
address receiver,
uint256 osTokenShares,
address referrer
) external payable returns (uint256 osTokenShares);
) external payable returns (uint256);

/**
* @notice Updates the state, deposits assets to the vault and mints OsToken shares to the receiver
* @param receiver The address to receive the OsToken
* @param osTokenShares The amount of OsToken shares to mint.
* If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount.
* @param referrer The address of the referrer
* @param harvestParams The parameters for the harvest
* @return osTokenShares The amount of OsToken shares minted
* @return The amount of OsToken shares minted
*/
function updateStateAndDepositAndMintOsToken(
address receiver,
uint256 osTokenShares,
address referrer,
IKeeperRewards.HarvestParams calldata harvestParams
) external payable returns (uint256 osTokenShares);
) external payable returns (uint256);
}
14 changes: 10 additions & 4 deletions contracts/interfaces/IEthVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,30 @@ interface IEthVault is
/**
* @notice Deposits assets to the vault and mints OsToken shares to the receiver
* @param receiver The address to receive the OsToken
* @param osTokenShares The amount of OsToken shares to mint.
* If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount.
* @param referrer The address of the referrer
* @return osTokenShares The amount of OsToken shares minted
* @return The amount of OsToken shares minted
*/
function depositAndMintOsToken(
address receiver,
uint256 osTokenShares,
address referrer
) external payable returns (uint256 osTokenShares);
) external payable returns (uint256);

/**
* @notice Updates the state, deposits assets to the vault and mints OsToken shares to the receiver
* @param receiver The address to receive the OsToken
* @param osTokenShares The amount of OsToken shares to mint.
* If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount.
* @param referrer The address of the referrer
* @param harvestParams The parameters for the harvest
* @return osTokenShares The amount of OsToken shares minted
* @return The amount of OsToken shares minted
*/
function updateStateAndDepositAndMintOsToken(
address receiver,
uint256 osTokenShares,
address referrer,
IKeeperRewards.HarvestParams calldata harvestParams
) external payable returns (uint256 osTokenShares);
) external payable returns (uint256);
}
14 changes: 10 additions & 4 deletions contracts/vaults/ethereum/EthErc20Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,27 @@ contract EthErc20Vault is
/// @inheritdoc IEthErc20Vault
function depositAndMintOsToken(
address receiver,
uint256 osTokenShares,
address referrer
) public payable override returns (uint256 osTokenShares) {
) public payable override returns (uint256) {
deposit(msg.sender, referrer);
osTokenShares = _calcMaxOsTokenShares(msg.value);
if (osTokenShares == type(uint256).max) {
// mint max OsToken shares based on the deposited amount
osTokenShares = _calcMaxOsTokenShares(msg.value);
}
mintOsToken(receiver, osTokenShares, referrer);
return osTokenShares;
}

/// @inheritdoc IEthErc20Vault
function updateStateAndDepositAndMintOsToken(
address receiver,
uint256 osTokenShares,
address referrer,
IKeeperRewards.HarvestParams calldata harvestParams
) external payable override returns (uint256 osTokenShares) {
) external payable override returns (uint256) {
updateState(harvestParams);
return depositAndMintOsToken(receiver, referrer);
return depositAndMintOsToken(receiver, osTokenShares, referrer);
}

/// @inheritdoc IERC20
Expand Down
Loading

0 comments on commit 53b48bd

Please sign in to comment.