Distributing fees to Reserve
#6967
-
ContextIn The Inter Protocol Whitepaper's QuestionI don't quite understand how the distribution of fees collected from await E(instanceKit.creatorFacet).setDestinations({
RewardDistributor:
rewardDistributorDepositFacet &&
E(instanceKit.creatorFacet).makeDepositFacetDestination(
rewardDistributorDepositFacet,
),
Reserve: E(instanceKit.creatorFacet).makeOfferDestination(
'Collateral',
E.get(reserveKit).publicFacet,
'makeAddCollateralInvitation',
),
}); As far as I can understand here's the flow; sequenceDiagram
boot->>+feeDistributer: Set destinations
Note over boot,feeDistributer: Reward, Reserve
feeDistributer ->> feeDistributer: update shareConfig
feeDistributer ->> vaultFacotry/amm/stakeFactory: collectFees
feeDistributer ->> bank (Reward Pool): pushPayment
feeDistributer ->> assetReserve (Reserve Pool): pushPayment
My questions; /**
* Create a destination that generates invitations and makes Zoe offers.
*
* @param {ERef<ZoeService>} zoe
* @param {string} keyword
* @param {unknown} target
* @param {PropertyKey} makeInvitationMethod
* @param {unknown[]} [args]
*/
makeOfferDestination: (
zoe,
keyword,
target,
makeInvitationMethod,
args = [],
) => {
// Method body...
} But in Reserve: E(instanceKit.creatorFacet).makeOfferDestination(
'Collateral',
E.get(reserveKit).publicFacet,
'makeAddCollateralInvitation',
Am I wrong or is this a bug? @dckc . If I'm wrong, can someone please point me to the correct direction? Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
I did some investigating by running
I inspected the arguments passed into Below is what the results of that looked like inside makeOfferDestination:::: ::: {
zoe: 'Collateral',
keyword: Promise { <pending> },
target: 'makeAddCollateralInvitation',
makeInvitationMethod: undefined,
args: []
}
inside makeOfferDestination:::: ::: {
zoe: 'Collateral',
keyword: Promise { <pending> },
target: 'makeAddCollateralInvitation',
makeInvitationMethod: undefined,
args: []
} Another thing to note is that the code stopped executing
I think that atomicTransfer(zcf, feeSeat, seat, { Collateral: amount }, { Fee: amount }); // To keyword is `Fee` I believe this would be OK and that "Fee" does not need to be passed in as the argument for inside collectFees::: ::: {
seat: Object [Alleged: zcfSeat] {},
feeSeat: Object [Alleged: zcfSeat] {},
feeBrand: Object [Alleged: IST brand] {},
keyword: 'Minted',
amount: { brand: Object [Alleged: IST brand] {}, value: 0n }
}
inside collectFees::: ::: {
seat: Object [Alleged: zcfSeat] {},
feeSeat: Object [Alleged: zcfSeat] {},
feeBrand: Object [Alleged: IST brand] {},
keyword: 'Minted',
amount: { brand: Object [Alleged: IST brand] {}, value: 0n }
}
inside collectFees::: ::: {
seat: Object [Alleged: zcfSeat] {},
feeSeat: Object [Alleged: zcfSeat] {},
feeBrand: Object [Alleged: IST brand] {},
keyword: 'Minted',
amount: { brand: Object [Alleged: IST brand] {}, value: 0n }
}
inside collectFees::: ::: {
seat: Object [Alleged: zcfSeat] {},
feeSeat: Object [Alleged: zcfSeat] {},
feeBrand: Object [Alleged: IST brand] {},
keyword: 'Minted',
amount: { brand: Object [Alleged: IST brand] {}, value: 0n }
}
inside collectFees::: ::: {
seat: Object [Alleged: zcfSeat] {},
feeSeat: Object [Alleged: zcfSeat] {},
feeBrand: Object [Alleged: IST brand] {},
keyword: 'Fee',
amount: { brand: Object [Alleged: IST brand] {}, value: 0n }
} There are a few more logs than this, but I left them out. That said, I think this behavior is correct, but maybe @dckc can add more context from here. |
Beta Was this translation helpful? Give feedback.
-
I have a relevant PR in progress: perhaps I can take a closer look when i swap that back in. Meanwhile, perhaps @Chris-Hibbert or @turadg has a moment to look into this. |
Beta Was this translation helpful? Give feedback.
-
I think I'm all clear now. As far as I can understand the fee distribution to flowchart
subgraph econ-behaviors
startRewardDist[Start Reward Distribution] --> startIns[Start feeDistributer]
farSetDest[Set Fee Destinations and Shares]
crCol[Make a collector]
startCol[Start Periodic Collection]
startCol -- Repeat 3 times for 'VF', 'AMM' and 'SF' ---crCol
end
feeDistributer -- creatorFacet --> farSetDest
startIns -- Start instance and return creatorFacet --> feeDistributer
farSetDest -- creatorFacet.setDestinations --> setDest
config --> crCol
crCol -- Create and return new collector --> makeCol
makeCol -- Collector --> startCol
startCol --> startP
subgraph feeDistributer
collectors[(Collectors)]
config[(Share Configuration)]
setDest[Set Destinations]
makeCol[Make a new collector]
startP[Start Collection]
start[startDistributing] -- On every interval --> schedule[schedulePayments]
schedule -- For every collector -->collectors
clct[Collect Fee]
schedule -- Collector --> clct
clct -- Collected Fee -->dist[Distribute]
dist -- For every share and destination -->config
dist -- Share and Destination --> pay[PushPayment]
setDest -- Update --> config
startP -- Add new collector --> collectors
startP --> clct
end
pay -- Fee --> assetRes[Reserve Pool]
Please let me know if there's anything I'm missing. @turadg @Chris-Hibbert @dckc |
Beta Was this translation helpful? Give feedback.
-
The args bug above is #7046 . |
Beta Was this translation helpful? Give feedback.
The args bug above is #7046 .
Thanks for finding it, folks!