Skip to content

Commit 1e7a0aa

Browse files
authored
document that source's claimed type is not trustworthy (#146)
1 parent 78ee361 commit 1e7a0aa

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

cadence/contracts/interfaces/DeFiActions.cdc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,17 @@ access(all) contract DeFiActions {
294294
/// graceful fallback on unexpected conditions, executing no-ops or returning an empty Vault instead of reverting.
295295
///
296296
access(all) struct interface Source : IdentifiableStruct {
297-
/// Returns the Vault type provided by this Source
297+
/// Returns the Vault type the Source claims to offer.
298+
/// CAUTION: Untrusted Source implementations may return a different Vault type than claimed in `withdrawAvailable`.
299+
/// Users MUST validate the type of all withdrawn funds.
298300
access(all) view fun getSourceType(): Type
299-
/// Returns an estimate of how much of the associated Vault Type can be provided by this Source
301+
/// Returns an estimate of how much of the associated Vault Type can be provided by this Source.
300302
access(all) fun minimumAvailable(): UFix64
301-
/// Withdraws the lesser of maxAmount or minimumAvailable(). If none is available, an empty Vault should be
302-
/// returned
303+
/// Withdraws the lesser of maxAmount or minimumAvailable(). If none is available, an empty Vault should be returned.
304+
/// CAUTION: Untrusted Source implementations may return a different Vault type than claimed in `getSourceType`.
305+
/// Users MUST validate the type of all withdrawn funds.
303306
access(FungibleToken.Withdraw) fun withdrawAvailable(maxAmount: UFix64): @{FungibleToken.Vault} {
304307
post {
305-
result.getType() == self.getSourceType():
306-
"Invalid vault provided for withdraw - \(result.getType().identifier) is not \(self.getSourceType().identifier)"
307308
DeFiActions.emitWithdrawn(
308309
type: result.getType().identifier,
309310
amount: result.balance,

0 commit comments

Comments
 (0)