USN is a NEAR-native USD stable coin.
The contract implements fungible token API according to the following standards:
- NEP-141 (ERC-20 fashioned)
- NEP-148
- Fungible Token Event
Mainnet | usn |
Testnet | usdn.testnet |
Sandbox | usn.test.near |
Method: ft_transfer_call
(USDT) -> ft_on_transfer
(USN)
Method: withdraw
(USN)
First, install prerequisites:
npm install
Then, build.
For local sandbox:
npm run build
For testnet:
npm run build:testnet
For mainnet:
npm run build:mainnet
WARNING: There is a difference in each target about the addresses for cross-contract communication.
Mainnet | dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near |
Testnet | usdt.fakes.testnet |
Sandbox | usdt.test.near |
cargo test
npm test
Build
npm run build:testnet
Deploy
near deploy --force --wasmFile target/wasm32-unknown-unknown/testnet/usn.wasm --accountId=usdn.testnet --masterAccount=usdn.testnet
Init once
near call usdn.testnet new --args '{"owner_id": "usdn.testnet"}' --accountId=usdn.testnet
Add a guardian
near call usdn.testnet extend_guardians --accountId usdn.testnet --args '{"guardians": ["alice.testnet"]}'
Deposit and withdraw
# Send USDT, mint USN.
near call usdt.fakes.testnet ft_transfer_call --args '{"receiver_id": "usdn.testnet", "amount": "1000000", "msg": ""}' --accountId alice.testnet --depositYocto 1 --gas 100000000000000
# Burn USN, withdraw USDT.
near call usdn.testnet withdraw --args '{"amount": "999500000000000000"}' --accountId alice.testnet --depositYocto 1 --gas 100000000000000
- Download
usn.mainnet.wasm
from https://github.com/DecentralBankDAO/usn/releases - Create an upgrade proposal:
sputnikdao proposal upgrade usn.mainnet.wasm usn --daoAcc decentralbank --accountId alice.near --network mainnet
// Deposit
pub fn ft_on_transfer(&mut self, sender_id: AccountId, amount: U128, msg: String) -> PromiseOrValue<U128>;
// Withdraw
pub fn withdraw(&mut self, asset_id: Option<AccountId>, amount: U128) -> Promise;
pub fn contract_status(&self) -> ContractStatus;
pub fn name(&self) -> String;
pub fn symbol(&self) -> String;
pub fn decimals(&self) -> u8;
pub fn version(&self) -> String;
pub fn blacklist_status(&self, account_id: &AccountId) -> BlackListStatus;
pub fn owner(&self);
pub fn treasury(&self) -> Vec<(AccountId, StableInfo)>;
pub fn commission(&self) -> CommissionOutput;
pub fn commission_rate(&self, asset_id: &AccountId) -> CommissionRate;
pub fn ft_transfer(&mut self, receiver_id: AccountId, amount: U128, memo: Option<String>);
pub fn ft_transfer_call(
&mut self,
receiver_id: AccountId,
amount: U128,
memo: Option<String>,
msg: String,
) -> PromiseOrValue<U128>;
pub fn ft_total_supply(&self) -> U128;
pub fn ft_balance_of(&self, account_id: AccountId) -> U128;
pub fn ft_metadata(&self) -> FungibleTokenMetadata;
pub fn ft_on_transfer(&mut self, sender_id: AccountId, amount: U128, msg: String) -> PromiseOrValue<U128>;
Always returns 125 milliNEAR indicating that user doesn't need to be registered
with storage_deposit
.
pub fn storage_balance_of(&self, account_id: AccountId) -> Option<StorageBalance>;
pub fn new(owner_id: AccountId) -> Self;
For owner only.
pub fn upgrade_name_symbol(&mut self, name: String, symbol: String);
pub fn upgrade_icon(&mut self, data: String);
pub fn add_to_blacklist(&mut self, account_id: &AccountId);
pub fn remove_from_blacklist(&mut self, account_id: &AccountId);
pub fn destroy_black_funds(&mut self, account_id: &AccountId);
pub fn pause(&mut self);
pub fn resume(&mut self);
pub fn extend_guardians(&mut self, guardians: Vec<AccountId>);
pub fn remove_guardians(&mut self, guardians: Vec<AccountId>);
pub fn add_stable_asset(&mut self, asset_id: &AccountId, decimals: u8);
pub fn enable_stable_asset(&mut self, asset_id: &AccountId);
pub fn disable_stable_asset(&mut self, asset_id: &AccountId);
pub fn transfer_commission(&mut self, account_id: AccountId, amount: U128);
pub fn set_commission_rate(&mut self, asset_id: &AccountId, rate: CommissionRate)
pub fn stake(&self, amount: U128, pool_id: AccountId) -> Promise;
pub fn unstake(&self, amount: U128, pool_id: AccountId) -> Promise;
pub fn unstake_all(&self, pool_id: AccountId) -> Promise;
pub fn withdraw_all(&self, pool_id: AccountId) -> Promise;
pub fn propose_new_owner(&mut self, proposed_owner_id: AccountId);
pub fn accept_ownership(&mut self);
pub fn upgrade();
pub fn migrate() -> Self;