-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from vmware-samples/bond_poc
Add bond issuance sample
- Loading branch information
Showing
18 changed files
with
1,567 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SCRIPT ENV VARIABLES | ||
export HOST=<ethereum-client-ip> | ||
|
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import argparse | ||
import os | ||
from enum import Enum | ||
from bond_poc import deploy_exchange, set_pt, mint_st, close_issuance, swap_tokens,set_env_var,setup_w3,mint_pt,get_balance | ||
|
||
class OperationType(str, Enum): | ||
""" | ||
class for defining operation type | ||
""" | ||
|
||
DEPLOY_EXCHANGE= "deploy" | ||
MINT_PT = "mint_pt" | ||
MINT_ST = "mint_st" | ||
SWAP = "swap" | ||
CLOSE_ISSUANCE = "close_issuance" | ||
GET_BALANCE = "get_balance" | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Run Bond POC') | ||
# deploy exchange and PT | ||
set_env_var() | ||
host = os.environ['HOST'] | ||
|
||
parser.add_argument('--PTName', action='store', type=str, help='Name of payment token') | ||
parser.add_argument('--PTSymbol', action='store',type=str, help='symbol of payment token') | ||
parser.add_argument('--operation', action='store',type=str, help='value can be deploy, mint_st, mint_pt, swap, close_issuance or get_balance',required=True) | ||
|
||
# mint PT | ||
parser.add_argument('--MMNumber', action='store',type=int, help='Market maker number(permissible value is 0,1,2)') | ||
parser.add_argument('--PTAmountMint', action='store',type=int, help='PT amount to be minted for a Market maker') | ||
|
||
# swap | ||
parser.add_argument('--STAmountSwap', action='store',type=int, help='ST amount to be to be swapped') | ||
parser.add_argument('--ISIN', action='store',type=str, help='ISIN of a ST') | ||
parser.add_argument('--Account', action='store',type=str, help='Account address') | ||
parser.add_argument('--delay', action='store',type=bool, help='whether introduce delay in swap',default=False) | ||
|
||
args = parser.parse_args() | ||
|
||
setup_w3(host) | ||
|
||
|
||
if args.operation.lower() == OperationType.DEPLOY_EXCHANGE: | ||
deploy_exchange(args.PTName, args.PTSymbol) | ||
set_pt() | ||
elif args.operation.lower() == OperationType.MINT_ST: | ||
mint_st() | ||
elif args.operation.lower() == OperationType.MINT_PT: | ||
mint_pt(args.MMNumber, args.PTAmountMint) | ||
elif args.operation.lower() == OperationType.SWAP: | ||
swap_tokens(args.MMNumber, args.STAmountSwap, args.ISIN, args.delay) | ||
elif args.operation.lower() == OperationType.CLOSE_ISSUANCE: | ||
close_issuance() | ||
elif args.operation.lower() == OperationType.GET_BALANCE: | ||
if args.ISIN: | ||
get_balance(args.Account, args.ISIN) | ||
else: | ||
get_balance(args.Account) | ||
else: | ||
print("Invalid operation") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol) | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @dev Provides information about the current execution context, including the | ||
* sender of the transaction and its data. While these are generally available | ||
* via msg.sender and msg.data, they should not be accessed in such a direct | ||
* manner, since when dealing with meta-transactions the account sending and | ||
* paying for execution may not be the actual sender (as far as an application | ||
* is concerned). | ||
* | ||
* This contract is only required for intermediate, library-like contracts. | ||
*/ | ||
abstract contract Context { | ||
function _msgSender() internal view virtual returns (address) { | ||
return msg.sender; | ||
} | ||
|
||
function _msgData() internal view virtual returns (bytes calldata) { | ||
return msg.data; | ||
} | ||
} |
Oops, something went wrong.