feat: update mainnet connector

This commit is contained in:
Shriya Tyagi 2024-02-11 14:33:32 +04:00
parent 4b7d9c6263
commit cf61ac8b22

View File

@ -92,6 +92,8 @@ abstract contract FluidConnector is Events, Stores {
ethAmount_ = isColMax_ ethAmount_ = isColMax_
? address(this).balance ? address(this).balance
: uint256(newCol_); : uint256(newCol_);
newCol_ = int256(ethAmount_);
} else { } else {
if (isColMax_) { if (isColMax_) {
newCol_ = int256( newCol_ = int256(
@ -108,24 +110,24 @@ abstract contract FluidConnector is Events, Stores {
} }
} }
bool isPaybackMax_ = newDebt_ == type(int256).min; bool isPaybackMin_ = newDebt_ == type(int256).min;
// Payback // Payback
if (newDebt_ < 0) { if (newDebt_ < 0) {
if (vaultDetails_.borrowToken == getEthAddr()) { if (vaultDetails_.borrowToken == getEthAddr()) {
// Needs to be positive as it will be send in msg.value // Needs to be positive as it will be send in msg.value
ethAmount_ = isPaybackMax_ ethAmount_ = isPaybackMin_
? repayApproveAmt_ ? repayApproveAmt_
: uint256(-1 * newDebt_); : uint256(-newDebt_);
} else { } else {
isPaybackMax_ isPaybackMin_
? TokenInterface(vaultDetails_.borrowToken).approve( ? TokenInterface(vaultDetails_.borrowToken).approve(
vaultAddress_, vaultAddress_,
repayApproveAmt_ repayApproveAmt_
) )
: TokenInterface(vaultDetails_.borrowToken).approve( : TokenInterface(vaultDetails_.borrowToken).approve(
vaultAddress_, vaultAddress_,
uint256(-1 * newDebt_) uint256(-newDebt_)
); );
} }
} }
@ -211,24 +213,24 @@ abstract contract FluidConnector is Events, Stores {
} }
} }
bool isPaybackMax_ = newDebt_ == type(int256).min; bool isPaybackMin_ = newDebt_ == type(int256).min;
// Payback // Payback
if (newDebt_ < 0) { if (newDebt_ < 0) {
if (vaultDetails_.borrowToken == getEthAddr()) { if (vaultDetails_.borrowToken == getEthAddr()) {
// Needs to be positive as it will be send in msg.value // Needs to be positive as it will be send in msg.value
ethAmount_ = isPaybackMax_ ethAmount_ = isPaybackMin_
? repayApproveAmt_ ? repayApproveAmt_
: uint256(-1 * newDebt_); : uint256(-newDebt_);
} else { } else {
isPaybackMax_ isPaybackMin_
? TokenInterface(vaultDetails_.borrowToken).approve( ? TokenInterface(vaultDetails_.borrowToken).approve(
vaultAddress_, vaultAddress_,
repayApproveAmt_ repayApproveAmt_
) )
: TokenInterface(vaultDetails_.borrowToken).approve( : TokenInterface(vaultDetails_.borrowToken).approve(
vaultAddress_, vaultAddress_,
uint256(-1 * newDebt_) uint256(-newDebt_)
); );
} }
} }