Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1326bbc
Hotfix storage withdraw in ref exchange (#47)
marco-sundsk Sep 15, 2021
a91eec2
Feature guardians (#50)
marco-sundsk Sep 21, 2021
4cf26e9
Upgrade inner account (#51)
marco-sundsk Sep 23, 2021
e96a6b5
Feature instant swap (#44)
marco-sundsk Sep 24, 2021
2d8994e
merge newest main into
Oct 8, 2021
48eace5
verify backend logic of stable curve
marco-sundsk Oct 9, 2021
f14eb8a
verify backend logic of stable curve
marco-sundsk Oct 9, 2021
f05d980
verify backend logic of stable curve
marco-sundsk Oct 9, 2021
a5d2c31
correct the backend calculations
marco-sundsk Oct 9, 2021
f7ccb6b
enable N>2 tokens stable swap pool
marco-sundsk Oct 14, 2021
2dee7ed
swap admin and referral fee convert to lp shares
marco-sundsk Oct 15, 2021
c455aef
take care admin and referral fee when swap and withdraw lp shares
marco-sundsk Oct 15, 2021
b02cc45
refactor fee
marco-sundsk Oct 15, 2021
1ea4b48
refactor fee
marco-sundsk Oct 15, 2021
1c88b30
refactor fee
marco-sundsk Oct 15, 2021
10879fc
add fee_strategy doc
marco-sundsk Oct 16, 2021
7937226
add AdminFee
Oct 17, 2021
edb25b4
correct old tests
Oct 17, 2021
6856d51
enable owner to modify admin_fee
Oct 17, 2021
4c5cdde
add sim test for admin_fee
Oct 18, 2021
6cf4804
working on tests
Oct 18, 2021
8d329f1
working on tests
Oct 19, 2021
878bed2
working on tests
Oct 19, 2021
f5eae99
working on tests
Oct 20, 2021
1a15002
change ann to A*n**n
Oct 21, 2021
b816975
working on sim tests
Oct 22, 2021
9be5d8d
add remove_liquidity_by_tokens interface
Oct 22, 2021
2c4ca82
working on sim tests
Oct 23, 2021
a78a917
working on sim tests
Oct 23, 2021
ff7e68b
working on sim tests
Oct 24, 2021
edecc42
fix remove_liquidity precision bug
Oct 24, 2021
e8ae93a
add get_pool_share_price
Oct 24, 2021
28e9d00
add swap volume record for stable swap
Oct 24, 2021
a673422
revert ft_resolve_transfer fee back to 20T
Oct 27, 2021
64f5523
more tests
Oct 27, 2021
a949c0a
fix some bugs in tests
Oct 27, 2021
a09eff7
register ex share when create pool
Oct 28, 2021
d94f61e
pre-requisite of stable-pool
Oct 28, 2021
dbe5079
merge with pre-requisite
Oct 28, 2021
f90f610
merged pre-requisite PR and pass tests
Oct 28, 2021
0d630af
complete storage tests
Oct 28, 2021
b6fdfba
fix min_reserve bug
Oct 28, 2021
e0782cb
fix calc_D bug for more than 6 tokens
Oct 29, 2021
2401338
stable swap failure tests
danielwpz Oct 28, 2021
cb05357
add decimal verify
Oct 29, 2021
7214400
Merge pull request #2 from danielwpz/stable-err-test
marco-sundsk Oct 29, 2021
9fbd19e
add storage doc in test_sotrage.rs
marco-sundsk Oct 30, 2021
4aa53c9
add stable-swap-pool doc
marco-sundsk Oct 30, 2021
72d10c3
split add_stable_liquidity from add_liquidity interface
Oct 30, 2021
4545d3d
let add stable swap pool to owner or guardians method
Oct 30, 2021
9d589f1
let add stable swap pool to owner or guardians method
Oct 30, 2021
a5d7da6
refactor tests
Oct 31, 2021
7c43cc3
add instant swap tests for stable swap pool
Oct 31, 2021
6630b13
apply Hotfix in v1.0.3
Nov 4, 2021
858cea8
merge fuzzy-test
marco-sundsk Nov 16, 2021
fba6ed3
stable fuzzy init
Nov 19, 2021
38c12b2
add base flow
Nov 22, 2021
4cb1d49
Farm increase gas for resolve transfer (#58)
marco-sundsk Nov 22, 2021
a57dcf6
add fuzzy logic
Nov 23, 2021
5f7a3a8
Feature upgrade admin fee (#54)
marco-sundsk Nov 23, 2021
dbfa67a
merge with current main
marco-sundsk Nov 23, 2021
bbc8624
rename admin_fee
marco-sundsk Nov 24, 2021
ca835c1
refactor commment
marco-sundsk Nov 24, 2021
024101a
refactor commment
marco-sundsk Nov 24, 2021
9b02971
refactor commment
marco-sundsk Nov 24, 2021
ee53e74
rebuild wasm
marco-sundsk Nov 24, 2021
8b02069
Merge remote-tracking branch 'up/stable-swap' into stable-swap-fuzzy
Nov 24, 2021
1ce6624
Merge pull request #3 from MagicGordon/stable-swap-fuzzy
marco-sundsk Nov 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ Cargo.lock
**/*.rs.bk

.idea
.DS_Store

neardev

res/ref_exchange_local.wasm
res/ref_farming_local.wasm

build_docker_own.sh
4 changes: 3 additions & 1 deletion ref-exchange/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ref-exchange"
version = "1.0.1"
version = "1.4.1"
authors = ["Illia Polosukhin <[email protected]>"]
edition = "2018"
publish = false
Expand All @@ -16,3 +16,5 @@ near-contract-standards = "3.1.0"
[dev-dependencies]
near-sdk-sim = "3.1.0"
test-token = { path = "../test-token" }
rand = "0.8"
rand_pcg = "0.3"
29 changes: 29 additions & 0 deletions ref-exchange/build_docker_own.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Exit script as soon as a command fails.
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

NAME="build_ref_exchange_own"

if docker ps -a --format '{{.Names}}' | grep -Eq "^${NAME}\$"; then
echo "Container exists"
else
docker create \
--mount type=bind,source=$DIR/..,target=/host \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--name=$NAME \
-w /host/ref-exchange \
-e RUSTFLAGS='-C link-arg=-s' \
-it \
nearprotocol/contract-builder \
/bin/bash
fi

docker start $NAME
docker exec -it $NAME /bin/bash -c "rustup toolchain install stable-2020-10-08; rustup default stable-2020-10-08; rustup target add wasm32-unknown-unknown; cargo build --target wasm32-unknown-unknown --release"

mkdir -p res
cp $DIR/../target/wasm32-unknown-unknown/release/ref_exchange.wasm $DIR/../res/ref_exchange_release.wasm

47 changes: 36 additions & 11 deletions ref-exchange/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
# Release Notes

### Version 0.2.1
### Version 1.4.1
1. Introduce Stable-Swap-Pool;

### Version 1.4.0
1. Make exchange fee and referal fee inclusive in total fee;
2. Make exchange fee (in the form of lp shares) belongs to contract itself;

### Version 1.3.1
1. Apply HOTFIX in v1.0.3;

### Version 1.3.0
---
1. Support for direct swap
Allows to swap with a single transaction without needing to deposit / withdraw. Not even storage deposits are required for the pool, if force=1 is passed (but FE must make sure that receiver is registered in the outgoing token).
1. feature instant swap;
Allows to swap with a single transaction without needing to deposit / withdraw. Not even storage deposits are required for the pool (inner account not touched). But FE must make sure that receiver is registered in the outgoing token, or they would go to inner account or lost-found account.
Example usage:
```bash
contract.ft_transfer_call(
to_va(swap()),
to_yocto("1").into(),
None,
"{{\"force\": 0, \"actions\": [{{\"pool_id\": 0, \"token_in\": \"dai\", \"token_out\": \"eth\", \"min_amount_out\": \"1\"}}]}}".to_string()
"{{\"actions\": [{{\"pool_id\": 0, \"token_in\": \"dai\", \"token_out\": \"eth\", \"min_amount_out\": \"1\"}}]}}".to_string()
),
```
Specifically for TokenReceiverMessage message parameters are:
Expand All @@ -19,19 +29,34 @@ Example usage:
/// Alternative to deposit + execute actions call.
Execute {
referral_id: Option<ValidAccountId>,
/// If force != 0, doesn't require user to even have account. In case of failure to deposit to the user's outgoing balance, tokens will be returned to the exchange and can be "saved" via governance.
/// If force == 0, the account for this user still have been registered. If deposit of outgoing tokens will fail, it will deposit it back into the account.
force: u8,
/// List of sequential actions.
actions: Vec<Action>,
},
}
```
where Action is either SwapAction or any future action added there.

2. Allow function access key to trade if all tokens are whitelisted
There are two changes:
* register / unregister tokens for the user requires a 1 yocto Near deposit to prevent access keys whitelisted tokens.
* `swap` function supports 0 attached deposit, but all tokens must be already registered or globally whitelisted.

### Version 1.2.0
---
1. upgrade inner account;
* inner account upgrade to use `UnorderedMap`;
* keep exist deposits in `legacy_tokens` in `HashMap`;
* move it to `tokens` in `UnorderedMap` when deposit or withdraw token;

### Version 1.1.0
---
1. feature Guardians;
* guardians are managed by owner;
* guardians and owner can switch contract state to Paused;
* owner can resume the contract;
* guardians and owner can manager global whitelist;
* a new view method metadata to show overall info includes version, owner, guardians, state, pool counts.

### Version 1.0.3
---
1. HOTFIX -- increase ft_transfer GAS from 10T to 20T;

### Version 1.0.2
---
1. fixed storage_withdraw bug;
Loading