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

Commit

Permalink
feat(playground-mod): set payback dusd by dfi & add dusd collateral t…
Browse files Browse the repository at this point in the history
…oken (#381)

* setgov payback dfi and set dusd as collateral token

* Update src/module.playground/setup/setup.loan.collateral.ts

* update fork height on dc

Co-authored-by: Fuxing Loh <[email protected]>
  • Loading branch information
canonbrother and fuxingloh authored Jan 31, 2022
1 parent fd494d2 commit edc7ff7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ services:
-eunosheight=6
-eunospayaheight=7
-fortcanningheight=8
-fortcanningmuseumheight=9
-fortcanninghillheight=10
defi-playground:
build: ../../..
Expand Down
13 changes: 12 additions & 1 deletion src/module.playground/_module.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,16 @@ it('should have loan tokens', async () => {

it('should have loan collateral tokens', async () => {
const results = await testing.client.loan.listCollateralTokens()
expect(results.length).toBe(9)
expect(results.length).toBe(10)
})

it('should have gov set', async () => {
const dusdInfo = await testing.client.token.getToken('DUSD')
const dusdId = Object.keys(dusdInfo)[0]
const gov = await testing.client.masternode.getGov('ATTRIBUTES')
expect(gov).toStrictEqual({
ATTRIBUTES: {
[`v0/token/${dusdId}/payback_dfi`]: 'true'
}
})
})
8 changes: 6 additions & 2 deletions src/module.playground/_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OracleBot } from './bot/oracle.bot'
import { SetupLoanScheme } from '@src/module.playground/setup/setup.loan.scheme'
import { SetupLoanToken } from '@src/module.playground/setup/setup.loan.token'
import { SetupLoanCollateral } from '@src/module.playground/setup/setup.loan.collateral'
import { SetupGov } from '@src/module.playground/setup/setup.gov'
import { VaultBot } from '@src/module.playground/bot/vault.bot'

@Global()
Expand All @@ -26,6 +27,7 @@ import { VaultBot } from '@src/module.playground/bot/vault.bot'
SetupLoanScheme,
SetupLoanToken,
SetupLoanCollateral,
SetupGov,
OracleBot,
VaultBot,
PlaygroundBlock,
Expand All @@ -50,7 +52,8 @@ export class PlaygroundModule implements OnApplicationBootstrap {
masternode: SetupMasternode,
loanScheme: SetupLoanScheme,
loanToken: SetupLoanToken,
loanCollateral: SetupLoanCollateral
loanCollateral: SetupLoanCollateral,
gov: SetupGov
) {
this.setups = [
utxo,
Expand All @@ -60,7 +63,8 @@ export class PlaygroundModule implements OnApplicationBootstrap {
loanScheme,
loanToken,
loanCollateral,
dex
dex,
gov
]
}

Expand Down
34 changes: 34 additions & 0 deletions src/module.playground/setup/setup.gov.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { PlaygroundSetup } from '@src/module.playground/setup/setup'
import { Injectable } from '@nestjs/common'

@Injectable()
export class SetupGov extends PlaygroundSetup<Record<string, any>> {
list (): Array<Record<string, any>> {
return [
{ ATTRIBUTES: { 'v0/token/:dusdId/payback_dfi': 'true' } }
]
}

async create (each: any): Promise<void> {
const key = Object.keys(each)[0]
if (key === 'ATTRIBUTES') {
const dusdInfo = await this.client.token.getToken('DUSD')
const dusdId = Object.keys(dusdInfo)[0]
/* eslint-disable-next-line */
var re = new RegExp(':dusdId', 'g');
const k = Object.keys(each[key])[0]
each[key] = { [k.replace(re, dusdId)]: 'true' }
}

await this.client.masternode.setGov(each)
}

async has (each: any): Promise<boolean> {
const key = Object.keys(each)[0]
const gov = await this.client.masternode.getGov(key)
if (Object.keys(gov[key]).length > 0) {
return true
}
return false
}
}
5 changes: 5 additions & 0 deletions src/module.playground/setup/setup.loan.collateral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export class SetupLoanCollateral extends PlaygroundSetup<SetCollateralToken> {
fixedIntervalPriceId: 'DFI/USD',
factor: new BigNumber('1')
},
{
token: 'DUSD',
fixedIntervalPriceId: 'DUSD/USD',
factor: new BigNumber('0.99')
},
{
token: 'BTC',
fixedIntervalPriceId: 'BTC/USD',
Expand Down

0 comments on commit edc7ff7

Please sign in to comment.