-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
51 changed files
with
1,078 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { flags } from '@oclif/command' | ||
import BigNumber from 'bignumber.js' | ||
import { BaseCommand } from '../../base' | ||
import { displaySendTx } from '../../utils/cli' | ||
import { Flags } from '../../utils/command' | ||
|
||
export default class ExchangeDollars extends BaseCommand { | ||
static description = 'Exchange Celo Dollars for Celo Gold via the stability mechanism' | ||
|
||
static flags = { | ||
...BaseCommand.flags, | ||
from: Flags.address({ | ||
required: true, | ||
description: 'The address with Celo Dollars to exchange', | ||
}), | ||
value: Flags.address({ | ||
required: true, | ||
description: 'The value of Celo Dollars to exchange for Celo Gold', | ||
}), | ||
for: Flags.address({ | ||
required: true, | ||
description: 'The minimum value of Celo Gold to receive in return', | ||
}), | ||
commission: flags.string({ required: true }), | ||
} | ||
|
||
static args = [] | ||
|
||
static examples = [ | ||
'dollars --value 10000000000000 --for 50000000000000 --from 0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d', | ||
] | ||
|
||
async run() { | ||
const res = this.parse(ExchangeDollars) | ||
const sellAmount = new BigNumber(res.flags.value) | ||
const minBuyAmount = new BigNumber(res.flags.for) | ||
|
||
this.kit.defaultAccount = res.flags.from | ||
const stableToken = await this.kit.contracts.getStableToken() | ||
const exchange = await this.kit.contracts.getExchange() | ||
|
||
await displaySendTx('approve', stableToken.approve(exchange.address, sellAmount.toFixed())) | ||
|
||
const exchangeTx = exchange.exchange(sellAmount.toFixed(), minBuyAmount.toFixed(), false) | ||
await displaySendTx('exchange', exchangeTx) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { flags } from '@oclif/command' | ||
import BigNumber from 'bignumber.js' | ||
import { BaseCommand } from '../../base' | ||
import { displaySendTx } from '../../utils/cli' | ||
import { Flags } from '../../utils/command' | ||
|
||
export default class ExchangeGold extends BaseCommand { | ||
static description = 'Exchange Celo Gold for Celo Dollars via the stability mechanism' | ||
|
||
static flags = { | ||
...BaseCommand.flags, | ||
from: Flags.address({ required: true, description: 'The address with Celo Gold to exchange' }), | ||
value: Flags.address({ | ||
required: true, | ||
description: 'The value of Celo Gold to exchange for Celo Dollars', | ||
}), | ||
for: Flags.address({ | ||
required: true, | ||
description: 'The minimum value of Celo Dollars to receive in return', | ||
}), | ||
commission: flags.string({ required: true }), | ||
} | ||
|
||
static args = [] | ||
|
||
static examples = [ | ||
'gold --value 5000000000000 --for 100000000000000 --from 0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d', | ||
] | ||
|
||
async run() { | ||
const res = this.parse(ExchangeGold) | ||
const sellAmount = new BigNumber(res.flags.value) | ||
const minBuyAmount = new BigNumber(res.flags.for) | ||
|
||
this.kit.defaultAccount = res.flags.from | ||
const goldToken = await this.kit.contracts.getGoldToken() | ||
const exchange = await this.kit.contracts.getExchange() | ||
|
||
await displaySendTx('approve', goldToken.approve(exchange.address, sellAmount.toFixed())) | ||
|
||
const exchangeTx = exchange.exchange(sellAmount.toFixed(), minBuyAmount.toFixed(), true) | ||
await displaySendTx('exchange', exchangeTx) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.