Skip to content

Commit 2d4ecb6

Browse files
authored
Merge pull request #38 from onflow/nialexsan/update-ref
update ref
2 parents 6024bab + 2b55fad commit 2d4ecb6

7 files changed

Lines changed: 83 additions & 43 deletions

File tree

DeFiActions

cadence/contracts/TidalProtocol.cdc

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ access(all) contract TidalProtocol {
17421742
/// be constructed from a Position object.
17431743
access(all) struct PositionSink: DeFiActions.Sink {
17441744
/// An optional DeFiActions.UniqueIdentifier that identifies this Sink with the DeFiActions stack its a part of
1745-
access(contract) let uniqueID: DeFiActions.UniqueIdentifier?
1745+
access(contract) var uniqueID: DeFiActions.UniqueIdentifier?
17461746
/// An authorized Capability on the Pool for which the related Position is in
17471747
access(self) let pool: Capability<auth(EPosition) &Pool>
17481748
/// The ID of the position in the Pool
@@ -1779,6 +1779,19 @@ access(all) contract TidalProtocol {
17791779
)
17801780
}
17811781
}
1782+
access(all) fun getComponentInfo(): DeFiActions.ComponentInfo {
1783+
return DeFiActions.ComponentInfo(
1784+
type: self.getType(),
1785+
id: self.id(),
1786+
innerComponents: []
1787+
)
1788+
}
1789+
access(contract) view fun copyID(): DeFiActions.UniqueIdentifier? {
1790+
return self.uniqueID
1791+
}
1792+
access(contract) fun setID(_ id: DeFiActions.UniqueIdentifier?) {
1793+
self.uniqueID = id
1794+
}
17821795
}
17831796

17841797
/// PositionSource
@@ -1788,7 +1801,7 @@ access(all) contract TidalProtocol {
17881801
///
17891802
access(all) struct PositionSource: DeFiActions.Source {
17901803
/// An optional DeFiActions.UniqueIdentifier that identifies this Sink with the DeFiActions stack its a part of
1791-
access(contract) let uniqueID: DeFiActions.UniqueIdentifier?
1804+
access(contract) var uniqueID: DeFiActions.UniqueIdentifier?
17921805
/// An authorized Capability on the Pool for which the related Position is in
17931806
access(self) let pool: Capability<auth(EPosition) &Pool>
17941807
/// The ID of the position in the Pool
@@ -1834,6 +1847,19 @@ access(all) contract TidalProtocol {
18341847
return <- DeFiActionsUtils.getEmptyVault(self.type)
18351848
}
18361849
}
1850+
access(all) fun getComponentInfo(): DeFiActions.ComponentInfo {
1851+
return DeFiActions.ComponentInfo(
1852+
type: self.getType(),
1853+
id: self.id(),
1854+
innerComponents: []
1855+
)
1856+
}
1857+
access(contract) view fun copyID(): DeFiActions.UniqueIdentifier? {
1858+
return self.uniqueID
1859+
}
1860+
access(contract) fun setID(_ id: DeFiActions.UniqueIdentifier?) {
1861+
self.uniqueID = id
1862+
}
18371863
}
18381864

18391865
/// BalanceDirection

cadence/contracts/mocks/MockOracle.cdc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ access(all) contract MockOracle {
1616
access(self) let bumpVariance: UInt16
1717

1818
access(all) struct PriceOracle : DeFiActions.PriceOracle {
19+
access(contract) var uniqueID: DeFiActions.UniqueIdentifier?
1920

21+
init() {
22+
self.uniqueID = nil
23+
}
2024
/// Returns the asset type serving as the price basis - e.g. USD in FLOW/USD
2125
access(all) view fun unitOfAccount(): Type {
2226
return MockOracle.unitOfAccount
@@ -29,6 +33,19 @@ access(all) contract MockOracle {
2933
}
3034
return MockOracle.mockedPrices[ofToken]
3135
}
36+
access(all) fun getComponentInfo(): DeFiActions.ComponentInfo {
37+
return DeFiActions.ComponentInfo(
38+
type: self.getType(),
39+
id: self.id(),
40+
innerComponents: []
41+
)
42+
}
43+
access(contract) view fun copyID(): DeFiActions.UniqueIdentifier? {
44+
return self.uniqueID
45+
}
46+
access(contract) fun setID(_ id: DeFiActions.UniqueIdentifier?) {
47+
self.uniqueID = id
48+
}
3249
}
3350

3451
// resets the price of the token within 0-bumpVariance (bps) of the current price
@@ -38,7 +55,7 @@ access(all) contract MockOracle {
3855
return
3956
}
4057
let current = self.mockedPrices[forToken]
41-
?? panic("MockOracle does not have a price set for token \(forToken.identifier)")
58+
?? panic("MockOracle does not have a price set for token \(forToken.identifier)")
4259
let sign = revertibleRandom<UInt8>(modulo: 2) // 0 - down | 1 - up
4360
let variance = self.convertToBPS(revertibleRandom<UInt16>(modulo: self.bumpVariance)) // bps up or down
4461
if sign == 0 {

cadence/tests/test_helpers.cdc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ fun deployContracts() {
9696
)
9797
Test.expect(err, Test.beNil())
9898

99-
// Deploy FungibleTokenStack
99+
// Deploy FungibleTokenConnectors
100100
err = Test.deployContract(
101-
name: "FungibleTokenStack",
102-
path: "../../DeFiActions/cadence/contracts/connectors/FungibleTokenStack.cdc",
101+
name: "FungibleTokenConnectors",
102+
path: "../../DeFiActions/cadence/contracts/connectors/FungibleTokenConnectors.cdc",
103103
arguments: []
104104
)
105105
Test.expect(err, Test.beNil())

cadence/tests/transactions/mock-tidal-protocol-consumer/create_wrapped_position.cdc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "FungibleToken"
22

33
import "DeFiActions"
4-
import "FungibleTokenStack"
4+
import "FungibleTokenConnectors"
55

66
import "MOET"
77
import "MockTidalProtocolConsumer"
@@ -12,7 +12,7 @@ import "MockTidalProtocolConsumer"
1212
/// MockTidalProtocolConsumer PositionWrapper
1313
///
1414
transaction(amount: UFix64, vaultStoragePath: StoragePath, pushToDrawDownSink: Bool) {
15-
15+
1616
// the funds that will be used as collateral for a TidalProtocol loan
1717
let collateral: @{FungibleToken.Vault}
1818
// this DeFiActions Sink that will receive the loaned funds
@@ -37,21 +37,21 @@ transaction(amount: UFix64, vaultStoragePath: StoragePath, pushToDrawDownSink: B
3737
let depositVaultCap = signer.capabilities.get<&{FungibleToken.Vault}>(MOET.VaultPublicPath)
3838
let withdrawVaultCap = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>(MOET.VaultStoragePath)
3939
assert(depositVaultCap.check(),
40-
message: "Invalid MOET Vault public Capability issued - ensure the Vault is properly configured")
40+
message: "Invalid MOET Vault public Capability issued - ensure the Vault is properly configured")
4141
assert(withdrawVaultCap.check(),
42-
message: "Invalid MOET Vault private Capability issued - ensure the Vault is properly configured")
43-
42+
message: "Invalid MOET Vault private Capability issued - ensure the Vault is properly configured")
43+
4444
// withdraw the collateral from the signer's stored Vault
4545
let collateralSource = signer.storage.borrow<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>(from: vaultStoragePath)
46-
?? panic("Could not borrow reference to Vault from \(vaultStoragePath)")
46+
?? panic("Could not borrow reference to Vault from \(vaultStoragePath)")
4747
self.collateral <- collateralSource.withdraw(amount: amount)
4848
// construct the DeFiActions Sink that will receive the loaned amount
49-
self.sink = FungibleTokenStack.VaultSink(
49+
self.sink = FungibleTokenConnectors.VaultSink(
5050
max: nil,
5151
depositVault: depositVaultCap,
5252
uniqueID: nil
5353
)
54-
self.source = FungibleTokenStack.VaultSource(
54+
self.source = FungibleTokenConnectors.VaultSource(
5555
min: nil,
5656
withdrawVault: withdrawVaultCap,
5757
uniqueID: nil

cadence/tests/transactions/mock-tidal-protocol-consumer/deposit_to_wrapped_position.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "FungibleToken"
22

3-
import "FungibleTokenStack"
3+
import "FungibleTokenConnectors"
44

55
import "MOET"
66
import "TidalProtocol"

flow.json

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
{
22
"contracts": {
3-
"FungibleTokenStack": {
4-
"source": "./DeFiActions/cadence/contracts/connectors/FungibleTokenStack.cdc",
5-
"aliases": {
6-
"testing": "0x0000000000000006"
7-
}
8-
},
93
"DeFiActions": {
104
"source": "./DeFiActions/cadence/contracts/interfaces/DeFiActions.cdc",
115
"aliases": {
12-
"testing": "0x0000000000000006"
6+
"testing": "0000000000000006"
137
}
148
},
159
"DeFiActionsMathUtils": {
1610
"source": "./DeFiActions/cadence/contracts/utils/DeFiActionsMathUtils.cdc",
1711
"aliases": {
18-
"testing": "0x0000000000000006"
12+
"testing": "0000000000000006"
1913
}
2014
},
2115
"DeFiActionsUtils": {
2216
"source": "./DeFiActions/cadence/contracts/utils/DeFiActionsUtils.cdc",
2317
"aliases": {
24-
"testing": "0x0000000000000006"
18+
"testing": "0000000000000006"
19+
}
20+
},
21+
"FungibleTokenConnectors": {
22+
"source": "./DeFiActions/cadence/contracts/connectors/FungibleTokenConnectors.cdc",
23+
"aliases": {
24+
"testing": "0000000000000006"
25+
}
26+
},
27+
"MOET": {
28+
"source": "./cadence/contracts/MOET.cdc",
29+
"aliases": {
30+
"testing": "0000000000000007"
2531
}
2632
},
2733
"MockOracle": {
2834
"source": "./cadence/contracts/mocks/MockOracle.cdc",
2935
"aliases": {
30-
"testing": "0x0000000000000007"
36+
"testing": "0000000000000007"
3137
}
3238
},
3339
"MockTidalProtocolConsumer": {
3440
"source": "./cadence/contracts/mocks/MockTidalProtocolConsumer.cdc",
3541
"aliases": {
36-
"testing": "0x0000000000000007"
42+
"testing": "0000000000000007"
3743
}
3844
},
3945
"MockYieldToken": {
4046
"source": "./cadence/contracts/mocks/MockYieldToken.cdc",
4147
"aliases": {
42-
"testing": "0x0000000000000007"
48+
"testing": "0000000000000007"
4349
}
4450
},
4551
"TidalProtocol": {
4652
"source": "./cadence/contracts/TidalProtocol.cdc",
4753
"aliases": {
48-
"testing": "0x0000000000000007"
49-
}
50-
},
51-
"MOET": {
52-
"source": "./cadence/contracts/MOET.cdc",
53-
"aliases": {
54-
"testing": "0x0000000000000007"
54+
"testing": "0000000000000007"
5555
}
5656
}
5757
},
@@ -94,12 +94,11 @@
9494
},
9595
"MetadataViews": {
9696
"source": "mainnet://1d7e57aa55817448.MetadataViews",
97-
"hash": "10a239cc26e825077de6c8b424409ae173e78e8391df62750b6ba19ffd048f51",
97+
"hash": "9032f46909e729d26722cbfcee87265e4f81cd2912e936669c0e6b510d007e81",
9898
"aliases": {
9999
"emulator": "f8d6e0586b0a20c7",
100100
"mainnet": "1d7e57aa55817448",
101-
"testnet": "631e88ae7f1d7c20",
102-
"testing": "0x0000000000000001"
101+
"testnet": "631e88ae7f1d7c20"
103102
}
104103
},
105104
"NonFungibleToken": {
@@ -108,8 +107,7 @@
108107
"aliases": {
109108
"emulator": "f8d6e0586b0a20c7",
110109
"mainnet": "1d7e57aa55817448",
111-
"testnet": "631e88ae7f1d7c20",
112-
"testing": "0x0000000000000001"
110+
"testnet": "631e88ae7f1d7c20"
113111
}
114112
},
115113
"ViewResolver": {
@@ -118,8 +116,7 @@
118116
"aliases": {
119117
"emulator": "f8d6e0586b0a20c7",
120118
"mainnet": "1d7e57aa55817448",
121-
"testnet": "631e88ae7f1d7c20",
122-
"testing": "0x0000000000000001"
119+
"testnet": "631e88ae7f1d7c20"
123120
}
124121
}
125122
},
@@ -157,4 +154,4 @@
157154
]
158155
}
159156
}
160-
}
157+
}

0 commit comments

Comments
 (0)