Skip to content
Merged
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ To understand DeFiActions, start with these key files:
**Protocol Connectors:**
- [`IncrementFiSwapper`](cadence/contracts/connectors/increment-fi/IncrementFiSwapConnectors.cdc) - DEX integration for token swapping via IncrementFi
- [`BandPriceOracle`](cadence/contracts/connectors/bande-oracle/BandOracleConnectors.cdc) - Price feed integration with Band Protocol oracle
- [`EVMSwapper`](cadence/contracts/connectors/evm/UniswapV2SwapConnectors.cdc) - UniswapV2-style swapping on Flow EVM
- [`EVMSwapperV2`](cadence/contracts/connectors/evm/UniswapV2SwapConnectors.cdc) - UniswapV2-style swapping on Flow EVM
- [`EVMSwapperV3`](cadence/contracts/connectors/evm/UniswapV3SwapConnectors.cdc) - UniswapV3-style swapping on Flow EVM

### Usage Patterns

Additional usage patterns will be linked here once they become available.

## Documentation

- **FLIP Document**: DeFiActions FLIP - TBD
- **FLIP Document**: DeFiActions FLIP - TBD
5 changes: 3 additions & 2 deletions cadence/contracts/connectors/SwapConnectors.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ access(all) contract SwapConnectors {
return // nothing to swap from, no capacity to ingest, invalid Vault type - do nothing
}

let quote = self.swapper.quoteIn(forDesired: limit, reverse: false)
var quote = self.swapper.quoteIn(forDesired: limit, reverse: false)
let swapVault <- from.createEmptyVault()
if from.balance <= quote.inAmount {
// sink can accept all of the available tokens, so we swap everything
swapVault.deposit(from: <-from.withdraw(amount: from.balance))
quote = self.swapper.quoteIn(forDesired: from.balance, reverse: false)
} else {
// sink is limited to fewer tokens than we have available - swap the amount we need to meet the limit
swapVault.deposit(from: <-from.withdraw(amount: quote.inAmount))
Expand Down Expand Up @@ -411,4 +412,4 @@ access(all) contract SwapConnectors {
return <- self.swapper.swap(quote: quote, inVault: <-sourceLiquidity)
}
}
}
}
Loading