Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "templar_protocol"
version = "0.1.0"
edition = "2021"

[lib]
name = "templar_protocol"
crate-type = ["cdylib"]

[dependencies]
near-contract-standards = "5.3.0"
near-sdk = "5.3.0"
uint = { version = "0.9.3", default-features = false }

[dev-dependencies]
rand = "0.8.4"

[profile.release]
codegen-units = 1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = true
80 changes: 78 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
# contract-mvp
MVP implementation of NFT gated 0% interest lending
# Templar Protocol

0% interest lending protocol on NEAR

## Getting Started

```sh
./build.sh
./dev-deploy.sh
```

```sh
cargo build --target wasm32-unknown-unknown --release

near dev-deploy ./target/wasm32-unknown-unknown/release/templar_protocol.wasm

export G= TEMPLAR_ACCOUNT
export USDT=usdt.fakes.testnet
export ACCT= YOUR_ACCOUNT
```

```sh
near call $G new '{"lower_collateral_accounts": ["kenobi.testnet"]}' --accountId $G
```

## Operations

### Update Price

### Get Latest Price

```sh
near call $G get_latest_price --accountId $G
```

### Get all Loans

```sh
near call $G get_all_loans --accountId $G
```

### Deposit Collateral

```sh
near call $G deposit_collateral '{"amount": 1000000}' --accountId $G
```

### Borrow

```sh
near call $G borrow '{"usdt_amount": 1}' --accountId $G --gas 300000000000000
```

### Repay

```sh
near call $G repay '{"account_id": "kenobi.testnet", "usdt_amount": 50}' --accountId $ACCT --gas 300000000000000
```

### Get USDT Value of NEAR

```sh
near call $G get_usdt_value --accountId $G --gas 300000000000000

near call $G get_prices --accountId $G --gas 300000000000000
```

### Open and Close an Account

```sh
near call $G deposit_collateral '{"amount": 10}' --accountId $ACCT --deposit 10

near call $G borrow '{"usdt_amount": 500}' --accountId $ACCT --gas 300000000000000

near call $USDT ft_transfer_call '{"receiver_id": "templar.kenobi.testnet", "amount": "1", "memo": "Test", "msg": "close"}' --accountId $ACCT --gas 300000000000000 --depositYocto 1

near call $G close '{}' --accountId $ACCT --gas 300000000000000
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
543 changes: 543 additions & 0 deletions architecture/protocol_state_machine.drawio

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RUSTFLAGS='-C link-arg=-s' cargo build --all --target wasm32-unknown-unknown --release
7 changes: 7 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export ACCT = {YOUR_ACCOUNT_ID}
export TEMPLAR = "g.${ACCT}"
export USDT = "usdt.fakes.testnet"

near delete $TEMPLAR --masterAccount $ACCT

cargo clean
14 changes: 14 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

export ACCT = {YOUR_ACCOUNT_ID}
export TEMPLAR = "g.${ACCT}"
export USDT = "usdt.fakes.testnet"

# Deploy
cargo build --target wasm32-unknown-unknown --release
near create-account $TEMPLAR --masterAccount $ACCT --initialBalance 10
near deploy --accountId $TEMPLAR --wasmFile ./target/wasm32-unknown-unknown/release/templar_protocol.wasm


# Register and provide USDT token
near call $USDT register_account '{"account_id": "'$TEMPLAR'"}' --accountId $ACCT --amount 0.125 --gas 300000000000000
near call $USDT ft_transfer '{"receiver_id": "'$TEMPLAR'", "amount": "10"}' --accountId $ACCT --amount 0.125 --gas 300000000000000
3 changes: 3 additions & 0 deletions dev-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cargo build --target wasm32-unknown-unknown --release

near dev-deploy ./target/wasm32-unknown-unknown/release/templar_protocol.wasm
1 change: 1 addition & 0 deletions node_modules/.bin/mustache

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading