Skyward Finance smart-contracts

Overview

Build and Init

./build.sh
near dev-deploy res/skyward.was
export CONTRACT_ID=skyward.testnet
near call $CONTRACT_ID new --account_id=$CONTRACT_ID

Register tokens for ACCOUNT_ID

export TOKEN1=token1.testnet
export TOKEN2=token2.testnet
export ACCOUNT_ID=account1.testnet
export ACCOUNT_ID2=account2.testnet

# Init tokens
# near call $TOKEN1 --accountId=$ACCOUNT_ID new_default_meta '{"owner_id": "'$ACCOUNT_ID'", "total_supply": "1000000000000000000000000000000000"}'
# near call $TOKEN2 --accountId=$ACCOUNT_ID2 new_default_meta '{"owner_id": "'$ACCOUNT_ID2'", "total_supply": "1000000000000000000000000000000000"}'

# Register both tokens for $ACCOUNT_ID (even though only TOKEN1) is needed now
near call $CONTRACT_ID --accountId=$ACCOUNT_ID register_tokens '{"token_account_ids": ["'$TOKEN1'", "'$TOKEN2'"]}' --amount=0.01

near view $CONTRACT_ID get_account_balances '{"account_id": "'$ACCOUNT_ID'"}'

Register contract with tokens

near call $TOKEN1 --accountId=$ACCOUNT_ID storage_deposit '{"account_id": "'$CONTRACT_ID'"}' --amount=0.00125
near call $TOKEN2 --accountId=$ACCOUNT_ID storage_deposit '{"account_id": "'$CONTRACT_ID'"}' --amount=0.00125

Deposit TOKEN1

export AMOUNT=1000000000000000000000000000000
near call $TOKEN1 --accountId=$ACCOUNT_ID ft_transfer_call '{"receiver_id": "'$CONTRACT_ID'", "amount": "'$AMOUNT'", "memo": "Yolo for sale", "msg": "\"AccountDeposit\""}' --amount=0.000000000000000000000001
near view $CONTRACT_ID get_account_balances '{"account_id": "'$ACCOUNT_ID'"}'

Register 2nd account with contract

near call $CONTRACT_ID --accountId=$ACCOUNT_ID2 register_token '{"token_account_id": "'$TOKEN2'"}' --amount=0.01

Deposit TOKEN2 from 2nd account to contract

export AMOUNT=1000000000000000000000000000000
near call $TOKEN2 --accountId=$ACCOUNT_ID2 ft_transfer_call '{"receiver_id": "'$CONTRACT_ID'", "amount": "'$AMOUNT'", "memo": "BUY BUY BUY", "msg": "\"AccountDeposit\""}' --amount=0.000000000000000000000001
near view $CONTRACT_ID get_account_balances '{"account_id": "'$ACCOUNT_ID2'"}'

Creating sale

# Mac + fish
# echo (date -v +10M '+%s')"000000000"
export START_TIMESTAMP=1600000000000000000
export SALE_AMOUNT=500000000000000000000000000000
near call $CONTRACT_ID --accountId=$ACCOUNT_ID sale_create '{"sale": {"out_token_account_id": "'$TOKEN1'", "out_token_balance": "'$SALE_AMOUNT'", "in_token_account_id": "'$TOKEN2'", "start_time": "'$START_TIMESTAMP'", "duration": "3600000000000"}}' --amount=0.1

near view $CONTRACT_ID get_sales

Joining SALE

export AMOUNT=1000000000000000000000000000
export SALE_ID=0
near call $CONTRACT_ID --accountId=$ACCOUNT_ID2 sale_deposit_in_token '{"sale_id": '$SALE_ID', "amount": "'$AMOUNT'"}' --amount=0.01

near view $CONTRACT_ID get_sales '{"account_id": "'$ACCOUNT_ID2'"}'

Claiming from SALE

near call $CONTRACT_ID --accountId=$ACCOUNT_ID2 sale_claim_out_tokens '{"sale_id": '$SALE_ID'}'

near view $CONTRACT_ID get_sales '{"account_id": "'$ACCOUNT_ID2'"}'
You might also like...
Rust library for build smart contracts on Internet Computer, by the Spinner.Cash team.

Spinner Rust library for building smart contracts on the Internet Computer. More specifically it is used by Spinner.Cash, a decentralized layer-2 prot

Rust implementation for Thippy -- a Substrate parachain for smart contracts.

Thippy ‒- A Smart Contracts Parachain This is a node implementation of Thippy, a Substrate parachain for smart contracts. Developing Smart Contracts f

Helpful functions and macros for developing smart contracts on NEAR Protocol.

near-contract-tools Helpful functions and macros for developing smart contracts on NEAR Protocol. This package is a collection of common tools and pat

🖨 Template for Rust applications & smart contracts @okp4.

Rust Template Template for Rust projects @okp4. Purpose & Philosophy This repository holds the template for building Rust projects with a consistent s

CLI for Stellar Smart Contracts.

stellar-contract-cli CLI for running Stellar contracts locally in a test VM. Executes WASM files built using the rs-stellar-contract-sdk. Install carg

A gRPC-based scripting library for interacting with CosmWasm smart-contracts.

Cosmos Rust Script Smart contract scripting library to ease CosmWasm smart contract development and deployment. cosm-script is inspired by terra-rust-

Helpful functions and macros for developing smart contracts on NEAR Protocol.

near-contract-tools Helpful functions and macros for developing smart contracts on NEAR Protocol. This package is a collection of common tools and pat

A simple example demonstrating cross-contract calls in CosmWasm smart contracts

Cross-contract calls This tutorial demonstrates cross-contract calls with CosmWasm v1. Overview An end user calls the reservation contract to register

Rust client to Seaport's APIs and Ethereum smart contracts(WIP)

Seaport-rs WIP - WORK IN PROGRESS. REFER TO https://github.com/Alcibiades-Capital/quay FOR PRODUCTION READY CODE I'm new to Rust and seek to be legend

Comments
  • Handle donation exception

    Handle donation exception

    In case donating receiver is a plain account or got some issue that can not accept ft_transfer_call successfully, the donating process must has the ability to identify that and restore the untouched balance as well as total balance.

    opened by marco-sundsk 0
  • in whitepaper: are referrals distributed wrong?

    in whitepaper: are referrals distributed wrong?

    don't know where to ask, so I'm asking here

    in whitepaper https://skyward.finance/whitepaper/ you write

    Since we had 10 participants, and out of them 6 participated as referrals, 60% (6/10) of $SKYWARD rewards will be distributed among them: 14% to Bob, 23% to Kyle, and 23% to Leo. The remaining 40% will be burned.

    In this example, we distributed 10,000 $SKYWARD tokens. 1% of $SKYWARD supply for this sale is 100; thus, Bob receives 20 $SKYWARD, Kyle - 30 $SKYWARD, Leo - 10 $SKYWARD, and 40 $SKYWARD was burned.

    shouldn't it be

    In this example, we distributed 10,000 $SKYWARD tokens. 1% of $SKYWARD supply for this sale is 100; thus, Bob receives 14 $SKYWARD, Kyle - 23 $SKYWARD, Leo - 23 $SKYWARD, and 40 $SKYWARD was burned.

    ?

    opened by srghma 2
Owner
Skyward Finance
Skyward Finance
Minimal Substrate node configured for smart contracts via pallet-contracts.

substrate-contracts-node This repository contains Substrate's node-template configured to include Substrate's pallet-contracts ‒ a smart contract modu

Parity Technologies 73 Dec 30, 2022
evm2near compiles Solidity contracts into NEAR WebAssembly contracts.

EVM → NEAR evm2near is a project for compiling EVM bytecode into wasm bytecode, with the particular goal of having that wasm artifact be executable on

Aurora 125 Dec 3, 2022
Ticketed Discreet Log Contracts (DLCs) to enable instant buy-in for wager-like contracts on Bitcoin.

dlctix Ticketed Discreet Log Contracts (DLCs) to enable instant buy-in for wager-like contracts on Bitcoin. This project is part of the Backdrop Build

null 7 Feb 29, 2024
Rust client to Opensea's APIs and Ethereum smart contracts

opensea.rs Rust bindings & CLI to the Opensea API and Contracts CLI Usage Run cargo r -- --help to get the top level help menu: opensea-cli 0.1.0 Choo

Georgios Konstantopoulos 226 Dec 27, 2022
A framework for creating PoC's for Solana Smart Contracts in a painless and intuitive way

Solana PoC Framework DISCLAIMER: any illegal usage of this framework is heavily discouraged. Most projects on Solana offer a more than generous bug bo

Neodyme 165 Dec 18, 2022
My code for the terra.academy course on CosmWasm smart contracts

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

Alex Incerti 0 Nov 7, 2021
Smart contracts powering Spectrum Protocol on Terra

Spectrum Core Contracts This monorepository contains the source code for the core smart contracts implementing Spectrum Protocol on the Terra blockcha

Spectrum Protocol 38 Dec 19, 2022
A template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it.

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

null 1 Mar 7, 2022
Create your personal token with rust smart contracts

Solana Rust Token ?? This application written Rust using Anchor ⚓

Ritesh 6 Nov 22, 2022
This is a node implementation of Thippy, a Substrate parachain for smart contracts

Thippy ‒- A Smart Contracts Parachain This is a node implementation of Thippy, a Substrate parachain for smart contracts. Developing Smart Contracts f

Arthur·Thomas 15 Mar 16, 2022