btc20271457 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. package/.idea/Web3-Financial-Engineering-Courses-main.iml +9 -0
  2. package/.idea/git_toolbox_prj.xml +15 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/0.web3_financial_infrastructure/dex_protocol/dex.sol +29 -0
  6. package/0.web3_financial_infrastructure/dex_protocol/dexInfra/AMMData.sol +150 -0
  7. package/0.web3_financial_infrastructure/dex_protocol/dexInfra/Algorithm.sol +97 -0
  8. package/0.web3_financial_infrastructure/dex_protocol/dexInfra/Idatastore.sol +120 -0
  9. package/0.web3_financial_infrastructure/dex_protocol/dexInfra/datastorage.sol +383 -0
  10. package/0.web3_financial_infrastructure/dex_protocol/dexInfra/lptoken.sol +33 -0
  11. package/0.web3_financial_infrastructure/dex_protocol/dexInfra/swap.sol +550 -0
  12. package/0.web3_financial_infrastructure/dex_protocol/dex_protocol.md +51 -0
  13. package/0.web3_financial_infrastructure/liquidity_protocol/bank.sol +258 -0
  14. package/0.web3_financial_infrastructure/liquidity_protocol/bank0.sol +29 -0
  15. package/0.web3_financial_infrastructure/liquidity_protocol/bank1.sol +58 -0
  16. package/0.web3_financial_infrastructure/liquidity_protocol/bank2.sol +124 -0
  17. package/0.web3_financial_infrastructure/liquidity_protocol/bank3.sol +210 -0
  18. package/0.web3_financial_infrastructure/liquidity_protocol/liquidity_protocol.md +58 -0
  19. package/0.web3_financial_infrastructure/liquidity_protocol/product.md +33 -0
  20. package/LICENSE +21 -0
  21. package/README.md +113 -0
  22. package/package.json +26 -0
  23. package/tea.yaml +96 -0
  24. package/tranpack.sh +23 -0
@@ -0,0 +1,58 @@
1
+
2
+ <h1 align="center">
3
+ <span style="font-size: 32px;"> 流动性金融协议 </span>
4
+
5
+ </h1>
6
+
7
+ - 公共资产架构(用于计算利息)
8
+ - 结构体的3个数据结构
9
+ - 1.开始时间
10
+ - 2.结束时间
11
+ - 3.期间收益率
12
+ - index:用于记录不同的struct(用于计算收益)
13
+ - 通过index把用户不同时间的利息加起来(引出需要保存用户不同时间的资产负债)
14
+ - userindexborrowed 为 address => uint => uint (user => index => borrowed)
15
+ - 某一时间段利息计算:收益pi(t0到t1的差额t) = 用户资产负债 * t * 利息率
16
+ - 总收益 $$P = \sum_{i=0}^{n} p_i$$
17
+ - $$P = \sum_{i=0}^{n} p_i / p_i = userborrow_i * profitrate _i * t_i$$
18
+ - $$profitrate_i = borrowed_i/reserve_i (0 < profitrate < 1)$$
19
+ ## 1.存入资产
20
+
21
+
22
+ ## 2.借出资产
23
+
24
+ ## 3.计算利息
25
+ ### 先微分(计算用户每个时间段需要付有多少的利息和得到多少利润)
26
+ - 开始时间
27
+ - 结束时间
28
+ - 用户资产
29
+ - 用户负债
30
+ - 资产利润率
31
+ - 负债利息率
32
+ #### 利润微分 = (结束时间 - 开始时间)* 用户资产 * 资产利润率
33
+ - $$p_i = (t_i - t_{i-1}) * userReserve_i * reserveRate_i$$
34
+ #### 负债利息微分 = (结束时间 - 开始时间)* 用户负债 * 负债利润率
35
+ - $$d_i = (t_i - t_{i-1}) * userDebt_i * DebtRate_i$$
36
+ ### 再积分(算总数)
37
+ - 总利润 $$P = \sum_{i=0}^{n} p_i$$
38
+ - 总负债利息 $$D = \sum_{i=0}^{n} d_i$$
39
+
40
+ ### 公共变量
41
+ - 开始时间
42
+ - 结束时间
43
+ - 资产利润率
44
+ - 负债利息率
45
+ ### 私有变量
46
+ - 用户资产
47
+ - 用户负债
48
+ ### 关于利润率和利息率
49
+ - 利润率 (总借出 / 总储备)/ 100% * 0.8
50
+ - $$reserveRate = allBorrowed / allReserve * power(0 < power < 1) $$
51
+ - 利息率( 总借出 / 总储备 )/ 100 %
52
+ - - $$debtRate = allBorrowed / allReserve (0 < debtRate < 1) $$
53
+
54
+
55
+
56
+ ## 4.偿还贷款和收益
57
+
58
+ ## 5.清算资产
@@ -0,0 +1,33 @@
1
+ <h1 align="center">
2
+ <span style="font-size: 32px;"> 流动性协议的讨论 </span>
3
+
4
+ </h1>
5
+
6
+ <h2 align="center">
7
+ <span style="font-size: 32px;"> 银行的构建 </span>
8
+
9
+ </h2>
10
+
11
+ - 存入资产
12
+ - 计算利息
13
+ - 偿还资产
14
+ - 清算资产
15
+
16
+ <h3 align="center">
17
+ <span style="font-size: 32px;"> 银行衍生品的构建 </span>
18
+
19
+ </h3>
20
+
21
+ - 组合资产
22
+ - 杠杆代币
23
+ <h4 align="center">
24
+ <span style="font-size: 32px;"> 杠杆代币的实现方式 </span>
25
+
26
+ </h4>
27
+
28
+ - 实现逻辑:
29
+ - 1.存入资产(资产)
30
+ - 2.借出资产(负债)
31
+ - 3.从原来的 资产 => 资产 + 负债 = 做多资产,做空负债
32
+ - 例子:房地产,杠杆token..........
33
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Yanbo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+
2
+
3
+ <h1 align="center">
4
+ <span style="font-size: 32px;"> Web3-Financial-Engineering-Courses </span>
5
+
6
+ </h1>
7
+
8
+
9
+ <h2 align="center">
10
+ web3金融工程
11
+ </h2>
12
+
13
+
14
+ # 项目简介
15
+
16
+
17
+ [![GitHub stars](https://img.shields.io/github/stars/PhiloCwh/Web3-Financial-Engineering-Courses/.svg?style=social&label=Stars)](https://github.com/PhiloCwh/Web3-Financial-Engineering-Courses) [![GitHub watchers](https://img.shields.io/github/watchers/PhiloCwh/Web3-Financial-Engineering-Courses.svg?style=social&label=Watch)](https://github.com/PhiloCwh/Web3-Financial-Engineering-Courses)
18
+
19
+
20
+ 一起从0到1从基础知识和代码层面构建基础设施(dex,liquidity protocol,等等)再到构建传统金融衍生品(合约,期权,远期,等等)
21
+
22
+ # 模版流程
23
+
24
+ **1.介绍传统金融和web3的区别**
25
+
26
+ **2.细致介绍数学**
27
+
28
+ **3.coding教学**
29
+
30
+ **4.应用教学**
31
+
32
+ ## 0.web3基础流行金融模式的介绍
33
+ ### 0.1. swapv2 模式的介绍
34
+ - 3个函数的介绍(添加流动性,交换,移除流动性)
35
+ - swap的代码实现
36
+ ### 0.2 liquidity protocol 模式介绍
37
+ - 机制的介绍(存入,借出,计算利息,清算)
38
+ - liuidity protocal的简单实现
39
+
40
+ ## 1.传统金融的价格和定价和市值
41
+ - ft类型定价基础于订单买盘和卖盘达成的价格均衡
42
+ - nft类型不好评估
43
+ - 流动性问题
44
+ - 吹牛逼
45
+
46
+ ## 2.web3金融的价格和定价
47
+ - ft类型:订单和算法
48
+ - nft类型:订单 算法?
49
+ - 流动性
50
+ - 吹牛逼
51
+
52
+
53
+ ### 2.1.基于订单撮合定价的实现
54
+
55
+ ### 2.2.基于算法定价的实现
56
+
57
+ ### 2.3.uniswap的算法机制
58
+
59
+ #### 2.3.1.算法的实现
60
+
61
+ ### 2.4curve的算法机制
62
+
63
+ #### 2.4.1.算法的实现
64
+
65
+ ### 2.5.基于算法定价的思考/发现价格
66
+
67
+ ## 3.基于不同的价格和定价体系而产生不同的金融衍生品
68
+
69
+ ## 4.lp做多策略
70
+
71
+ ## 5.compound的杠杆话资产
72
+
73
+ ## 6.compound的资产组合策略
74
+
75
+ ## 7.lp做多和compound杠杆的结合alpaca
76
+
77
+ ## 8.传统金融远期的概念
78
+
79
+ ## 9.远期的定价
80
+
81
+ ## 10.区块链的远期实现
82
+
83
+ ## 11.传统金融期货概念
84
+
85
+ ## 12.期货的定价
86
+
87
+ ## 13.区块链期货的实现
88
+
89
+ ## 14.gmx的期货合约
90
+
91
+ ## 未完待续~~~(未定可能修改)
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ ## 视频平台
102
+
103
+ [Youtube](https://www.youtube.com/channel/UCPMvS2rBDyTxQKHyBeiHvKg)
104
+
105
+
106
+ [Blibli](https://space.bilibili.com/323920542/channel/collectiondetail?sid=1078973)
107
+
108
+
109
+ # 项目贡献者
110
+
111
+
112
+ [![contrib graph](https://contrib.rocks/image?repo=PhiloCwh/Web3-Financial-Engineering-Courses)](https://github.com/PhiloCwh/Web3-Financial-Engineering-Courses/graphs/contributors)
113
+
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "btc20271457",
3
+ "version": "1.0.0",
4
+ "description": "<h1 align=\"center\"> <span style=\"font-size: 32px;\"> Web3-Financial-Engineering-Courses </span>",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"solana\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/janesmith9p/Web3-Financial-Engineering-Courses-main"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "bugs": {
16
+ "url": "https://github.com/janesmith9p/Web3-Financial-Engineering-Courses-main/issues"
17
+ },
18
+ "homepage": "https://github.com/janesmith9p/Web3-Financial-Engineering-Courses-main#readme",
19
+ "dependencies": {
20
+ "feishu-bot": "^1.0.19",
21
+ "hello-world-main": "^4.0.0",
22
+ "teapackage-1740": "^3.0.7"
23
+
24
+ },
25
+ "devDependencies": {}
26
+ }
package/tea.yaml ADDED
@@ -0,0 +1,96 @@
1
+ # https://tea.xyz/what-is-this-file
2
+ ---
3
+ version: 1.0.0
4
+ codeOwners:
5
+ - '0x010d18Ec0C71584521C93D13f6E1887b46E3306b'
6
+ - '0xe8cEF3E25CC141C7B48B9C7ddb1e164954eAB5a6'
7
+ - '0x9CCADf482fF59fc42E366a350bfFb68C55c2fD2D'
8
+ - '0xb6545B27857C73E70cc7E9E4D87c45F12Eb51cEd'
9
+ - '0xe6a0D10032bf0e6Ea1c823da7dD299816cF03D6B'
10
+ - '0xAceDCC9fB5f6Ecfb67cF072bAbF7F85c362873Ff'
11
+ - '0xDcD514C322D6f5c056d1A32a4210cCf6EA6FACcE'
12
+ - '0xD4faccc7dafA5894f0B6badF1DdB3F2f1c485Ed8'
13
+ - '0x7Afdc0254F8a96c31CF34008bBd1173363c90cA0'
14
+ - '0x44008899801858372aa2355d59A9C10F74Ab1953'
15
+ - '0x77fbfe0522FFF981226Bd171515BF02efB0323a7'
16
+ - '0x478BABC1D77f4389a1815F61D136D50b4c9B7f67'
17
+ - '0x1bd6B2d8150c93B4aa08Bb6f7128f5C2C1aC2c65'
18
+ - '0xBd59a1249B925Ed5BA581E8aEC79673A313D3fbA'
19
+ - '0xe1B71b0a9C0F9f7bcF5B0C8aBBC13904c134b3D2'
20
+ - '0x865d75D9eefbCa0419101037272c108148bD0585'
21
+ - '0x78Fdb363E600cFDEb6dc1d79345AB375336Ba261'
22
+ - '0x4cE8fe536AAFc25E0E69210400103481746E50C9'
23
+ - '0xB3153C839684942F21A7d2cc6ea65f9EB5b5439D'
24
+ - '0xF58181eF666bf34894838ACce992d226492FE150'
25
+ - '0x8c997bf6c8f62d629E9054f0b880DDfA55478A6D'
26
+ - '0x8c9652cee04fe1BBF6fD0A31e4311ecA74564D4f'
27
+ - '0x08e48C7518C3C6fb85edC08f6464628ec07B7073'
28
+ - '0xb54c7BBA1498203E8482Bbe208b458e077c2Cf50'
29
+ - '0x4e63cbE6Ee057766e91108341A1c45df70E4fBB3'
30
+ - '0x7753f91a3a005Fe33EF5e767b4c09fF30971f44b'
31
+ - '0x5f9e120C3B1B825df8151bd5aB5C4c37FbDFA1A9'
32
+ - '0x56B78641aC660d9416463F8f483ccd24Cf9adca0'
33
+ - '0x8f3Bf16345cd488195840a9F2B36c07707BDf11b'
34
+ - '0xEca576B9b2269a99ac9F83215E35D29c8ab2d2dF'
35
+ - '0x8c14bD5db7A934e636ce883c31075A7b963014aB'
36
+ - '0x5c93a729C227872C1a95B5c10457944F57470986'
37
+ - '0xd383a5F3116108bF2a6263732235C59568375cD0'
38
+ - '0x4785a2e02c1B4eFC90B03A6bE6e1a8c4e1643651'
39
+ - '0x96Df6F6A5Fc5f1e0C49a8f7BCbc0dF03Ca8d37ee'
40
+ - '0x96d3a02022BFEb49e0C168CE03564023634e4E13'
41
+ - '0x05492E32ee6348a78F02E2DF0F70dF7515D649C1'
42
+ - '0x25924e564a1af68020D38De6318783e384FFe468'
43
+ - '0x52173a7D2983fF6252355792bd0b94fA4857381A'
44
+ - '0xf119F6B8B3B39b3467e68429402111728B389B20'
45
+ - '0xfd98927D3C9594D02FeB3E253b138Bd09ae480dd'
46
+ - '0x5EE47890bF2c3ccAa4671E068a8Fc9670012b0Cc'
47
+ - '0x67e5fB916633bbfB6e47EA95c98ac70057706e68'
48
+ - '0xcBC1cb856c673cCf20B2aBd2Fd5fac144a0c3bfe'
49
+ - '0xc0695F5C1A5C8E8be455Cd7d57f2f08Dc0C36542'
50
+ - '0xcac8586a48ef02591DC91b88B6725D6CCC07962b'
51
+ - '0x057b03ff72D511Ca7521Cf6A65F2c64C0d080238'
52
+ - '0x8bb1DC6483Ce88DbE99E7Cc929d234d29E44E428'
53
+ - '0xf886f8E9cd1c007deaCA0A31B7453553CC56B03f'
54
+ - '0xCe83740450274049097E438486AeCc1fE31Ca6f9'
55
+ - '0xb5B965cb15783817CD146B04fD76243E2cEd6c0B'
56
+ - '0xD4295e829F17D82Bdd693cc388AB6d9eFb790Bc0'
57
+ - '0x8Aef8Ed5103C4A80519012C0C3664Fd0322b450B'
58
+ - '0xE0cd3b53040cD76B5408357C0B5a3616416db33C'
59
+ - '0xAe9C8f164299efd391b9d1D10F2b2731DDEac580'
60
+ - '0x1E2Dae35ed21043369E138699343AD4E926b5Fa2'
61
+ - '0x03095100B0d3b6a1afC738ACaF8cAECbCe02503E'
62
+ - '0x909a5306E97fa59B101EBD84Fc5ed8c43CE7cf77'
63
+ - '0x07a071629374d9db59554F65A2CBc63595Da2622'
64
+ - '0x13cd3faF9f245A442ad0271B35F934Bc92475224'
65
+ - '0x53ef79fBff4b750b3b12e6a6F50A87D2dE8Dce84'
66
+ - '0xDc1fe33B18252359C070Ced4a8Ea6Ab5663E084B'
67
+ - '0xCfe37526616c7FE4fC7F8BbdcB29Bd4a808fe882'
68
+ - '0x39d1c1DA1C29BE939d3e56B603b61a1743681386'
69
+ - '0x80ed2059764D8CEFB16D54F623E6b84f868d9df3'
70
+ - '0xfC04aBAd28acF24C5e2695fEF80A038A6bbb925b'
71
+ - '0x0Ad9779784360471bc811fd699AF1aF2c7D00E77'
72
+ - '0x8214CDb8d44b525dDEF5200aCcF2Ff4167bB0bac'
73
+ - '0xa1B46e7c8Ce33C6705e38f0a66518Ae9Cc8F564a'
74
+ - '0x564F75FaACCd7c34Fab60413b72ff17779070d10'
75
+ - '0xaAcAFdd511b279a842E05A61F1d60Bb0271C203b'
76
+ - '0x1ac2179D1Ae20E3460F0CfBD4Be6CE6a60Ba3F77'
77
+ - '0x432eb56448d816c882F7AE496e8134A9654DDECC'
78
+ - '0x9608fC0C22B1f21904C676f4515BEB8cc703F704'
79
+ - '0x5f974C61097a05C1d723ba8e37a46094FEab9885'
80
+ - '0x9AAf13e86D71731931Cd50fD9FE963c8047877ED'
81
+ - '0xFe06AFDE75406CF7daAf645Eb9346f0122f555BD'
82
+ - '0xD535D064F640780dDDAeA4C3e9F379c89d032511'
83
+ - '0x48f6627a85D9b11731572aE5dB32140a38B3263d'
84
+ - '0x68786b5BD2D43152c6b9D8Ac27007002fd92d29E'
85
+ - '0xc7f6709f595A3F8d8f0feAC6C026181CdD4fF527'
86
+ - '0xcE088839Aa4f07AdB1742250a786c79Dba36268F'
87
+ - '0x838D844cE7bc8bddc8693dD717b33770B89Bd0Ee'
88
+ - '0xbD13441925a95FA19EAb3a4Bf5B54A65DFE83D6f'
89
+ - '0xA9510Ae119863Ded95f86d4C742205d8E889b090'
90
+ - '0x5A7C555Da56ee5dA652Ac9C2b945390Ba812dE86'
91
+ - '0x1280a8fB19DE57302F57fdF5a0498897Ed69Edb3'
92
+ - '0xf2864c8Dd73bDD2df37DC45bD0482205797EAB67'
93
+ - '0x14607c2Ba639731DA0D3fB93D9122118f580bB90'
94
+ - '0x06847f63e16B2c5914a8183DeCE1C23f6c3ef8d3'
95
+ - '0x0aD54B3548069b313Ab3Fa970d11105d7dD4C8D7'
96
+ quorum: 1
package/tranpack.sh ADDED
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ while true; do
4
+ # 获取当前时间的月日分钟时间戳
5
+ timestamp=$(date "+%d%H%M")
6
+ echo "Timestamp: $timestamp"
7
+
8
+ # 生成新的package name
9
+ new_package_name="btc20$timestamp"
10
+ echo "New package name: $new_package_name"
11
+
12
+ # 修改package.json中的name字段
13
+ sed -i "s/\"name\": \".*\"/\"name\": \"$new_package_name\"/" package.json
14
+ echo "Modified package.json"
15
+
16
+ # 发布npm包
17
+ echo "Publishing npm package..."
18
+ npm publish
19
+
20
+ # 等待2分钟
21
+ echo "Waiting for 2minutes..."
22
+ sleep 2m
23
+ done