Repository navigation
Feat/never stop deal:Dashboard新增四个数据接口 - #21
Merged
Merged
Conversation
|
🎉🎉🎉 Congratulations on your new release! 🎉🎉🎉 We have created a release draft of the new version, please go to Release to publish it! ✨ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Netting 合约新增了四个只读 Dashboard 接口:
1.getSettlementWindowForecast() 返回下一结算窗口、目标区块和剩余区块数;
2.getBankNetPositions(bank) 返回该银行按金融产品区分的应付和应收;
3.getBankSettlementAssetRequirements(bank) 返回本轮必须准备的产品及数量;
4.getBankLiquidityShortfalls(bank) 返回所需数量、当前余额和预计借款额。
以下是详细解释:
以下接口均为
view只读调用,不发送交易、不消耗 Gas。前端传入当前登录银行的钱包地址作为bank。接入时使用最新部署的 Netting 合约地址,并从
out/Netting.sol/Netting.json复制 ABI。建议监听新区块后并行刷新四个接口。Solidity 返回的数量是原始整数,展示前必须按照对应 ERC20 的decimals()格式化(这个很重要,否则会把1U显示成1000000U这样)。调用
Netting.getSettlementWindowForecast(),返回:windowId:下一次要结算的窗口编号;settlementBlock:预计执行结算的目标区块;blocksRemaining:距离目标区块还剩多少块,达到目标后为0。调用
Netting.getBankNetPositions(bank)。每项按金融产品分别返回:asset:ERC20 金融产品地址;payableAmount:银行应付数量;receivableAmount:银行应收数量。同一项中应付和应收最多只有一个大于
0。前端用asset.symbol()和asset.decimals()格式化名称与金额。调用
Netting.getBankSettlementAssetRequirements(bank),返回银行本轮必须准备的金融产品:asset:产品地址;requiredAmount:结算需要准备的数量。没有应付义务时返回空数组。
调用
Netting.getBankLiquidityShortfalls(bank),每项返回:asset:产品地址;requiredAmount:结算需要数量;availableBalance:银行当前链上余额;borrowAmount:预计需要从 Liquidity Buffer 借入的数量。计算口径为
borrowAmount = max(requiredAmount - availableBalance, 0)。该值是预计借款需求,不代表资金池一定有足够余额。当然,在咱们的项目里假设liquidity pool是充足的