Skip to content
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!: makeOsmosisSwap() using getDenomOn #9814

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft

feat!: makeOsmosisSwap() using getDenomOn #9814

wants to merge 22 commits into from

Conversation

dckc
Copy link
Member

@dckc dckc commented Jul 31, 2024

refs:

stacked on

Description

The main goal, in support of #8863, is:

  • chore(swapExample): complete makeOsmosisSwap

to do that, I did:

  • feat: Orchestrator.getDenomOn (WIP)
    • I'd like to discuss the name and design before finishing the wait -> watch work
  • feat!: makeOsmosisSwap() using getDenomOn()
    • I'd like to discuss the change to orchestration-api.d.ts. Does this even belong there? or should it be in some osmosis-specific file?

While I was at it:

  • feat(LocalOrchestrationAccount): getBalance by brand
    • lacks testing, I think

Security Considerations

IOU

Scaling Considerations

IOU

Documentation Considerations

see API changes above

Testing Considerations

some noted above

Upgrade Considerations

not yet deployed

@dckc dckc requested review from turadg and 0xpatrickdev July 31, 2024 15:16
@@ -39,6 +40,11 @@ export const OrchestratorI = M.interface('Orchestrator', {
getChain: M.call(M.string()).returns(Vow$(ChainInfoShape)),
makeLocalAccount: M.call().returns(Vow$(LocalChainAccountShape)),
getBrandInfo: M.call(DenomShape).returns(BrandInfoShape),
getDenomOn: M.call(
DenomShape,
M.remotable('Chain'),
Copy link
Member

Choose a reason for hiding this comment

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

it is remotable but it lives in the same vat. can we have a stricter type in that case? (curious, not blocking)

Copy link
Member Author

Choose a reason for hiding this comment

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

no; patterns are pass-invariant, and "in the same vat" is the antithesis of pass-invariant.

@@ -67,7 +73,7 @@ const prepareOrchestratorKit = (
chainByName,
makeLocalChainFacade,
makeRemoteChainFacade,
vowTools: { watch, asVow },
vowTools: { watch, asVow, when }, // TODO: no when
Copy link
Member

Choose a reason for hiding this comment

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

will we need retriable?

Copy link
Member Author

Choose a reason for hiding this comment

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

no idea; I guess I should look into it

*
* @param baseDenom denom on issuing chain
* @param base issuing chain
* @param chain holding chain - connection to base chain must be regitered in chainHub
Copy link
Member

Choose a reason for hiding this comment

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

typo

* @param chain holding chain - connection to base chain must be regitered in chainHub
* @returns denom on holding chain
*/
getDenomOn: <
Copy link
Member

Choose a reason for hiding this comment

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

new top level interface method will need @tribble review

Copy link
Member Author

Choose a reason for hiding this comment

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

right...
+cc @mitdralla

Copy link
Member Author

@dckc dckc Jul 31, 2024

Choose a reason for hiding this comment

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

the name getDenomOn is sort of... uninspired

different arg names might help... orch.getDenomOn(baseDenom, issuingChain, holdingChain)

which suggests orch.getHoldingChainDenom(baseDenom, issuingChain, holdingChain)

* @returns denom on holding chain
*/
getDenomOn: <
HoldingChain extends keyof KnownChains,
Copy link
Member

Choose a reason for hiding this comment

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

not strictly necessary that it's a known chain. but we can tackle that when we have more use of contract-specified chains

Copy link
Member Author

Choose a reason for hiding this comment

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

I followed the structure of getBrandInfo(). I guess the comment applies to both?

@dckc dckc changed the title Dc brand info feat!: makeOsmosisSwap() using getDenomOn Jul 31, 2024
@dckc dckc requested review from dtribble and mitdralla July 31, 2024 15:51
Comment on lines +90 to +91
const asset = assets.find(a => a.brand === opts.brandOut);
if (!asset) throw Fail`${opts.brandOut} not registered in Agoric vbank`;
Copy link
Member Author

Choose a reason for hiding this comment

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

SwapExact is in terms of ERTP Amount with Brand, which limits the trade to assets in the Agoric vbank, which makes little sense

@@ -86,8 +87,6 @@ export interface Chain<CI extends ChainInfo> {
*/
makeAccount: () => Promise<OrchestrationAccount<CI>>;
// FUTURE supply optional port object; also fetch port object

// TODO provide a way to get the local denom/brand/whatever for this chain
Copy link
Member Author

Choose a reason for hiding this comment

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

getDenomOn() is intended to provide this.

It's on Orchestrator instead of Chain because the Chain implementation doesn't have ready access to chainHub. Perhaps we shouldn't let internal details like that drive the external API, but it was the easiest thing that seems to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

intended design is/was:

osmosis.getLocalDenom(baseDemon)

@dckc
Copy link
Member Author

dckc commented Jul 31, 2024

Documentation Considerations += let's document that the asset list is captured at some point in time and may trail updates etc...

perhaps in / near https://docs.agoric.com/reference/vstorage-ref.html

Copy link

cloudflare-workers-and-pages bot commented Aug 1, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 82e2040
Status:🚫  Build failed.

View logs

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