-
Notifications
You must be signed in to change notification settings - Fork 3
Fixed unfinished TODOs #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mts1715
wants to merge
5
commits into
main
Choose a base branch
from
taras/110-fix-unfinished-todos
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dc399de
Implement recovery logic in ERC4626SinkConnectors when EVM calls fail;
mts1715 b0aa9e5
review fixes
mts1715 3f4e26b
Update More-Vaults submodule to valid commit from new repository
mts1715 72af31c
Merge remote-tracking branch 'origin/main' into taras/110-fix-unfinis…
mts1715 5a972ad
Merge remote-tracking branch 'origin/main' into taras/110-fix-unfinis…
mts1715 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
cadence/tests/transactions/erc4626-sink-connectors/deposit_to_paused_vault.cdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import "FungibleToken" | ||
| import "FungibleTokenMetadataViews" | ||
| import "MetadataViews" | ||
| import "FlowToken" | ||
| import "EVM" | ||
| import "FlowEVMBridgeConfig" | ||
| import "FlowEVMBridgeUtils" | ||
| import "DeFiActions" | ||
| import "FungibleTokenConnectors" | ||
| import "ERC4626SinkConnectors" | ||
|
|
||
| /// Test transaction that attempts to deposit to a paused ERC4626 vault. When the vault is paused, either: | ||
| /// - minimumCapacity() returns 0 (if maxDeposit is guarded by pause) → no-op, balance unchanged | ||
| /// - deposit() reverts → recovery bridges tokens back, balance approximately unchanged | ||
| /// | ||
| /// In both cases the transaction succeeds without panic and no shares are gained. | ||
| /// | ||
| transaction(amount: UFix64, assetVaultIdentifier: String, erc4626VaultEVMAddressHex: String) { | ||
| let assetVault: auth(FungibleToken.Withdraw) &{FungibleToken.Vault} | ||
| let sink: {DeFiActions.Sink} | ||
| let beforeBalance: UFix64 | ||
|
|
||
| prepare(signer: auth(BorrowValue, IssueStorageCapabilityController, SaveValue, PublishCapability, UnpublishCapability) &Account) { | ||
| let assetVaultType = CompositeType(assetVaultIdentifier) | ||
| ?? panic("Invalid deposit token identifier: \(assetVaultIdentifier)") | ||
| let erc4626VaultEVMAddress = EVM.addressFromString(erc4626VaultEVMAddressHex) | ||
|
|
||
| let assetVaultData = MetadataViews.resolveContractViewFromTypeIdentifier( | ||
| resourceTypeIdentifier: assetVaultIdentifier, | ||
| viewType: Type<FungibleTokenMetadataViews.FTVaultData>() | ||
| ) as? FungibleTokenMetadataViews.FTVaultData | ||
| ?? panic("Could not resolve FTVaultData for \(assetVaultType.identifier)") | ||
| self.assetVault = signer.storage.borrow<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>(from: assetVaultData.storagePath) | ||
| ?? panic("Could not find asset Vault in signer's storage at path \(assetVaultData.storagePath)") | ||
|
|
||
| let coaPath = /storage/evm | ||
| let coa = signer.capabilities.storage.issue<auth(EVM.Call, EVM.Bridge) &EVM.CadenceOwnedAccount>(coaPath) | ||
|
|
||
| let feeVault = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>( | ||
| /storage/flowTokenVault | ||
| ) | ||
| let feeSource = FungibleTokenConnectors.VaultSinkAndSource( | ||
| min: nil, | ||
| max: nil, | ||
| vault: feeVault, | ||
| uniqueID: nil | ||
| ) | ||
|
|
||
| self.sink = ERC4626SinkConnectors.AssetSink( | ||
| asset: assetVaultType, | ||
| vault: erc4626VaultEVMAddress, | ||
| coa: coa, | ||
| feeSource: feeSource, | ||
| uniqueID: DeFiActions.createUniqueIdentifier() | ||
| ) | ||
|
|
||
| self.beforeBalance = self.assetVault.balance | ||
| } | ||
|
|
||
| execute { | ||
| self.sink.depositCapacity(from: self.assetVault) | ||
|
|
||
| // After a paused deposit, balance should be restored (either no-op or recovery). | ||
| // Allow small rounding tolerance from the bridge round-trip conversion. | ||
| let afterBalance = self.assetVault.balance | ||
| let tolerance: UFix64 = 0.00000001 | ||
| assert( | ||
| afterBalance >= self.beforeBalance - tolerance, | ||
| message: "Asset balance dropped unexpectedly: before=\(self.beforeBalance) after=\(afterBalance)" | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we require that the recovered amount is exactly as expected? Otherwise this still has the possibility of leaving excess tokens in the EVM state.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will add