Giter Site home page Giter Site logo

cheddar-nft-farming-contract's Introduction

Paras NFT Farming Contract

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.

How to compile

$ cd ref-farming
$ ./build_docker.sh

How to use

We have precompiled binary in res/ directory.

PARAS FT testnet: dev-1631277489384-75412609538902

Deploy to testnet (dev)

near dev-deploy --wasmFile res/ref_farming_release.wasm

Init

near call --accountId dev-1641987418790-52566958498708 dev-1641987418790-52566958498708 new '{"owner_id":"dev-1641987418790-52566958498708"}'

Create Farm (FT)

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

Create farm (NFT)

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

View farm

near view dev-1641987418790-52566958498708 get_farm '{"farm_id":"dev-1631277489384-75412609538902$1#0"}'

View seed

near view dev-1641987418790-52566958498708 get_seed_info '{"seed_id":"dev-1631277489384-75412609538902$1"}'

Add reward

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

Register as Farmer

near call --accountId cymac.testnet dev-1641987418790-52566958498708 storage_deposit '{"account_id":"cymac.testnet"}'
--depositYocto 18520000000000000000000

Stake FT

near call --accountId cymac.testnet dev-1631277489384-75412609538902 ft_transfer_call '{"receiver_id":"dev-1641987418790-52566958498708","amount":"10000000000000000000","msg":""}' --depositYocto 1 --gas 300000000000000

View staked FT

near view dev-1641987418790-52566958498708 list_user_seeds '{"account_id":"cymac.testnet"}'

Stake NFT

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

View staked NFT

near view dev-1641987418790-52566958498708 list_user_nft_seeds '{"account_id":"cymac.testnet"}'

Unstake FT

near call --accountId cymac.testnet dev-1641987418790-52566958498708 withdraw_seed '{"seed_id":"dev-1631277489384-75412609538902","amount":"10000000000000000000"}' --depositYocto 1 --gas 100000000000000

Unstake NFT

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

View unclaimed rewards

near view dev-1641987418790-52566958498708 get_unclaimed_reward '{"account_id":"cymac.testnet","farm_id":"dev-1631277489384-75412609538902$1#0"}'

Claim rewards

near call --accountId cymac.testnet dev-1641987418790-52566958498708 claim_reward_by_farm '{"farm_id":"dev-1631277489384-75412609538902$1#0"}'

List claimed rewards

near view dev-1641987418790-52566958498708 list_rewards '{"account_id":"cymac.testnet"}'

Withdraw reward

near call --accountId cymac.testnet dev-1641987418790-52566958498708 withdraw_reward '{"token_id":"dev-1631277489384-75412609538902"}' --depositYocto 1 --gas 300000000000000

Claim and withdraw reward

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

Claim and withdraw reward by seed

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

Ref Finance Contracts

This mono repo contains the source code for the smart contracts of Ref Finance on NEAR.

Contracts

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

Development

  1. Install rustup via https://rustup.rs/
  2. Run the following:
rustup default stable
rustup target add wasm32-unknown-unknown

Testing

Contracts have unit tests and also integration tests using NEAR Simulation framework. All together can be run:

cd ref-exchange
cargo test --all

Compiling

You can build release version by running next scripts inside each contract folder:

cd ref-exchange
./build.sh

Deploying to TestNet

To deploy to TestNet, you can use next command:

near dev-deploy

This will output on the contract ID it deployed.

cheddar-nft-farming-contract's People

Contributors

emarai avatar ilblackdragon avatar marco-sundsk avatar referencedev avatar robert-zaremba avatar mehtaphysical avatar joundy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.