Transaction #382319

Hash 789fc23fbbf3306aab85e0214c0d8242c1b9203ba5c8e0ca9c450d81a36abf8d
Status Success
Timestamp 73 days ago - 11/15/2021, 6:04:05 AM UTC+0
Block 370789
Stamps Used 514
Burned Fee 0.03041420 TAU
From fb8721c4f736b22075f08f1161f24522132522311ac4f1e19730e3298bb8a40e 
Contract Name submission
Function Name submit_contract

Additional Info
SubBlock Number 0
Nonce 1365
Processor 5b09493df6c18d17cc883ebce54fcb1f5afbd507533417fe32c006009a9c3c4a
Signature 3c520b3379176030d288d5936d898b511c26bcc1870f864cfdcd562139b50fc93807f1407aa0415835dbf9f067898f3a431dcbf672f92084d31e05aad27e840d
Stamps Supplied 1000
Stamps per TAU 169

Kwargs

code tad_contract = importlib.import_module('con_rubix_test_decimal_tad') vault_contract = importlib.import_module('con_rubix_test_decimal_vault') rate = Hash() balances = Hash(default_value=0) metadata = Hash() total_minted = Variable() operator = Variable() # 31536000 seconds per year @construct def seed(): operator.set(ctx.caller) rate['start_time'] = get_timestamp() rate['rate'] = 1.0000000015469297 # interest per second rate['start_price'] = 1 metadata['token_name'] = 'Staked tad' metadata['token_symbol'] = 'stad' metadata['token_logo_url'] = 'image.site' metadata['operator'] = ctx.caller total_minted.set(0) @export def get_timestamp(): # https://developers.lamden.io/docs/smart-contracts/datetime-module/ td = now - datetime.datetime(1970, 1, 1, 0, 0, 0) return td.seconds @export def stake(amount: float): assert amount > 0, 'Stake amount must be positive!' tad_contract.transfer_from( to=ctx.this, amount=amount, main_account=ctx.caller) amount_minted = amount / get_price() total = total_minted.get() + amount_minted total_minted.set(total) balances[ctx.caller] += amount_minted return amount_minted @export def withdraw_stake(amount: float): assert amount > 0, 'Stake amount must be positive!' assert balances[ctx.caller] >= amount, 'Not enough coins to withdraw!' balances[ctx.caller] -= amount current_price = get_price() return_amount = current_price * amount supply = total_minted.get() current_average = supply / tad_contract.balance_of(ctx.this) transfer_away_amount = amount * current_average total_minted.set(supply - amount) if return_amount - transfer_away_amount > 0: # todo: double check in future vault_contract.mint_rewards( amount=return_amount - transfer_away_amount) tad_contract.transfer(amount=return_amount, to=ctx.caller) return return_amount @export def change_rate(new_rate: float): # takes yearly interest as decimal assert_owner() assert new_rate >= 0, 'Cannot have negative staking!' current_price = get_price() rate['start_time'] = get_timestamp() rate['rate'] = new_rate # interest per second rate['start_price'] = current_price @export def transfer(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' sender = ctx.caller assert balances[sender] >= amount, 'Not enough coins to send!' balances[sender] -= amount balances[to] += amount @export def balance_of(account: str): return balances[account] @export def allowance(owner: str, spender: str): return balances[owner, spender] @export def approve(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' sender = ctx.caller assert balances[sender] >= amount, 'Cannot approve balance that exceeds total balance!' balances[sender, to] += amount return balances[sender, to] @export def transfer_from(amount: float, to: str, main_account: str): assert amount > 0, 'Cannot send negative balances!' sender = ctx.caller assert balances[main_account] >= amount, 'Not enough coins to send!' assert balances[main_account, sender] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\ .format(balances[main_account, sender], amount) balances[main_account, sender] -= amount balances[main_account] -= amount balances[to] += amount @export def get_price(): return rate['start_price'] * rate['rate'] ** ( get_timestamp() - rate['start_time']) @export def change_metadata(key: str, value: Any): assert ctx.caller == metadata['operator'], 'Only operator can set metadata!' metadata[key] = value @export def change_owner(new_owner: str): assert_owner() operator.set(new_owner) def assert_owner(): assert ctx.caller == operator.get(), 'Only operator can call!'
name con_rubix_test_decimal_stake

State Changes

Contract con_rubix_test_decimal_stake
Variable operator
New Value fb8721c4f736b22075f08f1161f24522132522311ac4f1e19730e3298bb8a40e
 
Contract con_rubix_test_decimal_stake
Variable rate
Key start_time
New Value 1636927448
 
Contract con_rubix_test_decimal_stake
Variable rate
Key rate
New Value 1.0000000015469297
 
Contract con_rubix_test_decimal_stake
Variable rate
Key start_price
New Value 1
 
Contract con_rubix_test_decimal_stake
Variable metadata
Key token_name
New Value Staked tad
 
Contract con_rubix_test_decimal_stake
Variable metadata
Key token_symbol
New Value stad
 
Contract con_rubix_test_decimal_stake
Variable metadata
Key token_logo_url
New Value image.site
 
Contract con_rubix_test_decimal_stake
Variable metadata
Key operator
New Value fb8721c4f736b22075f08f1161f24522132522311ac4f1e19730e3298bb8a40e
 
Contract con_rubix_test_decimal_stake
Variable total_minted
New Value 0
 
Contract con_rubix_test_decimal_stake
Variable __code__
New Value tad_contract = importlib.import_module('con_rubix_test_decimal_tad') vault_contract = importlib.import_module('con_rubix_test_decimal_vault') __rate = Hash(contract='con_rubix_test_decimal_stake', name='rate') __balances = Hash(default_value=0, contract='con_rubix_test_decimal_stake', name='balances') __metadata = Hash(contract='con_rubix_test_decimal_stake', name='metadata') __total_minted = Variable(contract='con_rubix_test_decimal_stake', name= 'total_minted') __operator = Variable(contract='con_rubix_test_decimal_stake', name='operator') def ____(): __operator.set(ctx.caller) __rate['start_time'] = get_timestamp() __rate['rate'] = decimal('1.0000000015469297') __rate['start_price'] = 1 __metadata['token_name'] = 'Staked tad' __metadata['token_symbol'] = 'stad' __metadata['token_logo_url'] = 'image.site' __metadata['operator'] = ctx.caller __total_minted.set(0) @__export('con_rubix_test_decimal_stake') def get_timestamp(): td = now - datetime.datetime(1970, 1, 1, 0, 0, 0) return td.seconds @__export('con_rubix_test_decimal_stake') def stake(amount: float): assert amount > 0, 'Stake amount must be positive!' tad_contract.transfer_from(to=ctx.this, amount=amount, main_account=ctx .caller) amount_minted = amount / get_price() total = __total_minted.get() + amount_minted __total_minted.set(total) __balances[ctx.caller] += amount_minted return amount_minted @__export('con_rubix_test_decimal_stake') def withdraw_stake(amount: float): assert amount > 0, 'Stake amount must be positive!' assert __balances[ctx.caller] >= amount, 'Not enough coins to withdraw!' __balances[ctx.caller] -= amount current_price = get_price() return_amount = current_price * amount supply = __total_minted.get() current_average = supply / tad_contract.balance_of(ctx.this) transfer_away_amount = amount * current_average __total_minted.set(supply - amount) if return_amount - transfer_away_amount > 0: vault_contract.mint_rewards(amount=return_amount - transfer_away_amount ) tad_contract.transfer(amount=return_amount, to=ctx.caller) return return_amount @__export('con_rubix_test_decimal_stake') def change_rate(new_rate: float): __assert_owner() assert new_rate >= 0, 'Cannot have negative staking!' current_price = get_price() __rate['start_time'] = get_timestamp() __rate['rate'] = new_rate __rate['start_price'] = current_price @__export('con_rubix_test_decimal_stake') def transfer(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' sender = ctx.caller assert __balances[sender] >= amount, 'Not enough coins to send!' __balances[sender] -= amount __balances[to] += amount @__export('con_rubix_test_decimal_stake') def balance_of(account: str): return __balances[account] @__export('con_rubix_test_decimal_stake') def allowance(owner: str, spender: str): return __balances[owner, spender] @__export('con_rubix_test_decimal_stake') def approve(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' sender = ctx.caller assert __balances[sender ] >= amount, 'Cannot approve balance that exceeds total balance!' __balances[sender, to] += amount return __balances[sender, to] @__export('con_rubix_test_decimal_stake') def transfer_from(amount: float, to: str, main_account: str): assert amount > 0, 'Cannot send negative balances!' sender = ctx.caller assert __balances[main_account] >= amount, 'Not enough coins to send!' assert __balances[main_account, sender ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format( __balances[main_account, sender], amount) __balances[main_account, sender] -= amount __balances[main_account] -= amount __balances[to] += amount @__export('con_rubix_test_decimal_stake') def get_price(): return __rate['start_price'] * __rate['rate'] ** (get_timestamp() - __rate['start_time']) @__export('con_rubix_test_decimal_stake') def change_metadata(key: str, value: Any): assert ctx.caller == __metadata['operator' ], 'Only operator can set metadata!' __metadata[key] = value @__export('con_rubix_test_decimal_stake') def change_owner(new_owner: str): __assert_owner() __operator.set(new_owner) def __assert_owner(): assert ctx.caller == __operator.get(), 'Only operator can call!'
 
Contract con_rubix_test_decimal_stake
Variable __compiled__
New Value e30000000000000000000000000500000040000000736e01000065006a01640083015a0265006a01640183015a0365046402640364048d025a05650464056402640664078d035a0665046402640864048d025a0765086402640964048d025a0965086402640a64048d025a0a640b640c84005a0b650c64028301640d640e840083015a0d650c64028301650e640f9c0164106411840483015a0f650c64028301650e640f9c0164126413840483015a10650c64028301650e64149c0164156416840483015a11650c64028301650e651264179c0264186419840483015a13650c640283016512641a9c01641b641c840483015a14650c6402830165126512641d9c02641e641f840483015a15650c64028301650e651264179c0264206421840483015a16650c64028301650e6512651264229c0364236424840483015a17650c6402830164256426840083015a18650c640283016512651964279c0264286429840483015a1a650c640283016512642a9c01642b642c840483015a1b642d642e84005a1c642f53002930da1a636f6e5f72756269785f746573745f646563696d616c5f746164da1c636f6e5f72756269785f746573745f646563696d616c5f7661756c74da1c636f6e5f72756269785f746573745f646563696d616c5f7374616b65da04726174652902da08636f6e7472616374da046e616d65e900000000da0862616c616e6365732903da0d64656661756c745f76616c756572050000007206000000da086d65746164617461da0c746f74616c5f6d696e746564da086f70657261746f72630000000000000000000000000300000043000000735a00000074006a0174026a038301010074048300740564013c00740664028301740564033c006404740564053c006406740764073c006408740764093c00640a7407640b3c0074026a037407640c3c0074086a01640d8301010064005300290e4eda0a73746172745f74696d657a12312e303030303030303031353436393239377204000000e901000000da0b73746172745f70726963657a0a5374616b656420746164da0a746f6b656e5f6e616d65da0473746164da0c746f6b656e5f73796d626f6c7a0a696d6167652e73697465da0e746f6b656e5f6c6f676f5f75726c720c00000072070000002909da0a5f5f6f70657261746f72da03736574da03637478da0663616c6c6572da0d6765745f74696d657374616d70da065f5f72617465da07646563696d616cda0a5f5f6d65746164617461da0e5f5f746f74616c5f6d696e746564a900721d000000721d000000da00da045f5f5f5f0c000000731200000000010c010a010c0108010801080108010a01721f000000630000000000000000010000000800000043000000731e000000740074016a01640164026402640364036403830618007d007c006a02530029044e69b2070000720e00000072070000002903da036e6f77da086461746574696d65da077365636f6e64732901da027464721d000000721d000000721e00000072180000001800000073040000000002180172180000002901da06616d6f756e74630100000000000000030000000500000043000000735a0000007c0064016b047310740064028301820174016a0274036a047c0074036a0564038d0301007c00740683001b007d0174076a0883007c0117007d0274076a097c0283010100740a74036a05050019007c01370003003c007c01530029044e72070000007a1e5374616b6520616d6f756e74206d75737420626520706f736974697665212903da02746f7224000000da0c6d61696e5f6163636f756e74290bda0e417373657274696f6e4572726f72da0c7461645f636f6e7472616374da0d7472616e736665725f66726f6d7216000000da04746869737217000000da096765745f7072696365721c000000da036765747215000000da0a5f5f62616c616e63657329037224000000da0d616d6f756e745f6d696e746564da05746f74616c721d000000721d000000721e000000da057374616b651e000000730e0000000002100114020a010c010a011201723000000063010000000000000006000000040000004300000073a40000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c00740483007d017c017c0014007d0274056a0683007d037c0374076a0874026a0983011b007d047c007c0414007d0574056a0a7c037c001800830101007c027c05180064016b047290740b6a0c7c027c05180064048d01010074076a0d7c0274026a0364058d0201007c02530029064e72070000007a1e5374616b6520616d6f756e74206d75737420626520706f736974697665217a1d4e6f7420656e6f75676820636f696e7320746f2077697468647261772129017224000000290272240000007225000000290e7227000000722d00000072160000007217000000722b000000721c000000722c0000007228000000da0a62616c616e63655f6f66722a0000007215000000da0e7661756c745f636f6e7472616374da0c6d696e745f72657761726473da087472616e7366657229067224000000da0d63757272656e745f7072696365da0d72657475726e5f616d6f756e74da06737570706c79da0f63757272656e745f61766572616765da147472616e736665725f617761795f616d6f756e74721d000000721d000000721e000000da0e77697468647261775f7374616b652a000000731a0000000002100116011201060108010801100108010e010c0110021001723a0000002901da086e65775f72617465630100000000000000020000000300000043000000733a0000007400830001007c0064016b0573167401640283018201740283007d0174038300740464033c007c00740464043c007c01740464053c006400530029064e72070000007a1d43616e6e6f742068617665206e65676174697665207374616b696e6721720d0000007204000000720f0000002905da0e5f5f6173736572745f6f776e65727227000000722b000000721800000072190000002902723b0000007235000000721d000000721d000000721e000000da0b6368616e67655f726174653c000000730c00000000020601100106010a010801723d000000290272240000007225000000630200000000000000030000000400000043000000734e0000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029044e72070000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904722700000072160000007217000000722d000000290372240000007225000000da0673656e646572721d000000721d000000721e000000723400000046000000730a0000000002100106011401100172340000002901da076163636f756e74630100000000000000010000000200000043000000730800000074007c001900530029014e2901722d0000002901723f000000721d000000721d000000721e00000072310000004f0000007302000000000272310000002902da056f776e6572da077370656e646572630200000000000000020000000300000043000000730c00000074007c007c0166021900530029014e2901722d000000290272400000007241000000721d000000721d000000721e000000da09616c6c6f77616e636554000000730200000000027242000000630200000000000000030000000400000043000000734a0000007c0064016b047310740064028301820174016a027d0274037c0219007c006b05732a740064038301820174037c027c016602050019007c00370003003c0074037c027c0166021900530029044e72070000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a3243616e6e6f7420617070726f76652062616c616e63652074686174206578636565647320746f74616c2062616c616e6365212904722700000072160000007217000000722d000000290372240000007225000000723e000000721d000000721d000000721e000000da07617070726f766559000000730c00000000021001060106010e01140172430000002903722400000072250000007226000000630300000000000000040000000500000043000000738a0000007c0064016b047310740064028301820174016a027d0374037c0219007c006b05732a740064038301820174037c027c03660219007c006b057352740064046a0474037c027c03660219007c0083028301820174037c027c036602050019007c00380003003c0074037c02050019007c00380003003c0074037c01050019007c00370003003c006400530029054e72070000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d2905722700000072160000007217000000722d000000da06666f726d61742904722400000072250000007226000000723e000000721d000000721d000000721e000000722900000063000000731200000000021001060114010a010c011201140110017229000000630000000000000000000000000500000043000000731e00000074006401190074006402190074018300740064031900180013001400530029044e720f0000007204000000720d000000290272190000007218000000721d000000721d000000721d000000721e000000722b00000070000000730400000000021001722b0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720c0000007a1f4f6e6c79206f70657261746f722063616e20736574206d6574616461746121290472160000007217000000721b0000007227000000290272450000007246000000721d000000721d000000721e000000da0f6368616e67655f6d6574616461746176000000730600000000021001060172470000002901da096e65775f6f776e6572630100000000000000010000000200000043000000731400000074008300010074016a027c00830101006400530029014e2903723c0000007214000000721500000029017248000000721d000000721d000000721e000000da0c6368616e67655f6f776e65727d0000007304000000000206017249000000630000000000000000000000000200000043000000731a00000074006a0174026a0383006b02731674046401830182016400530029024e7a174f6e6c79206f70657261746f722063616e2063616c6c212905721600000072170000007214000000722c0000007227000000721d000000721d000000721d000000721e000000723c0000008300000073020000000001723c0000004e291dda09696d706f72746c6962da0d696d706f72745f6d6f64756c6572280000007232000000da04486173687219000000722d000000721b000000da085661726961626c65721c0000007214000000721f000000da085f5f6578706f72747218000000da05666c6f61747230000000723a000000723d000000da0373747272340000007231000000724200000072430000007229000000722b000000da03416e7972470000007249000000723c000000721d000000721d000000721d000000721e000000da083c6d6f64756c653e0100000073400000000a010a010c01060108010c01040108010c03080c10060601100b0601101106011009060112080601100406011204060112090601140c10060601120606011005
 
Contract con_rubix_test_decimal_stake
Variable __owner__
New Value null
 
Contract con_rubix_test_decimal_stake
Variable __submitted__
New Value 2021,11,14,22,4,8,0
 
Contract con_rubix_test_decimal_stake
Variable __developer__
New Value fb8721c4f736b22075f08f1161f24522132522311ac4f1e19730e3298bb8a40e
 
Contract currency
Variable balances
Key fb8721c4f736b22075f08f1161f24522132522311ac4f1e19730e3298bb8a40e
New Value 4.82189338396449197