Skip to content

Instantly share code, notes, and snippets.

@tgrecojs
Created November 25, 2022 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgrecojs/4b24fd003c02805e8b03138ce151901d to your computer and use it in GitHub Desktop.
Save tgrecojs/4b24fd003c02805e8b03138ce151901d to your computer and use it in GitHub Desktop.

Inter Protocol Digrams

vaultInstance overview

flowchart TD
        %%{ init: { 'flowchart': { 'curve': 'monotoneY' } } }%%

subgraph vaultFactory[Vault Factory]
    direction BT
    vfT1[The vaultFactory owns a number of VaultManagers and a mint for Minted] ---> vfT2
    vfT2[vaultFactory is a 'Vault Director Machine'  <br/> <br /> - it creates the vaultDirector  </br> - vaultDirector is root user] --> vfT3
    vfT3[ vaultFactory's <code>start</code> function <br /> <br /> - 1. factory = makeVaultDirector&#40 zcf, vaultDirectorParams &#41 <br /> 2. uses factory to expose the Root Creator & Public Facets <br /> ]
    vfT3--exports the following object as the <code>VaultDirector</code> -->vaultFactoryReturnVal
    vaultFactoryReturnVal[&#40 &#123  <br /> creatorFacet: factory.creator <br /> publicFacet: factory.public <br/> &#125 &#41 ]
    

    subgraph vaultDirector[Vault Director <br/> <em>The root User</em>]
        vdT1[<b>Vault Director is the 'Director' of the vaultFactory</b> <br />] --> vdT2
        vdT2[<b>Oversees all Vault Managers</b> <br /> <br /> - VaultManagers for new Collateral types are created via the Director's creatorFacet <br /> <br /> - New vaults can be added to a manager using the VaultDirectors publicFacet </br> <br />] --- rootGovText
        rootGovText[<b>Vault Director Handles Protocol-level Governance details </b> <br> <br/> VaultDirector contract initializes a watchGovernance function before exiting the addVaultType contract <br /><br/>] --> watchGovText
        watchGovText[ <b>FIRST THOUGHTS: watchGovernance*** </b> &#40 need to investigate more&#41</br> <br/>watchGovernance is used to: set up a vaultTypes liquidation strategy </br> <br/>watch in background for governance to change terms regarding a collateralTypes params *]
        subgraph VDF[Vault Director Facets]
        vaultDirectorPublicFacet(( <b>publicFacet </b> <br /> <br /> getCollateralManager  <br /> - getMetrics </br> - getGovernedParams <br />))
        vaultDirectorCreatorFacet(( <b>creatorFacet</b> <br /> <br /> - addVaultType <br />  - getParamMgrRetriever <br /> - getGovernedApis <br /> - getLimitedCreatorFacet ))
        end
        end
end


vfT3 --- vaultDirector
vaultFactoryReturnVal ----> vaultDirectorCreatorFacet
vaultFactoryReturnVal ----> vaultDirectorPublicFacet


vaultDirectorCreatorFacet -- addVaulType&#40 atomIssuer, params &#41 --> vm2

vaultDirectorCreatorFacet -- addVaulType&#40 ethIssuer, params &#41 --> ethVm

vaultDirectorPublicFacet --> Alice
us1 --accessible via publicFacet -..-> vm2 -..- us2
Alice --> us1 ---> us2 --> us3 --> us4
   


subgraph vaultManager[Vault Manager]
    vmT1[Vault Manager object manages vault-based properties for a collateral type <br /> <br /></br> ]
        vmT1 --> vmT2([ Example Props </br> </br>  - compoundedInterest <br /> - totalDebt </br> - totalCollateral </br> - vaultCounter </br> ])
        vmT1 --> vmT3([ Example Methods </br> </br>  - makeAddVaultInvitation <br /> - getSubscriber </br> - getMetrics </br> ])
subgraph Vault Manager Examples
    subgraph  ethVm[ETH Vault Manager]
        EI[Vault Internals]
        EI --> EM[Metrics]
        EI --> EMM[Methods]
    end
    subgraph  vm2[ATOM Vault Manager]
        VI[Vault Internals]
        VI --> Metrics
        VI --> Methods
    end
end
end

subgraph Alice[Alice wants to interact with the ATOM vaults]
   us1[ 1. fetch vaultManager for ATOM-IST Vaults <br/><br/> <code>atomISTVaultManager = E&#40publicFacet&#41.getCollateralManager &#40 atomBrand  &#41</code> <br />]
    us2[2. create invitation for opening an ATOM-IST Vault ,<br/> </br/><code>makeVaultInvitation = E&#40atomISTVaultManager&#41.makeVaultInvitation&#40&#41</code> ]
  us3[3. use <code>makeVaultInvitation</code> open up a vault within the ATOM-IST collateral by using <br/></br> <code> openVaultSeat =  E&#40zoe&#41.offer&#40makeVaultInvitation, proposal,  &#123 Collateral: atomPayment  &#125 &#41 </code>]
  us4[ 4. use newly created <code>vault</code> object as you please! <code><br/> <br/></>const aliceVaultSeat = E&#40openVaultSeat&#41.getOfferResult&#40&#41</code>]
end
subgraph vaultSeat[aliceVaultSeat]
vaultBase[vaultBase</b> <br/> <br/> - created in vault.js  <br/>- <code>makeVaultBase</code> fn ] --<code>E&#40aliceVaultSeat&#41</code>-->fns
 fns((<br /><br/> - getCurrentDebt<br/> </br> - makeTransferInvitation <br/> </br> - makeAdjustBalancesInvitation <br/></br> - makeCloseInvitation </br> </br>))
end
us4 --> vaultSeat

vaultFactory:::parentComponent
vaultDirector:::rootAdminComponent
vaultManager:::childAdminComponent
%% Element type definitions
Alice:::userContainer

vaultSeat:::userOfferResult
us1:::userStoryStep
us2:::userStoryStep
us3:::userStoryStep
us4:::userStoryStep
fns:::userStoryStep 
classDef userStoryStep fill:#08427b,stroke:gray,stroke-width:1px, color: white, stroke-dasharray: 5 5
classDef userOfferResult fill:#d3aaff,stroke:steelblue,stroke-width:2px, color: black, stroke-dasharray: 5 5, font-size: 24px, line-height: 20px

classDef userContainer fill:#8aaceb, font-size: 24px, line-height: 20px,color: black
classDef rootAdminComponent fill:#7a3ae0, font-size: 24px, line-height: 20px, stroke: black, stroke-width: 4px, color: white
classDef parentComponent fill:#f29ba9, font-size: 26px, line-height: 20px, stroke: 3px, color: white
classDef left text-align: left;
classDef childAdminComponent fill:#c7a4ff, font-size: 26px, line-height: 20px, stroke: 3px, color: black
classDef type stroke-width:0px, color:#fff, fill:transparent, font-size:12px
classDef description stroke-width:0px, color:#fff, fill:transparent, font-size:13px
classDef heading font-size:30px;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment