diff --git a/contracts/partial/proxy/priceFeedMethods.ligo b/contracts/partial/proxy/priceFeedMethods.ligo index 16a41ef..ef981b1 100644 --- a/contracts/partial/proxy/priceFeedMethods.ligo +++ b/contracts/partial/proxy/priceFeedMethods.ligo @@ -98,7 +98,7 @@ function receivePrice( const pairName : string = param.0; const oraclePrice = param.1.1; const decimals : nat = getDecimal(pairName, s.tokensDecimals); - const price : nat = oraclePrice * precision / decimals; + const price : nat = oraclePrice * precision * precision / decimals; const tokenId : nat = checkPairId(pairName, s.pairId); var operations : list(operation) := list[ diff --git a/contracts/partial/yToken/adminMethods.ligo b/contracts/partial/yToken/adminMethods.ligo index 9505fea..c8652fd 100644 --- a/contracts/partial/yToken/adminMethods.ligo +++ b/contracts/partial/yToken/adminMethods.ligo @@ -84,7 +84,7 @@ function addMarket( token.collateralFactorF := params.collateralFactorF; token.reserveFactorF := params.reserveFactorF; token.maxBorrowRate := params.maxBorrowRate; - token.threshold := params.threshold; + token.thresholdF := params.thresholdF; token.liquidReserveRateF := params.liquidReserveRateF; s.storage.assets[params.asset] := lastTokenId; @@ -127,7 +127,7 @@ function setTokenFactors( token.reserveFactorF := params.reserveFactorF; token.interestRateModel := params.interestRateModel; token.maxBorrowRate := params.maxBorrowRate; - token.threshold := params.threshold; + token.thresholdF := params.thresholdF; token.liquidReserveRateF := params.liquidReserveRateF; s.tokens[params.tokenId] := token; } diff --git a/contracts/partial/yToken/fa2Methods.ligo b/contracts/partial/yToken/fa2Methods.ligo index 8a88ace..3313ffc 100644 --- a/contracts/partial/yToken/fa2Methods.ligo +++ b/contracts/partial/yToken/fa2Methods.ligo @@ -7,8 +7,8 @@ function getAccount( case accounts[(user, tokenId)] of None -> record [ allowances = (set [] : set(address)); - borrow = 0n; - lastBorrowIndex = 0n; + borrowF = 0n; + lastBorrowIndexF = 0n; ] | Some(v) -> v end @@ -37,16 +37,16 @@ function getToken( totalLiquidF = 0n; totalSupplyF = 0n; totalReservesF = 0n; - borrowIndex = precision; + borrowIndexF = precision; maxBorrowRate = 0n; collateralFactorF = 0n; reserveFactorF = 0n; liquidReserveRateF = 0n; - lastPrice = 0n; + lastPriceFF = 0n; borrowPause = False; enterMintPause = False; isInterestUpdating = False; - threshold = 0n; + thresholdF = 0n; ] | Some(v) -> v end @@ -115,20 +115,20 @@ function iterateTransfer( require(transferDst.token_id < s.lastTokenId, Errors.FA2.undefined); (* Get source info *) - var srcBalance : nat := getBalanceByToken(params.from_, transferDst.token_id, s.ledger); + var srcBalanceF : nat := getBalanceByToken(params.from_, transferDst.token_id, s.ledger); const transferAmountF : nat = transferDst.amount * precision; (* Update source balance *) - srcBalance := get_nat_or_fail(srcBalance - transferAmountF, Errors.FA2.lowBalance); + srcBalanceF := get_nat_or_fail(srcBalanceF - transferAmountF, Errors.FA2.lowBalance); - s.ledger[(params.from_, transferDst.token_id)] := srcBalance; + s.ledger[(params.from_, transferDst.token_id)] := srcBalanceF; (* Get receiver balance *) - var dstBalance : nat := getBalanceByToken(transferDst.to_, transferDst.token_id, s.ledger); + var dstBalanceF : nat := getBalanceByToken(transferDst.to_, transferDst.token_id, s.ledger); (* Update destination balance *) - dstBalance := dstBalance + transferAmountF; - s.ledger[(transferDst.to_, transferDst.token_id)] := dstBalance; + dstBalanceF := dstBalanceF + transferAmountF; + s.ledger[(transferDst.to_, transferDst.token_id)] := dstBalanceF; } with s } with List.fold(makeTransfer, params.txs, s) @@ -184,12 +184,12 @@ function getBalance( block { require(request.token_id < s.lastTokenId, Errors.FA2.undefined); (* Retrieve the asked account from the storage *) - const userBalance : nat = getBalanceByToken(request.owner, request.token_id, s.ledger); + const userBalanceF : nat = getBalanceByToken(request.owner, request.token_id, s.ledger); (* Form the response *) const response : balance_of_response = record [ request = request; - balance = userBalance / precision; + balance = userBalanceF / precision; ]; } with response # l; diff --git a/contracts/partial/yToken/lendingMethods.ligo b/contracts/partial/yToken/lendingMethods.ligo index 7549e24..1557cf4 100644 --- a/contracts/partial/yToken/lendingMethods.ligo +++ b/contracts/partial/yToken/lendingMethods.ligo @@ -52,11 +52,11 @@ function calcMaxCollateralInCU( : nat is block { function oneToken( - var acc : nat; + var accCU : nat; const tokenId : tokenId) : nat is block { - const userBalance : nat = getBalanceByToken(user, tokenId, ledger); + const userBalanceF : nat = getBalanceByToken(user, tokenId, ledger); const token : tokenType = getToken(tokenId, tokens); if token.totalSupplyF > 0n then { const liquidityF : nat = getLiquidity(token); @@ -65,15 +65,15 @@ function calcMaxCollateralInCU( verifyInterestUpdated(token); (* sum += collateralFactorF * exchangeRate * oraclePrice * balance *) - acc := acc + userBalance * token.lastPrice + accCU := accCU + userBalanceF * token.lastPriceFF * token.collateralFactorF * liquidityF / token.totalSupplyF / precision; } else skip; - } with acc; + } with accCU; } with Set.fold(oneToken, userMarkets, 0n) -function calcLiquidateCollateral( +function calcLiquidateCollateralInCU( const userMarkets : set(tokenId); const user : address; const ledger : big_map((address * tokenId), nat); @@ -81,11 +81,11 @@ function calcLiquidateCollateral( : nat is block { function oneToken( - var acc : nat; + var accFF : nat; const tokenId : tokenId) : nat is block { - const userBalance : nat = getBalanceByToken(user, tokenId, ledger); + const userBalanceF : nat = getBalanceByToken(user, tokenId, ledger); const token : tokenType = getToken(tokenId, tokens); if token.totalSupplyF > 0n then { const liquidityF : nat = getLiquidity(token); @@ -94,10 +94,10 @@ function calcLiquidateCollateral( verifyInterestUpdated(token); (* sum += balance * oraclePrice * exchangeRate *) - acc := acc + userBalance * token.lastPrice * liquidityF / token.totalSupplyF; + accCU := accCU + userBalanceF * token.lastPriceFF * liquidityF / token.totalSupplyF; } else skip; - } with acc * token.threshold / precision; + } with accCU * token.thresholdF / precision; } with Set.fold(oneToken, userMarkets, 0n) function applyInterestToBorrows( @@ -117,11 +117,11 @@ function applyInterestToBorrows( verifyInterestUpdated(token); - if userAccount.lastBorrowIndex =/= 0n - then userAccount.borrow := userAccount.borrow * token.borrowIndex / userAccount.lastBorrowIndex; + if userAccount.lastBorrowIndexF =/= 0n + then userAccount.borrowF := userAccount.borrowF * token.borrowIndexF / userAccount.lastBorrowIndexF; else skip; - userAccount.lastBorrowIndex := token.borrowIndex; + userAccount.lastBorrowIndexF := token.borrowIndexF; } with Map.update((user, tokenId), Some(userAccount), userAccMap); } with Set.fold(oneToken, borrowedTokens, accountsMap) @@ -134,21 +134,21 @@ function calcOutstandingBorrowInCU( : nat is block { function oneToken( - var acc : nat; + var accCU : nat; var tokenId : tokenId) : nat is block { const userAccount : account = getAccount(user, tokenId, accounts); - const userBalance : nat = getBalanceByToken(user, tokenId, ledger); + const userBalanceF : nat = getBalanceByToken(user, tokenId, ledger); var token : tokenType := getToken(tokenId, tokens); verifyPriceUpdated(token); (* sum += oraclePrice * borrow *) - if userBalance > 0n or userAccount.borrow > 0n - then acc := acc + userAccount.borrow * token.lastPrice; + if userBalanceF > 0n or userAccount.borrowF > 0n + then accCU := accCU + userAccount.borrowF * token.lastPriceFF; else skip; - } with acc; + } with accCU; } with Set.fold(oneToken, userBorrow, 0n) function updateInterest( @@ -197,6 +197,7 @@ function mint( require(params.tokenId < s.lastTokenId, Errors.YToken.undefined); var mintTokensF : nat := params.amount * precision; + require(mintTokensF / precision >= params.minReceived, Errors.YToken.highReceived); var token : tokenType := getToken(params.tokenId, s.tokens); require(token.enterMintPause = False, Errors.YToken.enterMintPaused); @@ -207,11 +208,10 @@ function mint( mintTokensF := mintTokensF * token.totalSupplyF / liquidityF; } else skip; - require(mintTokensF / precision >= params.minReceived, Errors.YToken.highReceived); - var userBalance : nat := getBalanceByToken(Tezos.sender, params.tokenId, s.ledger); - userBalance := userBalance + mintTokensF; - s.ledger[(Tezos.sender, params.tokenId)] := userBalance; + var userBalanceF : nat := getBalanceByToken(Tezos.sender, params.tokenId, s.ledger); + userBalanceF := userBalanceF + mintTokensF; + s.ledger[(Tezos.sender, params.tokenId)] := userBalanceF; token.totalSupplyF := token.totalSupplyF + mintTokensF; token.totalLiquidF := token.totalLiquidF + params.amount * precision; s.tokens[params.tokenId] := token; @@ -232,18 +232,18 @@ function redeem( require(params.tokenId < s.lastTokenId, Errors.YToken.undefined); var token : tokenType := getToken(params.tokenId, s.tokens); - var userBalance : nat := getBalanceByToken(Tezos.sender, params.tokenId, s.ledger); + var userBalanceF : nat := getBalanceByToken(Tezos.sender, params.tokenId, s.ledger); const liquidityF : nat = getLiquidity(token); const redeemAmount : nat = if params.amount = 0n - then userBalance * liquidityF / token.totalSupplyF / precision - else params.amount; + then userBalanceF * liquidityF / token.totalSupplyF / precision + else params.amount; require(redeemAmount >= params.minReceived, Errors.YToken.highReceived); var burnTokensF : nat := if params.amount = 0n - then userBalance - else ceil_div(redeemAmount * precision * token.totalSupplyF, liquidityF); + then userBalanceF + else ceil_div(redeemAmount * precision * token.totalSupplyF, liquidityF); - userBalance := get_nat_or_fail(userBalance - burnTokensF, Errors.YToken.lowBalance); - s.ledger[(Tezos.sender, params.tokenId)] := userBalance; + userBalanceF := get_nat_or_fail(userBalanceF - burnTokensF, Errors.YToken.lowBalance); + s.ledger[(Tezos.sender, params.tokenId)] := userBalanceF; token.totalSupplyF := get_nat_or_fail(token.totalSupplyF - burnTokensF, Errors.YToken.lowSupply); token.totalLiquidF := get_nat_or_fail(token.totalLiquidF - redeemAmount * precision, Errors.YToken.lowLiquidity); @@ -304,7 +304,7 @@ function borrow( var userAccount : account := getAccount(Tezos.sender, params.tokenId, s.accounts); const borrowsF : nat = params.amount * precision; - userAccount.borrow := userAccount.borrow + borrowsF; + userAccount.borrowF := userAccount.borrowF + borrowsF; s.accounts[(Tezos.sender, params.tokenId)] := userAccount; s.borrows[Tezos.sender] := borrowTokens; @@ -352,12 +352,12 @@ function repay( var repayAmountF : nat := params.amount * precision; if repayAmountF = 0n - then repayAmountF := userAccount.borrow; + then repayAmountF := userAccount.borrowF; else skip; - userAccount.borrow := get_nat_or_fail(userAccount.borrow - repayAmountF, Errors.YToken.repayOverflow); + userAccount.borrowF := get_nat_or_fail(userAccount.borrowF - repayAmountF, Errors.YToken.repayOverflow); - if userAccount.borrow = 0n + if userAccount.borrowF = 0n then borrowTokens := Set.remove(params.tokenId, borrowTokens); else skip; @@ -396,7 +396,7 @@ function liquidate( require(Tezos.sender =/= params.borrower, Errors.YToken.borrowerNotLiquidator); - const liquidateCollateral : nat = calcLiquidateCollateral( + const liquidateCollateralInCU : nat = calcLiquidateCollateralInCU( userCollateralTokens, params.borrower, s.ledger, @@ -410,17 +410,17 @@ function liquidate( s.tokens ); - require(liquidateCollateral < outstandingBorrowInCU, Errors.YToken.cantLiquidate); + require(liquidateCollateralInCU < outstandingBorrowInCU, Errors.YToken.cantLiquidate); var liqAmountF : nat := params.amount * precision; (* liquidate amount can't be more than allowed close factor *) - const maxClose : nat = borrowerAccount.borrow * s.closeFactorF / precision; + const maxCloseF : nat = borrowerAccount.borrowF * s.closeFactorF / precision; - require(maxClose >= liqAmountF, Errors.YToken.repayOverflow); + require(maxCloseF >= liqAmountF, Errors.YToken.repayOverflow); - borrowerAccount.borrow := get_nat_or_fail(borrowerAccount.borrow - liqAmountF, Errors.YToken.lowBorrowAmount); + borrowerAccount.borrowF := get_nat_or_fail(borrowerAccount.borrowF - liqAmountF, Errors.YToken.lowBorrowAmount); - if borrowerAccount.borrow = 0n + if borrowerAccount.borrowF = 0n then userBorrowedTokens := Set.remove(params.borrowToken, userBorrowedTokens); else skip; @@ -436,33 +436,33 @@ function liquidate( * priceBorrowed / priceCollateral seizeTokens = seizeAmount / exchangeRate *) - const seizeAmount : nat = liqAmountF * s.liqIncentiveF - * borrowToken.lastPrice * collateralToken.totalSupplyF; + const seizeAmountFFFFF : nat = liqAmountF * s.liqIncentiveF + * borrowToken.lastPriceFF * collateralToken.totalSupplyF; const liquidityF : nat = getLiquidity(collateralToken); - const exchangeRateF : nat = liquidityF * precision * collateralToken.lastPrice; - const seizeTokensF : nat = seizeAmount / exchangeRateF; + const exchangeRateFFFF : nat = liquidityF * precision * collateralToken.lastPriceFF; + const seizeTokensF : nat = seizeAmountFFFFF / exchangeRateFFFF; require(seizeTokensF / precision >= params.minSeized, Errors.YToken.highSeize); var liquidatorAccount : account := getAccount( Tezos.sender, params.collateralToken, s.accounts ); - var borrowerBalance : nat := getBalanceByToken(params.borrower, params.collateralToken, s.ledger); - var liquidatorBalance : nat := getBalanceByToken(Tezos.sender, params.collateralToken, s.ledger); - borrowerBalance := get_nat_or_fail(borrowerBalance - seizeTokensF, Errors.YToken.lowBorrowerBalanceS); - liquidatorBalance := liquidatorBalance + seizeTokensF; + var borrowerBalanceF : nat := getBalanceByToken(params.borrower, params.collateralToken, s.ledger); + var liquidatorBalanceF : nat := getBalanceByToken(Tezos.sender, params.collateralToken, s.ledger); + borrowerBalanceF := get_nat_or_fail(borrowerBalanceF - seizeTokensF, Errors.YToken.lowBorrowerBalanceS); + liquidatorBalanceF := liquidatorBalanceF + seizeTokensF; (* collect reserves incentive from liquidation *) - const reserveAmountF : nat = liqAmountF * collateralToken.liquidReserveRateF - * borrowToken.lastPrice * collateralToken.totalSupplyF; - const reserveSharesF : nat = ceil_div(reserveAmountF, exchangeRateF); - const reserveTokensF : nat = liqAmountF * collateralToken.liquidReserveRateF * borrowToken.lastPrice / ( precision * collateralToken.lastPrice) ; - borrowerBalance := get_nat_or_fail(borrowerBalance - reserveSharesF, Errors.YToken.lowBorrowerBalanceR); + const reserveAmountFFFFFF : nat = liqAmountF * collateralToken.liquidReserveRateF + * borrowToken.lastPriceFF * collateralToken.totalSupplyF; + const reserveSharesF : nat = ceil_div(reserveAmountFFFFFF, (exchangeRateFFFF)); + const reserveTokensF : nat = liqAmountF * collateralToken.liquidReserveRateF * borrowToken.lastPriceFF / ( precision * collateralToken.lastPriceFF) ; + borrowerBalanceF := get_nat_or_fail(borrowerBalanceF - reserveSharesF, Errors.YToken.lowBorrowerBalanceR); collateralToken.totalReservesF := collateralToken.totalReservesF + reserveTokensF; collateralToken.totalSupplyF := get_nat_or_fail(collateralToken.totalSupplyF - reserveSharesF, Errors.YToken.lowCollateralTotalSupply); - s.ledger[(params.borrower, params.collateralToken)] := borrowerBalance; - s.ledger[(Tezos.sender, params.collateralToken)] := liquidatorBalance; + s.ledger[(params.borrower, params.collateralToken)] := borrowerBalanceF; + s.ledger[(Tezos.sender, params.collateralToken)] := liquidatorBalanceF; s.accounts[(params.borrower, params.borrowToken)] := borrowerAccount; s.accounts[(Tezos.sender, params.collateralToken)] := liquidatorAccount; s.tokens[params.collateralToken] := collateralToken; @@ -540,7 +540,7 @@ function priceCallback( params.tokenId, s.storage.tokens ); - token.lastPrice := params.amount; + token.lastPriceFF := params.amount; token.priceUpdateTime := Tezos.now; s.storage.tokens[params.tokenId] := token; } with (noOperations, s) @@ -571,7 +571,7 @@ function accrueInterest( token.totalReservesF := interestAccumulatedF * token.reserveFactorF / precision + token.totalReservesF; // one mult operation with F require precision division - token.borrowIndex := simpleInterestFactorF * token.borrowIndex / precision + token.borrowIndex; + token.borrowIndexF := simpleInterestFactorF * token.borrowIndexF / precision + token.borrowIndexF; token.interestUpdateTime := Tezos.now; s.storage.tokens[params.tokenId] := token; diff --git a/contracts/partial/yToken/lendingTypes.ligo b/contracts/partial/yToken/lendingTypes.ligo index 2321ae5..4e1d1ed 100644 --- a/contracts/partial/yToken/lendingTypes.ligo +++ b/contracts/partial/yToken/lendingTypes.ligo @@ -9,8 +9,8 @@ type allowanceAmount is [@layout:comb] record [ type account is [@layout:comb] record [ allowances : set(address); - borrow : nat; - lastBorrowIndex : nat; + borrowF : nat; + lastBorrowIndexF : nat; ] type tokenType is [@layout:comb] record [ @@ -22,16 +22,16 @@ type tokenType is [@layout:comb] record [ totalLiquidF : nat; totalSupplyF : nat; totalReservesF : nat; - borrowIndex : nat; + borrowIndexF : nat; maxBorrowRate : nat; collateralFactorF : nat; liquidReserveRateF : nat; reserveFactorF : nat; - lastPrice : nat; + lastPriceFF : nat; borrowPause : bool; enterMintPause : bool; isInterestUpdating : bool; - threshold : nat; + thresholdF : nat; ] type yStorage is [@layout:comb] record [ @@ -114,7 +114,7 @@ type setTokenParams is [@layout:comb] record [ reserveFactorF : nat; interestRateModel : address; maxBorrowRate : nat; - threshold : nat; + thresholdF : nat; liquidReserveRateF : nat; ] @@ -149,7 +149,7 @@ type newMarketParams is [@layout:comb] record [ reserveFactorF : nat; maxBorrowRate : nat; token_metadata : newMetadataParams; - threshold : nat; + thresholdF : nat; liquidReserveRateF : nat; ] diff --git a/contracts/partial/yToken/views.ligo b/contracts/partial/yToken/views.ligo index 4a42546..f8804f0 100644 --- a/contracts/partial/yToken/views.ligo +++ b/contracts/partial/yToken/views.ligo @@ -20,7 +20,7 @@ type convertParams is [@layout:comb] record [ : balance_of_response is block { require(request.token_id < s.storage.lastTokenId, Errors.FA2.undefined); - const userBalance = getBalanceByToken( + const userBalanceF = getBalanceByToken( request.owner, request.token_id, s.storage.ledger @@ -28,8 +28,8 @@ type convertParams is [@layout:comb] record [ } with record [ request = request; balance = if p.precision - then userBalance / precision - else userBalance; + then userBalanceF / precision + else userBalanceF; ]; } with List.map(lookUpBalance, p.requests) diff --git a/integration_tests/helpers.py b/integration_tests/helpers.py index c2f3a8f..ade2111 100644 --- a/integration_tests/helpers.py +++ b/integration_tests/helpers.py @@ -41,7 +41,7 @@ def get_balance_by_token_id(res, address, token_id): # yToken storage variant def get_borrowBalance(res, address, token_id): # yToken storage variant account = res.storage["storage"]["accounts"][(address, token_id)] - return account["borrow"] + return account["borrowF"] def get_frozen_balance(res, address): return res.storage["ledger"][address]["frozenBalance"] @@ -61,7 +61,7 @@ def get_totalReservesF(res, token): return res.storage["storage"]["tokens"][token]["totalReservesF"] def get_lastPrice(res, token): - return res.storage["storage"]["tokens"][token]["lastPrice"] + return res.storage["storage"]["tokens"][token]["lastPriceFF"] def get_liqIncentiveF(res): return res.storage["storage"]["liqIncentiveF"] diff --git a/integration_tests/test_price_feed.py b/integration_tests/test_price_feed.py index e4b67fa..ece60e8 100644 --- a/integration_tests/test_price_feed.py +++ b/integration_tests/test_price_feed.py @@ -2,6 +2,7 @@ from helpers import * import copy +from decimal import Decimal from pprint import pprint @@ -44,12 +45,11 @@ def test_price_feed_decimals(self): op = res.operations[0]["parameters"] price = op["value"]["args"][1]["int"] - price = int(price) - one_btc = 1e8 - usd_precision = 1e6 - protocol_precision = 1e18 - - self.assertEqual(int(price / protocol_precision * one_btc / usd_precision), 45_252) + price = Decimal(price) + one_btc = Decimal(10) ** 8 + usd_precision = Decimal(10) ** 6 + protocol_precision = Decimal(10) ** 36 + self.assertEqual(int(price * one_btc / (usd_precision * protocol_precision)), 45_252) def test_price_feed_receive_outdated(self): chain = LocalChain(storage=self.storage) @@ -60,12 +60,12 @@ def test_price_feed_receive_outdated(self): op = res.operations[0]["parameters"] price = op["value"]["args"][1]["int"] - price = int(price) - one_btc = 1e8 - usd_precision = 1e6 - protocol_precision = 1e18 + price = Decimal(price) + one_btc = Decimal(10) ** 8 + usd_precision = Decimal(10) ** 6 + protocol_precision = Decimal(10) ** 36 - self.assertEqual(int(price / protocol_precision * one_btc / usd_precision), 45_252) + self.assertEqual(int(price * one_btc / (usd_precision * protocol_precision)), 45_252) chain.advance_blocks(300) # timestamp should be in allowed limit @@ -75,19 +75,6 @@ def test_price_feed_receive_outdated(self): res = chain.execute(self.ct.receivePrice("BTC-USD", 299 * SECONDS_PER_BLOCK, 45_500_000_000), sender=oracle) op = res.operations[0]["parameters"] price = op["value"]["args"][1]["int"] - price = int(price) - - self.assertEqual(int(price / protocol_precision * one_btc / usd_precision), 45_500) - - - - - + price = Decimal(price) - - - - - - - \ No newline at end of file + self.assertEqual(int(price * one_btc / (usd_precision * protocol_precision)), 45_500) diff --git a/integration_tests/test_quick.py b/integration_tests/test_quick.py index 37356f3..2733ba7 100644 --- a/integration_tests/test_quick.py +++ b/integration_tests/test_quick.py @@ -59,7 +59,7 @@ def add_token(self, chain, token, config=None): reserveFactorF = int(config["reserve_factor"] * PRECISION), maxBorrowRate = 1_000_000*PRECISION, token_metadata = {"": ""}, - threshold = int(config["threshold"] * PRECISION), + thresholdF = int(config["threshold"] * PRECISION), liquidReserveRateF = int(config["reserve_liquidation_rate"] * PRECISION) ), sender=admin) @@ -1196,7 +1196,7 @@ def test_change_collateral_factor(self): reserveFactorF=int(0.5 * 1e18), interestRateModel=interest_model, maxBorrowRate=1_000_000*PRECISION, - threshold=int(0.8 * 1e18), + thresholdF=int(0.8 * 1e18), liquidReserveRateF=int(0.05 * 1e18) ), sender=admin) diff --git a/integration_tests/test_transfers.py b/integration_tests/test_transfers.py index 8eb0e3f..bdab130 100644 --- a/integration_tests/test_transfers.py +++ b/integration_tests/test_transfers.py @@ -54,7 +54,7 @@ def add_token(self, chain, token, config=None): reserveFactorF = int(config["reserve_factor"] * PRECISION), maxBorrowRate = 1_000_000*PRECISION, token_metadata = {"": ""}, - threshold = int(config["threshold"] * PRECISION), + thresholdF = int(config["threshold"] * PRECISION), liquidReserveRateF = int(config["reserve_liquidation_rate"] * PRECISION) ), sender=admin) diff --git a/test/yToken.test.js b/test/yToken.test.js index 2d93c1d..b5d6519 100644 --- a/test/yToken.test.js +++ b/test/yToken.test.js @@ -456,7 +456,7 @@ describe("yToken tests", () => { let yTokenRes = await yToken.storage.storage.ledger.get([carol.pkh, 1]); let ytokens = await yToken.storage.storage.tokens.get("1"); - console.log(ytokens.lastPrice.toString()); + console.log(ytokens.lastPriceFF.toString()); strictEqual( await yTokenRes.toPrecision(40).split(".")[0], @@ -850,7 +850,7 @@ describe("yToken tests", () => { res = await yToken.storage.storage.accounts.get([bob.pkh, 1]); strictEqual( - res.borrow.toPrecision(40).split(".")[0], + res.borrowF.toPrecision(40).split(".")[0], "50000000000000000000000" ); }); @@ -864,7 +864,7 @@ describe("yToken tests", () => { await proxy.updateStorage(); let res = await yToken.storage.storage.accounts.get([bob.pkh, 1]); - console.log(res.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(res.borrowF.toPrecision(40).split(".")[0]); // not static result }); it("redeem 0 by carol", async () => { @@ -918,7 +918,7 @@ describe("yToken tests", () => { res = await yToken.storage.storage.accounts.get([peter.pkh, 1]); strictEqual( - res.borrow.toPrecision(40).split(".")[0], + res.borrowF.toPrecision(40).split(".")[0], "500000000000000000000" ); }); @@ -931,7 +931,7 @@ describe("yToken tests", () => { res = await yToken.storage.storage.accounts.get([dev2.pkh, 3]); strictEqual( - res.borrow.toPrecision(40).split(".")[0], + res.borrowF.toPrecision(40).split(".")[0], "1000000000000000000000" ); }); @@ -973,7 +973,7 @@ describe("yToken tests", () => { await yToken.updateStorage(); let yTokenRes = await yToken.storage.storage.accounts.get([bob.pkh, 1]); - console.log(yTokenRes.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(yTokenRes.borrowF.toPrecision(40).split(".")[0]); // not static result }); it("repay yTokens by dev2", async () => { @@ -983,7 +983,7 @@ describe("yToken tests", () => { await yToken.updateStorage(); let yTokenRes = await yToken.storage.storage.accounts.get([dev2.pkh, 3]); - strictEqual(yTokenRes.borrow.toPrecision(40).split(".")[0], "0"); + strictEqual(yTokenRes.borrowF.toPrecision(40).split(".")[0], "0"); }); it("exit market yTokens by dev2", async () => { @@ -1043,13 +1043,13 @@ describe("yToken tests", () => { console.log(await res.balance.toString()); // not static result let yTokenRes = await yToken.storage.storage.accounts.get([bob.pkh, 1]); - console.log(yTokenRes.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(yTokenRes.borrowF.toPrecision(40).split(".")[0]); // not static result await yToken.updateAndRepay(proxy, 1, 0); await yToken.updateStorage(); yTokenRes = await yToken.storage.storage.accounts.get([bob.pkh, 1]); - strictEqual(yTokenRes.borrow.toString(), "0"); + strictEqual(yTokenRes.borrowF.toString(), "0"); }); it("exit market yTokens by bob", async () => { @@ -1124,7 +1124,7 @@ describe("yToken tests", () => { console.log(yTokenRes.toPrecision(40).split(".")[0]); // not static result res = await yToken.storage.storage.accounts.get([peter.pkh, 1]); - console.log(res.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(res.borrowF.toPrecision(40).split(".")[0]); // not static result }); it("setTokenFactors [0] (return collateralFactor and threshhold) by admin", async () => { @@ -1217,7 +1217,7 @@ describe("yToken tests", () => { console.log(yTokenRes.toPrecision(40).split(".")[0]); // not static result res = await yToken.storage.storage.accounts.get([peter.pkh, 1]); - console.log(res.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(res.borrowF.toPrecision(40).split(".")[0]); // not static result }); it("liquidate by carol 3 (collateral price fell)", async () => { @@ -1230,7 +1230,7 @@ describe("yToken tests", () => { console.log(yTokenRes.toPrecision(40).split(".")[0]); // not static result res = await yToken.storage.storage.accounts.get([peter.pkh, 1]); - console.log(res.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(res.borrowF.toPrecision(40).split(".")[0]); // not static result }); it("liquidate by carol 4 (collateral price fell)", async () => { @@ -1243,7 +1243,7 @@ describe("yToken tests", () => { console.log(yTokenRes.toPrecision(40).split(".")[0]); // not static result res = await yToken.storage.storage.accounts.get([peter.pkh, 1]); - console.log(res.borrow.toPrecision(40).split(".")[0]); // not static result + console.log(res.borrowF.toPrecision(40).split(".")[0]); // not static result }); it("liquidation not achieved", async () => {