-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat: advancer integrates with LP and contract #10518
Conversation
a78e88c
to
3117eef
Compare
9ee81ea
to
b4a6de7
Compare
Deploying agoric-sdk with Cloudflare Pages
|
85ebd94
to
2e699e7
Compare
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 don't see anything wrong.
I think I skimmed some parts, though. I wonder if I should give it another look before approving.
* borrow(amount: Amount<"nat">): Promise<Payment<"nat">>; | ||
* repay(payments: PaymentKeywordRecord): Promise<void> | ||
* }} AssetManagerFacet | ||
* @import {BorrowerFacet} from './liquidity-pool.js'; |
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.
hm... do we want to name the types of each of the facets? I can see arguments both ways, but consider...
* @import {BorrowerFacet} from './liquidity-pool.js'; | |
* @import {LiquidityPoolKit['borrower']} from './liquidity-pool.js'; |
statusManager, | ||
usdc, | ||
vowTools: { watch, when }, | ||
zcf, |
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 only see zcf.makeEmptySeatKit
used. Narrow this to that 1 method?
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.
Agree this would be helpful towards limiting authority, but I don't think we can do this without making a new exo with something like prepareGuardedAttenuator
or the like.
Would you still like to see this in this PR? I also suspect Settler
will need the same - I can add a TODO if you're planning to tackle this there?
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 don't think we can do this without making a new exo ...
Right. Never mind.
usdc, | ||
vowTools: { watch, when }, | ||
zcf, | ||
zoeTools, |
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.
likewise, narrow to localTransfer
?
log( | ||
`Insufficient pool funds`, | ||
`Requested ${q(advanceAmount)} but only have ${q(poolBalance)}`, |
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.
note: I wonder if this makes use of the ses console as it should.
There's nothing to censor here. But "a more powerful distributed causal console" could be really handy.
Not for this PR, but I wonder when.
// report `requestedAmount`, not `advancedAmount`... do we need to | ||
// communicate net to `StatusManger` in case fees change in between? |
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.
That's an interesting idea: compute the split at advancement time.
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.
Yes, something to keep in our back packet. When .settle
is called, it could return the split amounts. But it's still not entirely clear to me if we should wait to .settle()
until the payments have actually returned back to the LP, or settling on intent is acceptable.
const amountKWR = harden({ USDC: advanceAmount }); | ||
borrowerFacet.borrow(tmpSeat, amountKWR); | ||
|
||
const depositV = zoeTools.localTransfer( |
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.
the comment below says that depositHandler
handles failures in localTransfer
, so it seems odd to have this inside the try
I suppose we can think again when we do #10510 (comprehensive error testing) but I struggle to be confident that we will.
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.
Good feedback, revis(ed|ing) to only include .borrow()
in the try
.
Regarding ".borrow()
might fail if the balance changes since we requested it" - I wonder if this comment can be removed since we changed the implementation to use seats. Since there are no awaits in between .getBalance()
and .borrow()
, and we have await null
at the beginning of handleTransactionEvent
, can we safely assume we'll be in the same turn?
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.
we safely assume we'll be in the same turn?
yes, it's statically evident that there are no turn boundaries between .getBalance()
and the return from .borrow()
.
// TODO return seat allocation from ctx to LP? | ||
log('🚨 advance deposit failed', q(error).toString()); | ||
log('TODO live payment to return to LP', q(payment).toString()); | ||
// TODO #10510 (comprehensive error testing) determine |
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.
this stuff is why #10510 looks to me like "the other 80% of the work".
The local deposit would only fail due to things in our control at design-time (i.e. bugs), but the remote transfer can fail for runtime reasons (timeout).
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.
The local deposit would only fail due to things in our control at design-time (i.e. bugs), but the remote transfer can fail for runtime reasons (timeout).
The is well-put - I should include this verbiage as a code comment.
Agree we can almost guarantee .deposit()
will never fail, so I decided not to add more noise to this PR with a repay()
method on the borrower
facet. Also agree .transfer()
failing is the more important failure path to be concerned with.
@@ -162,7 +189,7 @@ test('updates status to ADVANCED in happy path', async t => { | |||
|
|||
t.deepEqual(inspectLogs(0), [ | |||
'Advance transfer fulfilled', | |||
'{"amount":{"brand":"[Alleged: USDC brand]","value":"[150000000n]"},"destination":{"chainId":"osmosis-1","encoding":"bech32","value":"osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men"},"result":"[undefined]"}', | |||
'{"amount":{"brand":"[Alleged: USDC brand]","value":"[149999899n]"},"destination":{"chainId":"osmosis-1","encoding":"bech32","value":"osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men"},"result":"[undefined]"}', |
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.
suggestion: add a test to fees.tests.ts
using the numbers in this exo test such as 149999899n
.
Then I wouldn't have to do arithmetic to review this PR.
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.
Good suggestion. See ac61b3666e
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.
Perhaps better without the underscores. LMK
2e699e7
to
6e3eba4
Compare
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.
LGTM. We'll need more contract and error coverage but those are scheduled separately.
const creatorFacet = zone.exo('Fast USDC Creator', undefined, { | ||
/** @type {(operatorId: string) => Promise<Invitation<OperatorKit>>} */ | ||
async makeOperatorInvitation(operatorId) { | ||
// eslint-disable-next-line no-use-before-define |
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 didn't realize that #9361 hadn't landed. I'll try to get that in now.
* @satisfies {OrchestrationFlow} | ||
* @param {Orchestrator} orch | ||
*/ | ||
export const makeLocalAccount = async orch => { |
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.
is this our first flow? I thought we would be able to ship this without async-flow.
This is fine since it runs once but I'm curious what it would take to do this without a flow.
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.
curious what it would take to do this without a flow
Less complicated than a CosmosOrchAccount
Maybe something like:
const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
zone,
{
makeRecorderKit,
zcf,
timerService,
vowTools,
chainHub,
localchain,
zoeTools,
},
);
const account = await when(E(localchain).makeAccount());
const address = await when(E(account).getAddress());
const { holder } = makeLocalOrchestrationAccountKit({
account,
address: harden({
value: address,
encoding: 'bech32',
chainId: localChainInfo.chainId,
}),
// FIXME storage path https://github.com/Agoric/agoric-sdk/issues/9066
storageNode: childNode,
});
Something we can revisit . Also - I'm reminded that #9066 might need some love as we are getting to launch this FUSDC.
- document `MockCctpTxEvidences` with `FeeConfig` used `commonPrivateArgs.feeConfig` (contract tests) - increase `makeTestFeeConfig` `maxVariable` value so fees are more visible in tests - add `debugString` to `feeToolsScenario` macro for easier maintenance
6e3eba4
to
63d7b44
Compare
63d7b44
to
7ec6fcf
Compare
closes: #10390
Description
Advancer
to useLiquidityPool
borrower facetAdvancer
withcontract.js
PoolAccount
using a flow to provide tomakeAdvancer
Security Considerations
None
Scaling Considerations
None
Documentation Considerations
None
Testing Considerations
Includes exo tests for
Advancer
. Also includes a contract test covering the happy path, although out of scope for the ticket.Upgrade Considerations
None, unreleased