Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
sisyphusSmiling
left a comment
There was a problem hiding this comment.
We'll also need transactions to grant & claim beta access - the existing one seems to be test-related. I think a two transaction publish & claim would be easiest to coordinate across different teams.
| access(all) contract TestHelpers { | ||
|
|
||
| // Minimal sink for tests that accepts MOET and does nothing. | ||
| access(all) struct NoopSink: DeFiActions.Sink { |
There was a problem hiding this comment.
I think contract DummyConnectors and DummySink respectively would be more descriptive
| access(EParticipant) fun deposit(from: @{FungibleToken.Vault}) { | ||
| let pool = self.pool.borrow()! | ||
| pool.depositAndPush(pid: self.id, from: <-from, pushToDrawDownSink: false) | ||
| } | ||
| /// Deposits funds to the Position enabling the caller to configure whether excess value should be pushed to the | ||
| /// drawDownSink if the deposit puts the Position above its maximum health | ||
| access(all) fun depositAndPush(from: @{FungibleToken.Vault}, pushToDrawDownSink: Bool) { | ||
| access(EParticipant) fun depositAndPush(from: @{FungibleToken.Vault}, pushToDrawDownSink: Bool) { | ||
| let pool = self.pool.borrow()! | ||
| pool.depositAndPush(pid: self.id, from: <-from, pushToDrawDownSink: pushToDrawDownSink) | ||
| } | ||
| /// Withdraws funds from the Position without pulling from the topUpSource if the deposit puts the Position below | ||
| /// its minimum health | ||
| access(FungibleToken.Withdraw) fun withdraw(type: Type, amount: UFix64): @{FungibleToken.Vault} { | ||
| return <- self.withdrawAndPull(type: type, amount: amount, pullFromTopUpSource: false) | ||
| } | ||
| /// Withdraws funds from the Position enabling the caller to configure whether insufficient value should be | ||
| /// pulled from the topUpSource if the deposit puts the Position below its minimum health | ||
| access(FungibleToken.Withdraw) fun withdrawAndPull(type: Type, amount: UFix64, pullFromTopUpSource: Bool): @{FungibleToken.Vault} { | ||
| let pool = self.pool.borrow()! | ||
| return <- pool.withdrawAndPull(pid: self.id, type: type, amount: amount, pullFromTopUpSource: pullFromTopUpSource) | ||
| } | ||
| /// Returns a new Sink for the given token type that will accept deposits of that token and update the | ||
| /// position's collateral and/or debt accordingly. Note that calling this method multiple times will create | ||
| /// multiple sinks, each of which will continue to work regardless of how many other sinks have been created. | ||
| access(all) fun createSink(type: Type): {DeFiActions.Sink} { | ||
| access(EParticipant) fun createSink(type: Type): {DeFiActions.Sink} { | ||
| // create enhanced sink with pushToDrawDownSink option | ||
| return self.createSinkWithOptions(type: type, pushToDrawDownSink: false) | ||
| } | ||
| /// Returns a new Sink for the given token type and pushToDrawDownSink opetion that will accept deposits of that | ||
| /// token and update the position's collateral and/or debt accordingly. Note that calling this method multiple | ||
| /// times will create multiple sinks, each of which will continue to work regardless of how many other sinks | ||
| /// have been created. | ||
| access(all) fun createSinkWithOptions(type: Type, pushToDrawDownSink: Bool): {DeFiActions.Sink} { | ||
| access(EParticipant) fun createSinkWithOptions(type: Type, pushToDrawDownSink: Bool): {DeFiActions.Sink} { | ||
| let pool = self.pool.borrow()! | ||
| return PositionSink(id: self.id, pool: self.pool, type: type, pushToDrawDownSink: pushToDrawDownSink) | ||
| } |
There was a problem hiding this comment.
Not sure these need to be altered from all to EParticipant
| // Call EParticipant-gated methods | ||
| let zero1 <- DeFiActionsUtils.getEmptyVault(Type<@MOET.Vault>()) | ||
| let pid = pool.createPosition( | ||
| funds: <- zero1, |
There was a problem hiding this comment.
Beyond scope of this PR, but IMO we shouldn't allow 0.0 deposits at the protocol level at least when creating a position. Might also consider a minimum open position on a relative dollar amount. It's a bit of a spam vector
alternative approach with authorized pool