Skip to content

Commit

Permalink
Merge pull request #176 from vmware-samples/bond_poc
Browse files Browse the repository at this point in the history
Add bond issuance sample
  • Loading branch information
ramkri123 authored Oct 13, 2022
2 parents 3c57aaa + db0b467 commit 1ee8f12
Show file tree
Hide file tree
Showing 18 changed files with 1,567 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bond_issuance_py/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SCRIPT ENV VARIABLES
export HOST=<ethereum-client-ip>

467 changes: 467 additions & 0 deletions bond_issuance_py/bond_poc.py

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions bond_issuance_py/cli_parser.py
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()
24 changes: 24 additions & 0 deletions bond_issuance_py/contracts/Context.sol
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;
}
}
Loading

0 comments on commit 1ee8f12

Please sign in to comment.