Skip to content

Commit

Permalink
Merge 403236c into 12ca858
Browse files Browse the repository at this point in the history
  • Loading branch information
surangap authored Apr 8, 2022
2 parents 12ca858 + 403236c commit 00913fa
Show file tree
Hide file tree
Showing 13 changed files with 1,549 additions and 37 deletions.
16 changes: 10 additions & 6 deletions apps/playground-api/__tests__/modules/PlaygroundModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ afterAll(async () => {

it('should have pool pairs setup', async () => {
const pairs = await testing.container.call('listpoolpairs')
expect(Object.values(pairs).length).toBe(12)
expect(Object.values(pairs).length).toBe(14)
})

it('should have tokens setup', async () => {
const tokens = await testing.container.call('listtokens')
expect(Object.values(tokens).length).toBe(29)
expect(Object.values(tokens).length).toBe(31)
})

it('should have oracles setup', async () => {
Expand Down Expand Up @@ -116,10 +116,14 @@ it('should have gov set', async () => {
})
await testing.generate(1)

await testing.container.waitForPriceValid('TD10/USD')
await testing.container.waitForPriceValid('TU10/USD')
await testing.container.waitForPriceValid('TR50/USD')
await testing.container.waitForPriceValid('TS25/USD')
{
const prices = await testing.container.call('listfixedintervalprices')

const invalidPrices = prices.filter((p: any) => p.isLive !== true)
for (const p of invalidPrices) {
await testing.container.waitForPriceValid(p.priceFeedId)
}
}

await testing.rpc.loan.takeLoan({
vaultId: vaultId,
Expand Down
49 changes: 45 additions & 4 deletions apps/playground-api/src/setups/setup.dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export class SetupDex extends PlaygroundSetup<PoolPairSetup> {
commission: 0.02,
status: true,
ownerAddress: PlaygroundSetup.address
},
add: {
'*': ['10000000@DUSD', '10000000@DFI']
},
utxoToAccount: {
[PlaygroundSetup.address]: '10000000@0'
}
},
{
Expand All @@ -114,6 +120,9 @@ export class SetupDex extends PlaygroundSetup<PoolPairSetup> {
commission: 0.02,
status: true,
ownerAddress: PlaygroundSetup.address
},
add: {
'*': ['10000000@DUSD', '10000000@TU10']
}
},
{
Expand All @@ -124,6 +133,9 @@ export class SetupDex extends PlaygroundSetup<PoolPairSetup> {
commission: 0.02,
status: true,
ownerAddress: PlaygroundSetup.address
},
add: {
'*': ['10000000@DUSD', '10000000@TD10']
}
},
{
Expand All @@ -144,6 +156,9 @@ export class SetupDex extends PlaygroundSetup<PoolPairSetup> {
commission: 0.02,
status: true,
ownerAddress: PlaygroundSetup.address
},
add: {
'*': ['10000000@DUSD', '10000000@TR50']
}
},
{
Expand All @@ -165,6 +180,32 @@ export class SetupDex extends PlaygroundSetup<PoolPairSetup> {
status: false,
ownerAddress: PlaygroundSetup.address
}
},
{
symbol: 'BTC-DUSD',
create: {
tokenA: 'BTC',
tokenB: 'DUSD',
commission: 0.01,
status: true,
ownerAddress: PlaygroundSetup.address
},
add: {
'*': ['1000@BTC', '10000000@DUSD']
}
},
{
symbol: 'CU10-DUSD',
create: {
tokenA: 'CU10',
tokenB: 'DUSD',
commission: 0.01,
status: true,
ownerAddress: PlaygroundSetup.address
},
add: {
'*': ['100000@CU10', '1000@DUSD']
}
}
]
}
Expand Down Expand Up @@ -199,18 +240,18 @@ export class SetupDex extends PlaygroundSetup<PoolPairSetup> {
const poolPairs = await this.client.poolpair.listPoolPairs()
const poolPairIds = Object.keys(poolPairs)

// apply `toFixed(8)` due to 1 / 12 = 0.08333333333333333 which is invalid amount on setgov
// apply `toFixed(8)` due to 1 / 14 = 0.07142857 which is invalid amount on setgov
const splits = Number(new BigNumber(1 / poolPairIds.length).toFixed(8))

const lpSplits: any = {}
for (const k in poolPairs) {
lpSplits[parseInt(k)] = splits
}

// to fix: LP_SPLITS: total = 99999996 vs expected 100000000', code: -32600, method: setgov
// 0.08333333 * 11 !== 100000000
// to fix: LP_SPLITS: total = 99999998 vs expected 100000000', code: -32600, method: setgov
// 0.07142857 * 14 !== 100000000
const lstKey = Object.keys(lpSplits)[0]
lpSplits[lstKey] = Number(new BigNumber(lpSplits[lstKey]).plus(0.00000004).toFixed(8))
lpSplits[lstKey] = Number(new BigNumber(lpSplits[lstKey]).plus(0.00000002).toFixed(8))

await this.client.masternode.setGov({ LP_SPLITS: lpSplits })
await this.generate(1)
Expand Down
25 changes: 25 additions & 0 deletions docs/node/CATEGORIES/08-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,30 @@ interface BurnInfo {
* Amount of tokens that are paid back
*/
paybacktokens: string[]
/**
* Amount of tokens burned due to futureswap
*/
dfip2203: string[]
}
```

## futureSwap

Creates and submits to the network a futures contract.

```ts title="client.account.futureSwap()"
interface account {
futureSwap (future: FutureSwap, utxos: UTXO[] = []): Promise<string>
}

interface FutureSwap {
address: string
amount: string
destination?: string
}

interface UTXO {
txid: string
vout: number
}
```
2 changes: 1 addition & 1 deletion docs/node/CATEGORIES/09-oracle.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ interface ListFixedIntervalPrice {
timestamp: number
isLive: boolean
}
```
```
Loading

0 comments on commit 00913fa

Please sign in to comment.