Skip to content

Commit

Permalink
convert api amounts to token amounts with decimals()
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaszimmermann authored and doerfli committed Dec 30, 2024
1 parent 23d2f24 commit 2153277
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Settings(BaseSettings):
OPERATOR_ACCOUNT_INDEX: int = 0 # for local testing, for prod set value to 2

# farmer minimum funding amount
FARMER_FUNDING_AMOUNT: int = 100000001
FARMER_FUNDING_AMOUNT: int = 200000000000
FARMER_ETH_FUNDING_AMOUNT: int = 0.005 * 10 ** 18

# smart contracs settings
Expand Down
6 changes: 3 additions & 3 deletions app/server/sync/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from server.model.person import PersonOut
from server.model.policy import PolicyOut
from server.model.risk import RiskOut
from server.sync.onchain import operator, product
from server.sync.onchain import operator, product, token

from server.sync.person import sync_person_onchain
from server.sync.risk import sync_risk_onchain
Expand Down Expand Up @@ -35,8 +35,8 @@ def sync_policy_onchain(policy: PolicyOut, force: bool = False):
risk_id = product.getRiskId(risk_id_str)
subscription_date = datetime.fromisoformat(policy.subscriptionDate)
activate_at = int(subscription_date.timestamp())
sum_insured = int(policy.sumInsuredAmount) * 10 ** settings.LOCATION_DECIMALS
premium = int(policy.premiumAmount) * 10 ** settings.LOCATION_DECIMALS
sum_insured = int(policy.sumInsuredAmount * 10 ** token.decimals())
premium = int(policy.premiumAmount * 10 ** token.decimals())

logger.info(f"creating policy policy_holder {policy_holder} risk_id {risk_id} activate_at {activate_at} sum_insured {sum_insured} premium {premium}")
tx = product.createPolicy(policy_holder, risk_id, activate_at, sum_insured, premium, {'from': operator, 'gasLimit': 10000000, 'gasPrice': settings.GAS_PRICE})
Expand Down

0 comments on commit 2153277

Please sign in to comment.