-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatevault.js
45 lines (34 loc) · 1.13 KB
/
createvault.js
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
import { Account, Vault, VAULT_IDS} from '@xbacked-dao/xbacked-sdk';
import dotenv from 'dotenv';
dotenv.config();
const account = new Account({network: "TestNet", mnemonic: process.env.SEED_PHRASE});
//Select the vault you want to use
const algoToxUSDVault = new Vault({id: VAULT_IDS.TestNet.algo});
console.log("Address = ", await account.getAddress());
const vaultInfo = await account.getUserInfo({
vault: algoToxUSDVault,
address: await account.getAddress()
});
console.log(vaultInfo)
if (!vaultInfo.vaultFound){
//Let's opt into the xUSD asset
const xUSD = 62281549;
await account.optIntoToken(xUSD);
const isVaultCreated = await account.createVault({
collateral: 180,
mintAmount: 105,
vault: algoToxUSDVault
});
if (!vaultInfo.vaultFound){
//Let's opt into the xUSD asset
const xUSD = 62281549;
await account.optIntoToken(xUSD);
const isVaultCreated = await account.createVault({
collateral: 180,
mintAmount: 105,
vault: algoToxUSDVault
});
}
}
const vaultState = await algoToxUSDVault.getState({account: account})
console.log(vaultState)