-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathXUSDT.move
49 lines (38 loc) · 1.41 KB
/
XUSDT.move
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module Bridge::XUSDT {
use StarcoinFramework::Token;
use StarcoinFramework::Account;
// XUSDT token marker.
struct XUSDT has copy, drop, store {}
// precision of XUSDT token.
// https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code
// see USDT on ethereum Constructor Arguments, _decimals (uint256): 6
const PRECISION: u8 = 6;
// XUSDT initialization.
public fun init(account: &signer) {
Token::register_token<XUSDT>(account, PRECISION);
Account::do_accept_token<XUSDT>(account);
}
public fun mint(account: &signer, amount: u128) {
let token = Token::mint<XUSDT>(account, amount);
Account::deposit_to_self<XUSDT>(account, token)
}
public fun burn(account: &signer, amount: u128) {
Token::burn(account, Account::withdraw<XUSDT>(account, amount));
}
}
module Bridge::XUSDTScripts {
use Bridge::XUSDT;
use Bridge::LockProxy;
public entry fun init(account: signer) {
XUSDT::init(&account);
}
/// Only called with someone who have mint capability
public entry fun mint(account: signer, amount: u128) {
XUSDT::mint(&account, amount);
LockProxy::move_to_treasury<XUSDT::XUSDT>(&account, amount);
}
/// Only called with someone who have burn capability
public entry fun burn(account: signer, amount: u128) {
XUSDT::burn(&account, amount);
}
}