Skip to content
Draft
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 .github/workflows/cadence_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.0
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.0
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/incrementfi_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.0
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/punchswap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
cache-dependency-path: |
**/go.sum
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.0
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_rebalance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.14.2-evm-manipulation-poc.0
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
106 changes: 89 additions & 17 deletions cadence/contracts/FlowYieldVaultsStrategiesV1_1.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "UniswapV3SwapConnectors"
import "ERC4626SwapConnectors"
import "ERC4626Utils"
// Lending protocol
import "FlowALPv1"
import "FlowCreditMarket"
// FlowYieldVaults platform
import "FlowYieldVaults"
import "FlowYieldVaultsAutoBalancers"
Expand Down Expand Up @@ -76,15 +76,74 @@ access(all) contract FlowYieldVaultsStrategiesV1_1 {
/// An optional identifier allowing protocols to identify stacked connector operations by defining a protocol-
/// specific Identifier to associated connectors on construction
access(contract) var uniqueID: DeFiActions.UniqueIdentifier?
access(self) let position: @FlowALPv1.Position
access(self) let position: FlowCreditMarket.Position
access(self) var sink: {DeFiActions.Sink}
access(self) var source: {DeFiActions.Source}

init(id: DeFiActions.UniqueIdentifier, collateralType: Type, position: @FlowALPv1.Position) {
init(id: DeFiActions.UniqueIdentifier, collateralType: Type, position: FlowCreditMarket.Position) {
self.uniqueID = id
self.position = position
self.sink = position.createSink(type: collateralType)
self.source = position.createSourceWithOptions(type: collateralType, pullFromTopUpSource: true)
}

// Inherited from FlowYieldVaults.Strategy default implementation
// access(all) view fun isSupportedCollateralType(_ type: Type): Bool

access(all) view fun getSupportedCollateralTypes(): {Type: Bool} {
return { self.sink.getSinkType(): true }
}
/// Returns the amount available for withdrawal via the inner Source
access(all) fun availableBalance(ofToken: Type): UFix64 {
return ofToken == self.source.getSourceType() ? self.source.minimumAvailable() : 0.0
}
/// Deposits up to the inner Sink's capacity from the provided authorized Vault reference
access(all) fun deposit(from: auth(FungibleToken.Withdraw) &{FungibleToken.Vault}) {
self.sink.depositCapacity(from: from)
}
/// Withdraws up to the max amount, returning the withdrawn Vault. If the requested token type is unsupported,
/// an empty Vault is returned.
access(FungibleToken.Withdraw) fun withdraw(maxAmount: UFix64, ofToken: Type): @{FungibleToken.Vault} {
if ofToken != self.source.getSourceType() {
return <- DeFiActionsUtils.getEmptyVault(ofToken)
}
return <- self.source.withdrawAvailable(maxAmount: maxAmount)
}
/// Executed when a Strategy is burned, cleaning up the Strategy's stored AutoBalancer
access(contract) fun burnCallback() {
FlowYieldVaultsAutoBalancers._cleanupAutoBalancer(id: self.id()!)
}
access(all) fun getComponentInfo(): DeFiActions.ComponentInfo {
return DeFiActions.ComponentInfo(
type: self.getType(),
id: self.id(),
innerComponents: [
self.sink.getComponentInfo(),
self.source.getComponentInfo()
]
)
}
access(contract) view fun copyID(): DeFiActions.UniqueIdentifier? {
return self.uniqueID
}
access(contract) fun setID(_ id: DeFiActions.UniqueIdentifier?) {
self.uniqueID = id
}
}

access(all) resource FUSDEVStrategy : FlowYieldVaults.Strategy, DeFiActions.IdentifiableResource {
/// An optional identifier allowing protocols to identify stacked connector operations by defining a protocol-
/// specific Identifier to associated connectors on construction
access(contract) var uniqueID: DeFiActions.UniqueIdentifier?
access(self) let position: FlowCreditMarket.Position
access(self) var sink: {DeFiActions.Sink}
access(self) var source: {DeFiActions.Source}

init(id: DeFiActions.UniqueIdentifier, collateralType: Type, position: FlowCreditMarket.Position) {
self.uniqueID = id
self.position = position
self.sink = position.createSink(type: collateralType)
self.source = position.createSourceWithOptions(type: collateralType, pullFromTopUpSource: true)
self.position <-position
}

// Inherited from FlowYieldVaults.Strategy default implementation
Expand Down Expand Up @@ -279,7 +338,7 @@ access(all) contract FlowYieldVaultsStrategiesV1_1 {
)

// Open FlowCreditMarket position
let position <- self._openCreditPosition(
let position = self._openCreditPosition(
funds: <-withFunds,
issuanceSink: abaSwapSink,
repaymentSource: abaSwapSource
Expand All @@ -306,11 +365,22 @@ access(all) contract FlowYieldVaultsStrategiesV1_1 {
// Set AutoBalancer sink for overflow -> recollateralize
balancerIO.autoBalancer.setSink(positionSwapSink, updateSinkID: true)

return <-create FlowYieldVaultsStrategiesV1_1.mUSDFStrategy(
id: uniqueID,
collateralType: collateralType,
position: <-position
)
switch type {
case Type<@mUSDFStrategy>():
return <-create mUSDFStrategy(
id: uniqueID,
collateralType: collateralType,
position: position
)
case Type<@FUSDEVStrategy>():
return <-create FUSDEVStrategy(
id: uniqueID,
collateralType: collateralType,
position: position
)
default:
panic("Unsupported strategy type \(type.identifier)")
}
}

/* ===========================
Expand Down Expand Up @@ -478,22 +548,22 @@ access(all) contract FlowYieldVaultsStrategiesV1_1 {
funds: @{FungibleToken.Vault},
issuanceSink: {DeFiActions.Sink},
repaymentSource: {DeFiActions.Source}
): @FlowALPv1.Position {
): FlowCreditMarket.Position {
let poolCap = FlowYieldVaultsStrategiesV1_1.account.storage.copy<
Capability<auth(FlowALPv1.EParticipant, FlowALPv1.EPosition) &FlowALPv1.Pool>
>(from: FlowALPv1.PoolCapStoragePath)
Capability<auth(FlowCreditMarket.EParticipant, FlowCreditMarket.EPosition) &FlowCreditMarket.Pool>
>(from: FlowCreditMarket.PoolCapStoragePath)
?? panic("Missing or invalid pool capability")

let poolRef = poolCap.borrow() ?? panic("Invalid Pool Cap")

let position <- poolRef.createPosition(
let pid = poolRef.createPosition(
funds: <-funds,
issuanceSink: issuanceSink,
repaymentSource: repaymentSource,
pushToDrawDownSink: true
)

return <-position
return FlowCreditMarket.Position(id: pid, pool: poolCap)
}

access(self) fun _createYieldToCollateralSwapper(
Expand Down Expand Up @@ -671,7 +741,8 @@ access(all) contract FlowYieldVaultsStrategiesV1_1 {
access(Configure) fun purgeConfig() {
self.configs = {
Type<@mUSDFStrategyComposer>(): {
Type<@mUSDFStrategy>(): {} as {Type: FlowYieldVaultsStrategiesV1_1.CollateralConfig}
Type<@mUSDFStrategy>(): {} as {Type: FlowYieldVaultsStrategiesV1_1.CollateralConfig},
Type<@FUSDEVStrategy>(): {} as {Type: FlowYieldVaultsStrategiesV1_1.CollateralConfig}
}
}
}
Expand Down Expand Up @@ -757,7 +828,8 @@ access(all) contract FlowYieldVaultsStrategiesV1_1 {

let configs = {
Type<@mUSDFStrategyComposer>(): {
Type<@mUSDFStrategy>(): ({} as {Type: FlowYieldVaultsStrategiesV1_1.CollateralConfig})
Type<@mUSDFStrategy>(): {} as {Type: FlowYieldVaultsStrategiesV1_1.CollateralConfig},
Type<@FUSDEVStrategy>(): {} as {Type: FlowYieldVaultsStrategiesV1_1.CollateralConfig}
}
}
self.account.storage.save(<-create StrategyComposerIssuer(configs: configs), to: self.IssuerStoragePath)
Expand Down
Loading
Loading