📑Solidity API Docs

Event, Struct, State, and Function definitions

Solidity API

Ramp

AccountRegistered

event AccountRegistered(address accountOwner, bytes32 venmoIdHash)

DepositReceived

event DepositReceived(uint256 depositId, bytes32 venmoId, uint256 amount, uint256 conversionRate)

IntentSignaled

event IntentSignaled(bytes32 intentHash, uint256 depositId, bytes32 venmoId, address to, uint256 amount, uint256 timestamp)

IntentPruned

event IntentPruned(bytes32 intentHash, uint256 depositId)

IntentFulfilled

event IntentFulfilled(bytes32 intentHash, uint256 depositId, address onRamper, address to, uint256 amount, uint256 feeAmount)

DepositWithdrawn

event DepositWithdrawn(uint256 depositId, address depositor, uint256 amount)

DepositClosed

event DepositClosed(uint256 depositId, address depositor)

UserAddedToDenylist

event UserAddedToDenylist(bytes32 listOwner, bytes32 deniedUser)

UserRemovedFromDenylist

event UserRemovedFromDenylist(bytes32 listOwner, bytes32 approvedUser)

MinDepositAmountSet

event MinDepositAmountSet(uint256 minDepositAmount)

MaxOnRampAmountSet

event MaxOnRampAmountSet(uint256 maxOnRampAmount)

IntentExpirationPeriodSet

event IntentExpirationPeriodSet(uint256 intentExpirationPeriod)

OnRampCooldownPeriodSet

event OnRampCooldownPeriodSet(uint256 onRampCooldownPeriod)

SustainabilityFeeUpdated

event SustainabilityFeeUpdated(uint256 fee)

SustainabilityFeeRecipientUpdated

event SustainabilityFeeRecipientUpdated(address feeRecipient)

NewSendProcessorSet

event NewSendProcessorSet(address sendProcessor)

NewRegistrationProcessorSet

event NewRegistrationProcessorSet(address registrationProcessor)

NewReceiveProcessorSet

event NewReceiveProcessorSet(address receiveProcessor)

AccountInfo

struct AccountInfo {
  bytes32 venmoIdHash;
  uint256[] deposits;
}

Deposit

struct Deposit {
  address depositor;
  uint256[3] packedVenmoId;
  uint256 depositAmount;
  uint256 remainingDeposits;
  uint256 outstandingIntentAmount;
  uint256 conversionRate;
  bytes32[] intentHashes;
}

DepositWithAvailableLiquidity

struct DepositWithAvailableLiquidity {
  uint256 depositId;
  struct Ramp.Deposit deposit;
  uint256 availableLiquidity;
}

Intent

struct Intent {
  address onRamper;
  address to;
  uint256 deposit;
  uint256 amount;
  uint256 intentTimestamp;
}

IntentWithOnRamperId

struct IntentWithOnRamperId {
  struct Ramp.Intent intent;
  bytes32 onRamperIdHash;
}

DenyList

struct DenyList {
  bytes32[] deniedUsers;
  mapping(bytes32 => bool) isDenied;
}

GlobalAccountInfo

struct GlobalAccountInfo {
  bytes32 currentIntentHash;
  uint256 lastOnrampTimestamp;
  struct Ramp.DenyList denyList;
}

onlyRegisteredUser

modifier onlyRegisteredUser()

PRECISE_UNIT

uint256 PRECISE_UNIT

MAX_DEPOSITS

uint256 MAX_DEPOSITS

CIRCOM_PRIME_FIELD

uint256 CIRCOM_PRIME_FIELD

MAX_SUSTAINABILITY_FEE

uint256 MAX_SUSTAINABILITY_FEE

usdc

contract IERC20 usdc

poseidon

contract IPoseidon poseidon

registrationProcessor

contract IRegistrationProcessor registrationProcessor

sendProcessor

contract ISendProcessor sendProcessor

isInitialized

bool isInitialized

globalAccount

mapping(bytes32 => struct Ramp.GlobalAccountInfo) globalAccount

accounts

mapping(address => struct Ramp.AccountInfo) accounts

deposits

mapping(uint256 => struct Ramp.Deposit) deposits

intents

mapping(bytes32 => struct Ramp.Intent) intents

minDepositAmount

uint256 minDepositAmount

maxOnRampAmount

uint256 maxOnRampAmount

onRampCooldownPeriod

uint256 onRampCooldownPeriod

intentExpirationPeriod

uint256 intentExpirationPeriod

sustainabilityFee

uint256 sustainabilityFee

sustainabilityFeeRecipient

address sustainabilityFeeRecipient

depositCounter

uint256 depositCounter

constructor

constructor(address _owner, contract IERC20 _usdc, contract IPoseidon _poseidon, uint256 _minDepositAmount, uint256 _maxOnRampAmount, uint256 _intentExpirationPeriod, uint256 _onRampCooldownPeriod, uint256 _sustainabilityFee, address _sustainabilityFeeRecipient) public

initialize

function initialize(contract IRegistrationProcessor _registrationProcessor, contract ISendProcessor _sendProcessor) external

Initialize Ramp with the addresses of the Processors

Parameters

Name
Type
Description

_registrationProcessor

contract IRegistrationProcessor

Registration processor address

_sendProcessor

contract ISendProcessor

Send processor address

register

function register(uint256[2] _a, uint256[2][2] _b, uint256[2] _c, uint256[5] _signals) external

Registers a new account by pulling the hash of the account id from the proof and assigning the account owner to the sender of the transaction. One venmo account can be registered to multiple Ethereum addresses.

Parameters

Name
Type
Description

_a

uint256[2]

Parameter of zk proof

_b

uint256[2][2]

Parameter of zk proof

_c

uint256[2]

Parameter of zk proof

_signals

uint256[5]

Encoded public signals of the zk proof, contains mailserverHash, fromEmail, userIdHash

offRamp

function offRamp(uint256[3] _packedVenmoId, uint256 _depositAmount, uint256 _receiveAmount) external

Generates a deposit entry for off-rampers that can then be fulfilled by an on-ramper. This function will not add to previous deposits. Every deposit has it's own unique identifier. User must approve the contract to transfer the deposit amount of USDC.

Parameters

Name
Type
Description

_packedVenmoId

uint256[3]

The packed venmo id of the account owner (we pack for easy use with poseidon)

_depositAmount

uint256

The amount of USDC to off-ramp

_receiveAmount

uint256

The amount of USD to receive

signalIntent

function signalIntent(uint256 _depositId, uint256 _amount, address _to) external

Signals intent to pay the depositor defined in the _depositId the _amount * deposit conversionRate off-chain in order to unlock _amount of funds on-chain. Each user can only have one outstanding intent at a time regardless of address (tracked using venmoId). Caller must not be on the depositor's deny list. If there are prunable intents then they will be deleted from the deposit to be able to maintain state hygiene.

Parameters

Name
Type
Description

_depositId

uint256

The ID of the deposit the on-ramper intends to use for

_amount

uint256

The amount of USDC the user wants to on-ramp

_to

address

Address to forward funds to (can be same as onRamper)

cancelIntent

function cancelIntent(bytes32 _intentHash) external

Only callable by the originator of the intent. Cancels an outstanding intent thus allowing user to signal a new intent. Deposit state is updated to reflect the cancelled intent.

Parameters

Name
Type
Description

_intentHash

bytes32

Hash of intent being cancelled

onRamp

function onRamp(uint256[2] _a, uint256[2][2] _b, uint256[2] _c, uint256[12] _signals) external

Anyone can submit an on-ramp transaction, even if caller isn't on-ramper. Upon submission the proof is validated, intent is removed, and deposit state is updated. USDC is transferred to the on-ramper.

Parameters

Name
Type
Description

_a

uint256[2]

Parameter of zk proof

_b

uint256[2][2]

Parameter of zk proof

_c

uint256[2]

Parameter of zk proof

_signals

uint256[12]

Encoded public signals of the zk proof, contains mailserverHash, fromEmail, timestamp, onRamperIdHash, nullifier, intentHash

withdrawDeposit

function withdrawDeposit(uint256[] _depositIds) external

Caller must be the depositor for each depositId in the array, if not whole function fails. Depositor is returned all remaining deposits and any outstanding intents that are expired. If an intent is not expired then those funds will not be returned. Deposit will be deleted as long as there are no more outstanding intents.

Parameters

Name
Type
Description

_depositIds

uint256[]

Array of depositIds the depositor is attempting to withdraw

addAccountToDenylist

function addAccountToDenylist(bytes32 _deniedUser) external

Adds a venmoId to a depositor's deny list. If an address associated with the banned venmoId attempts to signal an intent on the user's deposit they will be denied.

Parameters

Name
Type
Description

_deniedUser

bytes32

Poseidon hash of the venmoId being banned

removeAccountFromDenylist

function removeAccountFromDenylist(bytes32 _approvedUser) external

Removes a venmoId from a depositor's deny list.

Parameters

Name
Type
Description

_approvedUser

bytes32

Poseidon hash of the venmoId being approved

setSendProcessor

function setSendProcessor(contract ISendProcessor _sendProcessor) external

GOVERNANCE ONLY: Updates the send processor address used for validating and interpreting zk proofs.

Parameters

Name
Type
Description

_sendProcessor

contract ISendProcessor

New send proccesor address

setRegistrationProcessor

function setRegistrationProcessor(contract IRegistrationProcessor _registrationProcessor) external

GOVERNANCE ONLY: Updates the registration processor address used for validating and interpreting zk proofs.

Parameters

Name
Type
Description

_registrationProcessor

contract IRegistrationProcessor

New registration proccesor address

setMinDepositAmount

function setMinDepositAmount(uint256 _minDepositAmount) external

GOVERNANCE ONLY: Updates the minimum deposit amount a user can specify for off-ramping.

Parameters

Name
Type
Description

_minDepositAmount

uint256

The new minimum deposit amount

setSustainabilityFee

function setSustainabilityFee(uint256 _fee) external

GOVERNANCE ONLY: Updates the sustainability fee. This fee is charged to on-rampers upon a successful on-ramp.

Parameters

Name
Type
Description

_fee

uint256

The new sustainability fee in precise units (10**18, ie 10% = 1e17)

setSustainabilityFeeRecipient

function setSustainabilityFeeRecipient(address _feeRecipient) external

GOVERNANCE ONLY: Updates the recepient of sustainability fees.

Parameters

Name
Type
Description

_feeRecipient

address

The new fee recipient address

setMaxOnRampAmount

function setMaxOnRampAmount(uint256 _maxOnRampAmount) external

GOVERNANCE ONLY: Updates the max amount allowed to be on-ramped in each transaction. To on-ramp more than this amount a user must make multiple transactions.

Parameters

Name
Type
Description

_maxOnRampAmount

uint256

The new max on ramp amount

setOnRampCooldownPeriod

function setOnRampCooldownPeriod(uint256 _onRampCooldownPeriod) external

GOVERNANCE ONLY: Updates the on-ramp cooldown period, once an on-ramp transaction is completed the user must wait this amount of time before they can signalIntent to on-ramp again.

Parameters

Name
Type
Description

_onRampCooldownPeriod

uint256

New on-ramp cooldown period

setIntentExpirationPeriod

function setIntentExpirationPeriod(uint256 _intentExpirationPeriod) external

GOVERNANCE ONLY: Updates the intent expiration period, after this period elapses an intent can be pruned to prevent locking up a depositor's funds.

Parameters

Name
Type
Description

_intentExpirationPeriod

uint256

New intent expiration period

getDeposit

function getDeposit(uint256 _depositId) external view returns (struct Ramp.Deposit)

getAccountInfo

function getAccountInfo(address _account) external view returns (struct Ramp.AccountInfo)

getVenmoIdCurrentIntentHash

function getVenmoIdCurrentIntentHash(address _account) external view returns (bytes32)

getLastOnRampTimestamp

function getLastOnRampTimestamp(address _account) external view returns (uint256)

getDeniedUsers

function getDeniedUsers(address _account) external view returns (bytes32[])

isDeniedUser

function isDeniedUser(address _account, bytes32 _deniedUser) external view returns (bool)

getIntentsWithOnRamperId

function getIntentsWithOnRamperId(bytes32[] _intentHashes) external view returns (struct Ramp.IntentWithOnRamperId[])

getAccountDeposits

function getAccountDeposits(address _account) external view returns (struct Ramp.DepositWithAvailableLiquidity[] accountDeposits)

getDepositFromIds

function getDepositFromIds(uint256[] _depositIds) external view returns (struct Ramp.DepositWithAvailableLiquidity[] depositArray)

_calculateIntentHash

function _calculateIntentHash(bytes32 _venmoId, uint256 _depositId) internal view virtual returns (bytes32 intentHash)

Calculates the intentHash of new intent

_getPrunableIntents

function _getPrunableIntents(uint256 _depositId) internal view returns (bytes32[] prunableIntents, uint256 reclaimedAmount)

Cycles through all intents currently open on a deposit and sees if any have expired. If they have expired the outstanding amounts are summed and returned alongside the intentHashes

_pruneIntents

function _pruneIntents(struct Ramp.Deposit _deposit, bytes32[] _intents) internal

_pruneIntent

function _pruneIntent(struct Ramp.Deposit _deposit, bytes32 _intentHash) internal

Pruning an intent involves deleting its state from the intents mapping, zeroing out the intendee's currentIntentHash in their global account mapping, and deleting the intentHash from the deposit's intentHashes array.

_closeDepositIfNecessary

function _closeDepositIfNecessary(uint256 _depositId, struct Ramp.Deposit _deposit) internal

Removes a deposit if no outstanding intents AND no remaining deposits. Deleting a deposit deletes it from the deposits mapping and removes tracking it in the user's accounts mapping.

_transferFunds

function _transferFunds(bytes32 _intentHash, struct Ramp.Intent _intent) internal

Checks if sustainability fee has been defined, if so sends fee to the fee recipient and intent amount minus fee to the on-ramper. If sustainability fee is undefined then full intent amount is transferred to on-ramper.

_verifyOnRampProof

function _verifyOnRampProof(uint256[2] _a, uint256[2][2] _b, uint256[2] _c, uint256[12] _signals) internal returns (struct Ramp.Intent, struct Ramp.Deposit, bytes32)

Validate venmo send payment email and check that it hasn't already been used (done on SendProcessor). Additionally, we validate that the offRamperIdHash matches the one from the specified intent and that enough was paid off-chain inclusive of the conversionRate.

_verifyRegistrationProof

function _verifyRegistrationProof(uint256[2] _a, uint256[2][2] _b, uint256[2] _c, uint256[5] _signals) internal view returns (bytes32)

Validate the user has a venmo account, we do not nullify this email since it can be reused to register under different addresses.

IRegistrationProcessor

RegistrationProof

struct RegistrationProof {
  uint256[2] a;
  uint256[2][2] b;
  uint256[2] c;
  uint256[5] signals;
}

processProof

function processProof(struct IRegistrationProcessor.RegistrationProof _proof) external view returns (bytes32)

ISendProcessor

SendProof

struct SendProof {
  uint256[2] a;
  uint256[2][2] b;
  uint256[2] c;
  uint256[12] signals;
}

processProof

function processProof(struct ISendProcessor.SendProof _proof) external returns (uint256, uint256, bytes32, bytes32, bytes32)

BaseProcessor

onlyRamp

modifier onlyRamp()

ramp

address ramp

mailserverKeyHashAdapter

contract IKeyHashAdapter mailserverKeyHashAdapter

nullifierRegistry

contract INullifierRegistry nullifierRegistry

emailFromAddress

bytes emailFromAddress

constructor

constructor(address _ramp, contract IKeyHashAdapter _mailserverKeyHashAdapter, contract INullifierRegistry _nullifierRegistry, string _emailFromAddress) public

setMailserverKeyHashAdapter

function setMailserverKeyHashAdapter(contract IKeyHashAdapter _mailserverKeyHashAdapter) external

setEmailFromAddress

function setEmailFromAddress(string _emailFromAddress) external

ONLY OWNER: Sets the from email address for validated emails. Check that email address is properly padded (if necessary). Padding will be dependent on if unpacking functions cut trailing 0s or not.

Parameters

Name
Type
Description

_emailFromAddress

string

The from email address for validated emails, MUST BE PROPERLY PADDED

getEmailFromAddress

function getEmailFromAddress() external view returns (bytes)

getMailserverKeyHash

function getMailserverKeyHash() public view returns (bytes32)

_validateAndAddNullifier

function _validateAndAddNullifier(bytes32 _nullifier) internal

VenmoRegistrationProcessor

constructor

constructor(address _ramp, contract IKeyHashAdapter _venmoMailserverKeyHashAdapter, contract INullifierRegistry _nullifierRegistry, string _emailFromAddress) public

processProof

function processProof(struct IRegistrationProcessor.RegistrationProof _proof) public view returns (bytes32 userIdHash)

_parseSignalArray

function _parseSignalArray(uint256[5] _signals, uint8 _from, uint8 _to) internal pure returns (string)

VenmoSendProcessor

constructor

constructor(address _ramp, contract IKeyHashAdapter _venmoMailserverKeyHashAdapter, contract INullifierRegistry _nullifierRegistry, string _emailFromAddress) public

processProof

function processProof(struct ISendProcessor.SendProof _proof) public returns (uint256 amount, uint256 timestamp, bytes32 offRamperIdHash, bytes32 onRamperIdHash, bytes32 intentHash)

_parseSignalArray

function _parseSignalArray(uint256[12] _signals, uint8 _from, uint8 _to) internal pure returns (string)

ManagedKeyHashAdapter

mailserverKeyHash

bytes32 mailserverKeyHash

constructor

constructor(bytes32 _mailserverKeyHash) public

setMailserverKeyHash

function setMailserverKeyHash(bytes32 _mailserverKeyHash) external

NullifierRegistry

NullifierAdded

event NullifierAdded(bytes32 nullifier, address writer)

WriterAdded

event WriterAdded(address writer)

WriterRemoved

event WriterRemoved(address writer)

onlyWriter

modifier onlyWriter()

isNullified

mapping(bytes32 => bool) isNullified

isWriter

mapping(address => bool) isWriter

writers

address[] writers

constructor

constructor() public

addNullifier

function addNullifier(bytes32 _nullifier) external

ONLY WRITER: Only addresses with permission to write to this contract can call. Stores a nullifier for an email.

Parameters

Name
Type
Description

_nullifier

bytes32

The nullifier to store

addWritePermission

function addWritePermission(address _newWriter) external

ONLY OWNER: Add address that has write permissions to the registry. Writer must not have been previously added.

Parameters

Name
Type
Description

_newWriter

address

The nullifier to store

removeWritePermission

function removeWritePermission(address _removedWriter) external

ONLY OWNER: Remove address that has write permissions to the registry. Writer must have been previously added.

Parameters

Name
Type
Description

_removedWriter

address

The nullifier to store

getWriters

function getWriters() external view returns (address[])

Last updated