Skip to content

Commit 56e84bf

Browse files
turbolentKay-Zeejribbinknialexsan
authored
Update to Flow CLI v2.15.3 (#152)
* update to Flow CLI v2.15.3 * Attempt to fix lint issues from running make lint * Panic when maxAmount exceeded in IncrementFiStakingConnectors (#155) --------- Co-authored-by: Kan Zhang <kan.zhang@flowfoundation.com> Co-authored-by: Jordan Ribbink <17958158+jribbink@users.noreply.github.com> Co-authored-by: Alex <12097569+nialexsan@users.noreply.github.com>
1 parent 6349695 commit 56e84bf

7 files changed

Lines changed: 25 additions & 20 deletions

File tree

.github/workflows/cadence_tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ jobs:
2323
path: ./imports
2424
key: flow-deps-${{ hashFiles('flow.json') }}
2525
- name: Install Flow CLI
26-
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.13.4
26+
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.15.3
2727
- name: Flow CLI Version
2828
run: flow version
29-
- name: Update PATH
30-
run: echo "/root/.local/bin" >> $GITHUB_PATH
29+
- name: Update PATH and show Flow version
30+
run: |
31+
echo "/root/.local/bin" >> $GITHUB_PATH
32+
echo "$HOME/.local/bin" >> $GITHUB_PATH
33+
which flow || true
34+
flow version
3135
- name: Install dependencies
3236
run: flow deps install --skip-alias --skip-deployments
3337
- name: Run tests

cadence/contracts/connectors/SwapConnectors.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ access(all) contract SwapConnectors {
505505
/// @return a Vault of type `outVault` containing the swapped currency.
506506
///
507507
access(self)
508-
fun _swap(quote: {DeFiActions.Quote}?, from: @{FungibleToken.Vault}, reverse: Bool): @{FungibleToken.Vault} {
508+
fun _swap(quote _: {DeFiActions.Quote}?, from: @{FungibleToken.Vault}, reverse: Bool): @{FungibleToken.Vault} {
509509
let range = reverse
510510
? InclusiveRange(self.swappers.length - 1, 0, step: -1)
511511
: InclusiveRange(0, self.swappers.length - 1)

cadence/contracts/connectors/evm/ERC4626SwapConnectors.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ access(all) contract ERC4626SwapConnectors {
289289
///
290290
/// @return A vault containing the original input tokens (not supported - always panics)
291291
///
292-
access(all) fun swapBack(quote: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
292+
access(all) fun swapBack(quote _: {DeFiActions.Quote}?, residual _1: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
293293
panic("ERC4626SwapConnectors.Swapper.swapBack() is not supported - ERC4626 Vaults do not support synchronous withdrawals")
294294
}
295295
/// Returns a ComponentInfo struct containing information about this component and a list of ComponentInfo for

cadence/contracts/connectors/evm/UniswapV2SwapConnectors.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ access(all) contract UniswapV2SwapConnectors {
201201
///
202202
access(self) fun swapExactTokensForTokens(
203203
exactVaultIn: @{FungibleToken.Vault},
204-
amountOutMin: UFix64,
204+
amountOutMin _: UFix64,
205205
reverse: Bool
206206
): @{FungibleToken.Vault} {
207207
let id = self.uniqueID?.id?.toString() ?? "UNASSIGNED"

cadence/contracts/connectors/increment-fi/IncrementFiPoolLiquidityConnectors.cdc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
245245

246246
let pairPublicRef = self.getPairPublicRef()
247247
let token0Key = SwapConfig.SliceTokenTypeIdentifierFromVaultType(vaultTypeIdentifier: self.token0Type.identifier)
248-
let token1Key = SwapConfig.SliceTokenTypeIdentifierFromVaultType(vaultTypeIdentifier: self.token1Type.identifier)
248+
249249
if (!reverse) {
250250
// Calculate how much to zap from token0 to token1
251251
let zappedAmount = self.calculateZappedAmount(forProvided: forProvided, pairPublicRef: pairPublicRef)
@@ -309,7 +309,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
309309
}
310310

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

@@ -328,7 +328,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
328328
}
329329

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

334334
// Remove liquidity
@@ -437,7 +437,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
437437
let reserveAft1 = token1Reserve - amountOut
438438
let ratioUser = (forProvided - midAmount) / amountOut
439439
let ratioPool = reserveAft0 / reserveAft1
440-
var ratioBias = 0.0
440+
441441
if (ratioUser >= ratioPool) {
442442
if (ratioUser - ratioPool) <= SwapConfig.ufix64NonZeroMin {
443443
break
@@ -629,7 +629,7 @@ access(all) contract IncrementFiPoolLiquidityConnectors {
629629
// Returns the maximum amount of LP tokens that can be minted
630630
// It's bound by the reserves of token1 that can be swapped to token0
631631
access(self) fun getMaxLpMintAmount(
632-
pairPublicRef: &{SwapInterfaces.PairPublic},
632+
pairPublicRef _: &{SwapInterfaces.PairPublic},
633633
): UFix64 {
634634
let quote = self.quoteOut(forProvided: UFix64.max, reverse: false)
635635
return quote.outAmount

cadence/contracts/connectors/increment-fi/IncrementFiStakingConnectors.cdc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@ access(all) contract IncrementFiStakingConnectors {
231231
return 0.0 // no capacity if the staking pool is not available
232232
}
233233

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

246247
if let pool = IncrementFiStakingConnectors.borrowPool(pid: self.pid) {
247248
if let userCertificate = self.userCertificate.borrow() {
248-
let withdrawAmount = maxAmount < minimumAvailable
249-
? maxAmount
250-
: minimumAvailable
251-
252249
let rewards <- pool.claimRewards(userCertificate: userCertificate)
253250
let targetSliceType = SwapConfig.SliceTokenTypeIdentifierFromVaultType(vaultTypeIdentifier: self.vaultType.identifier)
254251

@@ -265,6 +262,10 @@ access(all) contract IncrementFiStakingConnectors {
265262
)
266263
let reward <- rewards.remove(key: rewards.keys[0])!
267264
destroy rewards
265+
assert(
266+
reward.balance <= maxAmount,
267+
message: "Claimed reward balance \(reward.balance) exceeds maxAmount \(maxAmount). The staking pool does not support partial claims — callers must ensure maxAmount >= minimumAvailable()."
268+
)
268269
return <- reward
269270
}
270271
}

cadence/contracts/connectors/increment-fi/IncrementFiSwapConnectors.cdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ access(all) contract IncrementFiSwapConnectors {
111111
/// Performs a swap taking a Vault of type inVault, outputting a resulting outVault. Implementations may choose
112112
/// to swap along a pre-set path or an optimal path of a set of paths or even set of contained Swappers adapted
113113
/// to use multiple Flow swap protocols.
114-
access(all) fun swap(quote: {DeFiActions.Quote}?, inVault: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
114+
access(all) fun swap(quote _: {DeFiActions.Quote}?, inVault: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
115115
let amountOut = self.quoteOut(forProvided: inVault.balance, reverse: false).outAmount
116116
return <- SwapRouter.swapExactTokensForTokens(
117117
exactVaultIn: <-inVault,
@@ -123,7 +123,7 @@ access(all) contract IncrementFiSwapConnectors {
123123
/// Performs a swap taking a Vault of type outVault, outputting a resulting inVault. Implementations may choose
124124
/// to swap along a pre-set path or an optimal path of a set of paths or even set of contained Swappers adapted
125125
/// to use multiple Flow swap protocols.
126-
access(all) fun swapBack(quote: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
126+
access(all) fun swapBack(quote _: {DeFiActions.Quote}?, residual: @{FungibleToken.Vault}): @{FungibleToken.Vault} {
127127
let amountOut = self.quoteOut(forProvided: residual.balance, reverse: true).outAmount
128128
return <- SwapRouter.swapExactTokensForTokens(
129129
exactVaultIn: <-residual,

0 commit comments

Comments
 (0)