-
Notifications
You must be signed in to change notification settings - Fork 0
add superconduct case #19
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
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // 三个资产类型全局常量,可以先用全局变量实现 | ||
| // asset资产类型,32个字节长度的资产 | ||
| assetX := asset(1) // int类型强转 | ||
| assetY := asset(2) | ||
| assetM := asset(3) | ||
|
|
||
| // struct结构描述合约结构:field为三资产池状态数据,function为存取兑解锁函数 | ||
| // 暂通过全局函数实现 | ||
|
|
||
| // 三资产池状态数据[poolAmtX,poolAmtY,poolAmtM]构造交易时传入,存入辅栈 | ||
|
|
||
| // 全局函数实现存取兑 | ||
|
|
||
| // 构造交易时传入参数:兑换资产idassetX, 数量amtX, 选择swap兑换功能,checkoutput缠绕合约的program | ||
| // 如:[][]byte{assetX.Bytes(),amtX,swap,program} | ||
| // 状态数据传入参数,三资产池资产数量state [poolAmtX,poolAmtY,poolAmtM] | ||
| // 注意这里传参summoner的处理过程 | ||
| // 如:[][]byte{vm.Int64Bytes(10), vm.Int64Bytes(100), vm.Int64Bytes(1000)} | ||
| func Swap(amtX amount) { // 资产数量amount无符号整型,可为uint64类型别名 | ||
| verify(amtX > 0) // 暂builtin实现 | ||
| verify(poolAmtX * poolAmtY == poolAmtM) | ||
|
|
||
| newPoolAmtX := poolAmtX + amtX // 暂不计算手续费 | ||
| newPoolAmtY := poolAmtM / newPoolAmtX | ||
|
|
||
| lock(newPoolAmtX, assetX, program, state) // 注:state经过summoner取算存的过程 | ||
| lock(newPoolAmtY, assetY, program, state) | ||
| lock(poolAmtM, assetM, program, state) | ||
| } | ||
|
|
||
| // TOOD | ||
| func AddLiquidity(amtX amount, amtY amount) { | ||
|
||
| } | ||
|
|
||
| // TOOD | ||
| func RemoveLiquidity(amtX amount, amtY amount) { | ||
| } | ||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
全局变量定义用var来定义
var (
......
)
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.
这个几种定义方式都可以的吧