Skip to content

Nialexsan/non public pool#45

Merged
nialexsan merged 17 commits intomainfrom
nialexsan/non-public-pool
Sep 19, 2025
Merged

Nialexsan/non public pool#45
nialexsan merged 17 commits intomainfrom
nialexsan/non-public-pool

Conversation

@nialexsan
Copy link
Copy Markdown
Contributor

@nialexsan nialexsan commented Sep 9, 2025

alternative approach with authorized pool

@nialexsan nialexsan marked this pull request as ready for review September 9, 2025 21:31
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cadence/contracts/mocks/DummyConnectors.cdc 33.33% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@sisyphusSmiling sisyphusSmiling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cadence/contracts/mocks/TestHelpers.cdc Outdated
Comment on lines +5 to +8
access(all) contract TestHelpers {

// Minimal sink for tests that accepts MOET and does nothing.
access(all) struct NoopSink: DeFiActions.Sink {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think contract DummyConnectors and DummySink respectively would be more descriptive

Comment on lines +1913 to 1948
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)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@nialexsan nialexsan merged commit dc98433 into main Sep 19, 2025
2 checks passed
@nialexsan nialexsan deleted the nialexsan/non-public-pool branch September 19, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants