Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zkCRA PR into merge-create-loan #378

Open
wants to merge 159 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
7fc20ca
Merge branch 'develop' into feature/merge-create-loan
elclandestin0 Jun 3, 2021
dfffc22
data provider
elclandestin0 Jun 4, 2021
7c513d1
merge
elclandestin0 Jun 4, 2021
eee923c
fix compilation errors
elclandestin0 Jun 4, 2021
95eb4d5
some changes to dp
elclandestin0 Jun 4, 2021
1ccb5a4
Skelly for ZK CRA
tpscrpt Jun 4, 2021
031cbc3
Borrow function logic done, need to create loan and add configuratio…
tpscrpt Jun 4, 2021
d427b2d
Add snarks lib
tpscrpt Jun 4, 2021
cb26dae
Add documentation and fix using collateralAmount instead of collatera…
tpscrpt Jun 4, 2021
e08f40f
Into one file
tpscrpt Jun 4, 2021
c6eb931
Sample handler
tpscrpt Jun 4, 2021
b206dea
Updaets
tpscrpt Jun 4, 2021
07252f2
More clarity on market unctions
tpscrpt Jun 4, 2021
059c03c
zkCRA test template
elclandestin0 Jun 4, 2021
0d6dcd3
Save
tpscrpt Jun 5, 2021
3b40eea
attempt at fixing comp. errors
elclandestin0 Jun 7, 2021
3f3ed56
Fix compilation errors
tpscrpt Jun 7, 2021
6443352
packed variables
elclandestin0 Jun 8, 2021
08f7020
update test
elclandestin0 Jun 8, 2021
7a0c7c4
got witness, output & proof
elclandestin0 Jun 8, 2021
8c2e977
set config admins
elclandestin0 Jun 9, 2021
3cc58ab
tests almost done
elclandestin0 Jun 10, 2021
e76a85b
update tests
elclandestin0 Jun 10, 2021
3025c2f
ting
tpscrpt Jun 10, 2021
23162c0
Updates
tpscrpt Jun 10, 2021
aa3fe79
data being submitted onchain
elclandestin0 Jun 11, 2021
dadfc00
update tests
elclandestin0 Jun 11, 2021
26992f1
Keys
tpscrpt Jun 11, 2021
8776bb9
Snark proof verifying
tpscrpt Jun 11, 2021
cb7ffd1
YE
tpscrpt Jun 11, 2021
5728e29
Faster tests
tpscrpt Jun 12, 2021
be9bd3d
Progress
tpscrpt Jun 12, 2021
58efe8b
Packing properly hopefully
tpscrpt Jun 12, 2021
fca10a3
Working zk cra
tpscrpt Jun 12, 2021
9d94bfb
fix void signer error
elclandestin0 Jun 12, 2021
c83a425
Merge branch 'develop' into feature/zk-cra
elclandestin0 Jun 21, 2021
fce6a8b
zkcra.json stored in ipfs
elclandestin0 Jun 23, 2021
1f1ee5f
good scores bad scores
elclandestin0 Jun 23, 2021
5044652
ipfs successfully returning source
elclandestin0 Jun 23, 2021
cc8dccf
zkcra create loan changes
elclandestin0 Jun 24, 2021
fa6c4c6
fix errors
elclandestin0 Jun 24, 2021
5c79e38
merge fix
elclandestin0 Jun 24, 2021
40e8a65
market interest calc
elclandestin0 Jun 24, 2021
892e58a
moved init market admins to create loan facet
elclandestin0 Jun 25, 2021
ec8187b
reworked setting provider info
elclandestin0 Jun 25, 2021
c5da9b5
modifyign tests
elclandestin0 Jun 27, 2021
e584254
zkcra working
elclandestin0 Jun 28, 2021
3765885
zkcra updated tests
elclandestin0 Jun 28, 2021
3ab1604
fixing signaturedata datatype
elclandestin0 Jun 28, 2021
ee8c659
require statement
elclandestin0 Jun 28, 2021
e72d8ba
updated w/ noah's comments
elclandestin0 Jun 29, 2021
e9651ab
unused imports fix
elclandestin0 Jun 29, 2021
43e8f23
Revert "unused imports fix"
elclandestin0 Jun 29, 2021
f9b9f51
para programming w/ Noah
elclandestin0 Jun 29, 2021
70aac4e
process request library
elclandestin0 Jun 29, 2021
e8426f0
sample market handler
elclandestin0 Jun 30, 2021
e1e8058
fixed dir structure
elclandestin0 Jun 30, 2021
cbe2e82
ready for deployment
elclandestin0 Jun 30, 2021
90382a7
deployed process request library and teller market handler
elclandestin0 Jun 30, 2021
bfdb832
change to public function
elclandestin0 Jul 1, 2021
020d131
create provider factory
elclandestin0 Jul 1, 2021
1a489ce
deployed provider factory
elclandestin0 Jul 1, 2021
4e9d18c
signer successfully set
elclandestin0 Jul 1, 2021
d6a73af
provider set in market
elclandestin0 Jul 1, 2021
0a35fd5
commitments = number of signatures required
elclandestin0 Jul 2, 2021
55e7edf
end to end testing with good score done
elclandestin0 Jul 2, 2021
35d182b
provider creation with args
elclandestin0 Jul 2, 2021
3a70f50
added provider to request
elclandestin0 Jul 2, 2021
c6bdbf7
end to end testing for bad score completed
elclandestin0 Jul 2, 2021
84f4c23
removed console logs
elclandestin0 Jul 2, 2021
3831705
changed teller interest value
elclandestin0 Jul 5, 2021
82ffaf2
removed market lib
elclandestin0 Jul 5, 2021
0a53985
fix bad score test
elclandestin0 Jul 5, 2021
c6c50a2
update
elclandestin0 Jul 5, 2021
b9d8bc9
market handler updated with new loan calculator
elclandestin0 Jul 5, 2021
0a60b7a
removed useless require statement
elclandestin0 Jul 5, 2021
20aefc5
states file
elclandestin0 Jul 6, 2021
d9aec33
retrieve state's rate
elclandestin0 Jul 6, 2021
2df3405
fix bn error
elclandestin0 Jul 7, 2021
af9c5fa
fix market handling rounding error
elclandestin0 Jul 8, 2021
04087de
Merge pull request #421 from teller-protocol/zk-cra/test-flow
elclandestin0 Jul 9, 2021
996c352
data provider
elclandestin0 Jun 4, 2021
302ea5b
some changes to dp
elclandestin0 Jun 4, 2021
619181e
Skelly for ZK CRA
tpscrpt Jun 4, 2021
3b0459c
Borrow function logic done, need to create loan and add configuratio…
tpscrpt Jun 4, 2021
c724a92
Add snarks lib
tpscrpt Jun 4, 2021
28a7010
Add documentation and fix using collateralAmount instead of collatera…
tpscrpt Jun 4, 2021
34eb446
Into one file
tpscrpt Jun 4, 2021
6a7a0ee
Sample handler
tpscrpt Jun 4, 2021
da73525
Updaets
tpscrpt Jun 4, 2021
3cd3cc2
More clarity on market unctions
tpscrpt Jun 4, 2021
7409780
zkCRA test template
elclandestin0 Jun 4, 2021
402f868
Save
tpscrpt Jun 5, 2021
61faa69
attempt at fixing comp. errors
elclandestin0 Jun 7, 2021
ddbd7ac
Fix compilation errors
tpscrpt Jun 7, 2021
1648bbc
packed variables
elclandestin0 Jun 8, 2021
6bb792e
update test
elclandestin0 Jun 8, 2021
ebcbefb
got witness, output & proof
elclandestin0 Jun 8, 2021
464f372
set config admins
elclandestin0 Jun 9, 2021
f24b050
tests almost done
elclandestin0 Jun 10, 2021
023284a
update tests
elclandestin0 Jun 10, 2021
22080ea
ting
tpscrpt Jun 10, 2021
02dcfa7
Updates
tpscrpt Jun 10, 2021
94be52a
data being submitted onchain
elclandestin0 Jun 11, 2021
b0e6cf5
update tests
elclandestin0 Jun 11, 2021
7307e4d
Keys
tpscrpt Jun 11, 2021
ee9d83d
Snark proof verifying
tpscrpt Jun 11, 2021
1165739
YE
tpscrpt Jun 11, 2021
a37e0fe
Faster tests
tpscrpt Jun 12, 2021
7b6e983
Progress
tpscrpt Jun 12, 2021
3fe5a75
Packing properly hopefully
tpscrpt Jun 12, 2021
66700fa
Working zk cra
tpscrpt Jun 12, 2021
9596241
fix void signer error
elclandestin0 Jun 12, 2021
0aae7a7
zkcra.json stored in ipfs
elclandestin0 Jun 23, 2021
bd6766f
good scores bad scores
elclandestin0 Jun 23, 2021
dbab14a
ipfs successfully returning source
elclandestin0 Jun 23, 2021
b730f9f
zkcra create loan changes
elclandestin0 Jun 24, 2021
4cf9167
fix errors
elclandestin0 Jun 24, 2021
7d71c35
merge fix
elclandestin0 Jun 24, 2021
b7baa43
market interest calc
elclandestin0 Jun 24, 2021
addc0ff
moved init market admins to create loan facet
elclandestin0 Jun 25, 2021
d1fab5e
reworked setting provider info
elclandestin0 Jun 25, 2021
babd58a
modifyign tests
elclandestin0 Jun 27, 2021
b870397
zkcra working
elclandestin0 Jun 28, 2021
268d5c5
zkcra updated tests
elclandestin0 Jun 28, 2021
aae851a
fixing signaturedata datatype
elclandestin0 Jun 28, 2021
420bded
require statement
elclandestin0 Jun 28, 2021
a77ccd9
updated w/ noah's comments
elclandestin0 Jun 29, 2021
852f1ee
Revert "unused imports fix"
elclandestin0 Jun 29, 2021
29b2792
para programming w/ Noah
elclandestin0 Jun 29, 2021
94ac369
process request library
elclandestin0 Jun 29, 2021
fb49df4
sample market handler
elclandestin0 Jun 30, 2021
3587f25
fixed dir structure
elclandestin0 Jun 30, 2021
addb731
ready for deployment
elclandestin0 Jun 30, 2021
6959c2b
deployed process request library and teller market handler
elclandestin0 Jun 30, 2021
d03861b
change to public function
elclandestin0 Jul 1, 2021
4990170
create provider factory
elclandestin0 Jul 1, 2021
a199943
deployed provider factory
elclandestin0 Jul 1, 2021
735c85c
signer successfully set
elclandestin0 Jul 1, 2021
8b14b53
provider set in market
elclandestin0 Jul 1, 2021
f301a6d
commitments = number of signatures required
elclandestin0 Jul 2, 2021
96bef47
end to end testing with good score done
elclandestin0 Jul 2, 2021
351ae5d
provider creation with args
elclandestin0 Jul 2, 2021
805ae56
added provider to request
elclandestin0 Jul 2, 2021
0aa513b
end to end testing for bad score completed
elclandestin0 Jul 2, 2021
c9040de
removed console logs
elclandestin0 Jul 2, 2021
ebef161
changed teller interest value
elclandestin0 Jul 5, 2021
13def46
removed market lib
elclandestin0 Jul 5, 2021
9e2ee4e
fix bad score test
elclandestin0 Jul 5, 2021
688bb99
update
elclandestin0 Jul 5, 2021
50a1f36
market handler updated with new loan calculator
elclandestin0 Jul 5, 2021
c30bc65
removed useless require statement
elclandestin0 Jul 5, 2021
784171e
states file
elclandestin0 Jul 6, 2021
47d4887
retrieve state's rate
elclandestin0 Jul 6, 2021
c6b2a29
fix bn error
elclandestin0 Jul 7, 2021
aeabdd3
fix market handling rounding error
elclandestin0 Jul 8, 2021
6114b1e
created new loan facets
elclandestin0 Jul 29, 2021
ce38b12
Merge remote-tracking branch 'origin/zk-cra/market-handler' into zk-c…
elclandestin0 Jul 29, 2021
b395cd6
Merge pull request #434 from teller-protocol/zk-cra/market-handler
elclandestin0 Jul 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ coverage
# IDE
.idea
.vscode
.vs

# Build
build
Expand Down
3 changes: 2 additions & 1 deletion contracts/contexts/access-control/entry/renounce-role.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ contract ent_renounceRole_AccessControl_v1 is
{
/**
* @notice Grants an address a new role.
*
* @param role the role to revoke for the account
* @param account the address of the respective account to revoke
* Requirements:
* - Sender must be role admin.
*/
Expand Down
8 changes: 8 additions & 0 deletions contracts/escrow/dapps/DappMods.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
} from "../../settings/platform/libraries/PlatformSettingsLib.sol";

abstract contract DappMods {
/**
* @notice it checks if the caller to a respective loan escrow is the borrower
* @param loanID uint256 of the respective loan escrow
*/
modifier onlyBorrower(uint256 loanID) {
require(
msg.sender == LibLoans.loan(loanID).borrower,
Expand All @@ -16,6 +20,10 @@ abstract contract DappMods {
_;
}

/**
* @notice checks if the respective loan escrow is secure
* @param loanID uint256 of the respective loan escrow
*/
modifier onlySecured(uint256 loanID) {
require(
LibLoans.loan(loanID).collateralRatio >=
Expand Down
1 change: 1 addition & 0 deletions contracts/escrow/dapps/libraries/LibUniswap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ library LibUniswap {
* @param path An array of token addresses.
* @param sourceAmount amount of source token to swap.
* @param minDestination The minimum amount of output tokens that must be received for the transaction not to revert.
* @return amounts is the resulting number of tokens swapped for
*/
function swap(
address[] memory path,
Expand Down
18 changes: 18 additions & 0 deletions contracts/escrow/escrow/ILoansEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,30 @@ pragma solidity ^0.8.0;
interface ILoansEscrow {
function init() external;

/**
* @notice it calls a dapp like YearnFinance at a target contract address with specified calldata
* @param dappAddress address of the target contract address
* @param dappData encoded abi of the function in our contract we want to call
* @return the called data in bytes
*/
function callDapp(address dappAddress, bytes calldata dappData)
external
returns (bytes memory);

/**
* @notice it approves the spender to spend a maximum amount of a respective token from a token address
* @param token address of the respective ERC20 token to approve for the spender
* @param spender address of the respective spender who is approved by the token contract
*/
function setTokenAllowance(address token, address spender) external;

/**
* @notice it allows user to claim their escrow tokens
* @dev only the owner (TellerDiamond) can make this call on behalf of the users
* @param token address of the respective token contract to claim tokens from
* @param to address where the tokens should be transferred to
* @param amount uint256 amount of tokens to be claimed
*/
function claimToken(
address token,
address to,
Expand Down
18 changes: 18 additions & 0 deletions contracts/escrow/escrow/LoansEscrow_V1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ contract LoansEscrow_V1 is ILoansEscrow {
owner = msg.sender;
}

/**
* @notice it calls a dapp like YearnFinance at a target contract address with specified calldata
* @param dappAddress address of the target contract address
* @param dappData encoded abi of the function in our contract we want to call
* @return resData_ the called data in
*/
function callDapp(address dappAddress, bytes calldata dappData)
external
override
Expand All @@ -46,6 +52,11 @@ contract LoansEscrow_V1 is ILoansEscrow {
);
}

/**
* @notice it approves the spender to spend a maximum amount of a respective token from a token address
* @param token address of the respective ERC20 token to approve for the spender
* @param spender address of the respective spender who is approved by the token contract
*/
function setTokenAllowance(address token, address spender)
external
override
Expand All @@ -54,6 +65,13 @@ contract LoansEscrow_V1 is ILoansEscrow {
IERC20(token).approve(spender, type(uint256).max);
}

/**
* @notice it allows user to claim their escrow tokens
* @dev only the owner (TellerDiamond) can make this call on behalf of their users
* @param token address of the respective token contract to claim tokens from
* @param to address where the tokens should be transferred to
* @param amount uint256 amount of tokens to be claimed
*/
function claimToken(
address token,
address to,
Expand Down
11 changes: 11 additions & 0 deletions contracts/escrow/libraries/LibEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ library LibEscrow {
e_ = s().loanEscrows[loanID];
}

/**
* @notice It returns a list of tokens owned by a loan escrow
* @param loanID uint256 index used to return our token list
* @return t_ which is a list of tokens
*/
function getEscrowTokens(uint256 loanID)
internal
view
Expand All @@ -33,6 +38,12 @@ library LibEscrow {
t_ = s().escrowTokens[loanID];
}

/**
* @notice It returns the balance of a respective token in a loan escrow
* @param loanID uint256 index used to point to our loan escrow
* @param token address of respective token to give us the balance of in our loan escrow
* @return uint256 balance of respective token returned in an escrow loan
*/
function balanceOf(uint256 loanID, address token)
internal
view
Expand Down
2 changes: 1 addition & 1 deletion contracts/lending/LendingFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ contract LendingFacet is RolesMods, ReentryMods, PausableMods {
}

/**
* @notice Initialized a new lending pool for {asset}
* @notice It initializes a new lending pool for the respective token
* @param asset Token address to initialize the lending pool for.
*/
function initLendingPool(address asset)
Expand Down
24 changes: 17 additions & 7 deletions contracts/lending/ttoken/ITToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
*/
abstract contract ITToken is ERC20Upgradeable, RolesFacet {
/**
* @notice This event is emitted when an user deposits tokens into the pool.
* @notice This event is emitted when a user deposits tokens into the pool.
*/
event Mint(
address indexed sender,
Expand All @@ -26,7 +26,7 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {
);

/**
* @notice This event is emitted when an user withdraws tokens from the pool.
* @notice This event is emitted when a user withdraws tokens from the pool.
*/
event Redeem(
address indexed sender,
Expand All @@ -36,12 +36,14 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {

/**
* @notice The token that is the underlying assets for this Teller token.
* @return ERC20 token
*/
function underlying() external view virtual returns (ERC20);

/**
* @notice The balance of an {account} denoted in underlying value.
* @param account Address to calculate the underlying balance.
* @return balance_ the balance of the account
*/
function balanceOfUnderlying(address account)
external
Expand All @@ -55,16 +57,16 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {
function exchangeRate() external virtual returns (uint256 rate_);

/**
* @notice Redeem supplied Teller token underlying value.
* @return totalSupply_ The total value of the underlying token managed by the LP.
* @notice It calculates the total supply of the underlying asset.
* @return totalSupply_ the total supply denoted in the underlying asset.
*/
function totalUnderlyingSupply()
external
virtual
returns (uint256 totalSupply_);

/**
* @notice It calculates the market state values across a given markets.
* @notice It calculates the market state values across a given market.
* @notice Returns values that represent the global state across the market.
* @return totalSupplied Total amount of the underlying asset supplied.
* @return totalBorrowed Total amount borrowed through loans.
Expand Down Expand Up @@ -93,7 +95,7 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {

/**
* @notice It validates whether supply to debt (StD) ratio is valid including the loan amount.
* @param newLoanAmount the new loan amount to consider o the StD ratio.
* @param newLoanAmount the new loan amount to consider the StD ratio.
* @return ratio_ Whether debt ratio for lending pool is valid.
*/
function debtRatioFor(uint256 newLoanAmount)
Expand All @@ -104,7 +106,7 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {
/**
* @notice Called by the Teller Diamond contract when a loan has been taken out and requires funds.
* @param recipient The account to send the funds to.
* @param amount Funds requested to fulfil the loan.
* @param amount Funds requested to fulfill the loan.
*/
function fundLoan(address recipient, uint256 amount) external virtual;

Expand All @@ -118,6 +120,7 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {
/**
* @notice Increase account supply of specified token amount.
* @param amount The amount of underlying tokens to use to mint.
* @return mintAmount_ the amount minted of the specified token
*/
function mint(uint256 amount)
external
Expand Down Expand Up @@ -157,13 +160,20 @@ abstract contract ITToken is ERC20Upgradeable, RolesFacet {

/**
* @notice Gets the strategy used for balancing funds.
* @return address of the strategy contract
*/
function getStrategy() external view virtual returns (address);

/**
* @notice Sets the restricted state of the platform.
* @param state boolean value that resembles the platform's state
*/
function restrict(bool state) external virtual;

/**
* @notice it initializes the Teller Token
* @param admin address of the admin to the respective Teller Token
* @param underlying address of the ERC20 token
*/
function initialize(address admin, address underlying) external virtual;
}
23 changes: 18 additions & 5 deletions contracts/lending/ttoken/TToken_V1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import "./storage.sol" as Storage;

/**
* @notice This contract represents a lending pool for an asset within Teller protocol.
*
* @author [email protected]
*/
contract TToken_V1 is ITToken {
Expand All @@ -59,12 +58,17 @@ contract TToken_V1 is ITToken {

/* Public Functions */

/**
* @notice it returns the decimal places of the respective TToken
* @return decimals of the token
*/
function decimals() public view override returns (uint8) {
return s().decimals;
}

/**
* @notice The token that is the underlying assets for this Teller token.
* @return ERC20 token that is the underl
*/
function underlying() public view override returns (ERC20) {
return s().underlying;
Expand All @@ -73,6 +77,7 @@ contract TToken_V1 is ITToken {
/**
* @notice The balance of an {account} denoted in underlying value.
* @param account Address to calculate the underlying balance.
* @return balance_ the balance of the account
*/
function balanceOfUnderlying(address account)
public
Expand Down Expand Up @@ -149,7 +154,7 @@ contract TToken_V1 is ITToken {

/**
* @notice It validates whether supply to debt (StD) ratio is valid including the loan amount.
* @param newLoanAmount the new loan amount to consider o the StD ratio.
* @param newLoanAmount the new loan amount to consider the StD ratio.
* @return ratio_ Whether debt ratio for lending pool is valid.
*/
function debtRatioFor(uint256 newLoanAmount)
Expand Down Expand Up @@ -354,13 +359,15 @@ contract TToken_V1 is ITToken {

/**
* @notice Gets the strategy used for balancing funds.
* @return address of the strategy contract
*/
function getStrategy() external view override returns (address) {
return s().strategy;
}

/**
* @notice Sets the restricted state of the platform.
* @param state boolean value that resembles the platform's state
*/
function restrict(bool state)
public
Expand All @@ -371,7 +378,9 @@ contract TToken_V1 is ITToken {
}

/**
* @notice Initializes the Teller token
* @notice it initializes the Teller Token
* @param admin address of the admin to the respective Teller Token
* @param underlying address of the ERC20 token
*/
function initialize(address admin, address underlying)
external
Expand Down Expand Up @@ -401,7 +410,10 @@ contract TToken_V1 is ITToken {
}

/**
* @dev
* @notice it retrieves the value of the underlying token
* @param amount the amount of tokens to calculate the value of
* @param rate the exchangeRate() to divide with the amount * exchange_rate_factor
* @return value_ the underlying value of the token amount
*/
function _valueOfUnderlying(uint256 amount, uint256 rate)
internal
Expand All @@ -412,7 +424,8 @@ contract TToken_V1 is ITToken {
}

/**
* @dev
* @notice it retrives the value in the underlying tokens
*
*/
function _valueInUnderlying(uint256 amount, uint256 rate)
internal
Expand Down
3 changes: 3 additions & 0 deletions contracts/lending/ttoken/storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ struct Store {

bytes32 constant POSITION = keccak256("ttoken.storage.position");

/**
* @notice it saves the Store struct in a hashed slot
*/
function store() pure returns (Store storage s_) {
bytes32 position = POSITION;
assembly {
Expand Down
13 changes: 13 additions & 0 deletions contracts/lending/ttoken/strategies/ITTokenStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ interface ITTokenStrategy {
address indexed sender
);

/**
* @notice it returns the total supply of an underlying asset in a Teller token.
* @return uint256 the underlying supply
*/
function totalUnderlyingSupply() external returns (uint256);

/**
* @notice it rebalances the underlying asset held by the Teller Token.
*
*/
function rebalance() external;

/**
* @notice it withdraws amount of tokens in a pool
* @param amount amount to withdraw
*/

function withdraw(uint256 amount) external;
}
4 changes: 4 additions & 0 deletions contracts/lending/ttoken/strategies/TTokenStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import { ITTokenStrategy } from "./ITTokenStrategy.sol";

abstract contract TTokenStrategy is ITTokenStrategy, ERC165 {
/**
* @notice it checks if interface is supported according to the ERC165 standard
* @param interfaceId Id of the interface in question
*/
function supportsInterface(bytes4 interfaceId)
public
view
Expand Down
Loading