Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 cadence/contracts/connectors/SwapConnectors.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ access(all) contract SwapConnectors {
/// @return a Vault of type `outVault` containing the swapped currency.
///
access(self)
fun _swap(quote: {DeFiActions.Quote}?, from: @{FungibleToken.Vault}, reverse: Bool): @{FungibleToken.Vault} {
fun _swap(quote _: {DeFiActions.Quote}?, from: @{FungibleToken.Vault}, reverse: Bool): @{FungibleToken.Vault} {
let range = reverse
? InclusiveRange(self.swappers.length - 1, 0, step: -1)
: InclusiveRange(0, self.swappers.length - 1)
Expand Down
2 changes: 1 addition & 1 deletion cadence/contracts/connectors/evm/ERC4626SwapConnectors.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ access(all) contract ERC4626SwapConnectors {
///
/// @return A vault containing the original input tokens (not supported - always panics)
///
access(all) fun swapBack(quote: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
access(all) fun swapBack(quote _: {DeFiActions.Quote}?, residual _1: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
panic("ERC4626SwapConnectors.Swapper.swapBack() is not supported - ERC4626 Vaults do not support synchronous withdrawals")
}
/// Returns a ComponentInfo struct containing information about this component and a list of ComponentInfo for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ access(all) contract UniswapV2SwapConnectors {
///
access(self) fun swapExactTokensForTokens(
exactVaultIn: @{FungibleToken.Vault},
amountOutMin: UFix64,
amountOutMin _: UFix64,
reverse: Bool
): @{FungibleToken.Vault} {
let id = self.uniqueID?.id?.toString() ?? "UNASSIGNED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {

let pairPublicRef = self.getPairPublicRef()
let token0Key = SwapConfig.SliceTokenTypeIdentifierFromVaultType(vaultTypeIdentifier: self.token0Type.identifier)
let token1Key = SwapConfig.SliceTokenTypeIdentifierFromVaultType(vaultTypeIdentifier: self.token1Type.identifier)

if (!reverse) {
// Calculate how much to zap from token0 to token1
let zappedAmount = self.calculateZappedAmount(forProvided: forProvided, pairPublicRef: pairPublicRef)
Expand Down Expand Up @@ -309,7 +309,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
}

/// Converts inToken to LP token
access(all) fun swap(quote: {DeFiActions.Quote}?, inVault: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
access(all) fun swap(quote _: {DeFiActions.Quote}?, inVault: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
let pairPublicRef = self.getPairPublicRef()
let zappedAmount = self.calculateZappedAmount(forProvided: inVault.balance, pairPublicRef: pairPublicRef)

Expand All @@ -328,7 +328,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
}

/// Converts back LP token to inToken
access(all) fun swapBack(quote: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
access(all) fun swapBack(quote _: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
let pairPublicRef = self.getPairPublicRef()

// Remove liquidity
Expand Down Expand Up @@ -437,7 +437,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
let reserveAft1 = token1Reserve - amountOut
let ratioUser = (forProvided - midAmount) / amountOut
let ratioPool = reserveAft0 / reserveAft1
var ratioBias = 0.0

if (ratioUser >= ratioPool) {
if (ratioUser - ratioPool) <= SwapConfig.ufix64NonZeroMin {
break
Expand Down Expand Up @@ -629,7 +629,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
// Returns the maximum amount of LP tokens that can be minted
// It's bound by the reserves of token1 that can be swapped to token0
access(self) fun getMaxLpMintAmount(
pairPublicRef: &{SwapInterfaces.PairPublic},
pairPublicRef _: &{SwapInterfaces.PairPublic},
): UFix64 {
let quote = self.quoteOut(forProvided: UFix64.max, reverse: false)
return quote.outAmount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@ access(all) contract IncrementFiStakingConnectors {
return 0.0 // no capacity if the staking pool is not available
}

/// Withdraws rewards from the staking pool up to the specified maximum amount
/// Overflow rewards are sent to the appropriate overflow sinks if provided
/// Withdraws rewards from the staking pool up to the specified maximum amount.
/// Panics if the claimed rewards exceed maxAmount, as the staking pool does not support partial claims.
/// Callers must ensure maxAmount >= minimumAvailable() to avoid a panic.
///
/// @param maxAmount: The maximum amount of rewards to claim
/// @param maxAmount: The maximum amount of rewards to claim. The full reward balance is claimed and must not exceed this value.
/// @return a Vault containing the claimed rewards
///
access(FungibleToken.Withdraw) fun withdrawAvailable(maxAmount: UFix64): @{FungibleToken.Vault} {
Expand All @@ -245,10 +246,6 @@ access(all) contract IncrementFiStakingConnectors {

if let pool = IncrementFiStakingConnectors.borrowPool(pid: self.pid) {
if let userCertificate = self.userCertificate.borrow() {
let withdrawAmount = maxAmount < minimumAvailable
? maxAmount
: minimumAvailable

let rewards <- pool.claimRewards(userCertificate: userCertificate)
let targetSliceType = SwapConfig.SliceTokenTypeIdentifierFromVaultType(vaultTypeIdentifier: self.vaultType.identifier)

Expand All @@ -265,6 +262,10 @@ access(all) contract IncrementFiStakingConnectors {
)
let reward <- rewards.remove(key: rewards.keys[0])!
destroy rewards
assert(
reward.balance <= maxAmount,
message: "Claimed reward balance \(reward.balance) exceeds maxAmount \(maxAmount). The staking pool does not support partial claims — callers must ensure maxAmount >= minimumAvailable()."
)
return <- reward
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ access(all) contract IncrementFiSwapConnectors {
/// Performs a swap taking a Vault of type inVault, outputting a resulting outVault. Implementations may choose
/// to swap along a pre-set path or an optimal path of a set of paths or even set of contained Swappers adapted
/// to use multiple Flow swap protocols.
access(all) fun swap(quote: {DeFiActions.Quote}?, inVault: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
access(all) fun swap(quote _: {DeFiActions.Quote}?, inVault: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
let amountOut = self.quoteOut(forProvided: inVault.balance, reverse: false).outAmount
return <- SwapRouter.swapExactTokensForTokens(
exactVaultIn: <-inVault,
Expand All @@ -123,7 +123,7 @@ access(all) contract IncrementFiSwapConnectors {
/// Performs a swap taking a Vault of type outVault, outputting a resulting inVault. Implementations may choose
/// to swap along a pre-set path or an optimal path of a set of paths or even set of contained Swappers adapted
/// to use multiple Flow swap protocols.
access(all) fun swapBack(quote: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
access(all) fun swapBack(quote _: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
let amountOut = self.quoteOut(forProvided: residual.balance, reverse: true).outAmount
return <- SwapRouter.swapExactTokensForTokens(
exactVaultIn: <-residual,
Expand Down
Loading