Skip to content

Commit 2635ec4

Browse files
Initial commit, scheme of working
0 parents  commit 2635ec4

19 files changed

+6419
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
temp
3+
build

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 4,
4+
"singleQuote": true,
5+
"bracketSpacing": true,
6+
"semi": true
7+
}

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# MulDEX
2+
3+
## Project structure
4+
5+
- `contracts` - source code of all the smart contracts of the project and their dependencies.
6+
- `wrappers` - wrapper classes (implementing `Contract` from ton-core) for the contracts, including any [de]serialization primitives and compilation functions.
7+
- `tests` - tests for the contracts.
8+
- `scripts` - scripts used by the project, mainly the deployment scripts.
9+
10+
## How to use
11+
12+
### Build
13+
14+
`npx blueprint build` or `yarn blueprint build`
15+
16+
### Test
17+
18+
`npx blueprint test` or `yarn blueprint test`
19+
20+
### Deploy or run another script
21+
22+
`npx blueprint run` or `yarn blueprint run`
23+
24+
### Add a new contract
25+
26+
`npx blueprint create ContractName` or `yarn blueprint create ContractName`

contracts/imports/data.fc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{-
2+
uninit$0 jetton_masters:(Maybe ^Cell as map<Int, Address>) = ContractData;
3+
4+
init$1 jetton_wallets:(Maybe ^Cell as map<Address, Address>)
5+
assets:(Maybe ^Cell as map<Address, Int as uint256>)
6+
assets_sum:(Int as uint256) = ContractData;
7+
-}
8+
9+
const slice zero_asset = "00000000000000000000000000000000"s;
10+
11+
global cell jetton_wallets;
12+
global cell assets;
13+
global int assets_sum;
14+
15+
global cell jetton_masters;
16+
17+
int load_contract() impure inline {
18+
slice ds = get_data().begin_parse();
19+
if (ds~load_uint(1)) {
20+
jetton_wallets = ds~load_dict();
21+
assets = ds~load_dict();
22+
assets_sum = ds~load_uint(256);
23+
return 1;
24+
} else {
25+
jetton_masters = ds~load_dict();
26+
return 0;
27+
}
28+
}
29+
() save_contract() impure inline {
30+
set_data(begin_cell()
31+
.store_uint(1, 1)
32+
.store_dict(jetton_wallets)
33+
.store_dict(assets)
34+
.store_uint(assets_sum, 256)
35+
.end_cell());
36+
}
37+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
struct Swap {
2+
other_jetton_master: Address;
3+
min_swap_value: Int;
4+
swap_to: Address?;
5+
}
6+
7+
struct LiquidityTransaction {
8+
commit_after: map<Address, Int>;
9+
}
10+
11+
struct LiquidityRevert {}
12+
13+
struct DexInteraction {
14+
sw: Swap?;
15+
lt: LiquidityTransaction?;
16+
lr: LiquidityRevert?;
17+
}
18+

contracts/imports/messages.fc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;; op::dex_init#2CD21E85 jetton_wallets:(Maybe ^Cell as map<Address, Address>)
2+
;; = InMsgBody;
3+
4+
const int op::dex_init = 0x2CD21E85;
5+
6+
7+
8+
;; transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16)
9+
;; destination:MsgAddress response_destination:MsgAddress
10+
;; custom_payload:(Maybe ^Cell) forward_ton_amount:(VarUInteger 16)
11+
;; forward_payload:(Either Cell ^Cell) = OutMsgBody;
12+
13+
const int op::transfer_send = 0x0F8A7EA5;
14+
15+
() send_jettons(slice jetton_wallet, int query_id, int amount, slice dest,
16+
slice comment) impure inline {
17+
cell forward = begin_cell().store_uint(0, 32).store_slice(comment)
18+
.end_cell();
19+
send_raw_message(begin_cell()
20+
.store_uint(0x10, 6)
21+
.store_slice(jetton_wallet)
22+
.store_uint(op::transfer_send, 4 + 107 + 32)
23+
.store_uint(query_id, 64)
24+
.store_coins(amount)
25+
.store_slice(dest)
26+
.store_uint(0, 3)
27+
.store_coins(10 * 1000000)
28+
.store_dict(forward)
29+
.end_cell(), 64);
30+
}
31+
32+
33+
34+
;; transfer_notification#7362d09c query_id:uint64 amount:(VarUInteger 16)
35+
;; sender:MsgAddress forward_payload:(Either Cell ^Cell) = InMsgBody;
36+
37+
const int op::transfer_recv = 0x7362D09C;
38+

0 commit comments

Comments
 (0)