Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
vault.bot.ts to loan all tokens and add to DEX (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored Dec 7, 2021
1 parent b6f323f commit c156eeb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/fuxing.xml

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

30 changes: 27 additions & 3 deletions src/module.playground/bot/vault.bot.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,45 @@ it('should have a vault', async () => {
await waitForExpect(async () => {
const vaults = await testing.jsonRpcClient!.loan.listVaults()
expect(vaults.length).toBeGreaterThan(0)
}, 40000)
}, 90000)
})

it('should have liquidity in DUSD-DFI pool', async () => {
await waitForExpect(async () => {
const pairsResult = await testing.jsonRpcClient!.poolpair.getPoolPair('DUSD-DFI')
expect(Object.values(pairsResult)[0].reserveA.gt(0)).toBeTruthy()
expect(Object.values(pairsResult)[0].reserveB.gt(0)).toBeTruthy()
}, 40000)
}, 90000)
})

it('should have liquidity in TU10-DUSD pool', async () => {
await waitForExpect(async () => {
const pairsResult = await testing.jsonRpcClient!.poolpair.getPoolPair('TU10-DUSD')
expect(Object.values(pairsResult)[0].reserveA.gt(0)).toBeTruthy()
expect(Object.values(pairsResult)[0].reserveB.gt(0)).toBeTruthy()
}, 90000)
})

it('should have liquidity in TD10-DUSD pool', async () => {
await waitForExpect(async () => {
const pairsResult = await testing.jsonRpcClient!.poolpair.getPoolPair('TD10-DUSD')
expect(Object.values(pairsResult)[0].reserveA.gt(0)).toBeTruthy()
expect(Object.values(pairsResult)[0].reserveB.gt(0)).toBeTruthy()
}, 90000)
})

it('should have liquidity in TS25-DUSD pool', async () => {
await waitForExpect(async () => {
const pairsResult = await testing.jsonRpcClient!.poolpair.getPoolPair('TS25-DUSD')
expect(Object.values(pairsResult)[0].reserveA.gt(0)).toBeTruthy()
expect(Object.values(pairsResult)[0].reserveB.gt(0)).toBeTruthy()
}, 40000)
}, 90000)
})

it('should have liquidity in TR50-DUSD pool', async () => {
await waitForExpect(async () => {
const pairsResult = await testing.jsonRpcClient!.poolpair.getPoolPair('TR50-DUSD')
expect(Object.values(pairsResult)[0].reserveA.gt(0)).toBeTruthy()
expect(Object.values(pairsResult)[0].reserveB.gt(0)).toBeTruthy()
}, 90000)
})
28 changes: 20 additions & 8 deletions src/module.playground/bot/vault.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,29 @@ export class VaultBot {
async run (): Promise<void> {
if (this.vaultId === undefined) {
this.vaultId = await this.client.loan.createVault({
loanSchemeId: 'MIN200',
loanSchemeId: 'MIN150',
ownerAddress: PlaygroundSetup.address
})

await this.client.account.utxosToAccount({
[PlaygroundSetup.address]: '100000@0'
})
return
}

await this.client.account.utxosToAccount({
[PlaygroundSetup.address]: '20@0'
})

await this.client.loan.depositToVault({
amount: '10@DFI',
amount: '100@DFI',
from: PlaygroundSetup.address,
vaultId: this.vaultId
})

await this.client.loan.takeLoan({
amounts: [
'20@DUSD',
'0.1@TS25'
'0.01@TU10',
'0.00000010@TD10',
'0.1@TS25',
'0.01@TR50'
],
to: PlaygroundSetup.address,
vaultId: this.vaultId
Expand All @@ -43,7 +46,16 @@ export class VaultBot {
'*': ['1@DFI', '10@DUSD']
}, PlaygroundSetup.address)
await this.client.poolpair.addPoolLiquidity({
'*': ['2.5@DUSD', '0.1@TS25']
'*': ['2@DUSD', '0.01@TU10']
}, PlaygroundSetup.address)
await this.client.poolpair.addPoolLiquidity({
'*': ['2@DUSD', '0.00000010@TD10']
}, PlaygroundSetup.address)
await this.client.poolpair.addPoolLiquidity({
'*': ['2@DUSD', '0.1@TS25']
}, PlaygroundSetup.address)
await this.client.poolpair.addPoolLiquidity({
'*': ['2@DUSD', '0.01@TR50']
}, PlaygroundSetup.address)
}
}

0 comments on commit c156eeb

Please sign in to comment.