Skip to content

Commit

Permalink
Merge branch 'development' into feat/veion-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
vidvidvid committed Oct 25, 2024
2 parents da8c286 + beecb66 commit de7a5b2
Show file tree
Hide file tree
Showing 50 changed files with 22,859 additions and 21,880 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ packages/contracts/out/
packages/contracts/cache/
packages/contracts/cache_hardhat/
packages/contracts/transactions.json
notes.md
725 changes: 367 additions & 358 deletions .yarn/releases/yarn-4.5.0.cjs → .yarn/releases/yarn-4.5.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.0.cjs
yarnPath: .yarn/releases/yarn-4.5.1.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monorepo",
"packageManager": "[email protected].0",
"packageManager": "[email protected].1",
"private": true,
"workspaces": [
"packages/bots/liquidator",
Expand Down
16 changes: 16 additions & 0 deletions packages/chains/src/fraxtal/assets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
assetSymbols,
ChainlinkFeedBaseCurrency,
ChainlinkSpecificParams,
OracleTypes,
SupportedAsset,
SupportedChains
Expand All @@ -16,6 +17,7 @@ export const FXS = "0xfc00000000000000000000000000000000000002";
export const FRAX = "0xfc00000000000000000000000000000000000001";
export const sFRAX = "0xfc00000000000000000000000000000000000008";
export const frxBTC = "0xfc00000000000000000000000000000000000007";
export const insfrxETH = "0xE162075a1C0Ac7e985253972bEcA5e83Da3BBaa4";

export const assets: SupportedAsset[] = [
{
Expand Down Expand Up @@ -88,6 +90,20 @@ export const assets: SupportedAsset[] = [
initialSupplyCap: parseEther(String(10)).toString(),
initialBorrowCap: parseEther(String(8)).toString(),
initialCf: "0.1"
},
{
symbol: assetSymbols.insfrxETH,
underlying: insfrxETH,
name: "Inception Restaked sfrxETH",
decimals: 18,
oracle: OracleTypes.ChainlinkPriceOracleV2,
oracleSpecificParams: {
aggregator: "0x4E0Fce6FF8384241c686C26cA3bcE3A16CDcDB55",
feedBaseCurrency: ChainlinkFeedBaseCurrency.ETH
} as ChainlinkSpecificParams,
initialSupplyCap: parseEther(String(1000)).toString(),
initialBorrowCap: parseEther(String(800)).toString(),
initialCf: "0.70"
}
];

Expand Down
80 changes: 80 additions & 0 deletions packages/contracts/chainDeploy/helpers/oracles/api3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { prepareAndLogTransaction } from "../logging";
import { DeployResult } from "hardhat-deploy/types";
import { Address } from "viem";

import { addUnderlyingsToMpo } from "./utils";
import { underlying } from "../utils";
import { AerodromeDeployFnParams, ChainlinkDeployFnParams } from "../../types";

export const deployApi3Oracle = async ({
viem,
getNamedAccounts,
deployments,
deployConfig,
assets
}: ChainlinkDeployFnParams): Promise<{ apo: DeployResult }> => {
const { deployer, multisig } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();
let tx;

//// API3 Oracle
const apo = await deployments.deploy("API3PriceOracle", {
from: deployer,
args: [],
log: true,
proxy: {
execute: {
init: {
methodName: "initialize",
args: [deployConfig.stableToken, deployConfig.nativeTokenUsdChainlinkFeed]
}
},
proxyContract: "OpenZeppelinTransparentProxy",
owner: multisig ?? deployer
},
waitConfirmations: 1,
skipIfAlreadyDeployed: true
});
if (apo.transactionHash) await publicClient.waitForTransactionReceipt({ hash: apo.transactionHash as Address });

const api3 = await viem.getContractAt(
"API3PriceOracle",
(await deployments.get("API3PriceOracle")).address as Address
);

const underlyings = assets.map((c) => underlying(assets, c.symbol));

const mpo = await viem.getContractAt(
"MasterPriceOracle",
(await deployments.get("MasterPriceOracle")).address as Address
);
console.log("underlyings: ", underlyings);
await addUnderlyingsToMpo(mpo as any, underlyings, api3.address, deployer, publicClient);

const addressesProvider = await viem.getContractAt(
"AddressesProvider",
(await deployments.get("AddressesProvider")).address as Address
);
const api3Address = await addressesProvider.read.getAddress(["API3PriceOracle"]);
if (api3Address !== api3.address) {
if (((await addressesProvider.read.owner()) as Address).toLowerCase() === deployer.toLowerCase()) {
tx = await addressesProvider.write.setAddress(["API3PriceOracle", api3.address]);
await publicClient.waitForTransactionReceipt({ hash: tx });
console.log(`setAddress API3PriceOracle at ${tx}`);
} else {
prepareAndLogTransaction({
contractInstance: addressesProvider,
functionName: "setAddress",
args: ["API3PriceOracle", api3.address],
description: "Set API3PriceOracle address on AddressProvider",
inputs: [
{ internalType: "string", name: "id", type: "string" },
{ internalType: "address", name: "newAddress", type: "address" }
]
});
console.log("Logged Transaction to setAddress API3PriceOracle on AddressProvider");
}
}

return { apo };
};
5 changes: 3 additions & 2 deletions packages/contracts/chainDeploy/mainnets/fraxtal.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ChainDeployConfig, deployChainlinkOracle } from "../helpers";
import { fraxtal } from "@ionicprotocol/chains";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Address } from "viem";
import { Address, zeroAddress, zeroHash } from "viem";
import { ChainlinkSpecificParams, OracleTypes } from "../types";
import { deployApi3Oracle } from "../helpers/oracles/api3";

const assets = fraxtal.assets;

Expand Down Expand Up @@ -42,6 +43,7 @@ export const deploy = async ({
feedBaseCurrency: (asset.oracleSpecificParams as ChainlinkSpecificParams).feedBaseCurrency,
symbol: asset.symbol
}));
console.log("🚀 ~ chainlinkAssets:", chainlinkAssets);
await deployChainlinkOracle({
run,
viem,
Expand All @@ -52,7 +54,6 @@ export const deploy = async ({
chainlinkAssets
});

//// Uniswap V3 Liquidator Funder
const uniswapV2LiquidatorFunder = await deployments.deploy("UniswapV2LiquidatorFunder", {
from: deployer,
args: [],
Expand Down
46 changes: 12 additions & 34 deletions packages/contracts/contracts/compound/CTokenFirstExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@ contract CTokenFirstExtension is
* @param tokens The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferTokens(
address spender,
address src,
address dst,
uint256 tokens
) internal returns (uint256) {
function transferTokens(address spender, address src, address dst, uint256 tokens) internal returns (uint256) {
/* Fail if transfer not allowed */
uint256 allowed = comptroller.transferAllowed(address(this), src, dst, tokens);
if (allowed != 0) {
Expand Down Expand Up @@ -316,12 +311,9 @@ contract CTokenFirstExtension is
* @param newInterestRateModel the new interest rate model to use
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setInterestRateModel(InterestRateModel newInterestRateModel)
public
override
nonReentrant(false)
returns (uint256)
{
function _setInterestRateModel(
InterestRateModel newInterestRateModel
) public override nonReentrant(false) returns (uint256) {
accrueInterest();
if (!hasAdminRights()) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK);
Expand Down Expand Up @@ -483,11 +475,10 @@ contract CTokenFirstExtension is
uint256 interestAccumulated;
}

function _accrueInterestHypothetical(uint256 blockNumber, uint256 cashPrior)
internal
view
returns (InterestAccrual memory accrual)
{
function _accrueInterestHypothetical(
uint256 blockNumber,
uint256 cashPrior
) internal view returns (InterestAccrual memory accrual) {
uint256 totalFees = totalAdminFees + totalIonicFees;
uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, totalBorrows, totalReserves + totalFees);
if (borrowRateMantissa > borrowRateMaxMantissa) {
Expand Down Expand Up @@ -581,17 +572,7 @@ contract CTokenFirstExtension is
* @param account Address of the account to snapshot
* @return (possible error, token balance, borrow balance, exchange rate mantissa)
*/
function getAccountSnapshot(address account)
external
view
override
returns (
uint256,
uint256,
uint256,
uint256
)
{
function getAccountSnapshot(address account) external view override returns (uint256, uint256, uint256, uint256) {
uint256 cTokenBalance = accountTokens[account];
uint256 borrowBalance;
uint256 exchangeRateMantissa;
Expand Down Expand Up @@ -707,12 +688,9 @@ contract CTokenFirstExtension is
return ICErc20(address(this));
}

function multicall(bytes[] calldata data)
public
payable
override(CTokenFirstExtensionInterface, Multicall)
returns (bytes[] memory results)
{
function multicall(
bytes[] calldata data
) public payable override(CTokenFirstExtensionInterface, Multicall) returns (bytes[] memory results) {
return Multicall.multicall(data);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.10;

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via CL
interface ISwapRouter_Aerodrome {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
int24 tickSpacing;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}

/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}

/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
int24 tickSpacing;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}

/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}

/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}
64 changes: 0 additions & 64 deletions packages/contracts/contracts/external/aerodrome/ISwapRouter.sol

This file was deleted.

Loading

0 comments on commit de7a5b2

Please sign in to comment.