Skip to content

Commit 9d78192

Browse files
authored
Merge pull request #39 from onflow/gio/dfa-rename-followup
Rename DeFiBlocks (DFB) references to DeFiActions (DFA)
2 parents 78fc8b9 + ade6a41 commit 9d78192

17 files changed

Lines changed: 128 additions & 130 deletions

.gitmodules

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
[submodule "lib/DeFiBlocks"]
2-
path = lib/DeFiBlocks
3-
url = git@github.com:onflow/DeFiBlocks.git
4-
branch = main
51
[submodule "lib/TidalProtocol"]
62
path = lib/TidalProtocol
73
url = git@github.com:onflow/TidalProtocol.git
8-
branch = tracer-bullet
4+
branch = main
5+
[submodule "lib/DeFiActions"]
6+
path = lib/DeFiActions
7+
url = git@github.com:onflow/DeFiActions.git

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tidal Smart Contracts
22

3-
Tidal is a yield farming platform built on the Flow blockchain using Cadence 1.0. The platform enables users to deposit tokens to supported DeFi strategies such as collateralized borrowing via TidalProtocol's Active Lending Platform. Tidal aims to support yield-generating strategies, automatically optimizing returns through DeFiBlocks components and auto-balancing mechanisms.
3+
Tidal is a yield farming platform built on the Flow blockchain using Cadence 1.0. The platform enables users to deposit tokens to supported DeFi strategies such as collateralized borrowing via TidalProtocol's Active Lending Platform. Tidal aims to support yield-generating strategies, automatically optimizing returns through DeFiActions components and auto-balancing mechanisms.
44

55
## System Architecture
66

@@ -21,7 +21,7 @@ The main contract that orchestrates the entire yield farming system:
2121
Implements specific yield strategies:
2222

2323
- **TracerStrategy**: A strategy that uses TidalProtocol lending positions with auto-balancing
24-
- **TracerStrategyComposer**: Creates TracerStrategy instances with complex DeFiBlocks stacking
24+
- **TracerStrategyComposer**: Creates TracerStrategy instances with complex DeFiActions stacking
2525
- **StrategyComposerIssuer**: Controls access to strategy composer creation
2626

2727
#### 3. TidalYieldAutoBalancers.cdc - Auto-Balancing System
@@ -43,7 +43,7 @@ Mock FungibleToken implementations representing:
4343
#### MockOracle.cdc
4444
- Provides price feeds for testing and demonstrations
4545
- Supports price manipulation for testing scenarios
46-
- Implements DFB.PriceOracle interface
46+
- Implements DeFiActions.PriceOracle interface
4747

4848
#### MockSwapper.cdc
4949
- Simulates token swapping functionality
@@ -55,7 +55,7 @@ Mock FungibleToken implementations representing:
5555
Below is an overview of the initial prototype Tracer Strategy in the broader context of TidalProtocol and the Tidal platform.
5656

5757
### 1. Strategy Architecture
58-
The TracerStrategy demonstrates the power of DeFiBlocks composition:
58+
The TracerStrategy demonstrates the power of DeFiActions composition:
5959

6060
```
6161
User Deposit (FLOW) → TidalProtocol Position → MOET Issuance → Swap to YieldToken → AutoBalancer
@@ -69,8 +69,8 @@ User Deposit (FLOW) → TidalProtocol Position → MOET Issuance → Swap to Yie
6969
- Excess value flows into position recollateralization
7070
- Insufficient value triggers position adjustments
7171

72-
### 3. DeFiBlocks Integration
73-
The system heavily uses DeFiBlocks components:
72+
### 3. DeFiActions Integration
73+
The system heavily uses DeFiActions components:
7474
- **Sinks**: Accept token deposits
7575
- **Sources**: Provide token withdrawals
7676
- **Swappers**: Handle token conversions
@@ -248,9 +248,9 @@ Users can track their position status by comparing:
248248
3. **Yield Optimization**: Continuously adjusts to market conditions
249249
4. **User Experience**: No manual intervention required for position maintenance
250250

251-
### Integration with DeFiBlocks
251+
### Integration with DeFiActions
252252

253-
The rebalancing system leverages DeFiBlocks components:
253+
The rebalancing system leverages DeFiActions components:
254254

255255
- **Sinks**: Route tokens into rebalancing flows
256256
- **Sources**: Extract tokens for rebalancing operations
@@ -704,7 +704,7 @@ The TracerStrategy leverages this health system:
704704
#### Top-Up Source Integration
705705
```cadence
706706
// Position structure includes automatic top-up capability
707-
access(EImplementation) var topUpSource: {DFB.Source}?
707+
access(EImplementation) var topUpSource: {DeFiActions.Source}?
708708
```
709709

710710
### Oracle Price Integration
@@ -1441,7 +1441,7 @@ This testing framework allows you to validate that the rebalancing system correc
14411441
## Key Features
14421442

14431443
### 1. Composable Strategies
1444-
- Strategies are built by composing DeFiBlocks components
1444+
- Strategies are built by composing DeFiActions components
14451445
- Each strategy can have different risk/reward profiles
14461446
- New strategies can be added by implementing the Strategy interface
14471447

cadence/contracts/TidalYield.cdc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import "FungibleToken"
33
import "Burner"
44
import "ViewResolver"
5-
// DeFiBlocks
6-
import "DFB"
5+
// DeFiActions
6+
import "DeFiActions"
77

88
/// THIS CONTRACT IS A MOCK AND IS NOT INTENDED FOR USE IN PRODUCTION
99
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -34,28 +34,28 @@ access(all) contract TidalYield {
3434
/// Strategy
3535
///
3636
/// A Strategy is meant to encapsulate the Sink/Source entrypoints allowing for flows into and out of stacked
37-
/// DeFiBlocks components. These compositions are intended to capitalize on some yield-bearing opportunity so that
37+
/// DeFiActions components. These compositions are intended to capitalize on some yield-bearing opportunity so that
3838
/// a Strategy bears yield on that which is deposited into it, albeit not without some risk. A Strategy then can be
39-
/// thought of as the top-level of a nesting of DeFiBlocks connectors & adapters where one can deposit & withdraw
39+
/// thought of as the top-level of a nesting of DeFiActions connectors & adapters where one can deposit & withdraw
4040
/// funds into the composed DeFi workflows.
4141
///
42-
/// While two types of strategies may not highly differ with respect to their fields, the stacking of DeFiBlocks
42+
/// While two types of strategies may not highly differ with respect to their fields, the stacking of DeFiActions
4343
/// components & connections they provide access to likely do. This difference in wiring is why the Strategy is a
4444
/// resource - because the Type and uniqueness of composition of a given Strategy must be preserved as that is its
4545
/// distinguishing factor. These qualities are preserved by restricting the party who can construct it, which for
4646
/// resources is within the contract that defines it.
4747
///
4848
/// TODO: Consider making Sink/Source multi-asset - we could then make Strategy a composite Sink, Source & do away
4949
/// with the added layer of abstraction introduced by a StrategyComposer.
50-
access(all) resource interface Strategy : DFB.IdentifiableResource, Burner.Burnable {
50+
access(all) resource interface Strategy : DeFiActions.IdentifiableResource, Burner.Burnable {
5151
/// Returns the type of Vaults that this Strategy instance can handle
5252
access(all) view fun getSupportedCollateralTypes(): {Type: Bool}
5353
/// Returns whether the provided Vault type is supported by this Strategy instance
5454
access(all) view fun isSupportedCollateralType(_ type: Type): Bool {
5555
return self.getSupportedCollateralTypes()[type] ?? false
5656
}
5757
/// Returns the balance of the given token available for withdrawal. Note that this may be an estimate due to
58-
/// the lack of guarantees inherent to DeFiBlocks Sources
58+
/// the lack of guarantees inherent to DeFiActions Sources
5959
access(all) fun availableBalance(ofToken: Type): UFix64
6060
/// Deposits up to the balance of the referenced Vault into this Strategy
6161
access(all) fun deposit(from: auth(FungibleToken.Withdraw) &{FungibleToken.Vault}) {
@@ -75,10 +75,10 @@ access(all) contract TidalYield {
7575

7676
/// StrategyComposer
7777
///
78-
/// A StrategyComposer is responsible for stacking DeFiBlocks connectors in a manner that composes a final Strategy.
79-
/// Since DeFiBlock Sink/Source only support single assets and some Strategies may be multi-asset, we deal with
80-
/// building a Strategy distinctly from encapsulating the top-level DFB connectors acting as entrypoints in to the
81-
/// DeFiBlocks stack.
78+
/// A StrategyComposer is responsible for stacking DeFiActions connectors in a manner that composes a final Strategy.
79+
/// Since DeFiActions Sink/Source only support single assets and some Strategies may be multi-asset, we deal with
80+
/// building a Strategy distinctly from encapsulating the top-level DFA connectors acting as entrypoints in to the
81+
/// DeFiActions stack.
8282
///
8383
/// TODO: Consider making Sink/Source multi-asset - we could then make Strategy a composite Sink, Source & do away
8484
/// with the added layer of abstraction introduced by a StrategyComposer.
@@ -93,7 +93,7 @@ access(all) contract TidalYield {
9393
/// Composes a Strategy of the given type with the provided funds
9494
access(all) fun createStrategy(
9595
_ type: Type,
96-
uniqueID: DFB.UniqueIdentifier,
96+
uniqueID: DeFiActions.UniqueIdentifier,
9797
withFunds: @{FungibleToken.Vault}
9898
): @{Strategy} {
9999
pre {
@@ -131,10 +131,10 @@ access(all) contract TidalYield {
131131
?.getSupportedInstanceVaults(forStrategy: forStrategy, initializedWith: initializedWith)
132132
?? {}
133133
}
134-
/// Initializes a new Strategy of the given type with the provided Vault, identifying all associated DeFiBlocks
134+
/// Initializes a new Strategy of the given type with the provided Vault, identifying all associated DeFiActions
135135
/// components by the provided UniqueIdentifier
136136
access(all)
137-
fun createStrategy(_ type: Type, uniqueID: DFB.UniqueIdentifier, withFunds: @{FungibleToken.Vault}): @{Strategy} {
137+
fun createStrategy(_ type: Type, uniqueID: DeFiActions.UniqueIdentifier, withFunds: @{FungibleToken.Vault}): @{Strategy} {
138138
pre {
139139
self.composers[type] != nil: "Strategy \(type.identifier) is unsupported"
140140
}
@@ -193,15 +193,15 @@ access(all) contract TidalYield {
193193
/// A Tide is a resource enabling the management of a composed Strategy
194194
///
195195
access(all) resource Tide : Burner.Burnable, FungibleToken.Receiver, ViewResolver.Resolver {
196-
/// The UniqueIdentifier that identifies all related DeFiBlocks connectors used in the encapsulated Strategy
197-
access(contract) let uniqueID: DFB.UniqueIdentifier
196+
/// The UniqueIdentifier that identifies all related DeFiActions connectors used in the encapsulated Strategy
197+
access(contract) let uniqueID: DeFiActions.UniqueIdentifier
198198
/// The type of Vault this Tide can receive as a deposit and provides as a withdrawal
199199
access(self) let vaultType: Type
200-
/// The Strategy granting top-level access to the yield-bearing DeFiBlocks stack
200+
/// The Strategy granting top-level access to the yield-bearing DeFiActions stack
201201
access(self) var strategy: @{Strategy}?
202202

203203
init(strategyType: Type, withVault: @{FungibleToken.Vault}) {
204-
self.uniqueID = DFB.UniqueIdentifier()
204+
self.uniqueID = DeFiActions.UniqueIdentifier()
205205
self.vaultType = withVault.getType()
206206
let _strategy <- TidalYield.createStrategy(
207207
type: strategyType,
@@ -213,7 +213,7 @@ access(all) contract TidalYield {
213213
self.strategy <-_strategy
214214
}
215215

216-
/// Returns the Tide's ID as defined by it's DFB.UniqueIdentifier.id
216+
/// Returns the Tide's ID as defined by it's DeFiActions.UniqueIdentifier.id
217217
access(all) view fun id(): UInt64 {
218218
return self.uniqueID.id
219219
}
@@ -402,7 +402,7 @@ access(all) contract TidalYield {
402402
return self._borrowFactory().getSupportedInstanceVaults(forStrategy: forStrategy, initializedWith: initializedWith)
403403
}
404404
/// Creates a Strategy of the requested Type using the provided Vault as an initial deposit
405-
access(all) fun createStrategy(type: Type, uniqueID: DFB.UniqueIdentifier, withFunds: @{FungibleToken.Vault}): @{Strategy} {
405+
access(all) fun createStrategy(type: Type, uniqueID: DeFiActions.UniqueIdentifier, withFunds: @{FungibleToken.Vault}): @{Strategy} {
406406
return <- self._borrowFactory().createStrategy(type, uniqueID: uniqueID, withFunds: <-withFunds)
407407
}
408408
/// Creates a TideManager used to create and manage Tides

cadence/contracts/TidalYieldAutoBalancers.cdc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// standards
22
import "Burner"
33
import "FungibleToken"
4-
// DeFiBlocks
5-
import "DFB"
4+
// DeFiActions
5+
import "DeFiActions"
66

77
/// TidalYieldAutoBalancers
88
///
9-
/// This contract deals with the storage, retrieval and cleanup of DeFiBlocks AutoBalancers as they are used in
9+
/// This contract deals with the storage, retrieval and cleanup of DeFiActions AutoBalancers as they are used in
1010
/// TidalYield defined Strategies.
1111
///
12-
/// AutoBalancers are stored in contract account storage at paths derived by their related DFB.UniqueIdentifier.id
13-
/// which identifies all DeFiBlocks components in the stack related to their composite Strategy.
12+
/// AutoBalancers are stored in contract account storage at paths derived by their related DeFiActions.UniqueIdentifier.id
13+
/// which identifies all DeFiActions components in the stack related to their composite Strategy.
1414
///
1515
/// When a Tide and necessarily the related Strategy is closed & burned, the related AutoBalancer and its Capabilities
1616
/// are destroyed and deleted
@@ -30,24 +30,24 @@ access(all) contract TidalYieldAutoBalancers {
3030

3131
/// Returns an unauthorized reference to an AutoBalancer with the given UniqueIdentifier.id value. If none is
3232
/// configured, `nil` will be returned.
33-
access(all) fun borrowAutoBalancer(id: UInt64): &DFB.AutoBalancer? {
33+
access(all) fun borrowAutoBalancer(id: UInt64): &DeFiActions.AutoBalancer? {
3434
let publicPath = self.deriveAutoBalancerPath(id: id, storage: false) as! PublicPath
35-
return self.account.capabilities.borrow<&DFB.AutoBalancer>(publicPath)
35+
return self.account.capabilities.borrow<&DeFiActions.AutoBalancer>(publicPath)
3636
}
3737

3838
/* --- INTERNAL METHODS --- */
3939

4040
/// Configures a new AutoBalancer in storage, configures its public Capability, and sets its inner authorized
4141
/// Capability. If an AutoBalancer is stored with an associated UniqueID value, the operation reverts.
4242
access(account) fun _initNewAutoBalancer(
43-
oracle: {DFB.PriceOracle},
43+
oracle: {DeFiActions.PriceOracle},
4444
vaultType: Type,
4545
lowerThreshold: UFix64,
4646
upperThreshold: UFix64,
47-
rebalanceSink: {DFB.Sink}?,
48-
rebalanceSource: {DFB.Source}?,
49-
uniqueID: DFB.UniqueIdentifier
50-
): auth(DFB.Auto, DFB.Set, DFB.Get, FungibleToken.Withdraw) &DFB.AutoBalancer {
47+
rebalanceSink: {DeFiActions.Sink}?,
48+
rebalanceSource: {DeFiActions.Source}?,
49+
uniqueID: DeFiActions.UniqueIdentifier
50+
): auth(DeFiActions.Auto, DeFiActions.Set, DeFiActions.Get, FungibleToken.Withdraw) &DeFiActions.AutoBalancer {
5151

5252
// derive paths & prevent collision
5353
let storagePath = self.deriveAutoBalancerPath(id: uniqueID.id, storage: true) as! StoragePath
@@ -60,7 +60,7 @@ access(all) contract TidalYieldAutoBalancers {
6060
message: "Published Capability collision found when publishing AutoBalancer for UniqueIdentifier.id \(uniqueID.id) at path \(publicPath)")
6161

6262
// create & save AutoBalancer
63-
let autoBalancer <- DFB.createAutoBalancer(
63+
let autoBalancer <- DeFiActions.createAutoBalancer(
6464
oracle: oracle,
6565
vaultType: vaultType,
6666
lowerThreshold: lowerThreshold,
@@ -73,17 +73,17 @@ access(all) contract TidalYieldAutoBalancers {
7373
let autoBalancerRef = self._borrowAutoBalancer(uniqueID.id)
7474

7575
// issue & publish public capability
76-
let publicCap = self.account.capabilities.storage.issue<&DFB.AutoBalancer>(storagePath)
76+
let publicCap = self.account.capabilities.storage.issue<&DeFiActions.AutoBalancer>(storagePath)
7777
self.account.capabilities.publish(publicCap, at: publicPath)
7878

7979
// issue private capability & set within AutoBalancer
80-
let authorizedCap = self.account.capabilities.storage.issue<auth(FungibleToken.Withdraw) &DFB.AutoBalancer>(storagePath)
80+
let authorizedCap = self.account.capabilities.storage.issue<auth(FungibleToken.Withdraw) &DeFiActions.AutoBalancer>(storagePath)
8181
autoBalancerRef.setSelfCapability(authorizedCap)
8282

8383
// ensure proper configuration before closing
8484
storedType = self.account.storage.type(at: storagePath)
8585
publishedCap = self.account.capabilities.exists(publicPath)
86-
assert(storedType == Type<@DFB.AutoBalancer>(),
86+
assert(storedType == Type<@DeFiActions.AutoBalancer>(),
8787
message: "Error when configuring AutoBalancer for UniqueIdentifier.id \(uniqueID.id) at path \(storagePath)")
8888
assert(publishedCap,
8989
message: "Error when publishing AutoBalancer Capability for UniqueIdentifier.id \(uniqueID.id) at path \(publicPath)")
@@ -93,9 +93,9 @@ access(all) contract TidalYieldAutoBalancers {
9393
/// Returns an authorized reference on the AutoBalancer with the associated UniqueIdentifier.id. If none is found,
9494
/// the operation reverts.
9595
access(account)
96-
fun _borrowAutoBalancer(_ id: UInt64): auth(DFB.Auto, DFB.Set, DFB.Get, FungibleToken.Withdraw) &DFB.AutoBalancer {
96+
fun _borrowAutoBalancer(_ id: UInt64): auth(DeFiActions.Auto, DeFiActions.Set, DeFiActions.Get, FungibleToken.Withdraw) &DeFiActions.AutoBalancer {
9797
let storagePath = self.deriveAutoBalancerPath(id: id, storage: true) as! StoragePath
98-
return self.account.storage.borrow<auth(DFB.Auto, DFB.Set, DFB.Get, FungibleToken.Withdraw) &DFB.AutoBalancer>(
98+
return self.account.storage.borrow<auth(DeFiActions.Auto, DeFiActions.Set, DeFiActions.Get, FungibleToken.Withdraw) &DeFiActions.AutoBalancer>(
9999
from: storagePath
100100
) ?? panic("Could not borrow reference to AutoBalancer with UniqueIdentifier.id \(id) from StoragePath \(storagePath)")
101101
}
@@ -113,7 +113,7 @@ access(all) contract TidalYieldAutoBalancers {
113113
return true
114114
})
115115
// load & burn the AutoBalancer
116-
let autoBalancer <-self.account.storage.load<@DFB.AutoBalancer>(from: storagePath)
116+
let autoBalancer <-self.account.storage.load<@DeFiActions.AutoBalancer>(from: storagePath)
117117
Burner.burn(<-autoBalancer)
118118
}
119119

0 commit comments

Comments
 (0)