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 50 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
2 changes: 1 addition & 1 deletion contracts/escrow/dapps/DappMods.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract contract DappMods {
);
_;
}

/**
* @notice checks if the respective loan escrow is secure
* @param loanID uint256 of the respective loan escrow
Expand Down
4 changes: 3 additions & 1 deletion contracts/lending/ttoken/TToken_V1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ contract TToken_V1 is ITToken {

/**
* @notice it retrives the value in the underlying tokens
*
* @param amount the amount of underlying
* @param rate the rate the underlying is exchanging at
* @return value_ the value of the underlying
*/
function _valueInUnderlying(uint256 amount, uint256 rate)
internal
Expand Down
167 changes: 163 additions & 4 deletions contracts/market/CreateLoanFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
ReentryMods
} from "../contexts2/access-control/reentry/ReentryMods.sol";
import { RolesMods } from "../contexts2/access-control/roles/RolesMods.sol";
import { AUTHORIZED } from "../shared/roles.sol";
import { AUTHORIZED, ADMIN } from "../shared/roles.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

// Libraries
import { LibLoans } from "./libraries/LibLoans.sol";
import { LibEscrow } from "../escrow/libraries/LibEscrow.sol";
import { LibCollateral } from "./libraries/LibCollateral.sol";
import { LibConsensus } from "./libraries/LibConsensus.sol";
import { MarketLib } from "./cra/MarketLib.sol";
import { LendingLib } from "../lending/libraries/LendingLib.sol";
import {
PlatformSettingsLib
Expand All @@ -31,6 +31,9 @@ import {
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { NumbersLib } from "../shared/libraries/NumbersLib.sol";
import { NFTLib } from "../nft/libraries/NFTLib.sol";
import { Verifier } from "./cra/verifier.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { MarketLib } from "./cra/MarketLib.sol";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which import is the duplicate import?


// Interfaces
import { ILoansEscrow } from "../escrow/escrow/ILoansEscrow.sol";
Expand All @@ -48,10 +51,15 @@ import {
LoanStatus,
LoanTerms,
Loan,
MarketStorageLib
MarketStorageLib,
Signature,
SignatureData
} from "../storage/market.sol";
import { AppStorageLib } from "../storage/app.sol";

// hardhat helpers
import "hardhat/console.sol";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove and any logs in the contracts

contract CreateLoanFacet is RolesMods, ReentryMods, PausableMods {
/**
* @notice This event is emitted when a loan has been successfully taken out
Expand All @@ -72,6 +80,7 @@ contract CreateLoanFacet is RolesMods, ReentryMods, PausableMods {
* @param request Struct of the protocol loan request
*/
modifier __createLoan(LoanRequest calldata request, bool withNFT) {
console.log("creating loan");
Loan storage loan = CreateLoanLib.createLoan(request, withNFT);

_;
Expand All @@ -81,6 +90,28 @@ contract CreateLoanFacet is RolesMods, ReentryMods, PausableMods {
loan.duration = request.request.duration;
}

// used for testing our zkcra function
function initializeMarketAdmins() external authorized(ADMIN, msg.sender) {
// setting market admin
MarketLib.m(bytes32(0)).admin[msg.sender] = true;
// setting providers admin
MarketLib.p(bytes32(0)).admin[msg.sender] = true;
MarketLib.p(bytes32(uint256(1))).admin[msg.sender] = true;
MarketLib.p(bytes32(uint256(2))).admin[msg.sender] = true;
}

function setProviderInformation(
bytes32 providerId,
uint32 maxAge,
address signer,
bool signerValue
) external {
console.log("solidity: about to set provider signer");
MarketLib.setProviderSigner(providerId, signer, signerValue);
console.log("solidity: about to set provider max age");
MarketLib.setProviderMaxAge(providerId, maxAge);
}

/**
* @notice Creates a loan with the loan request and NFTs without any collateral
* @param request Struct of the protocol loan request
Expand Down Expand Up @@ -145,6 +176,7 @@ contract CreateLoanFacet is RolesMods, ReentryMods, PausableMods {
authorized(AUTHORIZED, msg.sender)
__createLoan(request, false)
{
console.log("taking out loan");
// Check if collateral token is zero
require(
collateralToken != address(0x0),
Expand Down Expand Up @@ -211,7 +243,7 @@ library CreateLoanLib {

// Get consensus values from request
(uint16 interestRate, uint16 collateralRatio, uint256 maxLoanAmount) =
LibConsensus.processLoanTerms(request);
processMarketRequest(request);

// Perform loan value checks
require(
Expand Down Expand Up @@ -254,6 +286,133 @@ library CreateLoanLib {
);
}

/**
* @notice it uses our request to verify the returned proof and witness with each other,
* verifies our signature data with our respective data providers, then retrieves our interest rate,
* collateral ratio and max loan amount
* @param request contains all the needed data to do the above
* @return interestRate the rate of the loan
* @return collateralRatio the collateral ratio required for the loan, if any
* @return maxLoanAmount the max loan amount the user is entitled to
*/
function processMarketRequest(LoanRequest memory request)
internal
returns (
uint16 interestRate,
uint16 collateralRatio,
uint256 maxLoanAmount
)
{
console.log("processing market request");
// Overwrite the first snark witness item with the on-chain identifier
// for the loan (msg.sender ^ nonce). This forces the CRA to have been
// run with the proper identifier.
request.witness[0] =
uint256(uint160(msg.sender)) ^
LibLoans.s().borrowerLoans[msg.sender].length;

// Verify the snark proof.
// call from deployed contract
// SnarkVerifier sv = new SnarkVerifier(contract address)

// deploy verifier library and integrate into create loan facet
console.log("about to verify tx");
require(
Verifier.verifyTx(request.proof, request.witness),
"Proof not verified"
);

bytes32[3] memory commitments = [bytes32(0), bytes32(0), bytes32(0)];

// constructing our commitments to verify with our signature data
for (uint8 i = 0; i < commitments.length; i++) {
for (uint8 j = 0; j < 8; j++) {
commitments[i] =
(commitments[i] << 32) ^
bytes32(request.witness[2 + i * 8 + j]);
}
commitments[i] ^= bytes32(request.signatureData[i].signedAt);
}

require(request.signatureData.length == 3, "Must have 3 providers!");

// Verify that the commitment signatures are valid and that the data
// is not too old for the market's liking.
_verifySignatures(commitments, request.signatureData);

// The second witness item (after identifier) is the market
// score
uint256 marketScore = uint256(request.witness[1]);

// Let the market handle the loan request and disperse the loan.

// create default teller market handler
// pass it the marketId and return max loan amount, collateral ratio, interest rate
// upper and lower bound for loan amount, interest rate and collateral ratio depending on
// market id
(interestRate, collateralRatio, maxLoanAmount) = MarketLib.handler(
marketScore,
request
);
return (interestRate, collateralRatio, maxLoanAmount);
}

function _verifySignatures(
bytes32[3] memory commitments,
SignatureData[] memory signatureData
) private {
for (uint256 i = 0; i < signatureData.length; i++) {
bytes32 providerId = bytes32(i);
require(
signatureData[i].signedAt >
// solhint-disable-next-line
block.timestamp - MarketLib.p(providerId).maxAge,
"Signed at less than max age"
);
require(
MarketLib.s().usedCommitments[commitments[i]] == false,
"Teller: commitment already used"
);

MarketLib.s().usedCommitments[commitments[i]] = true;

_validateSignature(
signatureData[i].signature,
commitments[i],
providerId
);
}
}

/**
* @notice It validates whether a signature is valid or not.
* @param signature signature to validate.
* @param commitment used to recover the signer.
* @param providerId the expected signer address.
*/
function _validateSignature(
Signature memory signature,
bytes32 commitment,
bytes32 providerId
) private view {
address recoveredSigner =
ECDSA.recover(
keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
uint256(commitment)
)
),
signature.v,
signature.r,
signature.s
);
require(
MarketLib.p(providerId).signer[recoveredSigner],
"Teller: not valid signature"
);
}

/**
* @notice increments the loanIDCounter
* @return id_ the new ID requested, which stores it in the loan data
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions contracts/market/LendingPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
contract LendingPool {
function deposit(uint256 loanAsset, uint256 depositAmount) external {}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this file needed?

2 changes: 1 addition & 1 deletion contracts/market/LoanDataFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ contract LoanDataFacet {
/**
* @notice it returns the total escrow tokens held by an escrow
* @param loanID the identifier of the respective escrow's loan
* @return tokens_ the tokens held at the escrow loan
* @return tokens_ the tokens held at the escrow loan
*/
function getEscrowTokens(uint256 loanID)
external
Expand Down
98 changes: 98 additions & 0 deletions contracts/market/cra/AMarket.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// // SPDX-License-Identifier: MIT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this file needed?


// pragma solidity ^0.8.0;

// // import { TellerAssets } from "./utils.sol";
// import { LoanRequest } from "./Borrow.sol";

// interface IMarket {
// // Called by teller.
// function handler(bytes memory input) external;
// }

// contract BasicMarket is IMarket {
// struct Storage {
// mapping(uint256 => bool) supportedCollateralAssets;
// mapping(uint256 => bool) supportedLoanAssets;
// }

// bytes32 internal constant POS = keccak256("teller.finance.market.storage");

// function handler(bytes memory input) external override {
// (address borrower, uint256 marketScore, LoanRequest memory request) =
// abi.decode(input, (address, uint256, LoanRequest));

// uint256 maxDebtRatio = 6666;
// uint256 minLoanValue = 1000 * 10**18;
// uint256 maxLoanValue = 5000 * 10**18;
// uint256 minCollateralRatio = 2000;
// uint256 maxCollateralRatio = 13500;
// uint256 minDuration = 1 days;
// uint256 maxDuration = 180 days;

// require(s().supportedLoanAssets[request.loanToken], "ME00");
// require(
// getDebtRatioFor(request.loanToken, request.loanAmount) <=
// maxDebtRatio,
// "ME06"
// );
// require(
// request.duration >= minDuration && request.duration <= maxDuration,
// "ME01"
// );

// uint256 collateralValue;

// for (uint8 i = 0; i < request.collateralAssets.length; i++) {
// require(
// s().supportedCollateralAssets[request.collateralAssets[i]],
// "ME03"
// );
// collateralValue += 100;
// // collateralValue += priceFor(
// // collateralAssets[i],
// // collateralAmounts[i]
// // );
// }

// uint256 loanValue = 100;
// // uint256 loanValue = priceFor(loanAsset, loanAmount);
// require(loanValue >= minLoanValue && loanValue <= maxLoanValue, "ME04");

// uint256 collateralRatio = (collateralValue * 10000) / loanValue;
// require(
// collateralRatio >= minCollateralRatio &&
// collateralRatio <= maxCollateralRatio,
// "ME05"
// );

// uint256 interestRate =
// (((maxCollateralRatio - collateralRatio) / 10)) +
// ((30 - marketScore) * 20);

// // teller.lend(
// // borrower,
// // loanAsset,
// // loanAmount,
// // collateralRatio,
// // interestRate,
// // duration
// // );
// }

// function getDebtRatioFor(uint256 loanAsset, uint256 loanAmount)
// internal
// view
// returns (uint256 debtRatio)
// {
// // TellerAssets.AssetType assetType = _assetType(loanAsset);
// return 10000;
// }

// function s() internal pure returns (Storage storage s_) {
// bytes32 pos = POS;
// assembly {
// s_.slot := pos
// }
// }
// }
Loading