-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This is task to be accomplished:
Description
Develop a smart contract on NEAR that is equivalent to the ERC20ConversionProxy (EVM), allowing users to pay a request denominated in fiat, with fungible tokens.
Details
It should have a similar style to the Native Conversion Proxy contract (already deployed on NEAR).
It should do with fungible tokens what the Native Conversion Proxy does with NEAR tokens.
All types for the method input and event parameters should be as close as possible to the Native Conversion Proxy.
The primary function should be named “transfer_with_reference”. It should transfer fungible tokens to a request issuer and send events that can be indexed to detect Request payments.
Support USDC.e in priority
The following event should be emitted:
{ "amount":"1000000", "currency":"USD", ”token_address”: “a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near”, "fee_address":"fee.requestfinance.near", "fee_amount":"200", "max_rate_timespan":"0", "payment_reference":"abc7c8bb1234fd12", "to":"dummy.payee.near", “crypto_amount”:“10000000000”, “crypto_fee_amount”:”2000000” }
Where:
the amount and fee_amount values are denominated in “currency” (USD in the example) with 2 decimals
the crypto_amount and crypto_fee_amount values are denominated in “token_address” (USDC.e in the example), with the according number of decimals. These amounts should match 2 transfers being made to the 2 recipients “to” and “fee_address”, and should reflect the conversion, given by the contract’s oracle, applied to the amount and fee_amount values.
to and fee_address are the 2 recipient addresses where amount and fee_amount have been paid.
all the params should be given by the payer when paying, except “crypto_amount” and “crypto_fee_amount”
the event cannot be sent if any of the transfers cannot be made (including due to a lack of funds)
the transfer cannot be made if the oracle’s conversion rate is older than the “max_rate_timespan” value, unless it is 0.
If the user needs to transfer more tokens than needed, they must be refunded by the contract at the end of the transaction. If the reimbursement cannot be made, the whole transaction should fail.
The contract should provide administration functions, similar to the ones in the Native Conversion Proxy.
set_oracle_account and get_oracle_account
set_provider_account and get_provider_account
set_owner
The contract should be tested. We expect 95% test coverage where all “happy” paths are tested and most failure modes are also tested. There should be many unit tests and a few integration tests, following the logic used for the Native Conversion Proxy.