Skip to content

Commit 955a94f

Browse files
committed
removed unnecessary methods
1 parent 2002d94 commit 955a94f

File tree

4 files changed

+7
-36
lines changed

4 files changed

+7
-36
lines changed

packages/ethereum-contracts/contracts/interfaces/superfluid/IYieldBackend.sol

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,15 @@ interface IYieldBackend {
2929
/// Deposits the given amount of the underlying asset into the yield backend.
3030
function deposit(uint256 amount) external;
3131

32-
/// Invoked by `SuperToken` as delegatecall.
33-
/// Deposits the maximum amount of the underlying asset into the yield backend.
34-
/// Maximum is defined by the underlying asset balance of the SuperToken and the yield backend capacity.
35-
function depositMax() external;
36-
3732
/// Invoked by `SuperToken` as delegatecall.
3833
/// Withdraws the given amount of the underlying asset from the yield backend.
3934
function withdraw(uint256 amount) external;
4035

4136
/// Invoked by `SuperToken` as delegatecall.
42-
/// Withdraws the maximum amount of the underlying asset from the yield backend.
43-
/// Maximum is defined by how much can be withdrawn from the yield backend at that point in time.
37+
/// Withdraws the maximum withdrawable amount of the underlying asset from the yield backend.
4438
function withdrawMax() external;
4539

4640
/// Invoked by `SuperToken` as delegatecall.
4741
/// tranfers the deposited asset exceeding totalSupply of the SuperToken to the preset receiver account
4842
function withdrawSurplus(uint256 totalSupply) external;
49-
50-
/// Invoked by `SuperToken` as delegatecall.
51-
/// Returns the amount of the underlying asset currently managed by the yield backend.
52-
/// This shall reflect the amount which could currently be withdrawn from the yield backend,
53-
/// including the generated yield.
54-
function getManagedAmount() external view returns (uint256);
5543
}

packages/ethereum-contracts/contracts/superfluid/AaveYieldBackend.sol

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ contract AaveYieldBackend is IYieldBackend {
7373
AAVE_POOL.supply(address(ASSET_TOKEN), amount, address(this), 0);
7474
}
7575

76-
function depositMax() external {
77-
uint256 amount = USING_WETH ? address(this).balance : ASSET_TOKEN.balanceOf(address(this));
78-
if (amount > 0) {
79-
deposit(amount);
80-
}
81-
}
82-
8376
function withdraw(uint256 amount) external {
8477
// withdraw amount asset by redeeming the corresponding aTokens amount
8578
if (USING_WETH) {
@@ -105,10 +98,6 @@ contract AaveYieldBackend is IYieldBackend {
10598
AAVE_POOL.withdraw(address(ASSET_TOKEN), surplusAmount, SURPLUS_RECEIVER);
10699
}
107100

108-
function getManagedAmount() external view returns (uint256) {
109-
return A_TOKEN.balanceOf(address(this));
110-
}
111-
112101
// ============ functions operating on this contract itself (NOT in delegatecall context) ============
113102

114103
// allow unwrapping from WETH to this contract

packages/ethereum-contracts/contracts/superfluid/SparkYieldBackend.sol

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ contract SparkYieldBackend is IYieldBackend {
3131
VAULT.deposit(amount, address(this));
3232
}
3333

34-
function depositMax() external {
35-
uint256 amount = ASSET_TOKEN.balanceOf(address(this));
36-
if (amount > 0) {
37-
VAULT.deposit(amount, address(this));
38-
}
39-
}
40-
4134
function withdraw(uint256 amount) external {
4235
VAULT.withdraw(amount, address(this), address(this));
4336
}
@@ -60,8 +53,4 @@ contract SparkYieldBackend is IYieldBackend {
6053
uint256 surplusAmount = vaultAssets + ASSET_TOKEN.balanceOf(address(this)) - normalizedTotalSupply;
6154
VAULT.withdraw(surplusAmount, SURPLUS_RECEIVER, address(this));
6255
}
63-
64-
function getManagedAmount() external view returns (uint256) {
65-
return VAULT.convertToAssets(VAULT.balanceOf(address(this)));
66-
}
6756
}

packages/ethereum-contracts/contracts/superfluid/SuperToken.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ contract SuperToken is
207207
require(address(_yieldBackend) == address(0), "yield backend already set");
208208
_yieldBackend = newYieldBackend;
209209
_yieldBackend.dCall(abi.encodeCall(IYieldBackend.enable, ()));
210-
_yieldBackend.dCall(abi.encodeCall(IYieldBackend.depositMax, ()));
210+
// Assumption: if no underlying token is set, it's the native token wrapper (SETH).
211+
// This doesn't hold for pure SuperTokens, but those can't have a yield backend.
212+
uint256 depositAmount = address(_underlyingToken) == address(0)
213+
? address(this).balance
214+
: _underlyingToken.balanceOf(address(this));
215+
_yieldBackend.dCall(abi.encodeCall(IYieldBackend.deposit, (depositAmount)));
211216
// TODO: emit event
212217
}
213218

0 commit comments

Comments
 (0)