update liquidation bot scripts
This commit is contained in:
@@ -4091,6 +4091,309 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ab6da29710b091ffad47d5dfd15ed9a4ad8febaa07a65377c607b48f5c63a74c": {
|
||||
"address": "0xA0E7B845DdD5d80e6012382502a4853C657244B5",
|
||||
"txHash": "0x5d90df4a312ec9bef621f54601acdbc567b2bd1e9a82cb32bee5cdc1d5413898",
|
||||
"layout": {
|
||||
"solcVersion": "0.8.28",
|
||||
"storage": [
|
||||
{
|
||||
"label": "gov",
|
||||
"offset": 0,
|
||||
"slot": "0",
|
||||
"type": "t_address",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:50"
|
||||
},
|
||||
{
|
||||
"label": "ytPoolManager",
|
||||
"offset": 0,
|
||||
"slot": "1",
|
||||
"type": "t_address",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:50"
|
||||
},
|
||||
{
|
||||
"label": "priceFeed",
|
||||
"offset": 0,
|
||||
"slot": "2",
|
||||
"type": "t_address",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:52"
|
||||
},
|
||||
{
|
||||
"label": "usdy",
|
||||
"offset": 0,
|
||||
"slot": "3",
|
||||
"type": "t_address",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:53"
|
||||
},
|
||||
{
|
||||
"label": "isSwapper",
|
||||
"offset": 0,
|
||||
"slot": "4",
|
||||
"type": "t_mapping(t_address,t_bool)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:53"
|
||||
},
|
||||
{
|
||||
"label": "isSwapEnabled",
|
||||
"offset": 0,
|
||||
"slot": "5",
|
||||
"type": "t_bool",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:58"
|
||||
},
|
||||
{
|
||||
"label": "emergencyMode",
|
||||
"offset": 1,
|
||||
"slot": "5",
|
||||
"type": "t_bool",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:59"
|
||||
},
|
||||
{
|
||||
"label": "allWhitelistedTokens",
|
||||
"offset": 0,
|
||||
"slot": "6",
|
||||
"type": "t_array(t_address)dyn_storage",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:60"
|
||||
},
|
||||
{
|
||||
"label": "whitelistedTokens",
|
||||
"offset": 0,
|
||||
"slot": "7",
|
||||
"type": "t_mapping(t_address,t_bool)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:61"
|
||||
},
|
||||
{
|
||||
"label": "stableTokens",
|
||||
"offset": 0,
|
||||
"slot": "8",
|
||||
"type": "t_mapping(t_address,t_bool)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:62"
|
||||
},
|
||||
{
|
||||
"label": "tokenDecimals",
|
||||
"offset": 0,
|
||||
"slot": "9",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:63"
|
||||
},
|
||||
{
|
||||
"label": "tokenWeights",
|
||||
"offset": 0,
|
||||
"slot": "10",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:64"
|
||||
},
|
||||
{
|
||||
"label": "totalTokenWeights",
|
||||
"offset": 0,
|
||||
"slot": "11",
|
||||
"type": "t_uint256",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:67"
|
||||
},
|
||||
{
|
||||
"label": "poolAmounts",
|
||||
"offset": 0,
|
||||
"slot": "12",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:68"
|
||||
},
|
||||
{
|
||||
"label": "tokenBalances",
|
||||
"offset": 0,
|
||||
"slot": "13",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:71"
|
||||
},
|
||||
{
|
||||
"label": "usdyAmounts",
|
||||
"offset": 0,
|
||||
"slot": "14",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:75"
|
||||
},
|
||||
{
|
||||
"label": "maxUsdyAmounts",
|
||||
"offset": 0,
|
||||
"slot": "15",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:76"
|
||||
},
|
||||
{
|
||||
"label": "swapFeeBasisPoints",
|
||||
"offset": 0,
|
||||
"slot": "16",
|
||||
"type": "t_uint256",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:78"
|
||||
},
|
||||
{
|
||||
"label": "stableSwapFeeBasisPoints",
|
||||
"offset": 0,
|
||||
"slot": "17",
|
||||
"type": "t_uint256",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:79"
|
||||
},
|
||||
{
|
||||
"label": "taxBasisPoints",
|
||||
"offset": 0,
|
||||
"slot": "18",
|
||||
"type": "t_uint256",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:82"
|
||||
},
|
||||
{
|
||||
"label": "stableTaxBasisPoints",
|
||||
"offset": 0,
|
||||
"slot": "19",
|
||||
"type": "t_uint256",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:84"
|
||||
},
|
||||
{
|
||||
"label": "hasDynamicFees",
|
||||
"offset": 0,
|
||||
"slot": "20",
|
||||
"type": "t_bool",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:85"
|
||||
},
|
||||
{
|
||||
"label": "maxSwapSlippageBps",
|
||||
"offset": 0,
|
||||
"slot": "21",
|
||||
"type": "t_uint256",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:88"
|
||||
},
|
||||
{
|
||||
"label": "maxSwapAmount",
|
||||
"offset": 0,
|
||||
"slot": "22",
|
||||
"type": "t_mapping(t_address,t_uint256)",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:91"
|
||||
},
|
||||
{
|
||||
"label": "__gap",
|
||||
"offset": 0,
|
||||
"slot": "23",
|
||||
"type": "t_array(t_uint256)50_storage",
|
||||
"contract": "YTVault",
|
||||
"src": "contracts/ytLp/core/YTVault.sol:675"
|
||||
}
|
||||
],
|
||||
"types": {
|
||||
"t_bool": {
|
||||
"label": "bool",
|
||||
"numberOfBytes": "1"
|
||||
},
|
||||
"t_struct(InitializableStorage)73_storage": {
|
||||
"label": "struct Initializable.InitializableStorage",
|
||||
"members": [
|
||||
{
|
||||
"label": "_initialized",
|
||||
"type": "t_uint64",
|
||||
"offset": 0,
|
||||
"slot": "0"
|
||||
},
|
||||
{
|
||||
"label": "_initializing",
|
||||
"type": "t_bool",
|
||||
"offset": 8,
|
||||
"slot": "0"
|
||||
}
|
||||
],
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_struct(ReentrancyGuardStorage)288_storage": {
|
||||
"label": "struct ReentrancyGuardUpgradeable.ReentrancyGuardStorage",
|
||||
"members": [
|
||||
{
|
||||
"label": "_status",
|
||||
"type": "t_uint256",
|
||||
"offset": 0,
|
||||
"slot": "0"
|
||||
}
|
||||
],
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_uint256": {
|
||||
"label": "uint256",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_uint64": {
|
||||
"label": "uint64",
|
||||
"numberOfBytes": "8"
|
||||
},
|
||||
"t_address": {
|
||||
"label": "address",
|
||||
"numberOfBytes": "20"
|
||||
},
|
||||
"t_array(t_address)dyn_storage": {
|
||||
"label": "address[]",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_array(t_uint256)50_storage": {
|
||||
"label": "uint256[50]",
|
||||
"numberOfBytes": "1600"
|
||||
},
|
||||
"t_mapping(t_address,t_bool)": {
|
||||
"label": "mapping(address => bool)",
|
||||
"numberOfBytes": "32"
|
||||
},
|
||||
"t_mapping(t_address,t_uint256)": {
|
||||
"label": "mapping(address => uint256)",
|
||||
"numberOfBytes": "32"
|
||||
}
|
||||
},
|
||||
"namespaces": {
|
||||
"erc7201:openzeppelin.storage.ReentrancyGuard": [
|
||||
{
|
||||
"contract": "ReentrancyGuardUpgradeable",
|
||||
"label": "_status",
|
||||
"type": "t_uint256",
|
||||
"src": "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol:43",
|
||||
"offset": 0,
|
||||
"slot": "0"
|
||||
}
|
||||
],
|
||||
"erc7201:openzeppelin.storage.Initializable": [
|
||||
{
|
||||
"contract": "Initializable",
|
||||
"label": "_initialized",
|
||||
"type": "t_uint64",
|
||||
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
|
||||
"offset": 0,
|
||||
"slot": "0"
|
||||
},
|
||||
{
|
||||
"contract": "Initializable",
|
||||
"label": "_initializing",
|
||||
"type": "t_bool",
|
||||
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
|
||||
"offset": 8,
|
||||
"slot": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +128,45 @@
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_tokenIn",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_tokenOut",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_amountIn",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getSwapAmountOut",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOut",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOutAfterFees",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "feeBasisPoints",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
|
||||
@@ -641,6 +641,45 @@
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_tokenIn",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_tokenOut",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_amountIn",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getSwapAmountOut",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOut",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOutAfterFees",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "feeBasisPoints",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -11,6 +11,7 @@ interface IYTVault {
|
||||
function getMinPrice(address _token) external view returns (uint256);
|
||||
function getSwapFeeBasisPoints(address _tokenIn, address _tokenOut, uint256 _usdyAmount) external view returns (uint256);
|
||||
function getRedemptionFeeBasisPoints(address _token, uint256 _usdyAmount) external view returns (uint256);
|
||||
function getSwapAmountOut(address _tokenIn, address _tokenOut, uint256 _amountIn) external view returns (uint256 amountOut, uint256 amountOutAfterFees, uint256 feeBasisPoints);
|
||||
function ytPrice() external view returns (uint256);
|
||||
function wusdPrice() external view returns (uint256);
|
||||
}
|
||||
|
||||
@@ -503,6 +503,42 @@ contract YTVault is Initializable, UUPSUpgradeable, ReentrancyGuardUpgradeable {
|
||||
) public view returns (uint256) {
|
||||
return _getSwapFeeBasisPoints(usdy, _token, _usdyAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice 预估swap输出数量
|
||||
* @param _tokenIn 输入代币地址
|
||||
* @param _tokenOut 输出代币地址
|
||||
* @param _amountIn 输入数量
|
||||
* @return amountOut 扣费前输出量
|
||||
* @return amountOutAfterFees 扣费后实际输出量
|
||||
* @return feeBasisPoints 动态手续费率
|
||||
*/
|
||||
function getSwapAmountOut(
|
||||
address _tokenIn,
|
||||
address _tokenOut,
|
||||
uint256 _amountIn
|
||||
) external view returns (
|
||||
uint256 amountOut,
|
||||
uint256 amountOutAfterFees,
|
||||
uint256 feeBasisPoints
|
||||
) {
|
||||
if (_amountIn == 0) revert InvalidAmount();
|
||||
if (!whitelistedTokens[_tokenIn]) revert TokenNotWhitelisted();
|
||||
if (!whitelistedTokens[_tokenOut]) revert TokenNotWhitelisted();
|
||||
if (_tokenIn == _tokenOut) revert SameToken();
|
||||
|
||||
uint256 priceIn = _getPrice(_tokenIn, false);
|
||||
uint256 priceOut = _getPrice(_tokenOut, true);
|
||||
|
||||
uint256 usdyAmount = _amountIn * priceIn / PRICE_PRECISION;
|
||||
usdyAmount = _adjustForDecimals(usdyAmount, _tokenIn, usdy);
|
||||
|
||||
amountOut = usdyAmount * PRICE_PRECISION / priceOut;
|
||||
amountOut = _adjustForDecimals(amountOut, usdy, _tokenOut);
|
||||
|
||||
feeBasisPoints = _getSwapFeeBasisPoints(_tokenIn, _tokenOut, usdyAmount);
|
||||
amountOutAfterFees = amountOut * (BASIS_POINTS_DIVISOR - feeBasisPoints) / BASIS_POINTS_DIVISOR;
|
||||
}
|
||||
|
||||
function _getSwapFeeBasisPoints(
|
||||
address _tokenIn,
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{"id":"0ee4530324ac9712","source_id_to_path":{"0":"contracts/interfaces/IUSDY.sol","1":"contracts/interfaces/IYTAssetVault.sol","2":"contracts/interfaces/IYTLPToken.sol","3":"contracts/interfaces/IYTPoolManager.sol","4":"contracts/interfaces/IYTPriceFeed.sol","5":"contracts/interfaces/IYTVault.sol","6":"contracts/ytLp/core/YTPoolManager.sol","7":"contracts/ytLp/core/YTPriceFeed.sol","8":"contracts/ytLp/core/YTRewardRouter.sol","9":"contracts/ytLp/core/YTVault.sol","10":"contracts/ytLp/tokens/USDY.sol","11":"contracts/ytLp/tokens/YTLPToken.sol","12":"contracts/ytVault/YTAssetFactory.sol","13":"contracts/ytVault/YTAssetVault.sol","14":"lib/forge-std/src/Base.sol","15":"lib/forge-std/src/StdAssertions.sol","16":"lib/forge-std/src/StdChains.sol","17":"lib/forge-std/src/StdCheats.sol","18":"lib/forge-std/src/StdConstants.sol","19":"lib/forge-std/src/StdError.sol","20":"lib/forge-std/src/StdInvariant.sol","21":"lib/forge-std/src/StdJson.sol","22":"lib/forge-std/src/StdMath.sol","23":"lib/forge-std/src/StdStorage.sol","24":"lib/forge-std/src/StdStyle.sol","25":"lib/forge-std/src/StdToml.sol","26":"lib/forge-std/src/StdUtils.sol","27":"lib/forge-std/src/Test.sol","28":"lib/forge-std/src/Vm.sol","29":"lib/forge-std/src/console.sol","30":"lib/forge-std/src/console2.sol","31":"lib/forge-std/src/interfaces/IMulticall3.sol","32":"lib/forge-std/src/safeconsole.sol","33":"node_modules/@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol","34":"node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol","35":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol","36":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol","37":"node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol","38":"node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol","39":"node_modules/@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol","40":"node_modules/@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol","41":"node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol","42":"node_modules/@openzeppelin/contracts/interfaces/IERC165.sol","43":"node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol","44":"node_modules/@openzeppelin/contracts/interfaces/IERC20.sol","45":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol","46":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC6093.sol","47":"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol","48":"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol","49":"node_modules/@openzeppelin/contracts/proxy/Proxy.sol","50":"node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol","51":"node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol","52":"node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol","53":"node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol","54":"node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol","55":"node_modules/@openzeppelin/contracts/utils/Address.sol","56":"node_modules/@openzeppelin/contracts/utils/Context.sol","57":"node_modules/@openzeppelin/contracts/utils/Errors.sol","58":"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol","59":"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol","60":"test/YtLp.t.sol"},"language":"Solidity"}
|
||||
1
out/build-info/3dc62104ba72c6eb.json
Normal file
1
out/build-info/3dc62104ba72c6eb.json
Normal file
@@ -0,0 +1 @@
|
||||
{"id":"3dc62104ba72c6eb","source_id_to_path":{"0":"contracts/interfaces/ILending.sol","1":"contracts/interfaces/IYTLendingPriceFeed.sol","2":"contracts/ytLending/Configurator.sol","3":"contracts/ytLending/ConfiguratorStorage.sol","4":"contracts/ytLending/Lending.sol","5":"contracts/ytLending/LendingConfiguration.sol","6":"contracts/ytLending/LendingFactory.sol","7":"contracts/ytLending/LendingMath.sol","8":"contracts/ytLending/LendingStorage.sol","9":"lib/forge-std/src/Base.sol","10":"lib/forge-std/src/Script.sol","11":"lib/forge-std/src/StdChains.sol","12":"lib/forge-std/src/StdCheats.sol","13":"lib/forge-std/src/StdConstants.sol","14":"lib/forge-std/src/StdJson.sol","15":"lib/forge-std/src/StdMath.sol","16":"lib/forge-std/src/StdStorage.sol","17":"lib/forge-std/src/StdStyle.sol","18":"lib/forge-std/src/StdUtils.sol","19":"lib/forge-std/src/Vm.sol","20":"lib/forge-std/src/console.sol","21":"lib/forge-std/src/console2.sol","22":"lib/forge-std/src/interfaces/IMulticall3.sol","23":"lib/forge-std/src/safeconsole.sol","24":"node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol","25":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol","26":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol","27":"node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol","28":"node_modules/@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol","29":"node_modules/@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol","30":"node_modules/@openzeppelin/contracts/access/Ownable.sol","31":"node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol","32":"node_modules/@openzeppelin/contracts/interfaces/IERC165.sol","33":"node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol","34":"node_modules/@openzeppelin/contracts/interfaces/IERC20.sol","35":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol","36":"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol","37":"node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol","38":"node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol","39":"node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol","40":"node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol","41":"node_modules/@openzeppelin/contracts/utils/Address.sol","42":"node_modules/@openzeppelin/contracts/utils/Context.sol","43":"node_modules/@openzeppelin/contracts/utils/Errors.sol","44":"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol","45":"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol","46":"scripts/test.s.sol"},"language":"Solidity"}
|
||||
@@ -1 +0,0 @@
|
||||
{"id":"54dc7690fc637aae","source_id_to_path":{"0":"contracts/interfaces/IUSDY.sol","1":"contracts/interfaces/IYTAssetVault.sol","2":"contracts/interfaces/IYTLPToken.sol","3":"contracts/interfaces/IYTPoolManager.sol","4":"contracts/interfaces/IYTPriceFeed.sol","5":"contracts/interfaces/IYTVault.sol","6":"contracts/ytLp/core/YTPoolManager.sol","7":"contracts/ytLp/core/YTPriceFeed.sol","8":"contracts/ytLp/core/YTRewardRouter.sol","9":"contracts/ytLp/core/YTVault.sol","10":"contracts/ytLp/tokens/USDY.sol","11":"contracts/ytLp/tokens/YTLPToken.sol","12":"contracts/ytVault/YTAssetFactory.sol","13":"contracts/ytVault/YTAssetVault.sol","14":"lib/forge-std/src/Base.sol","15":"lib/forge-std/src/StdAssertions.sol","16":"lib/forge-std/src/StdChains.sol","17":"lib/forge-std/src/StdCheats.sol","18":"lib/forge-std/src/StdConstants.sol","19":"lib/forge-std/src/StdError.sol","20":"lib/forge-std/src/StdInvariant.sol","21":"lib/forge-std/src/StdJson.sol","22":"lib/forge-std/src/StdMath.sol","23":"lib/forge-std/src/StdStorage.sol","24":"lib/forge-std/src/StdStyle.sol","25":"lib/forge-std/src/StdToml.sol","26":"lib/forge-std/src/StdUtils.sol","27":"lib/forge-std/src/Test.sol","28":"lib/forge-std/src/Vm.sol","29":"lib/forge-std/src/console.sol","30":"lib/forge-std/src/console2.sol","31":"lib/forge-std/src/interfaces/IMulticall3.sol","32":"lib/forge-std/src/safeconsole.sol","33":"node_modules/@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol","34":"node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol","35":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol","36":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol","37":"node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol","38":"node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol","39":"node_modules/@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol","40":"node_modules/@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol","41":"node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol","42":"node_modules/@openzeppelin/contracts/interfaces/IERC165.sol","43":"node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol","44":"node_modules/@openzeppelin/contracts/interfaces/IERC20.sol","45":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol","46":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC6093.sol","47":"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol","48":"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol","49":"node_modules/@openzeppelin/contracts/proxy/Proxy.sol","50":"node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol","51":"node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol","52":"node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol","53":"node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol","54":"node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol","55":"node_modules/@openzeppelin/contracts/utils/Address.sol","56":"node_modules/@openzeppelin/contracts/utils/Context.sol","57":"node_modules/@openzeppelin/contracts/utils/Errors.sol","58":"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol","59":"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol","60":"test/YtLp.t.sol"},"language":"Solidity"}
|
||||
1
out/build-info/7a3a00b0088e087b.json
Normal file
1
out/build-info/7a3a00b0088e087b.json
Normal file
@@ -0,0 +1 @@
|
||||
{"id":"7a3a00b0088e087b","source_id_to_path":{"0":"contracts/interfaces/IUSDY.sol","1":"contracts/interfaces/IYTLPToken.sol","2":"contracts/interfaces/IYTPoolManager.sol","3":"contracts/interfaces/IYTPriceFeed.sol","4":"contracts/interfaces/IYTVault.sol","5":"contracts/ytLp/core/YTPoolManager.sol","6":"contracts/ytLp/core/YTRewardRouter.sol","7":"contracts/ytLp/core/YTVault.sol","8":"lib/forge-std/src/Base.sol","9":"lib/forge-std/src/Script.sol","10":"lib/forge-std/src/StdChains.sol","11":"lib/forge-std/src/StdCheats.sol","12":"lib/forge-std/src/StdConstants.sol","13":"lib/forge-std/src/StdJson.sol","14":"lib/forge-std/src/StdMath.sol","15":"lib/forge-std/src/StdStorage.sol","16":"lib/forge-std/src/StdStyle.sol","17":"lib/forge-std/src/StdUtils.sol","18":"lib/forge-std/src/Vm.sol","19":"lib/forge-std/src/console.sol","20":"lib/forge-std/src/console2.sol","21":"lib/forge-std/src/interfaces/IMulticall3.sol","22":"lib/forge-std/src/safeconsole.sol","23":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol","24":"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol","25":"node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol","26":"node_modules/@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol","27":"node_modules/@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol","28":"node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol","29":"node_modules/@openzeppelin/contracts/interfaces/IERC165.sol","30":"node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol","31":"node_modules/@openzeppelin/contracts/interfaces/IERC20.sol","32":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol","33":"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol","34":"node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol","35":"node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol","36":"node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol","37":"node_modules/@openzeppelin/contracts/utils/Address.sol","38":"node_modules/@openzeppelin/contracts/utils/Errors.sol","39":"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol","40":"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol","41":"scripts/test.s.sol"},"language":"Solidity"}
|
||||
@@ -1 +1 @@
|
||||
{"id":"02c612b68d04265b","source_id_to_path":{"0":"lib/forge-std/src/Base.sol","1":"lib/forge-std/src/Script.sol","2":"lib/forge-std/src/StdChains.sol","3":"lib/forge-std/src/StdCheats.sol","4":"lib/forge-std/src/StdConstants.sol","5":"lib/forge-std/src/StdJson.sol","6":"lib/forge-std/src/StdMath.sol","7":"lib/forge-std/src/StdStorage.sol","8":"lib/forge-std/src/StdStyle.sol","9":"lib/forge-std/src/StdUtils.sol","10":"lib/forge-std/src/Vm.sol","11":"lib/forge-std/src/console.sol","12":"lib/forge-std/src/console2.sol","13":"lib/forge-std/src/interfaces/IMulticall3.sol","14":"lib/forge-std/src/safeconsole.sol","15":"scripts/test.s.sol"},"language":"Solidity"}
|
||||
{"id":"d81065d09c259d5f","source_id_to_path":{"0":"lib/forge-std/src/Base.sol","1":"lib/forge-std/src/Script.sol","2":"lib/forge-std/src/StdChains.sol","3":"lib/forge-std/src/StdCheats.sol","4":"lib/forge-std/src/StdConstants.sol","5":"lib/forge-std/src/StdJson.sol","6":"lib/forge-std/src/StdMath.sol","7":"lib/forge-std/src/StdStorage.sol","8":"lib/forge-std/src/StdStyle.sol","9":"lib/forge-std/src/StdUtils.sol","10":"lib/forge-std/src/Vm.sol","11":"lib/forge-std/src/console.sol","12":"lib/forge-std/src/console2.sol","13":"lib/forge-std/src/interfaces/IMulticall3.sol","14":"lib/forge-std/src/safeconsole.sol","15":"scripts/test.s.sol"},"language":"Solidity"}
|
||||
File diff suppressed because one or more lines are too long
@@ -91,13 +91,13 @@ async function main() {
|
||||
console.log("\n添加 USDC 到白名单...");
|
||||
const usdcParams = {
|
||||
weight: 1000, // 1000/10000 = 10%
|
||||
maxUsdyAmount: ethers.parseUnits("30000000", 6), // 3000万 USDC
|
||||
maxUsdyAmount: ethers.parseUnits("30000000", 18), // 3000万 USDC
|
||||
isStable: true // USDC是稳定币
|
||||
};
|
||||
|
||||
const usdcTx = await vault.setWhitelistedToken(
|
||||
usdcAddress,
|
||||
6, // Todo USDC在Arbitrum测试网是6位精度
|
||||
18, // USDC的精度是18
|
||||
usdcParams.weight,
|
||||
usdcParams.maxUsdyAmount,
|
||||
usdcParams.isStable
|
||||
|
||||
@@ -33,7 +33,6 @@ async function main() {
|
||||
|
||||
console.log('📋 Contract Addresses:');
|
||||
console.log(' Lending Proxy:', deployment.lendingProxy);
|
||||
console.log(' Price Feed:', deployment.lendingPriceFeedProxy);
|
||||
console.log(' Base Token (USDC):', deployment.usdcAddress);
|
||||
console.log('');
|
||||
|
||||
@@ -49,12 +48,6 @@ async function main() {
|
||||
signer
|
||||
);
|
||||
|
||||
const priceFeedContract = await hre.ethers.getContractAt(
|
||||
'LendingPriceFeed',
|
||||
deployment.lendingPriceFeedProxy,
|
||||
signer
|
||||
);
|
||||
|
||||
console.log('✅ Contracts initialized\n');
|
||||
console.log('==========================================');
|
||||
console.log('🔄 Starting main loop...\n');
|
||||
@@ -75,7 +68,6 @@ async function main() {
|
||||
// 执行清算逻辑
|
||||
await liquidateUnderwaterBorrowers(
|
||||
lendingContract,
|
||||
priceFeedContract,
|
||||
signer
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import hre from 'hardhat';
|
||||
import { Signer } from 'ethers';
|
||||
|
||||
const LOOKBACK_BLOCKS = 10000; // 查询最近 50000 个区块
|
||||
const LIQUIDATION_THRESHOLD = 1; // $10 的最小清算阈值(美元单位)
|
||||
|
||||
/**
|
||||
* 获取最近活跃的地址(通过多个事件)
|
||||
@@ -94,7 +93,6 @@ export async function getUniqueAddresses(
|
||||
*/
|
||||
export async function liquidateUnderwaterBorrowers(
|
||||
lendingContract: any,
|
||||
priceFeedContract: any,
|
||||
signer: Signer
|
||||
): Promise<boolean> {
|
||||
// 步骤 1: 获取最近活跃的地址
|
||||
@@ -116,29 +114,8 @@ export async function liquidateUnderwaterBorrowers(
|
||||
const isLiquidatable = await lendingContract.isLiquidatable(address);
|
||||
|
||||
if (isLiquidatable) {
|
||||
// 应用清算阈值过滤(防止清算小额账户,gas 成本过高)
|
||||
const borrowBalance = await lendingContract.borrowBalanceOf(address);
|
||||
const baseToken = await lendingContract.baseToken();
|
||||
const basePrice = await priceFeedContract.getPrice(baseToken);
|
||||
|
||||
// 动态获取 baseToken 的 decimals
|
||||
const baseTokenContract = await hre.ethers.getContractAt('IERC20Metadata', baseToken);
|
||||
const baseDecimals = await baseTokenContract.decimals();
|
||||
|
||||
// debtValue 计算:borrowBalance * basePrice / 10^decimals
|
||||
// 结果精度为 30 decimals (价格精度)
|
||||
const debtValue = (BigInt(borrowBalance) * BigInt(basePrice)) / BigInt(10) ** BigInt(baseDecimals);
|
||||
const debtValueInBaseUnit = Number(debtValue / (BigInt(10) ** BigInt(30))); // 转换为美元单位
|
||||
|
||||
// 将清算阈值(美元)转换为 30 decimals 精度进行比较
|
||||
const thresholdValue = BigInt(LIQUIDATION_THRESHOLD) * BigInt(10) ** BigInt(30);
|
||||
|
||||
if (debtValue >= thresholdValue) {
|
||||
console.log(`💰 Liquidatable: ${address}, Debt: $${debtValueInBaseUnit.toFixed(2)}`);
|
||||
liquidatableAccounts.push(address);
|
||||
} else {
|
||||
console.log(`⏭️ Skip (below threshold): ${address}, Debt: $${debtValueInBaseUnit.toFixed(2)}`);
|
||||
}
|
||||
console.log(`💰 Liquidatable: ${address}`);
|
||||
liquidatableAccounts.push(address);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error checking ${address}:`, error);
|
||||
|
||||
@@ -12,9 +12,9 @@ contract TestFun is Script {
|
||||
function run() external {
|
||||
|
||||
address from = 0xa013422A5918CD099C63c8CC35283EACa99a705d;
|
||||
address to = 0xfdbFD4656b74aD16F23264121eD9F58219f5C3Cf;
|
||||
address to = 0x7f9eEA491eE53045594ee4669327f0355aCd0e58;
|
||||
|
||||
bytes memory data = hex"2e1a7d4d000000000000000000000000000000000000000000000005f68e8131ecf80000";
|
||||
bytes memory data = hex"7229bc3c0000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
|
||||
vm.startPrank(from);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user