This contract is based from Ref-Finance farming contract. We modified the contract to create a farm with staked NFT. The staked NFT will be valued as X amount of FT.
$ cd ref-farming
$ ./build_docker.sh
We have precompiled binary in res/ directory.
PARAS FT testnet: dev-1631277489384-75412609538902
near dev-deploy --wasmFile res/ref_farming_release.wasm
near call --accountId dev-1641987418790-52566958498708 dev-1641987418790-52566958498708 new '{"owner_id":"dev-1641987418790-52566958498708"}'
near call --accountId dev-1641987418790-52566958498708 dev-1641987418790-52566958498708 create_simple_farm '{"terms":{"seed_id":"dev-1631277489384-75412609538902","reward_token":"dev-1631277489384-75412609538902","start_at":0,"reward_per_session":"1000000000000000000","session_interval":60},"metadata":{"title":"PARAS Staking","media":"https://paras-cdn.imgix.net/bafybeidoerucqfzyazvyfm5axjixs6vie7ts2myru7g5mu2ub7tlvixpqq?w=800"}}' --depositYocto 19380000000000000000000
near call --accountId dev-1641987418790-52566958498708 dev-1641987418790-52566958498708 create_simple_farm '{"terms":{"seed_id":"dev-1631277489384-75412609538902$1","reward_token":"dev-1631277489384-75412609538902","start_at":0,"reward_per_session":"1000000000000000000","session_interval":60},"nft_balance":{"paras-token-v1.testnet@194":"500000000000000000000","paras-token-v1.testnet@177":"100000000000000000000","paras-comic-dev.testnet@6":"200000000000000000000"},"metadata":{"title":"Vitamins Pool","media":"https://cdn.paras.id/tr:w-0.8/bafybeiboxzb5qzwuvkw4vlcubc6sd5vfu532qr6nomzj2dgq7pigh5jfay"}}' --depositYocto 19380000000000000000000
near view dev-1641987418790-52566958498708 get_farm '{"farm_id":"dev-1631277489384-75412609538902$1#0"}'
near view dev-1641987418790-52566958498708 get_seed_info '{"seed_id":"dev-1631277489384-75412609538902$1"}'
near call --accountId orang.testnet dev-1631277489384-75412609538902 ft_transfer_call '{"receiver_id":"dev-1641987418790-52566958498708","amount":"250000000000000000000000","msg":"dev-1631277489384-75412609538902$1#0"}' --depositYocto 1 --gas 300000000000000
near call --accountId cymac.testnet dev-1641987418790-52566958498708 storage_deposit '{"account_id":"cymac.testnet"}'
--depositYocto 18520000000000000000000
near call --accountId cymac.testnet dev-1631277489384-75412609538902 ft_transfer_call '{"receiver_id":"dev-1641987418790-52566958498708","amount":"10000000000000000000","msg":""}' --depositYocto 1 --gas 300000000000000
near view dev-1641987418790-52566958498708 list_user_seeds '{"account_id":"cymac.testnet"}'
near call --accountId cymac.testnet paras-token-v1.testnet nft_transfer_call '{"receiver_id":"dev-1641987418790-52566958498708","token_id":"177:5","msg":"dev-1631277489384-75412609538902$1"}' --depositYocto 1 --gas 300000000000000
near view dev-1641987418790-52566958498708 list_user_nft_seeds '{"account_id":"cymac.testnet"}'
near call --accountId cymac.testnet dev-1641987418790-52566958498708 withdraw_seed '{"seed_id":"dev-1631277489384-75412609538902","amount":"10000000000000000000"}' --depositYocto 1 --gas 100000000000000
near call --accountId cymac.testnet dev-1641987418790-52566958498708 withdraw_nft '{"seed_id":"dev-1631277489384-75412609538902$1","nft_contract_id":"paras-token-v1.testnet","nft_token_id":"177:5"}' --depositYocto 1 --gas 100000000000000
near view dev-1641987418790-52566958498708 get_unclaimed_reward '{"account_id":"cymac.testnet","farm_id":"dev-1631277489384-75412609538902$1#0"}'
near call --accountId cymac.testnet dev-1641987418790-52566958498708 claim_reward_by_farm '{"farm_id":"dev-1631277489384-75412609538902$1#0"}'
near view dev-1641987418790-52566958498708 list_rewards '{"account_id":"cymac.testnet"}'
near call --accountId cymac.testnet dev-1641987418790-52566958498708 withdraw_reward '{"token_id":"dev-1631277489384-75412609538902"}' --depositYocto 1 --gas 300000000000000
near call --accountId cymac.testnet dev-1641987418790-52566958498708 claim_reward_by_farm_and_withdraw '{"farm_id":"dev-1631277489384-75412609538902$1#0"}' --depositYocto 1 --gas 300000000000000
near call --accountId cymac.testnet dev-1641987418790-52566958498708 claim_reward_by_seed_and_withdraw '{"seed_id":"dev-1631277489384-75412609538902$1","token_id":"dev-1631277489384-75412609538902"}' --depositYocto 1 --gas 300000000000000
This mono repo contains the source code for the smart contracts of Ref Finance on NEAR.
Contract | Reference | Description |
---|---|---|
test-token | - | Test token contract |
ref-exchange | docs | Main exchange contract, that allows to deposit and withdraw tokens, exchange them via various pools |
- Install
rustup
via https://rustup.rs/ - Run the following:
rustup default stable
rustup target add wasm32-unknown-unknown
Contracts have unit tests and also integration tests using NEAR Simulation framework. All together can be run:
cd ref-exchange
cargo test --all
You can build release version by running next scripts inside each contract folder:
cd ref-exchange
./build.sh
To deploy to TestNet, you can use next command:
near dev-deploy
This will output on the contract ID it deployed.