Open Goro2030 opened 2 years ago
ANy ideas?
Off topic, but I lived in Chile for years and still don't understand why UF exists and what purpose it serves. :P los chilenos wn!
Off topic, but I lived in Chile for years and still don't understand why UF exists and what purpose it serves. :P los chilenos wn!
But it still unfortunatelly exists and we need to deal with it, right? :)
Off topic, but I lived in Chile for years and still don't understand why UF exists and what purpose it serves. :P los chilenos wn!
UF helps a lot when you have to make long term contracts and protect the transactional value against inflation, don't be wn! :D
@NicolasDorier , any chance to assign/review this Feature request?
@NicolasDorier , any chance to assign/review this Feature request?
@NicolasDorier ?
hey @Goro2030 sorry for taking time about this, our currency field is free typing, so you can enter what you want. We can add the currency in the suggestion list though.
The problem is that we need to pull out the rate from some supported exchange. So either:
UF_BTC=UF_USD * USD_BTC;
UF_USD=234.49;
USD_BTC=kraken(USD_BTC);
(Or you can also just use a single line like UF_BTC=234.49 * kraken(USD_BTC);
)
Then BTCPay will use this formula to calculate the rate of UF_BTC. This is just an example, if there are several conversion along the way, and not directly to USD, you can add those.
UF_BTC=UF_CLP * CLP_USD * USD_BTC;
UF_CLP=234.49;
CLP_USD=CLP_BTC * BTC_USD;
CLP_BTC=someotherexchange(CLP_BTC);
USD_BTC=kraken(USD_BTC);
hey @NicolasDorier ! Thanks for following up on this.
The UF is not a real currency, but an "unit of account" made up by the government to serve as an inflation adjusted unit. The citizens use it to create contracts that automatically updates by inflation ( like a subscription service ).
On your 3 options:
All the API calls that the government entities provide are "API KEY" based, for which one needs to register for.
The call is like this:
https://api.cmfchile.cl/api-sbifv3/recursos_api/uf?apikey=
The response, for the value for TODAY is 32.518,72 ( over 32 thousand Chilean pesos! ). Then if a product costs 1 UF, the system will have to translate that to CLP ( x 32518 ), and then look up that amount at the exchange (for Chile you developed for us the CryptoMarket API call ) under BTC_CLP for 32518 CLPs to get the BTC value for the invoice.
<IndicadoresFinancieros xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://api.sbif.cl" SchemaVersion="1.0" xsi:schemaLocation="http://api.sbif.cl http://api.sbif.cl/IndicadoresFinancieros-v1.0.xsd">
<UFs>
<UF>
<Fecha>2022-05-20</Fecha>
<Valor>32.518,72</Valor>
</UF>
</UFs>
<UTMs/>
<TABs/>
<IPCs/>
<Dolares/>
<Euros/>
<TMCs/>
<TIPs/>
<Perfiles/>
</IndicadoresFinancieros>
We can do 2 things on the API KEY. I can give you mine, or you can get your own?
I have a server in Chile, and I would like to use a local pseudo-currency that we have called "Chilean Unit of Account" (UF for short, Unidad de Fomento in spanish). We of course have the Chilean Peso ( CLP in BTCPay ), but some transactions are done in UF's.
The UF has an official exchange rate into Chilean Pesos that's dictated by the government and it changes daily.
I can easily get the value of one UF by doing a search in google, or using the GoogleFinance API from within Google Sheets, but I was wondering if I can add a "custom FIAT currency" in BTCPayServer, and tell BTCPay how to find out it's quote?
I currently get it for other purposes with this API call: =IMPORTJSON("https://mindicador.cl/api","/uf/valor","noHeaders")